:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #60a5fa;
    --secondary: #0f172a;
    --accent: #f59e0b;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --bg-page: #f8fafc;
    --bg-card: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
    background-color: var(--bg-page);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Offline Banner */
#offline-banner {
    display: none;
    background: #dc2626;
    color: #ffffff;
    text-align: center;
    padding: 10px 16px;
    font-size: 0.9rem;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 9999;
}
#offline-banner.active {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* Header & Nav */
header.app-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    padding: 0.85rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--secondary);
}

.brand-badge {
    background: linear-gradient(135deg, #1e40af, #3b82f6);
    color: #fff;
    font-weight: 800;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 1.1rem;
    letter-spacing: 0.5px;
}

.brand-info h1 {
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.2;
}

.brand-info p {
    font-size: 0.75rem;
    color: var(--text-muted);
}

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

.user-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: #f1f5f9;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

/* User Profile Menu & Dropdown */
.user-menu-wrapper {
    position: relative;
    display: inline-block;
}

.user-menu-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 8px 3px 3px;
    background: #f1f5f9;
    border: 1px solid var(--border-color);
    border-radius: 24px;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
    text-decoration: none;
}

.user-menu-btn:hover, .user-menu-btn.active {
    background: #e2e8f0;
    border-color: #cbd5e1;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.user-avatar-img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.12);
    background: #cbd5e1;
}

.user-menu-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.15;
    text-align: left;
}

.user-menu-name {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--secondary);
    max-width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-menu-chevron {
    font-size: 0.7rem;
    color: var(--text-muted);
    transition: transform 0.2s;
    margin-left: 2px;
}

.user-menu-wrapper.open .user-menu-chevron {
    transform: rotate(180deg);
}

/* Dropdown Menu Box */
.user-dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 260px;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    overflow: hidden;
    animation: dropdownFadeIn 0.15s ease-out;
}

.user-menu-wrapper.open .user-dropdown-menu {
    display: block;
}

@keyframes dropdownFadeIn {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}

.dropdown-header {
    padding: 0.9rem 1.1rem;
    background: #f8fafc;
    border-bottom: 1px solid var(--border-color);
}

.dropdown-user-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--secondary);
}

