/*
  Neural Care Monitor — Light Glassmorphic Theme
  Production-ready. English only. No emojis.
  Accent: Cyan (#00B4D8)
*/

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700;800&family=JetBrains+Mono:wght@400;700&display=swap');

:root {
    --bg: #F0F4F8;
    --bg-gradient: linear-gradient(170deg, #F0F4F8 0%, #E2ECF5 40%, #F0F4F8 100%);
    --card: rgba(255, 255, 255, 0.72);
    --card-solid: #FFFFFF;
    --card-border: rgba(0, 0, 0, 0.06);
    --glass: rgba(255, 255, 255, 0.55);
    --glass-border: rgba(255, 255, 255, 0.8);
    --glass-shadow: 0 4px 24px rgba(0, 50, 100, 0.06), 0 1px 4px rgba(0, 50, 100, 0.04);
    --primary: #00B4D8;
    --primary-light: #90E0EF;
    --primary-pale: rgba(0, 180, 216, 0.08);
    --primary-glow: rgba(0, 180, 216, 0.25);
    --danger: #FF6B6B;
    --danger-pale: rgba(255, 107, 107, 0.08);
    --danger-glow: rgba(255, 107, 107, 0.25);
    --success: #10B981;
    --warning: #F59E0B;
    --text: #1E293B;
    --text-mid: #475569;
    --text-dim: #94A3B8;
    --separator: rgba(0, 0, 0, 0.05);
    --font-main: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', monospace;
}

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

body {
    background: var(--bg-gradient);
    color: var(--text);
    font-family: var(--font-main);
    -webkit-font-smoothing: antialiased;
}

/* Subtle ambient blobs */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background:
        radial-gradient(ellipse 50% 40% at 15% 20%, rgba(0, 180, 216, 0.07) 0%, transparent 70%),
        radial-gradient(ellipse 40% 50% at 85% 75%, rgba(144, 224, 239, 0.06) 0%, transparent 70%),
        radial-gradient(ellipse 60% 30% at 50% 95%, rgba(0, 180, 216, 0.04) 0%, transparent 70%);
}

/* ============================================================
   MAIN APP SHELL
   ============================================================ */
.app-shell {
    max-width: 428px;
    margin: 0 auto;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

.app-shell::-webkit-scrollbar { width: 0; }

/* ============================================================
   HEADER
   ============================================================ */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px 12px;
    flex-shrink: 0;
}

.logo {
    font-family: var(--font-mono);
    font-weight: 700;
    letter-spacing: 3px;
    font-size: 0.7rem;
    color: var(--text-dim);
    text-transform: uppercase;
}

.status-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-mono);
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-dim);
    background: var(--card);
    border: 1px solid var(--card-border);
    padding: 6px 16px;
    border-radius: 20px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: var(--glass-shadow);
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--primary);
    box-shadow: 0 0 6px var(--primary-glow);
    animation: pulse 2.5s ease-in-out infinite;
}

.status-dot.learning { background: var(--warning); box-shadow: 0 0 6px rgba(245, 158, 11, 0.3); }
.status-dot.alert { background: var(--danger); box-shadow: 0 0 6px var(--danger-glow); animation: pulseAlert 1s ease-in-out infinite; }

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(1.4); }
}

@keyframes pulseAlert {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(1.5); }
}

/* ============================================================
   MAIN VIEW — Status + Diamond
   ============================================================ */
.main-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 0;
    padding: 0 24px;
}

.status-text {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    color: var(--text-dim);
    letter-spacing: 3px;
    text-transform: uppercase;
    margin-bottom: 8px;
    transition: color 0.5s ease;
}

.status-value {
    font-size: 2.8rem;
    font-weight: 800;
    letter-spacing: -1px;
    line-height: 1;
    transition: all 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.status-value.ok {
    color: var(--primary);
}

.status-value.learning {
    color: var(--warning);
}

.status-value.alert {
    color: var(--danger);
    animation: alertBreathe 1.5s ease-in-out infinite;
}

@keyframes alertBreathe {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.85; transform: scale(1.02); }
}

/* ============================================================
   DIAMOND (Plumbob) — Cyan, Interactive
   ============================================================ */
.diamond-area {
    margin: 32px 0 20px;
    cursor: pointer;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.diamond-area:active { transform: scale(0.94); }

.gem-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: bob 3.8s ease-in-out infinite;
}

.halo {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    top: 50%;
    left: 50%;
}

.h1 {
    width: 140px;
    height: 140px;
    transform: translate(-50%, -50%);
    border: 1.5px solid rgba(0, 180, 216, 0.18);
    animation: haloAnim 2.8s ease-in-out infinite;
}

.h2 {
    width: 200px;
    height: 200px;
    transform: translate(-50%, -50%);
    border: 1px solid rgba(0, 180, 216, 0.08);
    animation: haloAnim 2.8s ease-in-out infinite 0.8s;
}

@keyframes haloAnim {
    0%, 100% { opacity: 0.6; transform: translate(-50%, -50%) scale(1); }
    50% { opacity: 0.15; transform: translate(-50%, -50%) scale(1.1); }
}

