/* ══════════════════════════════════════════
   DESIGN TOKENS
══════════════════════════════════════════ */
:root {
    --forest:    #1a2e1a;
    --moss:      #2d4a2d;
    --sage:      #4a7c59;
    --lime:      #7ab648;
    --gold:      #c9a84c;
    --cream:     #f5f0e8;
    --charcoal:  #1c1c1c;
    --text:      #2a2a2a;
    --muted:     #6b7163;
    --white:     #ffffff;

    --safe-top:    env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left:   env(safe-area-inset-left, 0px);
    --safe-right:  env(safe-area-inset-right, 0px);

    --nav-h: 64px;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    font-family: 'Outfit', sans-serif;
    overflow: hidden;
    background: #000;
    height: 100%;
    overscroll-behavior: none;
}

/* ══════════════════════════════════════════
   NAVBAR
══════════════════════════════════════════ */
/* SESUDAH */
.navbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 6%;
    padding-top: calc(16px + var(--safe-top));
    background: rgba(26,46,26,0.97);
    box-shadow: 0 2px 20px rgba(0,0,0,0.3);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.brand {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--white);
    text-decoration: none;
    letter-spacing: 1px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}
.brand span { color: var(--gold); }

.brand-logo {
    width: 36px;
    height: 36px;
    max-width: 36px;
    max-height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 1.5px solid rgba(255,255,255,0.25);
    flex-shrink: 0;
}

.nav-links {
    display: flex;
    gap: 28px;
}
.nav-links a {
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    transition: color 0.2s;
    position: relative;
}
.nav-links a::after {
    content: '';
    position: absolute;
    bottom: -4px; left: 0;
    width: 0; height: 1px;
    background: var(--gold);
    transition: width 0.3s;
}
.nav-links a:hover        { color: var(--gold); }
.nav-links a:hover::after { width: 100%; }
.nav-links a.active       { color: var(--gold); }
.nav-links a.active::after{ width: 100%; }

.nav-auth { display: flex; gap: 10px; align-items: center; }

.btn-profil {
    background: var(--sage); color: white;
    padding: 8px 18px; border-radius: 3px;
    text-decoration: none; font-size: 0.8rem;
    font-weight: 600; letter-spacing: 0.5px;
    text-transform: uppercase; border: none;
    cursor: pointer; font-family: 'Outfit', sans-serif;
    transition: background 0.2s; white-space: nowrap;
}
.btn-profil:hover { background: var(--moss); }

.btn-logout {
    background: transparent; color: rgba(255,255,255,0.7);
    padding: 8px 14px; border-radius: 3px;
    text-decoration: none; font-size: 0.8rem;
    font-weight: 500; letter-spacing: 0.5px;
    text-transform: uppercase;
    border: 1px solid rgba(255,255,255,0.3);
    cursor: pointer; font-family: 'Outfit', sans-serif;
    transition: all 0.25s; white-space: nowrap;
}
.btn-logout:hover { color: white; border-color: white; }

/* Hamburger */
.hamburger {
    display: none;
    flex-direction: column;
    gap: 5px;
    cursor: pointer;
    padding: 4px;
    background: none;
    border: none;
}
.hamburger span {
    display: block;
    width: 24px; height: 2px;
    background: white;
    border-radius: 2px;
    transition: all 0.3s;
}
.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Mobile Menu */
.mobile-menu {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 9000;
    background: rgba(26,46,26,0.99);
    padding-top: calc(var(--nav-h) + var(--safe-top) + 8px);
    padding-bottom: 20px;
    padding-left: 24px;
    padding-right: 24px;
    flex-direction: column;
    transform: translateY(-100%);
    transition: transform 0.35s ease;
    box-shadow: 0 8px 30px rgba(0,0,0,0.5);
}
.mobile-menu.open { transform: translateY(0); }
.mobile-menu a {
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    font-size: 1rem; font-weight: 500;
    padding: 13px 0;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    display: flex; align-items: center; gap: 12px;
    transition: color 0.2s;
    -webkit-tap-highlight-color: transparent;
}
.mobile-menu a:last-of-type { border-bottom: none; }
.mobile-menu a i { color: var(--gold); width: 18px; }
.mobile-menu a:hover,
.mobile-menu a.active { color: var(--gold); }
.mobile-menu-auth { display: flex; gap: 10px; margin-top: 16px; }
.mobile-menu-auth a {
    flex: 1; justify-content: center;
    border-bottom: none !important;
    padding: 11px !important;
    border-radius: 4px;
    font-size: 0.875rem !important;
}
.mob-btn-profil { background: var(--sage); color: white !important; }
.mob-btn-logout { border: 1px solid rgba(255,255,255,0.3); color: rgba(255,255,255,0.7) !important; }