.dropdown-user-email {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dropdown-user-role {
    margin-top: 8px;
}

.dropdown-body {
    padding: 6px 0;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0.65rem 1.1rem;
    font-size: 0.88rem;
    font-weight: 500;
    color: #334155;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    border: none;
    width: 100%;
    background: none;
    text-align: left;
}

.dropdown-item:hover {
    background: #f1f5f9;
    color: var(--primary);
}

.dropdown-item.text-danger {
    color: #ef4444;
}

.dropdown-item.text-danger:hover {
    background: #fef2f2;
    color: #dc2626;
}

.dropdown-divider {
    height: 1px;
    background: var(--border-color);
    margin: 4px 0;
}

.role-tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 14px;
    text-transform: capitalize;
    letter-spacing: 0.3px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

/* Specific Role Colors */
.role-tag.role-administrator, .role-administrator {
    background: #581c87;
    color: #f3e8ff;
    border: 1px solid #9333ea;
}

.role-tag.role-curriculum_officer, .role-curriculum_officer {
    background: #064e3b;
    color: #a7f3d0;
    border: 1px solid #10b981;
}

.role-tag.role-teacher, .role-teacher {
    background: #1e3a8a;
    color: #bfdbfe;
    border: 1px solid #3b82f6;
}

.role-tag.role-parent, .role-parent {
    background: #7c2d12;
    color: #fed7aa;
    border: 1px solid #f97316;
}

.role-tag.role-learner, .role-learner {
    background: #0e7490;
    color: #cffafe;
    border: 1px solid #06b6d4;
}

/* Main Container */
main.app-main {
    flex: 1;
    padding: 2rem 1.5rem;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
}

/* Auth Card Layout */
.auth-container {
    max-width: 480px;
    margin: 2rem auto;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    padding: 2.2rem;
}

.auth-header {
    text-align: center;
    margin-bottom: 1.8rem;
}

.auth-header h2 {
    font-size: 1.6rem;
    color: var(--secondary);
    margin-bottom: 0.4rem;
}

.auth-header p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Forms */
.form-group {
    margin-bottom: 1.2rem;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
    color: #334155;
}

.form-control {
    width: 100%;
    padding: 0.75rem 0.9rem;
    font-size: 0.95rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    outline: none;
    transition: all 0.2s;
    background: #f8fafc;
}

.form-control:focus {
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.form-row {
    display: flex;
    gap: 12px;
}

.form-row .form-group {
    flex: 1;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0.75rem 1.2rem;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

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

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

.btn-secondary {
    background: #f1f5f9;
    color: var(--secondary);
    border: 1px solid var(--border-color);
}

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

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

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
}

/* Alerts */
.alert {
    padding: 0.85rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    margin-bottom: 1.2rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-success {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.alert-danger {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-warning {
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fde68a;
}

/* Dashboard Views */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card h3 {
    font-size: 1.2rem;
    color: var(--secondary);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card p {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 1.2rem;
}

/* Tables */
.table-container {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    overflow-x: auto;
    margin-top: 1.5rem;
}

table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    text-align: left;
}

table.data-table th {
    background: #f8fafc;
    padding: 0.85rem 1.2rem;
    font-weight: 700;
    color: #475569;
    border-bottom: 1px solid var(--border-color);
}

table.data-table td {
    padding: 0.85rem 1.2rem;
    border-bottom: 1px solid var(--border-color);
}

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

.status-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

.status-active { background: #dcfce7; color: #15803d; }
.status-suspended { background: #fee2e2; color: #b91c1c; }
.status-inactive { background: #f1f5f9; color: #64748b; }
.status-pending { background: #fef3c7; color: #b45309; }

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-overlay.active {
    display: flex;
}

.modal-box {
    background: var(--bg-card);
    width: 100%;
    max-width: 520px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 2rem;
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-box-lg {
    max-width: 780px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.2rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.75rem;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
}

.close-btn:hover {
    color: var(--text-main);
}

/* Learner Management Styles */
.learner-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.25rem;
    margin-top: 1.25rem;
}

.learner-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.learner-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: #cbd5e1;
}

.learner-card-header {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}

.learner-avatar-box {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.3rem;
    flex-shrink: 0;
    box-shadow: 0 4px 10px rgba(59, 130, 246, 0.25);
}

.learner-avatar-female {
    background: linear-gradient(135deg, #ec4899, #8b5cf6);
    box-shadow: 0 4px 10px rgba(236, 72, 153, 0.25);
}

.learner-card-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.3;
}

.learner-meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
    align-items: center;
}

.class-badge {
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.class-p1 { background: #dbeafe; color: #1e40af; }
.class-p2 { background: #e0e7ff; color: #3730a3; }
.class-p3 { background: #ede9fe; color: #5b21b6; }
.class-p4 { background: #fae8ff; color: #86198f; }
.class-p5 { background: #fce7f3; color: #9d174d; }
.class-p6 { background: #ffedd5; color: #9a3412; }
.class-p7 { background: #fee2e2; color: #991b1b; }

.needs-badge {
    background: #fef3c7;
    color: #92400e;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.learner-stats-strip {
    background: #f8fafc;
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    margin: 1rem 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    font-size: 0.85rem;
}

.learner-stat-item strong {
    display: block;
    color: var(--text-main);
    font-size: 0.95rem;
}

.learner-stat-item span {
    color: var(--text-muted);
    font-size: 0.78rem;
}

.subject-tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0.75rem 0;
}

.subject-tag {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    color: #334155;
    font-size: 0.78rem;
    padding: 3px 8px;
    border-radius: 4px;
    font-weight: 500;
}

.learner-card-actions {
    display: flex;
    gap: 8px;
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
}

.stats-summary-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.summary-stat-box {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.1rem;
    display: flex;
    align-items: center;
    gap: 12px;
}

.summary-stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: #eff6ff;
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
}

.summary-stat-content h4 {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1.1;
}

.summary-stat-content p {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Footer */
footer.app-footer {
    margin-top: auto;
    border-top: 1px solid var(--border-color);
    background: var(--bg-card);
    padding: 1.2rem;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
}
