/* Parent panel responsive + cross-browser overhaul.
 *
 * Namespaced via `body[data-panel="parent"]` so it doesn't bleed into the
 * other 5 panels (school / teacher / cafeteria / seller / admin).
 *
 * Mirrors the cafeteria-responsive.css pattern (sections 1-21 + Phase 2
 * a11y M-U + polish V-AE + critical sticky fix) but tuned for the parent
 * panel's purple identity. Reuses every lesson learned during the
 * cafeteria 2026-05-26 marathon.
 *
 * Load order:
 *   <link rel="stylesheet" href="/css/parent-responsive.css?v=N">
 *   <script src="https://cdn.tailwindcss.com"></script>
 *
 * Tailwind comes AFTER so its utilities still win where we want them.
 * Our overrides target areas Tailwind can't reach (vendor prefixes,
 * RTL-aware logical properties, safe-area-inset, focus-visible).
 */

/* ─── 1. iOS input zoom prevention ────────────────────────────────── */
@media (max-width: 768px) {
    body[data-panel="parent"] input,
    body[data-panel="parent"] select,
    body[data-panel="parent"] textarea {
        font-size: 16px !important;
    }
}

/* ─── 2. Safe-area-inset support (notched devices) ────────────────── */
body[data-panel="parent"] {
    padding-top: env(safe-area-inset-top, 0);
}
body[data-panel="parent"] aside {
    padding-bottom: env(safe-area-inset-bottom, 0);
}

/* ─── 3. Slim cross-browser scrollbars ────────────────────────────── */
body[data-panel="parent"] * {
    scrollbar-width: thin;
    scrollbar-color: rgba(76, 19, 162, 0.32) transparent;
}
body[data-panel="parent"] *::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
body[data-panel="parent"] *::-webkit-scrollbar-thumb {
    background: rgba(76, 19, 162, 0.32);
    border-radius: 3px;
}
body[data-panel="parent"] *::-webkit-scrollbar-thumb:hover {
    background: rgba(76, 19, 162, 0.5);
}

/* ─── 4. Sidebar mobile drawer ────────────────────────────────────── */
@media (max-width: 1023px) {
    body[data-panel="parent"] aside#parent-sidebar {
        width: min(86vw, 320px) !important;
        will-change: transform;
        overscroll-behavior: contain;
        box-shadow: 0 0 40px rgba(31, 8, 70, 0.18);
    }
}

/* ─── 5. Touch targets ≥ 44×44 (WCAG AAA) ─────────────────────────── */
@media (hover: none) and (pointer: coarse) {
    body[data-panel="parent"] .nav-link,
    body[data-panel="parent"] .btn-primary,
    body[data-panel="parent"] button:not(.no-touch-min),
    body[data-panel="parent"] a.btn-primary {
        min-height: 44px;
    }
}

/* ─── 6. Topbar padding collapse on phones ────────────────────────── */
@media (max-width: 640px) {
    body[data-panel="parent"] header.topbar-glass {
        padding-left: 12px;
        padding-right: 12px;
    }
}

/* ─── 7. Tables → cards on mobile (opt-in via data-mobile-card) ───── */
@media (max-width: 640px) {
    body[data-panel="parent"] table[data-mobile-card],
    body[data-panel="parent"] table[data-mobile-card] thead,
    body[data-panel="parent"] table[data-mobile-card] tbody,
    body[data-panel="parent"] table[data-mobile-card] th,
    body[data-panel="parent"] table[data-mobile-card] td,
    body[data-panel="parent"] table[data-mobile-card] tr {
        display: block;
    }
    body[data-panel="parent"] table[data-mobile-card] thead {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }
    body[data-panel="parent"] table[data-mobile-card] tr {
        border: 1px solid rgba(76, 19, 162, 0.12);
        border-radius: 12px;
        padding: 12px;
        margin-bottom: 10px;
        background: #fff;
    }
    body[data-panel="parent"] table[data-mobile-card] td {
        border: none;
        padding: 6px 0;
        position: relative;
        padding-inline-start: 40%;
    }
    body[data-panel="parent"] table[data-mobile-card] td::before {
        content: attr(data-label) ":";
        position: absolute;
        inset-inline-start: 0;
        top: 6px;
        font-weight: 600;
        color: #4c13a2;
        font-size: 12px;
    }
}

/* ─── 8. focus-visible accessibility ring ─────────────────────────── */
body[data-panel="parent"] *:focus-visible {
    outline: 2px solid #7e3dd0;
    outline-offset: 2px;
    border-radius: 4px;
}

/* ─── 9. prefers-reduced-motion respect ───────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    body[data-panel="parent"] *,
    body[data-panel="parent"] *::before,
    body[data-panel="parent"] *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* ─── 10. Print styles ────────────────────────────────────────────── */
@media print {
    body[data-panel="parent"] aside,
    body[data-panel="parent"] header,
    body[data-panel="parent"] .no-print {
        display: none !important;
    }
    body[data-panel="parent"] main {
        padding: 0 !important;
    }
}