@keyframes bob {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-12px); }
}

#plumbobSvg {
    display: block;
    overflow: visible;
    width: 88px;
    height: 168px;
}

.diamond-hint {
    font-family: var(--font-mono);
    font-size: 0.5rem;
    color: var(--text-dim);
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-top: 6px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.diamond-area:hover .diamond-hint,
.diamond-hint.visible { opacity: 0.6; }

/* Sub-status line */
.sub-status {
    font-size: 0.65rem;
    color: var(--text-dim);
    margin-top: 12px;
    font-family: var(--font-mono);
    letter-spacing: 0.5px;
}

/* ============================================================
   MAP OVERLAY (Full-screen, on diamond tap)
   ============================================================ */
#mapOverlay {
    position: fixed;
    inset: 0;
    z-index: 800;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    transform: translateY(100%);
    transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
    will-change: transform;
}

#mapOverlay.open {
    transform: translateY(0);
}

.map-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    flex-shrink: 0;
    background: var(--card);
    border-bottom: 1px solid var(--card-border);
}

.map-header-title {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 0.7rem;
    letter-spacing: 2px;
    color: var(--text-dim);
    text-transform: uppercase;
}

.close-btn {
    background: var(--bg);
    border: 1px solid var(--card-border);
    color: var(--text-mid);
    padding: 8px 18px;
    border-radius: 20px;
    font-family: var(--font-mono);
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.2s ease;
}

.close-btn:active {
    transform: scale(0.96);
    background: var(--card);
}

.map-area {
    flex: 1;
    min-height: 0;
}

#liveMap {
    width: 100%;
    height: 100%;
}

/* Timeline below map */
.timeline-section {
    max-height: 35vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: var(--card-solid);
    border-top: 1px solid var(--card-border);
    padding: 12px 20px 24px;
    flex-shrink: 0;
}

.timeline-section::-webkit-scrollbar { width: 0; }

.timeline-title {
    font-family: var(--font-mono);
    font-size: 0.55rem;
    color: var(--text-dim);
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: 10px;
}

.timeline-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 8px 0;
}

.timeline-item + .timeline-item {
    border-top: 1px solid var(--separator);
}

.timeline-dot-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 4px;
}

.timeline-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary);
    flex-shrink: 0;
}

.timeline-dot.anomaly { background: var(--danger); }

.timeline-line {
    width: 1px;
    flex: 1;
    background: var(--separator);
    min-height: 16px;
}

.timeline-content {
    flex: 1;
    min-width: 0;
}

.timeline-time {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 2px;
}

.timeline-coords {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    color: var(--text-dim);
}

.timeline-empty {
    text-align: center;
    padding: 24px;
    font-size: 0.75rem;
    color: var(--text-dim);
}

/* ============================================================
   LOADING OVERLAY
   ============================================================ */
#loadingOverlay {
    position: fixed;
    inset: 0;
    background: var(--bg-gradient);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.8s ease;
}

#loadingOverlay::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse 50% 40% at 50% 45%, rgba(0, 180, 216, 0.08) 0%, transparent 70%);
    pointer-events: none;
}

#loadingOverlay.done {
    opacity: 0;
    pointer-events: none;
}

.loading-label {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    color: var(--text-dim);
    letter-spacing: 4px;
    text-transform: uppercase;
    margin-top: 20px;
}

/* ============================================================
   TOAST
   ============================================================ */
.toast {
    position: fixed;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%) translateY(60px);
    background: var(--card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--card-border);
    color: var(--text);
    padding: 12px 24px;
    border-radius: 24px;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    letter-spacing: 0.5px;
    box-shadow: 0 8px 32px rgba(0, 50, 100, 0.1);
    opacity: 0;
    z-index: 2000;
    max-width: 85%;
    transition: all 0.35s cubic-bezier(0.22, 1, 0.36, 1);
    text-align: center;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ============================================================
   GPS PERMISSION PROMPT
   ============================================================ */
.gps-prompt {
    position: fixed;
    inset: 0;
    z-index: 900;
    background: rgba(240, 244, 248, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    text-align: center;
}

.gps-prompt.show { display: flex; }

.gps-prompt-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 12px;
}

.gps-prompt-desc {
    font-size: 0.85rem;
    color: var(--text-mid);
    line-height: 1.6;
    margin-bottom: 32px;
    max-width: 280px;
}

.gps-prompt-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 16px 48px;
    border-radius: 16px;
    font-family: var(--font-main);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 180, 216, 0.3);
    transition: all 0.2s ease;
}

.gps-prompt-btn:active {
    transform: scale(0.97);
    box-shadow: 0 2px 8px rgba(0, 180, 216, 0.2);
}

/* ============================================================
   SAFE AREA
   ============================================================ */
@supports (padding: max(0px)) {
    .app-shell { padding-bottom: max(16px, env(safe-area-inset-bottom)); }
    .timeline-section { padding-bottom: max(24px, env(safe-area-inset-bottom)); }
}
