/* ===================================================================
   Allem Tasad Academy - Modern Web Student Portal Design System
   Version: 3.6.0 | Responsive for Desktop, iPad, iOS Safari & Android
   =================================================================== */

:root {
    --primary-color: #10b981;
    --primary-dark: #059669;
    --primary-light: #ecfdf5;
    --brand-navy: #11324d;
    --brand-navy-dark: #091a29;
    --accent-purple: #8b5cf6;
    --purple-light: #faf5ff;
    --accent-amber: #f59e0b;
    --amber-light: #fffbeb;
    --accent-red: #ef4444;
    --red-light: #fef2f2;
    --text-color: #1e293b;
    --text-muted: #64748b;
    --bg-light: #f8fafc;
    --bg-surface: #ffffff;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.08);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;
}

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

body {
    font-family: 'Cairo', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: #f1f5f9;
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

/* --- Top Header --- */
.portal-header {
    background: var(--bg-surface);
    box-shadow: var(--shadow-sm);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.portal-header-container {
    max-width: 1140px;
    margin: 0 auto;
    padding: 10px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.portal-brand-link {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: inherit;
}

.portal-logo {
    height: 42px;
    width: 42px;
    object-fit: contain;
    border-radius: var(--radius-sm);
}

.portal-title {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--brand-navy);
    line-height: 1.2;
}

.portal-subtitle {
    font-size: 0.75rem;
    color: var(--primary-dark);
    font-weight: 600;
}

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

.header-child-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
    padding: 5px 10px;
    border-radius: var(--radius-full);
    font-size: 0.82rem;
    font-weight: 700;
}

.header-switch-btn {
    background: none;
    border: none;
    color: #1d4ed8;
    cursor: pointer;
    font-size: 0.8rem;
    padding: 2px 4px;
    border-radius: 4px;
}

.header-switch-btn:hover {
    background: rgba(29, 78, 216, 0.1);
}

.icon-btn-header {
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    color: var(--brand-navy);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    font-size: 0.95rem;
}

.notif-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    background: var(--accent-red);
    color: white;
    font-size: 0.65rem;
    font-weight: 800;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
}

/* --- Main Layout --- */
.portal-main-container {
    max-width: 1140px;
    width: 100%;
    margin: 20px auto;
    padding: 0 16px;
    flex: 1;
}

/* --- Base Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
    border: 1px solid transparent;
    text-decoration: none;
    font-family: inherit;
}

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

.btn-outline {
    background: white;
    border-color: var(--border-color);
    color: var(--brand-navy);
}
.btn-outline:hover {
    background: var(--bg-light);
    border-color: #cbd5e1;
}

.btn-danger {
    background: var(--accent-red);
    color: white;
}
.btn-danger-outline {
    background: white;
    border-color: #fca5a5;
    color: var(--accent-red);
}
.btn-danger-outline:hover {
    background: var(--red-light);
}

.btn-sm {
    padding: 5px 10px;
    font-size: 0.8rem;
}
.btn-lg {
    padding: 12px 20px;
    font-size: 1rem;
}
.btn-block {
    width: 100%;
}

/* --- Cards --- */
.portal-card {
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 20px;
    margin-bottom: 16px;
    border: 1px solid var(--border-color);
}

.portal-card-header {
    margin-bottom: 14px;
}
.portal-card-header h2, .portal-card-header h3, .portal-card-header h4 {
    color: var(--brand-navy);
    font-weight: 800;
    margin-bottom: 4px;
}
.portal-card-header p {
    color: var(--text-muted);
    font-size: 0.88rem;
}

/* --- Authentication Card --- */
.auth-card {
    max-width: 520px;
    margin: 24px auto;
    padding: 28px;
    box-shadow: var(--shadow-lg);
}

.portal-icon-wrapper {
    width: 60px;
    height: 60px;
    background: var(--primary-light);
    color: var(--primary-dark);
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    margin-bottom: 12px;
}

.auth-tabs-nav {
    display: flex;
    gap: 6px;
    background: #f1f5f9;
    padding: 4px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
}

.auth-tab-btn {
    flex: 1;
    background: none;
    border: none;
    padding: 8px 12px;
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-muted);
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-family: inherit;
    transition: all 0.15s ease;
}

.auth-tab-btn.active {
    background: white;
    color: var(--brand-navy);
    box-shadow: var(--shadow-sm);
}

.form-group {
    margin-bottom: 14px;
}
.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--brand-navy);
    margin-bottom: 5px;
}

