/* Modern SMS App Styling with Theme Support */
:root {
    /* Light theme colors */
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-accent: #f1f3f4;
    --text-primary: #2c3e50;
    --text-secondary: #6c757d;
    --text-accent: #495057;
    --border-color: #dee2e6;
    --success-color: #28a745;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --info-color: #6f42c1;
    --sidebar-bg: #343a40;
    --sidebar-text: #ffffff;
    --sidebar-hover: #495057;
    --card-bg: #ffffff;
    --card-shadow: rgba(0, 0, 0, 0.1);
    --input-bg: #ffffff;
    --input-border: #ced4da;
    --button-primary: #6f42c1;
    --button-primary-hover: #5a32a3;
    --accent-gradient: linear-gradient(135deg, #6f42c1 0%, #8e44ad 100%);
    --main-gradient: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}

[data-theme="dark"] {
    /* Dark theme colors */
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-accent: #3a3a3a;
    --text-primary: #f1f3f4;
    --text-secondary: #b0b0b0;
    --text-accent: #e0e0e0;
    --border-color: #404040;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --info-color: #8b5cf6;
    --sidebar-bg: #111827;
    --sidebar-text: #f9fafb;
    --sidebar-hover: #374151;
    --card-bg: #2d2d2d;
    --card-shadow: rgba(0, 0, 0, 0.3);
    --input-bg: #374151;
    --input-border: #4b5563;
    --button-primary: #a78bfa;
    --button-primary-hover: #8b5cf6;
    --accent-gradient: linear-gradient(135deg, #8b5cf6 0%, #a855f7 100%);
    --main-gradient: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--main-gradient);
    min-height: 100vh;
    color: var(--text-primary);
    transition: background 0.3s ease, color 0.3s ease;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Sidebar Navigation */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 70px;
    height: 100vh;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 0;
    z-index: 1000;
    transition: all 0.3s ease;
    box-shadow: 2px 0 10px var(--card-shadow);
}

.sidebar.expanded {
    width: 250px;
}

.sidebar-brand {
    color: var(--sidebar-text);
    font-size: 24px;
    margin-bottom: 30px;
    text-decoration: none;
    transition: all 0.3s ease;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    flex-grow: 1;
}

.sidebar-item {
    position: relative;
    display: flex;
    align-items: center;
    padding: 15px;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    transition: all 0.3s ease;
    border-radius: 0 25px 25px 0;
    margin-right: 10px;
}

.sidebar-item:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text);
    transform: translateX(5px);
}

.sidebar-item.active {
    background: var(--accent-gradient);
    color: var(--sidebar-text);
}

.sidebar-item .icon {
    font-size: 20px;
    min-width: 20px;
    text-align: center;
}

button.sidebar-item.logout-btn {
    background: none;
    border: none;
    cursor: pointer;
    font: inherit;
    color: inherit;
    box-sizing: border-box;
}

.sidebar-item .text {
    margin-left: 15px;
    opacity: 0;
    transition: opacity 0.3s ease;
    white-space: nowrap;
}

.sidebar.expanded .sidebar-item .text {
    opacity: 1;
}

.sidebar-toggle {
    position: absolute;
    bottom: 20px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    padding: 10px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
}

.sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Tooltip */
.tooltip {
    position: absolute;
    left: 80px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 1001;
}

.tooltip::before {
    content: '';
    position: absolute;
    left: -5px;
    top: 50%;
    transform: translateY(-50%);
    border: 5px solid transparent;
    border-right-color: rgba(0, 0, 0, 0.8);
}

.sidebar-item:hover .tooltip {
    opacity: 1;
}

.sidebar.expanded .tooltip {
    display: none;
}

/* Main content adjustment */
.main-content {
    margin-left: 70px;
    transition: margin-left 0.3s ease;
    min-height: 100vh;
}

.sidebar.expanded + .main-content {
    margin-left: 250px;
}

/* Mobile hamburger menu */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 1002;
    background: var(--button-primary);
    border: none;
    color: white;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 2px 10px var(--card-shadow);
}

.mobile-menu-toggle:hover {
    background: var(--button-primary-hover);
}

/* Mobile responsive */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
        background: var(--sidebar-bg);
    }
    
    .sidebar.mobile-open {
        transform: translateX(0);
    }
    
    .sidebar.mobile-open .sidebar-item .text {
        opacity: 1;
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .mobile-menu-toggle {
        display: block;
    }
    
    .sidebar-toggle {
        display: none;
    }
    
    /* Mobile overlay */
    .mobile-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
    }
    
    .mobile-overlay.active {
        display: block;
    }
}

