/* ==================================================================
   App-wide styles: native-feel mobile rules + admin layout chrome.
   Mobile-first; the sidebar appears ≥768px, the bottom tab bar below.
   ================================================================== */

:root {
    --brand: #3F51B5;
    --brand-dark: #303F9F;
    --surface: #F5F6FA;
    --bottom-nav-height: 60px;
    --sidebar-width: 240px;
}

html {
    /* Respect notches / home indicators on installed PWAs */
    padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}

body {
    background: var(--surface);
    min-height: 100vh;
    -webkit-tap-highlight-color: transparent;
}

/* Touch targets: never smaller than 44px on coarse pointers */
@media (pointer: coarse) {
    .btn, .form-control, .form-select, .nav-link, .list-group-item-action {
        min-height: 44px;
    }
}

/* ------------------------------------------------------------------
   Admin shell
   ------------------------------------------------------------------ */

.app-topbar {
    background: var(--brand);
    color: #fff;
    height: 56px;
    position: sticky;
    top: 0;
    z-index: 1030;
}

.app-topbar .navbar-brand { color: #fff; font-weight: 600; }

.app-sidebar {
    display: none;
}

.app-content {
    padding: 1rem;
    padding-bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom) + 1rem);
}

/* Bottom tab bar — phones only */
.app-bottomnav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: #fff;
    border-top: 1px solid #e5e7eb;
    display: flex;
    z-index: 1030;
}

.app-bottomnav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font-size: 11px;
    color: #6b7280;
    text-decoration: none;
    min-height: 44px;
}

.app-bottomnav a.active { color: var(--brand); font-weight: 600; }
.app-bottomnav a i { font-size: 20px; line-height: 1; }

@media (min-width: 768px) {
    .app-bottomnav { display: none; }

    .app-sidebar {
        display: block;
        position: fixed;
        top: 56px;
        bottom: 0;
        width: var(--sidebar-width);
        background: #fff;
        border-right: 1px solid #e5e7eb;
        overflow-y: auto;
        z-index: 1020;
    }

    .app-sidebar .nav-link {
        color: #374151;
        border-radius: 8px;
        margin: 2px 8px;
        padding: 10px 14px;
    }

    .app-sidebar .nav-link.active,
    .app-sidebar .nav-link:hover { background: #eef0fb; color: var(--brand); }

    .app-sidebar .nav-group-toggle {
        display: flex;
        align-items: center;
        cursor: pointer;
    }

    .app-sidebar .nav-group-chevron {
        font-size: 0.75rem;
        transition: transform 0.15s ease-in-out;
    }

    .app-sidebar .nav-group-toggle[aria-expanded="true"] .nav-group-chevron {
        transform: rotate(180deg);
    }

    .app-sidebar .nav-link-child {
        padding-left: 2.5rem;
        font-size: 0.925rem;
    }

    .app-content {
        margin-left: var(--sidebar-width);
        padding: 1.5rem;
    }
}

/* ------------------------------------------------------------------
   Skeleton loaders (used instead of spinners on slow lists)
   ------------------------------------------------------------------ */

.skeleton {
    background: linear-gradient(90deg, #ececf3 25%, #f6f6fa 37%, #ececf3 63%);
    background-size: 400% 100%;
    animation: skeleton-wave 1.4s ease infinite;
    border-radius: 6px;
    min-height: 1em;
}

@keyframes skeleton-wave {
    0% { background-position: 100% 50%; }
    100% { background-position: 0 50%; }
}

/* ------------------------------------------------------------------
   Auth screens
   ------------------------------------------------------------------ */

.auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.auth-card {
    width: 100%;
    max-width: 400px;
}

/* PWA install button hidden until beforeinstallprompt fires */
#pwa-install-btn { display: none; }

/* Print: hide app chrome */
@media print {
    .app-topbar, .app-sidebar, .app-bottomnav, .btn, .no-print { display: none !important; }
    .app-content { margin: 0; padding: 0; }
}