.form-input {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.92rem;
    font-family: inherit;
    transition: border-color 0.15s;
    background: white;
}
.form-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

.password-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}
.password-input-wrapper .form-input {
    padding-left: 40px;
}
.toggle-password-btn {
    position: absolute;
    left: 8px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    font-size: 0.95rem;
}

.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.form-helper-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.82rem;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 8px;
}
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    color: var(--text-muted);
}
.forgot-link {
    color: var(--primary-dark);
    text-decoration: none;
    font-weight: 700;
}

.registration-divider {
    text-align: center;
    margin: 16px 0;
    position: relative;
}
.registration-divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--border-color);
}
.registration-divider span {
    position: relative;
    background: white;
    padding: 0 10px;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
}

/* --- Alerts --- */
.alert {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
}
.alert-error {
    background: var(--red-light);
    border: 1px solid #fecaca;
    color: #991b1b;
}
.alert-info {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e40af;
}

/* --- Dashboard Header Card --- */
.dashboard-header-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    margin-bottom: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 14px;
    box-shadow: var(--shadow-sm);
}

.dashboard-user-info {
    display: flex;
    align-items: center;
    gap: 14px;
}

.student-avatar-badge {
    width: 52px;
    height: 52px;
    background: linear-gradient(135deg, var(--brand-navy) 0%, #1e4976 100%);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.greeting-sub {
    font-size: 0.82rem;
    color: var(--text-muted);
}
.greeting-name {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--brand-navy);
    line-height: 1.3;
}
.greeting-badges {
    display: flex;
    gap: 6px;
    margin-top: 4px;
    flex-wrap: wrap;
}

.dashboard-top-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

/* --- Badges --- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 700;
}
.badge-primary {
    background: var(--primary-light);
    color: var(--primary-dark);
}
.badge-secondary {
    background: #f1f5f9;
    color: #475569;
}
.badge-outline {
    background: white;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
}
.badge-success {
    background: #dcfce7;
    color: #15803d;
}
.badge-warning {
    background: var(--amber-light);
    color: #b45309;
}
.badge-danger {
    background: var(--red-light);
    color: #b91c1c;
}

/* --- Multi-Child Switcher Bar --- */
.parent-children-bar {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 8px 14px;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.children-bar-label {
    font-size: 0.82rem;
    font-weight: 700;
    color: #475569;
    display: flex;
    align-items: center;
    gap: 6px;
}

.children-pills-container {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.child-pill-btn {
    background: white;
    border: 1px solid var(--border-color);
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 700;
    color: #475569;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: inherit;
    transition: all 0.15s ease;
}
.child-pill-btn.active {
    background: var(--brand-navy);
    color: white;
    border-color: var(--brand-navy);
}

/* --- Next Live Lesson Hero Banner --- */
.next-lesson-hero-card {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: white;
    border: 1.5px solid #334155;
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

.hero-lesson-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.hero-lesson-title {
    font-size: 1.2rem;
    font-weight: 800;
    color: white;
    margin-bottom: 4px;
}

.hero-lesson-meta {
    display: flex;
    gap: 10px;
    font-size: 0.85rem;
    color: #94a3b8;
    flex-wrap: wrap;
}
.hero-lesson-meta span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.hero-countdown-box {
    display: inline-flex;
    gap: 6px;
    background: rgba(0,0,0,0.35);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid #475569;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 1rem;
    color: #facc15;
    font-weight: 700;
}

.btn-zoom-live {
    background: #10b981;
    color: white;
    border: none;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 800;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.4);
    animation: pulse-green 2s infinite;
}
@keyframes pulse-green {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6); }
    70% { transform: scale(1.03); box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.btn-zoom-waiting {
    background: #334155;
    color: #94a3b8;
    border: 1px solid #475569;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-weight: 700;
    cursor: not-allowed;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

/* --- Navigation Tabs --- */
.lms-student-nav {
    display: flex;
    gap: 8px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 6px;
    margin-bottom: 20px;
    overflow-x: auto;
    box-shadow: var(--shadow-sm);
}

.lms-nav-btn {
    background: none;
    border: none;
    padding: 8px 14px;
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: inherit;
    white-space: nowrap;
    transition: all 0.15s ease;
    position: relative;
}

.lms-nav-btn.active {
    background: var(--brand-navy);
    color: white;
}

.tab-badge {
    background: var(--accent-purple);
    color: white;
    font-size: 0.7rem;
    padding: 1px 6px;
    border-radius: var(--radius-full);
}

/* --- Tab Content --- */
.portal-tab-content {
    display: none;
}
.portal-tab-content.active {
    display: block;
}

.tab-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
}
.tab-section-header h3 {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--brand-navy);
}
.tab-section-header p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* --- Session Cards List --- */
.sessions-list-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.session-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 14px;
    box-shadow: var(--shadow-sm);
    transition: transform 0.15s;
}
.session-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.session-info-col {
    display: flex;
    align-items: center;
    gap: 14px;
}