/* User info in sidebar */
.sidebar-user {
    padding: 20px 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.8);
    font-size: 12px;
    text-align: center;
    margin-top: auto;
    margin-bottom: 60px;
}

.sidebar.expanded .sidebar-user {
    text-align: left;
}

/* Remove old header styles */
.header {
    display: none;
}

.sidebar-toggle {
    position: absolute;
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 12px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar.expanded .sidebar-toggle {
    left: calc(100% - 25px);
}

.sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateX(-50%) scale(1.05);
}

.sidebar.expanded .sidebar-toggle:hover {
    transform: translateX(-50%) scale(1.05);
}

/* Cards */
.group-card {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 30px;
    margin-bottom: 25px;
    box-shadow: 0 10px 40px var(--card-shadow);
    border: 1px solid var(--border-color);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.group-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 50px var(--card-shadow);
}

.group-card h3 {
    color: var(--text-accent);
    margin-bottom: 20px;
    font-size: 22px;
    font-weight: 600;
}

.group-card h4 {
    color: var(--text-accent);
    margin-bottom: 15px;
    font-size: 18px;
}

/* Form Elements */
.form-group {
    margin-bottom: 25px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 15px 20px;
    border: 2px solid var(--input-border);
    border-radius: 12px;
    font-size: 16px;
    transition: all 0.3s ease;
    background: var(--input-bg);
    color: var(--text-primary);
}

.form-group select {
    padding-right: 40px; /* Extra space for dropdown arrow */
    background-image: url('data:image/svg+xml;charset=US-ASCII,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 4 5"><path fill="%23666" d="M2 0L0 2h4zm0 5L0 3h4z"/></svg>');
    background-repeat: no-repeat;
    background-position: right 15px center;
    background-size: 12px;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--button-primary);
    box-shadow: 0 0 0 3px rgba(111, 66, 193, 0.1);
    transform: translateY(-2px);
}

.form-group textarea {
    resize: vertical;
    min-height: 120px;
}

/* Buttons */
.btn {
    background: var(--accent-gradient);
    color: white;
    padding: 15px 30px;
    border: none;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    box-shadow: 0 5px 15px rgba(111, 66, 193, 0.3);
}

.btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(111, 66, 193, 0.4);
}

.btn:active {
    transform: translateY(-1px);
}

.btn:disabled {
    background: var(--text-secondary);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-secondary {
    background: linear-gradient(135deg, var(--text-secondary) 0%, var(--text-accent) 100%);
}

.btn-success {
    background: linear-gradient(135deg, var(--success-color) 0%, #20c997 100%);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger-color) 0%, #e83e8c 100%);
}

/* Alerts */
.alert {
    padding: 15px 20px;
    margin-bottom: 20px;
    border-radius: 12px;
    font-weight: 500;
    border-left: 4px solid;
}

.alert-success {
    background: var(--bg-secondary);
    color: var(--success-color);
    border-left-color: var(--success-color);
    border: 1px solid var(--success-color);
}

.alert-error {
    background: var(--bg-secondary);
    color: var(--danger-color);
    border-left-color: var(--danger-color);
    border: 1px solid var(--danger-color);
}

/* Checkbox Styling */
.checkbox-group {
    max-height: 250px;
    overflow-y: auto;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    background: var(--bg-secondary);
}

.checkbox-item {
    display: flex;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}

.checkbox-item:last-child {
    border-bottom: none;
}

.checkbox-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin-right: 15px;
    accent-color: var(--button-primary);
}

.checkbox-item label {
    margin: 0;
    font-weight: 500;
    cursor: pointer;
    flex-grow: 1;
    color: var(--text-primary);
}

.checkbox-item small {
    color: var(--text-secondary);
    font-style: italic;
}

/* Preview Section */
#preview-section {
    background: var(--bg-secondary);
    border-radius: 15px;
    padding: 25px;
    margin: 25px 0;
    border: 2px solid var(--border-color);
}

#preview-info {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
}

#preview-info p {
    margin-bottom: 10px;
    font-size: 16px;
    color: var(--text-primary);
}

#preview-info strong {
    color: var(--text-accent);
}

