/* ══════════════════════════════════════════════════════════
   Hasight MobileHost — Mobile PWA Shell Styles
   Uses Haori design tokens where possible
   ══════════════════════════════════════════════════════════ */

:root {
    --color-primary: #0078D4;
    --color-primary-dark: #005A9E;
    --color-background: #F3F2F1;
    --color-surface: #FFFFFF;
    --color-text: #323130;
    --color-text-muted: #605E5C;
    --color-danger: #D13438;
    --color-warning: #FFB900;
    --color-success: #107C10;
    --mobile-topbar-height: 48px;
    --mobile-bottomnav-height: 56px;
    --mobile-text-base: 16px;
    --mobile-touch-min: 44px;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: var(--mobile-text-base);
    color: var(--color-text);
    background: var(--color-background);
    -webkit-text-size-adjust: 100%;
    overflow-x: hidden;
}

/* ── Banners ── */
.haori-clock-banner,
.haori-offline-banner {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    z-index: 1100;
}

.haori-offline-banner {
    background: #605E5C;
    color: #FFFFFF;
}

.haori-clock-banner--warning {
    background: #FFF4CE;
    color: #835C00;
}

.haori-clock-banner--danger {
    background: #FDE7E9;
    color: #A80000;
}

/* ── Top Bar ── */
.mobile-topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--mobile-topbar-height);
    background: var(--color-primary);
    color: #FFFFFF;
    display: flex;
    align-items: center;
    padding: 0 8px;
    z-index: 1000;
    box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}

.mobile-topbar__btn {
    width: var(--mobile-touch-min);
    height: var(--mobile-touch-min);
    background: transparent;
    border: none;
    color: #FFFFFF;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.mobile-topbar__btn:active {
    background: rgba(255,255,255,0.15);
}

.mobile-topbar__title {
    flex: 1;
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mobile-topbar__actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ── Storage Indicator ── */
.storage-indicator {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(255,255,255,0.2);
    color: #FFFFFF;
}

.storage-indicator--warning {
    background: var(--color-warning);
    color: #323130;
}

.storage-indicator--danger {
    background: var(--color-danger);
    color: #FFFFFF;
}

/* ── Main Content Area ── */
.mobile-content {
    margin-top: var(--mobile-topbar-height);
    margin-bottom: var(--mobile-bottomnav-height);
    padding: 16px;
    min-height: calc(100vh - var(--mobile-topbar-height) - var(--mobile-bottomnav-height));
}

/* ── Bottom Navigation ── */
.mobile-bottomnav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--mobile-bottomnav-height);
    background: var(--color-surface);
    display: flex;
    align-items: center;
    justify-content: space-around;
    box-shadow: 0 -1px 3px rgba(0,0,0,0.12);
    z-index: 1000;
}

.mobile-bottomnav__tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: var(--mobile-touch-min);
    min-height: var(--mobile-touch-min);
    text-decoration: none;
    color: var(--color-text-muted);
    font-size: 10px;
    position: relative;
    padding: 4px 8px;
}

.mobile-bottomnav__tab i {
    font-size: 20px;
    margin-bottom: 2px;
}

.mobile-bottomnav__tab.active,
.mobile-bottomnav__tab:hover {
    color: var(--color-primary);
}

.mobile-bottomnav__badge {
    position: absolute;
    top: 2px;
    right: 2px;
    background: var(--color-danger);
    color: #FFFFFF;
    font-size: 10px;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    line-height: 16px;
    text-align: center;
    border-radius: 8px;
    padding: 0 4px;
}

/* ── Login Page ── */
.mobile-login {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
    background: var(--color-surface);
}

.mobile-login__logo {
    width: 96px;
    height: 96px;
    margin-bottom: 24px;
}

.mobile-login__title {
    font-size: 24px;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 24px;
}

.mobile-login__form {
    width: 100%;
    max-width: 360px;
}

.mobile-login__field {
    margin-bottom: 16px;
}

.mobile-login__field label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text);
    margin-bottom: 4px;
}

.mobile-login__field input {
    width: 100%;
    height: var(--mobile-touch-min);
    padding: 8px 12px;
    border: 1px solid #EDEBE9;
    border-radius: 4px;
    font-size: 16px;
    background: var(--color-surface);
    color: var(--color-text);
}

.mobile-login__field input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(0, 120, 212, 0.2);
}

.mobile-login__btn {
    width: 100%;
    height: var(--mobile-touch-min);
    background: var(--color-primary);
    color: #FFFFFF;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
}

.mobile-login__btn:active {
    background: var(--color-primary-dark);
}

.mobile-login__btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.mobile-login__error {
    display: none;
    background: #FDE7E9;
    color: #A80000;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 14px;
    margin-bottom: 16px;
    text-align: center;
}

.mobile-login__error.visible {
    display: block;
}

.mobile-login__link {
    text-align: center;
    margin-top: 16px;
}

.mobile-login__link a {
    color: var(--color-primary);
    font-size: 14px;
    text-decoration: none;
}