.session-icon-box {
    width: 46px;
    height: 46px;
    border-radius: var(--radius-sm);
    background: #eff6ff;
    color: #1d4ed8;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}
.session-icon-box.live {
    background: #ecfdf5;
    color: #059669;
}

.session-title {
    font-size: 1rem;
    font-weight: 800;
    color: var(--brand-navy);
    margin-bottom: 2px;
}

.session-meta-row {
    display: flex;
    gap: 10px;
    font-size: 0.82rem;
    color: var(--text-muted);
    flex-wrap: wrap;
}

/* --- Homework Cards --- */
.homework-list-container, .exams-list-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.homework-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 14px;
    box-shadow: var(--shadow-sm);
}

/* --- Subscriptions Grid --- */
.subscriptions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 14px;
}

.subscription-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 18px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 12px;
}

.sub-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}
.sub-subject {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--brand-navy);
}
.sub-teacher {
    font-size: 0.84rem;
    color: var(--text-muted);
}

.sub-progress-box {
    margin: 6px 0;
}
.sub-progress-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    font-weight: 700;
    color: #475569;
    margin-bottom: 4px;
}
.progress-bar-track {
    height: 8px;
    background: #f1f5f9;
    border-radius: var(--radius-full);
    overflow: hidden;
}
.progress-bar-fill {
    height: 100%;
    background: var(--primary-color);
    border-radius: var(--radius-full);
    transition: width 0.3s;
}

/* --- Questions & Messages --- */
.questions-list-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.question-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    box-shadow: var(--shadow-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.conversation-messages-list {
    max-height: 280px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 10px;
    background: #f8fafc;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.msg-bubble {
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 0.88rem;
    line-height: 1.5;
    max-width: 85%;
}
.msg-student {
    background: #dbeafe;
    color: #1e3a8a;
    align-self: flex-start;
}
.msg-teacher {
    background: #dcfce7;
    color: #14532d;
    align-self: flex-end;
}

/* --- Tables --- */
.table-responsive {
    overflow-x: auto;
}
.portal-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
    text-align: right;
}
.portal-table th {
    background: #f8fafc;
    color: #475569;
    font-weight: 700;
    padding: 10px 12px;
    border-bottom: 2px solid var(--border-color);
}
.portal-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-color);
}

/* --- Info Lists --- */
.info-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.88rem;
    border-bottom: 1px dashed var(--border-color);
    padding-bottom: 6px;
}
.info-label {
    color: var(--text-muted);
}
.info-value {
    font-weight: 700;
    color: var(--brand-navy);
}

.dashboard-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* --- Modals --- */
.portal-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(17, 50, 77, 0.65);
    backdrop-filter: blur(4px);
}

.modal-dialog {
    position: relative;
    background: white;
    border-radius: var(--radius-md);
    max-width: 520px;
    width: 100%;
    padding: 24px;
    box-shadow: var(--shadow-lg);
    max-height: 90vh;
    overflow-y: auto;
    z-index: 10;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
    margin-bottom: 16px;
}
.modal-header h3 {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--brand-navy);
}

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

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

.modal-info-box {
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-bottom: 14px;
    font-size: 0.85rem;
}

/* --- Footer --- */
.portal-footer {
    background: white;
    border-top: 1px solid var(--border-color);
    padding: 14px 20px;
    margin-top: auto;
}
.portal-footer-container {
    max-width: 1140px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 0.82rem;
    color: var(--text-muted);
}
.version-badge {
    background: #f1f5f9;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 700;
}

/* --- Responsive Media Queries --- */
@media (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }
    .form-grid-2, .dashboard-grid-2 {
        grid-template-columns: 1fr;
    }
    .dashboard-header-card {
        flex-direction: column;
        align-items: flex-start;
    }
    .dashboard-top-actions {
        width: 100%;
        justify-content: space-between;
    }
    .hero-lesson-content {
        flex-direction: column;
        align-items: flex-start;
    }
    .hero-lesson-actions {
        width: 100%;
    }
    .btn-zoom-live, .btn-zoom-waiting {
        width: 100%;
        justify-content: center;
    }
}
