/* ===================================================================
   Allem Tasad Academy - Unified Mobile Design System (alem-ui.css)
   =================================================================== */

:root {
    --primary-color: #28d59a;
    --primary-dark: #1ea877;
    --primary-light: #e6f9f2;
    --secondary-color: #11324d;
    --secondary-light: #1d4d75;
    --accent-color: #f59e0b;
    --danger-color: #ef4444;
    --info-color: #3b82f6;
    --text-color: #1e293b;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    --bg-body: #f8fafc;
    --bg-surface: #ffffff;
    --border-color: #e2e8f0;
    --border-radius-sm: 8px;
    --border-radius: 12px;
    --border-radius-lg: 18px;
    --border-radius-full: 9999px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.12);
    --bottom-nav-height: 64px;
    --top-header-height: 60px;
    --font-family: 'Cairo', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-body);
    color: var(--text-color);
    direction: rtl;
    text-align: right;
    line-height: 1.5;
    padding-top: calc(var(--top-header-height) + 12px);
    padding-bottom: calc(var(--bottom-nav-height) + 36px);
    overflow-x: hidden;
    user-select: none;
    -webkit-font-smoothing: antialiased;
}

/* --- Mobile Top Header --- */
.mobile-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--top-header-height);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 900;
    box-shadow: var(--shadow-sm);
}

.mobile-header .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.mobile-header .brand img {
    height: 38px;
    width: auto;
    object-fit: contain;
}

.mobile-header .brand-title {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--secondary-color);
    line-height: 1.1;
}

.mobile-header .brand-subtitle {
    font-size: 0.72rem;
    color: var(--primary-dark);
    font-weight: 700;
}

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

.icon-btn {
    position: relative;
    background: #f1f5f9;
    border: none;
    width: 38px;
    height: 38px;
    border-radius: var(--border-radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--secondary-color);
    font-size: 1.05rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.icon-btn:active {
    background: #e2e8f0;
    transform: scale(0.94);
}

.icon-btn .badge-count {
    position: absolute;
    top: -2px;
    left: -2px;
    background: var(--danger-color);
    color: white;
    font-size: 0.65rem;
    font-weight: 800;
    min-width: 17px;
    height: 17px;
    border-radius: var(--border-radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid white;
}

/* --- Mobile Bottom Navigation --- */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-height);
    background: var(--bg-surface);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 900;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}

.bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.72rem;
    font-weight: 700;
    gap: 3px;
    padding: 6px 0;
    cursor: pointer;
    transition: color 0.2s ease;
    border: none;
    background: transparent;
}

.bottom-nav-item i {
    font-size: 1.25rem;
    transition: transform 0.2s ease;
}

.bottom-nav-item.active {
    color: var(--primary-dark);
}

.bottom-nav-item.active i {
    transform: translateY(-2px);
    color: var(--primary-color);
}

/* --- Main Screen Container & Views --- */
.app-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 16px;
    min-height: calc(100vh - var(--top-header-height) - var(--bottom-nav-height));
}

.screen-view {
    display: none;
    animation: fadeIn 0.25s ease-in-out;
}

.screen-view.active {
    display: block;
}

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

/* --- UI Cards --- */
.ui-card {
    background: var(--bg-surface);
    border-radius: var(--border-radius);
    padding: 16px;
    margin-bottom: 14px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.ui-card:active {
    transform: scale(0.99);
}

.ui-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 10px;
}

.ui-card-title {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--secondary-color);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* --- Badges & Pills --- */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: var(--border-radius-full);
    font-size: 0.76rem;
    font-weight: 700;
}