/* ══════════════════════════════════════════
   MAP
══════════════════════════════════════════ */
#map {
    position: absolute;
    top: calc(var(--nav-h) + var(--safe-top));
    bottom: 0;
    left: 0; right: 0;
}

/* ══════════════════════════════════════════
   STATUS BOX (GPS)
══════════════════════════════════════════ */
.status-box {
    position: absolute;
    top: calc(var(--nav-h) + var(--safe-top) + 12px);
    right: 14px;
    background: rgba(26,46,26,0.92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 10px 16px;
    border-radius: 8px;
    z-index: 1000;
    box-shadow: 0 4px 15px rgba(0,0,0,0.35);
    border-left: 3px solid var(--gold);
    min-width: 160px;
    max-width: 200px;
}
.status-box small {
    display: block;
    font-size: 0.6rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: rgba(255,255,255,0.45);
    margin-bottom: 3px;
}
.status-box strong {
    font-size: 0.82rem;
    color: var(--white);
    font-weight: 500;
}

/* ══════════════════════════════════════════
   SIDEBAR CONTROLS
══════════════════════════════════════════ */
.sidebar {
    position: absolute;
    left: 14px;
    top: calc(var(--nav-h) + var(--safe-top) + 12px);
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 1000;
}

.btn-side {
    width: 44px; height: 44px;
    border: none;
    border-radius: 8px;
    background: rgba(26,46,26,0.92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: rgba(255,255,255,0.85);
    cursor: pointer;
    font-size: 15px;
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
.btn-side:hover,
.btn-side:active      { background: var(--moss); color: var(--white); }
.btn-download         { background: var(--sage); color: var(--white); }
.btn-download:hover   { background: var(--moss); }

.btn-download.loading {
    opacity: 0.7;
    cursor: not-allowed;
    pointer-events: none;
}
.btn-download.loading i { animation: spin 1s linear infinite; }

@keyframes spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* ══════════════════════════════════════════
   LEGEND PANEL
══════════════════════════════════════════ */
.legend {
    position: absolute;
    bottom: calc(80px + var(--safe-bottom));
    left: 14px;
    background: rgba(26,46,26,0.92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 8px;
    z-index: 1000;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    overflow: hidden;
    transition: max-height 0.35s ease;
    max-height: 260px;
}
.legend.collapsed { max-height: 44px; }
.legend-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 14px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.legend-header span {
    font-size: 0.7rem; letter-spacing: 2px;
    text-transform: uppercase; color: var(--gold);
    font-weight: 600;
}
.legend-header i {
    color: rgba(255,255,255,0.6);
    font-size: 0.8rem;
    transition: transform 0.3s;
}
.legend.collapsed .legend-header i { transform: rotate(-90deg); }
.legend-body { padding: 0 14px 12px; }
.legend-item {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 8px;
    font-size: 0.78rem; color: rgba(255,255,255,0.75);
}
.legend-dot {
    width: 12px; height: 12px;
    border-radius: 50%; border: 2px solid white;
    flex-shrink: 0;
}
.l-basecamp { background: var(--sage); }
.l-pos      { background: var(--lime); }
.l-puncak   { background: #c0392b; }
.l-air      { background: #2980b9; }
.l-mushola  { background: #16a085; }
.legend-line {
    width: 20px; height: 3px;
    background: var(--lime);
    border-radius: 2px;
    flex-shrink: 0;
}

/* ══════════════════════════════════════════
   SOS BUTTON
══════════════════════════════════════════ */
.btn-sos {
    position: fixed;
    bottom: calc(16px + var(--safe-bottom));
    right: 14px;
    background: #c0392b;
    color: white;
    border: none;
    padding: 14px 22px;
    border-radius: 50px;
    font-weight: 700;
    font-size: 0.82rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    cursor: pointer;
    z-index: 9998;
    font-family: 'Outfit', sans-serif;
    box-shadow: 0 4px 20px rgba(192,57,43,0.55);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    animation: sosPulse 2.5s infinite;
}
@keyframes sosPulse {
    0%, 100% { box-shadow: 0 4px 20px rgba(192,57,43,0.55); }
    50%       { box-shadow: 0 4px 28px rgba(192,57,43,0.85); }
}
.btn-sos:hover,
.btn-sos:active {
    background: #a93226;
    transform: scale(1.03);
    animation: none;
}
.btn-sos i { font-size: 0.95rem; }

/* ══════════════════════════════════════════
   ELEVATION BADGE
══════════════════════════════════════════ */
.elevasi {
    position: absolute;
    bottom: calc(16px + var(--safe-bottom));
    left: 50%;
    transform: translateX(-50%);
    background: rgba(26,46,26,0.92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: var(--white);
    padding: 9px 22px;
    border-radius: 50px;
    border: 1px solid rgba(201,168,76,0.4);
    z-index: 1000;
    font-size: 0.76rem;
    font-weight: 500;
    letter-spacing: 0.5px;
    white-space: nowrap;
    pointer-events: none;
}
.elevasi span { color: var(--gold); font-weight: 600; }

/* ══════════════════════════════════════════
   POPUP & MARKER STYLES
══════════════════════════════════════════ */
.maplibregl-popup-content {
    font-family: 'Outfit', sans-serif !important;
    border-radius: 10px !important;
    padding: 14px 16px !important;
    box-shadow: 0 8px 24px rgba(0,0,0,0.25) !important;
    max-width: 220px !important;
}
.maplibregl-popup-content h4 {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1rem;
    color: var(--forest);
    margin-bottom: 5px;
}
.maplibregl-popup-content p {
    font-size: 0.81rem;
    color: var(--muted);
    line-height: 1.6;
}

.marker-pos { display: flex; flex-direction: column; align-items: center; cursor: pointer; }
.icon-p {
    width: 30px; height: 30px;
    background: var(--sage); color: #fff;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid #fff;
    font-size: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    transition: transform 0.2s;
    -webkit-tap-highlight-color: transparent;
}
.icon-p:hover,
.icon-p:active  { transform: scale(1.2); }
.icon-p.puncak  { background: #c0392b; width: 36px; height: 36px; font-size: 14px; }
.icon-p.air     { background: #2980b9; }
.icon-p.mushola { background: #16a085; }
.lbl {
    background: rgba(26,46,26,0.88);
    color: #fff;
    font-size: 9px;
    font-family: 'Outfit', sans-serif;
    padding: 3px 7px;
    border-radius: 4px;
    margin-top: 3px;
    white-space: nowrap;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
.user-dot {
    width: 18px; height: 18px;
    background: #3498db;
    border-radius: 50%;
    border: 3px solid #fff;
    box-shadow: 0 0 14px rgba(52,152,219,0.8);
}

/* ══════════════════════════════════════════
   TOAST NOTIFICATION
══════════════════════════════════════════ */
.toast {
    position: fixed;
    top: calc(var(--nav-h) + var(--safe-top) + 16px);
    left: 50%; transform: translateX(-50%);
    background: rgba(26,46,26,0.97);
    color: white;
    padding: 12px 22px;
    border-radius: 8px;
    font-size: 0.85rem;
    z-index: 99999;
    box-shadow: 0 4px 20px rgba(0,0,0,0.35);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    border-left: 3px solid var(--gold);
    max-width: 90vw;
    white-space: normal;
    text-align: center;
}
.toast.show    { opacity: 1; pointer-events: auto; }
.toast.success { border-left-color: var(--lime); }
.toast.error   { border-left-color: #e74c3c; }

/* ══════════════════════════════════════════
   SOS CONFIRM DIALOG
══════════════════════════════════════════ */
.confirm-overlay {
    display: none;
    position: fixed; inset: 0;
    z-index: 99999;
    background: rgba(0,0,0,0.65);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    align-items: flex-end;
    justify-content: center;
}
.confirm-overlay.open { display: flex; }
.confirm-box {
    background: white;
    width: 100%; max-width: 480px;
    border-radius: 16px 16px 0 0;
    padding: 24px 24px calc(24px + var(--safe-bottom));
    animation: slideUpModal 0.3s ease-out;
}
@keyframes slideUpModal {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}
.confirm-handle {
    width: 40px; height: 4px;
    background: rgba(0,0,0,0.12);
    border-radius: 2px;
    margin: 0 auto 20px;
}
.confirm-icon {
    width: 60px; height: 60px;
    background: #fde8e8;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 16px;
}
.confirm-icon i { color: #c0392b; font-size: 1.6rem; }
.confirm-box h3 {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.4rem; text-align: center;
    color: var(--forest); margin-bottom: 8px;
}
.confirm-box p {
    font-size: 0.88rem; text-align: center;
    color: var(--muted); line-height: 1.6;
    margin-bottom: 22px;
}
.confirm-actions { display: flex; gap: 10px; }
.confirm-yes {
    flex: 1; padding: 13px;
    background: #c0392b; color: white;
    border: none; border-radius: 8px;
    font-size: 0.9rem; font-weight: 700;
    font-family: 'Outfit', sans-serif;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.confirm-no {
    flex: 1; padding: 13px;
    background: #f3f3f3; color: var(--text);
    border: none; border-radius: 8px;
    font-size: 0.9rem; font-weight: 500;
    font-family: 'Outfit', sans-serif;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

/* ══════════════════════════════════════════
   DOWNLOAD OVERLAY
══════════════════════════════════════════ */
.download-overlay {
    display: none;
    position: fixed; inset: 0;
    z-index: 99998;
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    align-items: center;
    justify-content: center;
}
.download-overlay.open { display: flex; }
.download-box {
    background: rgba(26,46,26,0.97);
    border: 1px solid rgba(201,168,76,0.3);
    border-radius: 16px;
    padding: 32px 40px;
    text-align: center;
    min-width: 240px;
    box-shadow: 0 16px 48px rgba(0,0,0,0.5);
}
.download-spinner {
    width: 48px; height: 48px;
    border: 3px solid rgba(255,255,255,0.15);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
    margin: 0 auto 16px;
}
.download-box p {
    color: rgba(255,255,255,0.85);
    font-size: 0.9rem; font-weight: 500;
    letter-spacing: 0.3px;
}
.download-box small {
    color: rgba(255,255,255,0.4);
    font-size: 0.75rem;
    display: block;
    margin-top: 6px;
}

/* ══════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════ */
@media (max-width: 768px) {
    :root { --nav-h: 56px; }

    .nav-links  { display: none; }
    .nav-auth   { display: none; }
    .hamburger  { display: flex; }

    .sidebar    { left: 10px; gap: 6px; }
    .btn-side   { width: 40px; height: 40px; font-size: 13px; border-radius: 6px; }

    .status-box { right: 10px; min-width: 140px; padding: 8px 12px; }
    .status-box strong { font-size: 0.78rem; }

    .btn-sos    { padding: 13px 18px; font-size: 0.78rem; right: 10px; }
    .elevasi    { font-size: 0.7rem; padding: 7px 16px; }
    .legend     { bottom: calc(70px + var(--safe-bottom)); left: 10px; }
}

@media (max-width: 390px) {
    .brand   { font-size: 1.25rem; }
    .elevasi { display: none; }
    .btn-sos { padding: 11px 14px; font-size: 0.72rem; gap: 6px; }
}