/* ─── 11. iOS PWA standalone-mode top safe-area ───────────────────── */
@media (display-mode: standalone) {
    body[data-panel="parent"] header.topbar-glass {
        padding-top: max(12px, env(safe-area-inset-top));
    }
}

/* ─── 12. Firefox backdrop-filter fallback ────────────────────────── */
@supports not (backdrop-filter: blur(10px)) {
    body[data-panel="parent"] .topbar-glass {
        background: rgba(255, 255, 255, 0.95);
    }
}

/* ─── 13. WebKit number-input arrow removal ───────────────────────── */
body[data-panel="parent"] input[type="number"]::-webkit-inner-spin-button,
body[data-panel="parent"] input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    appearance: none;
    margin: 0;
}
body[data-panel="parent"] input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}

/* ─── 14. Auth shell purple selection color ───────────────────────── */
body[data-panel="parent"] ::selection {
    background: rgba(126, 61, 208, 0.25);
    color: #1f0846;
}

/* ─── 15. x-cloak (Alpine reveal) ─────────────────────────────────── */
[x-cloak] { display: none !important; }

/* ─── 16. Hover state suppression on touch devices ────────────────── */
@media (hover: none) {
    body[data-panel="parent"] .feature-card:hover {
        transform: none;
        background: rgba(255, 255, 255, 0.10);
    }
}

/* ─── 17. CRITICAL: avoid [class*="sticky"] substring trap ─────────── */
/* Lesson from cafeteria 17132b5 — never use substring class selectors
   that could accidentally match Tailwind's lg:sticky / md:sticky /
   xl:sticky responsive variants. Force position only on EXPLICIT class
   names so Tailwind's responsive utilities keep their breakpoint
   gating intact. */
body[data-panel="parent"] .sticky-explicit { position: sticky; }

/* ─── 18. RTL bell + avatar dropdown viewport-anchor on mobile ────── */
/* Lesson from cafeteria 55145da — in RTL the header right-cluster
   renders visually on the LEFT side. `absolute end-0` resolves to
   `left: 0` of the dropdown's relative parent. A 320-px wide dropdown
   then extends RIGHTWARD off-screen on phones. Fix: flip both
   dropdowns to fixed + inset-inline on ≤640px so they become a sheet
   pinned to the viewport, not the parent.

   Apply via .parent-notif-dropdown / .parent-avatar-dropdown class
   hooks on the dropdown wrappers. */
@media (max-width: 640px) {
    body[data-panel="parent"] .parent-notif-dropdown,
    body[data-panel="parent"] .parent-avatar-dropdown {
        position: fixed !important;
        top: 4.75rem !important;
        inset-inline: 0.75rem !important;
        width: auto !important;
        max-height: calc(100vh - 5.5rem - env(safe-area-inset-bottom, 0)) !important;
        overflow-y: auto !important;
    }
}

/* ─── 19. Layered card shadows (mirror cafeteria polish 6617ce4) ─── */
/* 3-layer stack: hairline ring + tight contact + soft ambient.
   Apply via .parent-card class on the card wrapper. */
body[data-panel="parent"] .parent-card {
    box-shadow:
        0 0 0 1px rgba(76, 19, 162, 0.06),
        0 1px 2px rgba(76, 19, 162, 0.04),
        0 8px 24px rgba(76, 19, 162, 0.08);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}
body[data-panel="parent"] .parent-card:hover {
    box-shadow:
        0 0 0 1px rgba(76, 19, 162, 0.10),
        0 4px 12px rgba(76, 19, 162, 0.08),
        0 16px 40px rgba(76, 19, 162, 0.12);
}

/* ─── 20. KPI numbers — tabular + nowrap ─────────────────────────── */
/* Lesson from cafeteria 6617ce4 — currency totals like "1,234.500 ﷼"
   wrap mid-glyph on narrow phones if break-all is left default. */
body[data-panel="parent"] .num-en {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
    white-space: nowrap;
}

/* ─── 21. Status badge utility (.parent-status-badge) ─────────────── */
body[data-panel="parent"] .parent-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 9999px;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.4;
}
body[data-panel="parent"] .parent-status-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}

/* ─── 22. Skeleton shimmer for loading states ───────────────────── */
@keyframes parentSkeletonShimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}
body[data-panel="parent"] .parent-skeleton {
    background: linear-gradient(90deg, #f3e8ff 0%, #faf5ff 50%, #f3e8ff 100%);
    background-size: 200% 100%;
    animation: parentSkeletonShimmer 1.6s ease-in-out infinite;
    border-radius: 8px;
}

/* ─── 23. Section divider (Shopify POS-style small-caps + rail) ──── */
body[data-panel="parent"] .parent-section-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 20px 0 12px;
}
body[data-panel="parent"] .parent-section-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(76, 19, 162, 0.12);
}
body[data-panel="parent"] .parent-section-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(76, 19, 162, 0.6);
}

/* ─── 24. Reduce-motion respect for layered shadows ──────────────── */
@media (prefers-reduced-motion: reduce) {
    body[data-panel="parent"] .parent-card { transition: none; }
    body[data-panel="parent"] .parent-card:hover { transform: none; }
}