.status-new { background: #fef9c3; color: #854d0e; }
.status-review { background: #dbeafe; color: #1e40af; }
.status-answered { background: #dcfce7; color: #166534; }
.status-closed { background: #f1f5f9; color: #475569; }
.status-active { background: #dcfce7; color: #166534; }
.status-full { background: #fee2e2; color: #991b1b; }

.badge-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 700;
}
.badge-tag-primary { background: var(--primary-light); color: var(--primary-dark); }
.badge-tag-secondary { background: #e0f2fe; color: #0369a1; }
.badge-tag-purple { background: #ede9fe; color: #6d28d9; }

/* --- Forms & Inputs --- */
.form-group {
    margin-bottom: 14px;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--text-color);
}

.form-control {
    width: 100%;
    padding: 12px 14px;
    border-radius: var(--border-radius-sm);
    border: 1.5px solid var(--border-color);
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--text-color);
    background: var(--bg-surface);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(40, 213, 154, 0.2);
}

select.form-control {
    background-color: #ffffff;
    color: var(--text-color, #1e293b);
    font-weight: 600;
    cursor: pointer;
    line-height: 1.5;
}

select.form-control option {
    background-color: #ffffff;
    color: #1e293b;
    padding: 8px 12px;
}

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

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    box-shadow: 0 4px 10px rgba(40, 213, 154, 0.3);
}

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

.btn-outline {
    background: transparent;
    border: 1.5px solid var(--border-color);
    color: var(--text-color);
}

.btn-danger-outline {
    background: transparent;
    border: 1.5px solid var(--danger-color);
    color: var(--danger-color);
}

.btn-whatsapp {
    background: #25d366;
    color: white;
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.82rem;
    border-radius: 6px;
}

/* --- Stats Grid --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}

.stat-box {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 14px;
    text-align: center;
    box-shadow: var(--shadow-sm);
}

.stat-box .stat-icon {
    font-size: 1.5rem;
    margin-bottom: 4px;
    color: var(--primary-dark);
}

.stat-box .stat-val {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--secondary-color);
}

.stat-box .stat-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 600;
}

/* --- Modal Open Background Scroll Lock --- */
body.modal-open {
    position: fixed !important;
    width: 100% !important;
    left: 0 !important;
    right: 0 !important;
    overflow: hidden !important;
}

/* --- Defensive rules for generic .modal --- */
.modal {
    display: none !important;
}
.modal.show {
    display: flex !important;
}

/* --- Modal Bottom Sheets --- */
.mobile-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(17, 50, 77, 0.65);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: none;
    align-items: flex-end;
    justify-content: center;
    animation: fadeIn 0.2s ease-out;
}

.mobile-modal.show {
    display: flex;
}

#teacher-bio-modal {
    z-index: 9999 !important;
}

.mobile-modal-sheet {
    background: #ffffff !important;
    width: 100%;
    max-width: 600px;
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    padding: 20px;
    max-height: 88vh;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior: contain !important;
    overscroll-behavior-y: contain !important;
    touch-action: pan-y !important;
    box-shadow: 0 -5px 25px rgba(0,0,0,0.15);
    animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.sheet-handle {
    width: 40px;
    height: 4px;
    background: #cbd5e1;
    border-radius: 4px;
    margin: 0 auto 15px auto;
}

.sheet-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
}

.sheet-close {
    background: #f1f5f9;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.1rem;
    color: var(--text-muted);
}

/* --- In-App Toast Alerts --- */
.toast-container {
    position: fixed;
    top: calc(var(--top-header-height) + 10px);
    left: 16px;
    right: 16px;
    max-width: 450px;
    margin: 0 auto;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    background: var(--secondary-color);
    color: white;
    padding: 12px 16px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    font-size: 0.88rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    pointer-events: auto;
    animation: toastIn 0.3s ease;
}

.toast-success { background: #065f46; border-right: 4px solid var(--primary-color); }
.toast-error { background: #991b1b; border-right: 4px solid var(--danger-color); }
.toast-info { background: #1e3a8a; border-right: 4px solid var(--info-color); }

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

/* Phone Numbers and LTR Direction Isolation */
.phone-ltr,
.phone-number,
[dir="ltr"],
[data-phone],
.ltr-text {
    direction: ltr !important;
    unicode-bidi: isolate !important;
    text-align: right;
    display: inline-block;
}

input[type="tel"],
input.phone-ltr {
    direction: ltr !important;
    unicode-bidi: isolate !important;
    text-align: right;
    display: block;
    width: 100%;
}

/* Shared Registration Form Styles */
.checkbox-teachers-box {
    max-height: 240px;
    overflow-y: auto;
    padding: 12px;
    border: 1.5px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.teacher-select-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 8px;
    transition: all 0.2s ease;
}

.teacher-select-card.selected-card {
    border-color: var(--primary-color);
    background: #f0fdf4;
}

.teacher-checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--secondary-color);
    transition: border-color 0.2s ease;
}

.schedule-slot-item {
    background: white;
    border: 1.5px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    padding: 10px 12px;
    margin-bottom: 6px;
}

/* Startup Splash Loading Screen */
.app-startup-splash {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #ffffff;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    text-align: center;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.app-startup-splash.fade-out {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.app-startup-splash-logo {
    width: 80px;
    height: 80px;
    border-radius: 16px;
    object-fit: contain;
    margin-bottom: 16px;
    box-shadow: 0 4px 14px rgba(0,0,0,0.08);
    animation: splashLogoPulse 1.8s ease-in-out infinite;
}

@keyframes splashLogoPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.9; }
}

.app-startup-splash-title {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--secondary-color, #11324d);
    margin-bottom: 4px;
}

.app-startup-splash-sub {
    font-size: 0.85rem;
    color: var(--text-muted, #64748b);
    margin-bottom: 20px;
}

.app-startup-splash-spinner {
    display: inline-block;
    width: 28px;
    height: 28px;
    border: 3px solid rgba(17, 50, 77, 0.15);
    border-radius: 50%;
    border-top-color: var(--primary-color, #10b981);
    animation: splashSpin 0.8s linear infinite;
}

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

