/* ModRes — mobile-first EdTech, Cairo, RTL/LTR, dark/light */

:root {
    --font: "Cairo", system-ui, sans-serif;
    --radius: 16px;
    --radius-sm: 12px;
    --shadow: 0 8px 32px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 20px 50px rgba(15, 23, 42, 0.12);
    --transition: 0.25s ease;
    --top-h: 56px;
    --bottom-h: 64px;
    --safe-b: env(safe-area-inset-bottom, 0);
}

html[data-theme="light"] {
    --bg: #f6f8fc;
    --bg-card: rgba(255, 255, 255, 0.72);
    --text: #0f172a;
    --muted: #64748b;
    --border: rgba(148, 163, 184, 0.35);
    --primary: #1e3a8a;
    --primary-2: #312e81;
    --accent: linear-gradient(135deg, #7c3aed 0%, #06b6d4 100%);
    --glass: rgba(255, 255, 255, 0.55);
    --top-bar: rgba(255, 255, 255, 0.85);
}

html[data-theme="dark"] {
    --bg: #0b1220;
    --bg-card: rgba(30, 41, 59, 0.65);
    --text: #f1f5f9;
    --muted: #94a3b8;
    --border: rgba(148, 163, 184, 0.2);
    --primary: #60a5fa;
    --primary-2: #a78bfa;
    --accent: linear-gradient(135deg, #8b5cf6 0%, #22d3ee 100%);
    --glass: rgba(15, 23, 42, 0.6);
    --top-bar: rgba(15, 23, 42, 0.9);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body.app-body {
    margin: 0;
    min-height: 100dvh;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    transition: background-color var(--transition), color var(--transition);
}

.app-shell {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    padding-bottom: calc(var(--bottom-h) + var(--safe-b));
}

.app-main {
    flex: 1;
    width: 100%;
    max-width: 720px;
    margin-inline: auto;
    padding: 1rem 1rem 1.5rem;
}

.glass {
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    background: var(--glass);
    border: 1px solid var(--border);
}

.top-bar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--top-h);
    padding: 0 0.75rem;
    background: var(--top-bar);
    border-bottom: 1px solid var(--border);
}

.top-bar__brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: inherit;
    font-weight: 700;
}

.top-bar__logo {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--accent);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 1rem;
    font-weight: 800;
}

.top-bar__actions {
    display: flex;
    gap: 0.35rem;
}

.btn-icon {
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text);
    border-radius: var(--radius-sm);
    padding: 0.4rem 0.65rem;
    font-family: inherit;
    font-size: 0.85rem;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow var(--transition);
}

.btn-icon:active {
    transform: scale(0.96);
}

.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    padding: 1rem 1.1rem;
    margin-bottom: 1rem;
    transition: box-shadow var(--transition), background var(--transition);
}

.card--gradient-h {
    border: none;
    background-image: var(--accent);
    color: #fff;
    box-shadow: var(--shadow-lg);
}

.card--gradient-h .muted,
.card--gradient-h p {
    color: rgba(255, 255, 255, 0.92);
}

h1,
h2,
h3 {
    margin: 0 0 0.5rem;
    font-weight: 700;
    line-height: 1.25;
}

h1 {
    font-size: 1.35rem;
}

h2 {
    font-size: 1.15rem;
}

p {
    margin: 0 0 0.75rem;
    line-height: 1.6;
    color: var(--muted);
}

.muted {
    color: var(--muted);
    font-size: 0.9rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.65rem 1.1rem;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-weight: 600;
    font-size: 0.95rem;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: transform 0.15s ease, opacity var(--transition);
}

.btn:active {
    transform: scale(0.98);
}

.btn--primary {
    background: var(--accent);
    color: #fff;
}

.btn--ghost {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--border);
}

.btn--block {
    width: 100%;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.35rem;
    font-weight: 600;
    font-size: 0.9rem;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.65rem 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text);
    font-family: inherit;
    font-size: 1rem;
}

