/* Admin Dashboard Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #667eea;
    --primary-dark: #5a67d8;
    --sidebar-bg: #1a202c;
    --sidebar-text: #a0aec0;
    --bg: #f7fafc;
    --card-bg: white;
    --text: #2d3748;
    --text-light: #718096;
    --border: #e2e8f0;
    --success: #48bb78;
    --warning: #ed8936;
    --danger: #f56565;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg);
    min-height: 100vh;
}

.admin-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h1 {
    color: white;
    font-size: 1.4rem;
    margin-bottom: 4px;
}

.sidebar-header span {
    font-size: 0.85rem;
}

.sidebar-nav {
    flex: 1;
    padding: 20px 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 24px;
    color: var(--sidebar-text);
    text-decoration: none;
    transition: all 0.2s;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-size: 0.95rem;
    cursor: pointer;
}

.nav-item:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}

.nav-item.active {
    background: var(--primary);
    color: white;
}

.nav-icon {
    font-size: 1.1rem;
}

.badge {
    background: var(--danger);
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    margin-left: auto;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
    display: flex;
    flex-direction: column;
    gap: 0;
}

.sidebar-footer .nav-item,
.sidebar-footer .logout-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 24px;
    color: var(--sidebar-text);
    text-decoration: none;
    transition: all 0.2s;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-size: 0.95rem;
    cursor: pointer;
}

.sidebar-footer .nav-item:hover,
.sidebar-footer .logout-btn:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}

.sidebar-footer .logout-btn {
    color: var(--danger);
}

.sidebar-footer .logout-btn:hover {
    color: #ff6b6b;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 30px;
}

.section {
    display: none;
}

.section.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.section h2 {
    color: var(--text);
    font-size: 1.6rem;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--card-bg);
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    font-size: 2.5rem;
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text);
}

.stat-label {
    font-size: 0.9rem;
    color: var(--text-light);
}

/* Tables */
.table-container {
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    overflow: hidden;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th, .data-table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    background: #f8fafc;
    font-weight: 600;
    color: var(--text);
    font-size: 0.85rem;
    text-transform: uppercase;
}

.data-table td {
    color: var(--text);
    font-size: 0.95rem;
}

.data-table tr:hover {
    background: #f8fafc;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--border);
    color: var(--text);
}

.btn-secondary:hover {
    background: #cbd5e0;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.action-btns {
    display: flex;
    gap: 8px;
}

/* Status badges */
.status-badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

.status-active {
    background: #c6f6d5;
    color: #276749;
}

.status-inactive {
    background: #fed7d7;
    color: #c53030;
}

.role-badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
}

.role-system_admin {
    background: #e9d8fd;
    color: #553c9a;
}

.role-family_admin {
    background: #bee3f8;
    color: #2b6cb0;
}

.role-family_member {
    background: #e2e8f0;
    color: #4a5568;
}

/* Filter bar */
.filter-bar {
    margin-bottom: 16px;
}

.filter-bar select {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.9rem;
}