/* ── Lock Screen ── */
.haori-lock-screen {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--color-background);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
}
.haori-lock-screen__inner {
    text-align: center;
    padding: 32px 24px;
    max-width: 320px;
    width: 100%;
}
.haori-lock-screen__logo {
    width: 64px; height: 64px;
    margin-bottom: 16px;
}
.haori-lock-screen__inner h2 {
    font-size: 20px;
    font-weight: 600;
    margin: 0 0 8px;
}
.haori-lock-screen__inner p {
    color: var(--color-text-muted);
    font-size: 14px;
    margin: 0 0 20px;
}
.haori-lock-screen__input {
    display: block;
    width: 120px;
    margin: 0 auto 16px;
    padding: 12px;
    font-size: 24px;
    text-align: center;
    letter-spacing: 8px;
    border: 2px solid #D2D0CE;
    border-radius: 8px;
    background: var(--color-surface);
    -webkit-appearance: none;
}
.haori-lock-screen__input:focus {
    border-color: var(--color-primary);
    outline: none;
}
.haori-lock-screen__btn {
    display: block;
    width: 200px;
    margin: 0 auto;
    padding: 12px;
    background: var(--color-primary);
    color: #FFFFFF;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    min-height: 44px;
}
.haori-lock-screen__btn:active {
    background: var(--color-primary-dark);
}
.haori-lock-screen__error {
    color: var(--color-danger);
    font-size: 14px;
    margin-top: 12px;
    min-height: 20px;
}

/* ── Utility ── */
.me-2 { margin-right: 8px; }
.ms-auto { margin-left: auto; }
.text-center { text-align: center; }
.mt-3 { margin-top: 16px; }

/* === Page header === */
.mobile-page-header { display: flex; align-items: center; padding: 0.75rem 0; margin-bottom: 0.5rem; }
.mobile-page-header__back {
    width: 36px; height: 36px; border: none; background: transparent;
    font-size: 1.1rem; color: var(--color-primary); cursor: pointer;
    display: flex; align-items: center; justify-content: center; border-radius: 50%;
}
.mobile-page-header__back:active { background: rgba(0,120,212,0.1); }
.mobile-page-header__title { flex: 1; font-size: 1.15rem; font-weight: 600; margin: 0; }
.mobile-page-header__action {
    width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
    border-radius: 50%; color: var(--color-primary); font-size: 1.1rem; text-decoration: none;
}
.mobile-page-header__action:active { background: rgba(0,120,212,0.1); }

/* === Skeleton loader === */
.mobile-skeleton__card { padding: 1rem; border-radius: 8px; background: #fff; margin-bottom: 0.75rem; }
.mobile-skeleton__line {
    height: 14px; border-radius: 4px; margin-bottom: 8px;
    background: linear-gradient(90deg, #e0e0e0 25%, #f0f0f0 50%, #e0e0e0 75%);
    background-size: 200% 100%;
    animation: skeleton-pulse 1.5s ease-in-out infinite;
}
.mobile-skeleton__line--short  { width: 40%; }
.mobile-skeleton__line--medium { width: 70%; }
@keyframes skeleton-pulse {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* === Offline banner (per-page stale data indicator) === */
.mobile-offline-banner {
    display: flex; align-items: center; padding: 0.5rem 1rem;
    background: #fff3cd; border-left: 4px solid #ffc107;
    font-size: 0.85rem; color: #856404; margin-bottom: 0.75rem;
}

/* === KPI tiles (Mobile.Intelligence) === */
.mobile-kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; margin-bottom: 1rem; }
.mobile-kpi-tile { background: #fff; border-radius: 8px; padding: 1rem; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.mobile-kpi-tile__icon { font-size: 1.4rem; margin-bottom: 0.5rem; color: #0078D4; }
.mobile-kpi-tile__value { font-size: 1.4rem; font-weight: 700; color: #111; }
.mobile-kpi-tile__label { font-size: 0.78rem; color: #666; margin-top: 0.25rem; }
.mobile-kpi-tile__trend { font-size: 0.75rem; margin-top: 0.25rem; }
.mobile-kpi-tile__trend--up   { color: #28a745; }
.mobile-kpi-tile__trend--down { color: #dc3545; }

/* === Health score cards === */
.mobile-health-card { background: #fff; border-radius: 8px; padding: 1rem; margin-bottom: 0.75rem; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.mobile-health-card__score { font-size: 2rem; font-weight: 700; }
.mobile-health-card__score--good   { color: #28a745; }
.mobile-health-card__score--warn   { color: #fd7e14; }
.mobile-health-card__score--bad    { color: #dc3545; }
.mobile-health-bar { height: 4px; border-radius: 2px; background: #e9ecef; margin: 2px 0; }
.mobile-health-bar__fill { height: 100%; border-radius: 2px; }

/* === Home page module cards === */
.mobile-home__card { position: relative; }
.mobile-home__badge {
    position: absolute; top: -4px; right: -4px;
    background: #dc3545; color: #fff; border-radius: 50%;
    width: 20px; height: 20px; font-size: 0.65rem;
    display: flex; align-items: center; justify-content: center; font-weight: 700;
}