.form-group textarea {
    min-height: 120px;
    resize: vertical;
}

.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

.alert--error {
    background: rgba(239, 68, 68, 0.12);
    color: #b91c1c;
    border: 1px solid rgba(239, 68, 68, 0.35);
}

html[data-theme="dark"] .alert--error {
    color: #fecaca;
}

.alert--ok {
    background: rgba(34, 197, 94, 0.12);
    color: #166534;
    border: 1px solid rgba(34, 197, 94, 0.35);
}

html[data-theme="dark"] .alert--ok {
    color: #bbf7d0;
}

.progress {
    height: 8px;
    border-radius: 99px;
    background: var(--border);
    overflow: hidden;
    margin-top: 0.35rem;
}

.progress__bar {
    height: 100%;
    border-radius: 99px;
    background: var(--accent);
    transition: width 0.4s ease;
}

.list-link {
    display: block;
    text-decoration: none;
    color: inherit;
}

.list-link .card {
    margin-bottom: 0.65rem;
    transition: transform 0.15s ease;
}

.list-link:active .card {
    transform: scale(0.99);
}

.badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 600;
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary-2);
}

html[data-theme="dark"] .badge {
    color: #c4b5fd;
}

.bottom-nav {
    position: fixed;
    inset-inline: 0.5rem;
    bottom: calc(0.5rem + var(--safe-b));
    z-index: 60;
    display: flex;
    justify-content: space-around;
    align-items: center;
    height: var(--bottom-h);
    border-radius: var(--radius);
    padding: 0 0.25rem;
    box-shadow: var(--shadow-lg);
}

.bottom-nav__item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    text-decoration: none;
    color: var(--muted);
    font-size: 0.65rem;
    font-weight: 600;
    padding: 0.35rem;
    border-radius: var(--radius-sm);
    transition: color var(--transition), background var(--transition);
}

.bottom-nav__item.is-active {
    color: var(--primary);
    background: rgba(99, 102, 241, 0.12);
}

.bottom-nav__icon {
    font-size: 1.25rem;
    line-height: 1;
}

.landing-hero {
    text-align: center;
    padding: 2rem 0 1rem;
}

.landing-hero h1 {
    font-size: 1.6rem;
    margin-bottom: 0.75rem;
}

.video-shell {
    position: relative;
    border-radius: var(--radius);
    overflow: hidden;
    background: #000;
    aspect-ratio: 16 / 9;
    user-select: none;
    -webkit-user-select: none;
}

.video-shell iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    pointer-events: auto;
}

.video-shell__shield {
    position: absolute;
    inset: 0;
    z-index: 2;
    background: transparent;
    cursor: default;
}

/* Allow clicks through shield only when using overlay trick — we block context menu on shell */
.video-shell {
    -webkit-touch-callout: none;
}

.chat-window {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 55vh;
    overflow-y: auto;
    padding: 0.5rem 0;
}

.chat-bubble {
    max-width: 85%;
    padding: 0.6rem 0.85rem;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    line-height: 1.45;
}

.chat-bubble--me {
    align-self: flex-end;
    background: var(--accent);
    color: #fff;
}

.chat-bubble--them {
    align-self: flex-start;
    background: var(--bg-card);
    border: 1px solid var(--border);
}

.chat-input-row {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.chat-input-row input {
    flex: 1;
}

.admin-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table.simple {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

table.simple th,
table.simple td {
    padding: 0.5rem 0.4rem;
    border-bottom: 1px solid var(--border);
    text-align: start;
}

table.simple th {
    font-weight: 700;
    color: var(--muted);
}

.lazy-img {
    opacity: 0;
    transition: opacity 0.35s ease;
}

.lazy-img.is-loaded {
    opacity: 1;
}

@media (min-width: 768px) {
    .app-main {
        max-width: 960px;
        padding: 1.5rem 1.5rem 2rem;
    }

    h1 {
        font-size: 1.5rem;
    }
}