/* Details/Summary Styling */
details {
    background: var(--card-bg);
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

details summary {
    padding: 15px 20px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    color: var(--text-primary);
    background: var(--bg-secondary);
}

details summary:hover {
    opacity: 0.9;
}

details.styled-details summary {
    background: var(--accent-gradient);
    color: white;
}

#recipients-list {
    max-height: 300px;
    overflow-y: auto;
    padding: 20px;
    background: var(--bg-secondary);
}

#recipients-list div {
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-primary);
}

#recipients-list div:last-child {
    border-bottom: none;
}

/* Member List */
.member-list {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 20px;
    margin-top: 20px;
    border: 1px solid var(--border-color);
}

.member-list div {
    background: var(--card-bg);
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 10px;
    border-left: 4px solid var(--button-primary);
    color: var(--text-primary);
}

.member-list div:last-child {
    margin-bottom: 0;
}

/* Character Counter */
#char-counter {
    display: block;
    text-align: right;
    margin-top: 5px;
    font-weight: 500;
}

/* Login Page */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.login-card {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 15px 50px var(--card-shadow);
    width: 100%;
    max-width: 400px;
    border: 1px solid var(--border-color);
}

.login-card h2 {
    text-align: center;
    color: var(--text-accent);
    margin-bottom: 30px;
    font-size: 28px;
}

/* Mobile-First Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    /* Cards */
    .group-card {
        padding: 20px 15px;
        margin-bottom: 15px;
    }
    
    .group-card h2 {
        font-size: 24px !important;
    }
    
    .group-card h3 {
        font-size: 18px;
    }
    
    /* Forms */
    .form-group input,
    .form-group textarea,
    .form-group select {
        padding: 12px 15px;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .btn {
        padding: 12px 20px;
        font-size: 16px;
        min-height: 44px; /* Touch target size */
    }
    
    /* Tables - Make scrollable */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    table {
        min-width: 600px;
    }
    
    /* Checkbox groups */
    .checkbox-group {
        max-height: 200px;
    }
    
    .checkbox-item {
        padding: 15px 0;
        min-height: 44px;
    }
    
    .checkbox-item input[type="checkbox"] {
        width: 24px;
        height: 24px;
        margin-right: 12px;
    }
    
    /* Grid layouts */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px;
    }
    
    .form-grid {
        grid-template-columns: 1fr !important;
        gap: 15px;
    }
    
    /* Modals */
    .modal-content {
        width: 95% !important;
        max-width: none !important;
        margin: 20px;
    }
    
    /* Message preview */
    #preview-section {
        padding: 15px;
    }
    
    #preview-info {
        padding: 15px;
    }
    
    /* Recipients list */
    #recipients-list {
        padding: 15px;
        max-height: 250px;
    }
    
    /* Login */
    .login-container {
        padding: 10px;
    }
    
    .login-card {
        padding: 25px 20px;
    }
    
    /* Admin panel actions */
    .action-buttons {
        flex-direction: column !important;
        gap: 5px !important;
    }
    
    .action-buttons .btn {
        width: 100%;
        margin: 0;
    }
}

@media (max-width: 480px) {
    /* Extra small screens */
    .container {
        padding: 5px;
    }
    
    .group-card {
        padding: 15px 10px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr !important;
    }
    
    .btn {
        padding: 15px 20px;
        font-size: 16px;
    }
    
    /* Make text inputs full width */
    input, textarea, select {
        width: 100% !important;
        box-sizing: border-box;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    /* Touch devices */
    .btn:hover {
        transform: none;
    }
    
    .btn:active {
        transform: scale(0.98);
        transition: transform 0.1s;
    }
    
    .group-card:hover {
        transform: none;
    }
    
    .nav a:hover {
        transform: none;
    }
    
    /* Larger touch targets */
    a, button {
        min-height: 44px;
        min-width: 44px;
    }

    input[type="checkbox"], input[type="radio"] {
        min-height: 24px;
        min-width: 24px;
    }
}

/* Utility classes for mobile */
.mobile-hidden {
    display: block;
}

.mobile-only {
    display: none;
}

@media (max-width: 768px) {
    .mobile-hidden {
        display: none;
    }
    
    .mobile-only {
        display: block;
    }
    
    .mobile-stack {
        flex-direction: column !important;
    }
    
    .mobile-full-width {
        width: 100% !important;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.group-card {
    animation: fadeIn 0.6s ease-out;
}

/* Loading States */
.loading {
    opacity: 0.7;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid var(--button-primary);
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}