/* ═══════════════════════════════════════════════════════════════════════
   aic-nav.css — מערכת ניווט אחידה לכל האתר (מורה + תלמיד)
   ───────────────────────────────────────────────────────────────────────
   שלושה רכיבים משותפים, קובץ אחד, בלי כפילויות:
     1) .aic-topbar   — סרגל עליון מלא לדפי-בית של המורה
                         (index.php / classes.php / analytics.php / org_dashboard.php)
     2) .aic-backbar   — סרגל קומפקטי לדפי יצירה/עורכים (בונים, quest_ai וכו')
     3) .aic-pill      — כפתור "חזרה" צף לדפי נגן תלמיד (מסך מלא, בלי סרגל)
   כל הרכיבים תומכים RTL, מובייל + דסקטופ, ו-safe-area (iPhone notch).
   ═══════════════════════════════════════════════════════════════════════ */

:root {
    --aic-primary: #4f46e5;
    --aic-primary-dark: #4338ca;
    --aic-ink: #1e293b;
}

/* ─────────────────────────────────────────────────────────────────────
   1) TOPBAR — סרגל עליון מלא (דפי-בית של המורה)
   ───────────────────────────────────────────────────────────────────── */
.aic-topbar {
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    box-shadow: 0 1px 2px rgba(0,0,0,.03);
    position: sticky;
    top: 0;
    z-index: 100;
    padding-top: env(safe-area-inset-top);
}
.aic-topbar__inner {
    max-width: 1180px;
    margin: 0 auto;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.aic-topbar__brand {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    flex-shrink: 0;
}
.aic-topbar__logo {
    width: 32px; height: 32px;
    background: var(--aic-primary);
    color: #fff;
    border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 900; font-size: 16px;
    flex-shrink: 0;
}
.aic-topbar__brandname {
    font-weight: 900;
    color: var(--aic-ink);
    font-size: 15px;
    white-space: nowrap;
}
.aic-topbar__nav {
    display: flex;
    align-items: center;
    gap: 2px;
    flex: 1;
    min-width: 0;
}
.aic-topbar__link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 13.5px;
    font-weight: 700;
    color: #475569;
    text-decoration: none;
    white-space: nowrap;
    transition: background .12s, color .12s;
}
@media (hover: hover) {
    .aic-topbar__link:hover { background: #f1f5f9; color: var(--aic-ink); }
}
.aic-topbar__link:active { background: #e2e8f0; }
.aic-topbar__link.is-active {
    background: #eef2ff;
    color: var(--aic-primary);
}
.aic-topbar__user {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
.aic-topbar__org {
    font-size: 11px;
    font-weight: 700;
    color: #4338ca;
    background: #eef2ff;
    border: 1px solid #c7d2fe;
    padding: 2px 9px;
    border-radius: 999px;
    white-space: nowrap;
}
.aic-topbar__name {
    font-size: 13px;
    color: #64748b;
    white-space: nowrap;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.aic-topbar__logout {
    font-size: 13px;
    font-weight: 700;
    color: #dc2626;
    background: #fef2f2;
    padding: 7px 12px;
    border-radius: 9px;
    text-decoration: none;
    white-space: nowrap;
    flex-shrink: 0;
}
@media (hover: hover) { .aic-topbar__logout:hover { background: #fee2e2; } }

/* Hamburger — מוסתר בדסקטופ */
.aic-topbar__burger {
    display: none;
    flex-shrink: 0;
    width: 38px; height: 38px;
    border-radius: 9px;
    border: 1px solid #e2e8f0;
    background: #fff;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 4px;
    padding: 0;
}
.aic-topbar__burger span {
    display: block;
    width: 18px; height: 2px;
    background: #475569;
    border-radius: 2px;
    transition: transform .18s, opacity .18s;
}
.aic-topbar__burger[aria-expanded="true"] span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.aic-topbar__burger[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.aic-topbar__burger[aria-expanded="true"] span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

.aic-topbar__mobile {
    display: none;
    border-top: 1px solid #e5e7eb;
    background: #fafafa;
    padding: 8px 12px calc(12px + env(safe-area-inset-bottom));
}
.aic-topbar__mobile.is-open { display: block; }
.aic-topbar__mobile .aic-topbar__link {
    display: flex;
    width: 100%;
    padding: 12px 14px;
    font-size: 15px;
    min-height: 44px;
}
.aic-topbar__mobile-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 14px 4px;
    border-top: 1px solid #e5e7eb;
    margin-top: 6px;
}

@media (max-width: 860px) {
    .aic-topbar__nav,
    .aic-topbar__inner > .aic-topbar__user { display: none; }
    .aic-topbar__burger { display: flex; }
    .aic-topbar__brandname { display: none; }
}

/* ─────────────────────────────────────────────────────────────────────
   2) BACKBAR — סרגל קומפקטי לדפי יצירה/עריכה (בונים)
   תומך בשני ערכות נושא: light (בהיר, Tailwind) ו-dark (Studio, לילי)
   ───────────────────────────────────────────────────────────────────── */
.aic-backbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    padding-top: calc(10px + env(safe-area-inset-top));
    flex-wrap: wrap;
}
.aic-backbar--light {
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    box-shadow: 0 1px 2px rgba(0,0,0,.03);
}
.aic-backbar--dark {
    background: rgba(13,11,30,.93);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid rgba(123,79,255,.25);
}
.aic-backbar__back {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 7px 14px;
    border-radius: 9px;
    font-weight: 700;
    font-size: 13.5px;
    text-decoration: none;
    white-space: nowrap;
    flex-shrink: 0;
}
.aic-backbar--light .aic-backbar__back {
    color: var(--aic-primary);
    background: #eef2ff;
}
@media (hover: hover) { .aic-backbar--light .aic-backbar__back:hover { background: #e0e7ff; } }
.aic-backbar--dark .aic-backbar__back {
    color: #bcb2dd;
    background: rgba(255,255,255,.06);
    border: 1px solid rgba(255,255,255,.1);
    font-family: 'Heebo', sans-serif;
}
@media (hover: hover) { .aic-backbar--dark .aic-backbar__back:hover { color: #f1ebff; background: rgba(123,79,255,.25); } }

.aic-backbar__title {
    font-weight: 800;
    font-size: 14.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}
.aic-backbar--light .aic-backbar__title { color: #1e293b; }
.aic-backbar--dark .aic-backbar__title { color: #f1ebff; }

.aic-backbar__spacer { flex: 1; min-width: 8px; }

.aic-backbar__extra {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

@media (max-width: 640px) {
    .aic-backbar__title { display: none; }
}

/* ─────────────────────────────────────────────────────────────────────
   3) PILL — כפתור "חזרה" צף (למסכי נגן תלמיד במסך מלא — בלי סרגל)
   מיקום קבוע, תמיד באותו מקום, בכל פעילות (חידון/תשבץ/משחק/תרחיש/אלגו)
   ───────────────────────────────────────────────────────────────────── */
.aic-pill {
    position: fixed;
    top: calc(12px + env(safe-area-inset-top));
    right: calc(12px + env(safe-area-inset-right));
    z-index: 500;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-height: 38px;
    padding: 8px 14px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 13px;
    text-decoration: none;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    font-family: 'Heebo', sans-serif;
    box-shadow: 0 2px 10px rgba(0,0,0,.12);
}
.aic-pill--studio {
    background: rgba(13,11,30,.85);
    color: #f0c040;
    border: 1px solid rgba(123,79,255,.25);
}
@media (hover: hover) { .aic-pill--studio:hover { background: rgba(123,79,255,.25); } }

.aic-pill--game {
    background: rgba(255,255,255,.18);
    color: #fff;
}
@media (hover: hover) { .aic-pill--game:hover { background: rgba(255,255,255,.28); } }

.aic-pill--amber {
    background: rgba(0,0,0,.55);
    color: #fff;
}
@media (hover: hover) { .aic-pill--amber:hover { background: rgba(0,0,0,.7); } }

.aic-pill--light {
    background: rgba(255,255,255,.92);
    color: #4338ca;
    border: 1px solid #e2e8f0;
}
@media (hover: hover) { .aic-pill--light:hover { background: #fff; } }

@media (max-width: 480px) {
    .aic-pill { font-size: 12px; padding: 7px 11px; }
}