/* Notifications */
.notifications-list, .activity-list {
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.notif-item {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

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

.notif-item.unread {
    background: #eef2ff;
}

.notif-content h4 {
    color: var(--text);
    margin-bottom: 4px;
}

.notif-content p {
    color: var(--text-light);
    font-size: 0.9rem;
}

.notif-meta {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-top: 4px;
}

.notif-actions {
    display: flex;
    gap: 8px;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    background: white;
    border-radius: 12px;
    padding: 30px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal h3 {
    margin-bottom: 20px;
    color: var(--text);
}

.modal-form .form-group {
    margin-bottom: 16px;
}

.modal-form label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: var(--text);
}

.modal-form input, .modal-form select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.95rem;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 24px;
}

/* Account Status Toggle */
.account-status-group {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.toggle-switch {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
}

.toggle-switch input[type="checkbox"] {
    width: 50px;
    height: 26px;
    appearance: none;
    background: #dc3545;
    border-radius: 13px;
    position: relative;
    cursor: pointer;
    transition: background 0.3s;
}

.toggle-switch input[type="checkbox"]:checked {
    background: #28a745;
}

.toggle-switch input[type="checkbox"]::before {
    content: '';
    position: absolute;
    width: 22px;
    height: 22px;
    background: white;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: transform 0.3s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.toggle-switch input[type="checkbox"]:checked::before {
    transform: translateX(24px);
}

.toggle-switch .toggle-label {
    display: none;
}

.toggle-status {
    font-weight: 500;
    font-size: 0.9rem;
}

.toggle-status.status-active {
    color: #28a745;
}

.toggle-status.status-inactive {
    color: #dc3545;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--text-light);
}

/* Invite code display */
.invite-code {
    font-family: monospace;
    background: #f7fafc;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 600;
}

/* Request History Styles */
.history-stats {
    margin-bottom: 20px;
}

.stat-pills {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.stat-pill {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.85em;
    font-weight: 600;
}

.stat-pill.total {
    background: #e2e8f0;
    color: #4a5568;
}

.stat-pill.pending {
    background: #fef3c7;
    color: #92400e;
}

.stat-pill.approved {
    background: #d1fae5;
    color: #065f46;
}

.stat-pill.rejected {
    background: #fee2e2;
    color: #991b1b;
}

.status-pending {
    color: #d69e2e;
    font-weight: 600;
}

.status-approved {
    color: #38a169;
    font-weight: 600;
}

.status-rejected {
    color: #e53e3e;
    font-weight: 600;
}

.header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.btn-small {
    padding: 4px 8px;
    font-size: 0.8em;
}

/* Responsive - Tablet */
@media (max-width: 900px) {
    .sidebar {
        width: 70px;
    }
    .sidebar-header h1 { display: none; }
    .sidebar-header span { display: none; }
    .nav-item span:not(.nav-icon) { display: none; }
    .main-content {
        margin-left: 70px;
        padding: 20px;
    }
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    .header-actions {
        flex-wrap: wrap;
    }
}

/* Responsive - Mobile */
@media (max-width: 600px) {
    .admin-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        flex-direction: row;
        flex-wrap: wrap;
    }

    .sidebar-header {
        width: 100%;
        padding: 12px 16px;
        display: flex;
        align-items: center;
        gap: 10px;
    }

    .sidebar-header h1 {
        display: inline;
        font-size: 1.1rem;
    }
    .sidebar-header span {
        display: inline;
        font-size: 0.8rem;
    }

    .sidebar-nav {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        padding: 0;
        border-top: 1px solid rgba(255,255,255,0.1);
    }

    .sidebar-nav .nav-item {
        flex: 1;
        min-width: 50%;
        justify-content: center;
        padding: 12px 8px;
        font-size: 0.85rem;
        gap: 6px;
        border-bottom: 1px solid rgba(255,255,255,0.05);
    }

    .sidebar-nav .nav-item span:not(.nav-icon) {
        display: inline;
        font-size: 0.75rem;
    }

    .sidebar-footer {
        width: 100%;
        flex-direction: row;
        padding: 0;
        border-top: 1px solid rgba(255,255,255,0.1);
    }

    .sidebar-footer .nav-item,
    .sidebar-footer .logout-btn {
        flex: 1;
        justify-content: center;
        padding: 12px 8px;
        font-size: 0.85rem;
        gap: 6px;
    }

    .sidebar-footer .nav-item span:not(.nav-icon),
    .sidebar-footer .logout-btn span:not(.nav-icon) {
        display: inline;
        font-size: 0.75rem;
    }

    .main-content {
        margin-left: 0;
        padding: 16px;
    }

    .section h2 {
        font-size: 1.3rem;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .stat-card {
        padding: 14px;
        flex-direction: column;
        text-align: center;
        gap: 8px;
    }

    .stat-icon {
        font-size: 1.8rem;
    }

    .stat-value {
        font-size: 1.4rem;
    }

    .stat-label {
        font-size: 0.8rem;
    }

    /* Make tables horizontally scrollable */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .data-table {
        min-width: 600px;
    }

    .data-table th, .data-table td {
        padding: 10px 12px;
        font-size: 0.85rem;
    }

    /* Buttons */
    .btn {
        padding: 8px 14px;
        font-size: 0.85rem;
    }

    .section-header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .header-actions {
        flex-direction: column;
        width: 100%;
    }

    .header-actions select,
    .header-actions .btn {
        width: 100%;
    }

    /* Filter bar */
    .filter-bar {
        flex-direction: column;
        gap: 8px;
    }

    .filter-bar select {
        width: 100%;
    }

    /* Stat pills */
    .stat-pills {
        flex-direction: column;
        gap: 6px;
    }

    .stat-pill {
        text-align: center;
    }

    /* Modals */
    .modal-content {
        width: 95%;
        max-width: none;
        margin: 10px;
        padding: 16px;
    }

    .modal-content h2 {
        font-size: 1.2rem;
    }

    .form-group input,
    .form-group select {
        font-size: 16px; /* Prevents zoom on iOS */
    }

    /* Notifications */
    .notification-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .activity-list {
        max-height: none;
    }
}

