/* =========================================================================
   dialogue. — design tokens (mengikuti Blueprint v1 dari Rin Consultant)
   ========================================================================= */
:root {
    --paper: #F4F6F8;
    --panel: #FFFFFF;
    --ink: #141B2E;
    --ink-soft: #4A5468;
    --coral: #EF6F53;
    --coral-dark: #DD5A3E;
    --mint: #2F9C87;
    --amber: #E8A33D;
    --line: #DDE2E8;
    --bubble-received: #EEF1F4;
    --online: #2F9C87;
    --radius: 14px;
    --font-display: 'Bricolage Grotesque', sans-serif;
    --font-body: 'IBM Plex Sans', sans-serif;
    --font-mono: 'IBM Plex Mono', monospace;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font-body);
    color: var(--ink);
    background: var(--paper);
}

/* =========================================================================
   SHELL — rail (desktop) + bottom nav (mobile), dipakai di semua halaman
   ========================================================================= */
.shell {
    display: flex;
    height: 100vh;
    height: var(--app-height, 100vh);
    width: 100%;
    overflow: hidden;
}

.rail {
    width: 64px;
    min-width: 64px;
    background: var(--ink);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 0;
    gap: 16px;
}
.rail-icon {
    width: 38px; height: 38px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 17px;
    color: #8A93A6;
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease;
}
.rail-icon.active { background: var(--coral); color: #fff; }
.rail-icon:not(.active):hover { background: rgba(255,255,255,0.08); color: #fff; }

.nav-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--coral);
    color: #fff;
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 700;
    min-width: 17px;
    height: 17px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid var(--ink);
}
.nav-badge-bottom { top: -2px; right: 14px; border-color: #fff; }

.shell-content {
    flex: 1;
    min-width: 0;
    height: 100%;
    overflow: hidden;
    display: flex;
    position: relative;
}

.bottom-nav { display: none; }

@media (max-width: 820px) {
    .rail { display: none; }
    .shell-content { height: calc(100vh - 58px); height: calc(var(--app-height, 100vh) - 58px); }
    .bottom-nav {
        display: flex;
        position: fixed;
        left: 0; right: 0; bottom: 0;
        height: 58px;
        background: #fff;
        border-top: 1px solid var(--line);
        z-index: 50;
        justify-content: space-around;
        align-items: center;
    }
    .bottom-nav a {
        display: flex; flex-direction: column; align-items: center; gap: 2px;
        font-size: 19px;
        color: var(--ink-soft);
        text-decoration: none;
    }
    .bottom-nav a span { font-size: 10px; font-family: var(--font-mono); letter-spacing: 0.02em; }
    .bottom-nav a.active { color: var(--coral); }
}

/* ---------- Sidebar (halaman Pesan) ---------- */
.app {
    display: flex;
    height: 100%;
    width: 100%;
    overflow: hidden;
    position: relative;
}

.sidebar {
    width: 320px;
    min-width: 320px;
    background: var(--panel);
    border-right: 1px solid var(--line);
    color: var(--ink);
    display: flex;
    flex-direction: column;
    height: 100%;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 20px 14px;
}

.brand {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 21px;
    margin: 0;
    color: var(--ink);
}
.brand span { color: var(--coral); }

.icon-btn {
    background: var(--paper);
    border: none;
    color: var(--ink);
    width: 38px;
    height: 38px;
    border-radius: 50%;
    cursor: pointer;
    font-family: var(--font-mono);
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: background 0.15s ease;
}
.icon-btn:hover { background: var(--line); }

.profile-link-avatar {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: var(--coral);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-mono);
    font-weight: 600;
    text-decoration: none;
    font-size: 13px;
}

.user-list {
    flex: 1;
    overflow-y: auto;
    padding: 6px 10px 16px;
}

.empty-hint {
    color: var(--ink-soft);
    font-size: 14px;
    padding: 20px;
    text-align: center;
}

.user-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 10px;
    border-radius: 12px;
    cursor: pointer;
    margin-bottom: 2px;
    transition: background 0.15s ease;
}
.user-item:hover { background: var(--paper); }
.user-item.active { background: rgba(239,111,83,0.12); }

.avatar {
    width: 42px;
    height: 42px;
    min-width: 42px;
    border-radius: 50%;
    background: var(--coral);
    color: #fff;
    font-family: var(--font-mono);
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    font-size: 14px;
}
.avatar .dot {
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: #C7CEDA;
    border: 2px solid var(--panel);
}
.avatar .dot.online { background: var(--online); }

.user-item-info { flex: 1; min-width: 0; }
.user-item-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.user-item-last {
    font-size: 12.5px;
    color: var(--ink-soft);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.unread-badge {
    background: var(--coral);
    color: #fff;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
}

/* ---------- Chat panel ---------- */
.chat-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--paper);
    height: 100%;
}

.chat-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}
.chat-empty-inner { text-align: center; color: var(--ink-soft); }
.chat-empty-logo {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 26px;
    color: var(--line);
    margin-bottom: 10px;
}
.chat-empty-logo span { color: var(--coral); opacity: 0.7; }

.chat-active {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--line);
    background: var(--panel);
}
.back-btn { display: none; background: var(--paper); color: var(--ink); }
.chat-header-avatar {
    width: 40px; height: 40px; border-radius: 50%;
    background: var(--coral); color: #fff;
    font-family: var(--font-mono); font-weight: 600;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px;
}
.chat-header-name { font-weight: 600; font-size: 14.5px; }
.chat-header-status { font-size: 12px; color: var(--ink-soft); font-family: var(--font-mono); }
.chat-header-info { flex: 1; min-width: 0; }

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.bubble-row { display: flex; }
.bubble-row.mine { justify-content: flex-end; }

.bubble {
    max-width: 68%;
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 14px;
    line-height: 1.45;
}
.bubble-row.mine .bubble {
    background: var(--coral);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.bubble-row:not(.mine) .bubble {
    background: var(--bubble-received);
    color: var(--ink);
    border-bottom-left-radius: 4px;
}
.bubble img {
    max-width: 260px;
    border-radius: 10px;
    display: block;
    margin-bottom: 4px;
    cursor: zoom-in;
}
.bubble-time {
    font-size: 10px;
    font-family: var(--font-mono);
    opacity: 0.7;
    margin-top: 4px;
    text-align: right;
}

.chat-input-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 20px;
    border-top: 1px solid var(--line);
    background: var(--panel);
}
.photo-btn {
    cursor: pointer;
    font-size: 19px;
    width: 40px; height: 40px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%;
    background: var(--paper);
}
#textInput {
    flex: 1;
    border: 1px solid var(--line);
    background: var(--paper);
    border-radius: 20px;
    padding: 10px 16px;
    font-family: var(--font-body);
    font-size: 14px;
    outline: none;
}
#textInput:focus { border-color: var(--coral); }
.send-btn {
    background: var(--coral);
    color: #fff;
    border: none;
    border-radius: 20px;
    padding: 10px 20px;
    font-weight: 600;
    font-size: 13.5px;
    cursor: pointer;
    font-family: var(--font-body);
}
.send-btn:hover { background: var(--coral-dark); }

.photo-preview {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 20px 14px;
    background: var(--panel);
}
.photo-preview img {
    width: 60px; height: 60px; object-fit: cover; border-radius: 8px;
}
.photo-preview button {
    background: var(--paper);
    border: none;
    border-radius: 50%;
    width: 24px; height: 24px;
    cursor: pointer;
}

/* ---------- Auth pages (login/register/settings) ---------- */
.auth-body {
    min-height: 100vh;
    min-height: var(--app-height, 100vh);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--ink);
    font-family: var(--font-body);
    padding: 20px;
    position: relative;
    overflow-x: hidden;
    overflow-y: auto;
}
.auth-body::after {
    content: "";
    position: absolute; right: -120px; top: -120px;
    width: 380px; height: 380px; border-radius: 50%;
    background: radial-gradient(circle, rgba(239,111,83,0.35), transparent 70%);
}
.auth-card {
    background: var(--panel);
    padding: 36px 32px;
    border-radius: 18px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.3);
    position: relative;
    z-index: 1;
}
.auth-logo {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 25px;
    margin: 0 0 4px;
    color: var(--ink);
}
.auth-logo span { color: var(--coral); }
.auth-sub { color: var(--ink-soft); margin: 0 0 20px; font-size: 14px; }
.auth-form { display: flex; flex-direction: column; gap: 4px; }
.auth-form label { font-size: 12.5px; font-weight: 600; margin-top: 10px; color: var(--ink); font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.04em; }
.auth-form input[type="text"],
.auth-form input[type="password"] {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 14.5px;
    font-family: var(--font-body);
    outline: none;
}
.auth-form input:focus { border-color: var(--coral); }
.btn-primary {
    margin-top: 18px;
    background: var(--coral);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 12px;
    font-weight: 600;
    font-size: 14.5px;
    cursor: pointer;
}
.btn-primary:hover { background: var(--coral-dark); }
.auth-error {
    background: #FDEBEA;
    color: #C0392B;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13.5px;
    margin-bottom: 6px;
}
.auth-success {
    background: rgba(47,156,135,0.12);
    color: var(--mint);
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13.5px;
    margin-bottom: 6px;
}
.auth-switch { text-align: center; font-size: 13.5px; color: var(--ink-soft); margin-top: 18px; }
.auth-switch a { color: var(--coral); font-weight: 600; text-decoration: none; }
.switch-row { display: flex; align-items: flex-start; gap: 10px; font-size: 13.5px; font-weight: 400 !important; color: var(--ink); margin-top: 14px; font-family: var(--font-body) !important; text-transform: none !important; }
.switch-row input { margin-top: 3px; }

/* ---------- Nearby ("Orang Terdekat") page ---------- */
.nearby-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    width: 100%;
}
.nearby-page-header {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 22px;
    margin-bottom: 4px;
}
.nearby-page-sub {
    color: var(--ink-soft);
    font-size: 13.5px;
    margin-bottom: 20px;
}
.nearby-status {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 16px;
    font-size: 14px;
    color: var(--ink-soft);
    text-align: center;
    margin-bottom: 16px;
}
.nearby-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
}
.nearby-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 16px 12px;
    text-align: center;
}
.nearby-card .avatar { margin: 0 auto 8px; width: 48px; height: 48px; font-size: 15px; }
.nearby-card .nm { font-weight: 600; font-size: 13.5px; }
.nearby-card .dist { font-size: 11.5px; color: var(--ink-soft); font-family: var(--font-mono); margin: 3px 0 10px; }
.nearby-bio {
    font-size: 11.5px;
    color: var(--ink-soft);
    margin: -4px 0 10px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.35;
}
.btn-chat-small {
    display: inline-block;
    background: var(--coral);
    color: #fff;
    text-decoration: none;
    font-size: 12.5px;
    font-weight: 600;
    padding: 6px 16px;
    border-radius: 16px;
}
.btn-chat-small:hover { background: var(--coral-dark); }
.btn-danger {
    background: #FDEBEA; color: #C0392B; border: none; padding: 6px 14px;
    border-radius: 16px; font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.btn-danger:hover { background: #FBDAD7; }

/* ---------- Profil page ---------- */
.profile-content {
    flex: 1;
    overflow-y: auto;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 40px 20px;
    width: 100%;
}
.profile-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 32px 28px;
    width: 100%;
    max-width: 360px;
    text-align: center;
}
.profile-avatar-big {
    width: 76px; height: 76px;
    border-radius: 50%;
    background: var(--coral);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 26px;
    margin: 0 auto 14px;
}
.profile-name { font-family: var(--font-display); font-weight: 700; font-size: 20px; }
.profile-username { color: var(--ink-soft); font-size: 13px; font-family: var(--font-mono); margin-top: 2px; }
.profile-status {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 12.5px; color: var(--ink-soft);
    margin: 10px 0 22px;
}
.profile-status .dot { width: 8px; height: 8px; border-radius: 50%; background: #C7CEDA; }
.profile-status .dot.online { background: var(--online); }
.profile-stats { display: flex; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 14px 0; margin-bottom: 18px; }
.profile-stat { flex: 1; }
.profile-stat .num { font-family: var(--font-display); font-weight: 700; font-size: 19px; }
.profile-stat .lbl { font-size: 11.5px; color: var(--ink-soft); margin-top: 2px; }
.profile-actions { display: flex; flex-direction: column; gap: 8px; }
.profile-action-btn {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 14px;
    border-radius: 10px;
    background: var(--paper);
    color: var(--ink);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    text-align: left;
}
.profile-action-btn:hover { background: var(--line); }
.profile-action-btn.danger { color: #C0392B; }

/* ---------- Momen (story bar + viewer) ---------- */
.moments-bar {
    display: flex;
    gap: 14px;
    padding: 14px 16px 12px;
    overflow-x: auto;
    border-bottom: 1px solid var(--line);
}
.moment-avatar-item { display: flex; flex-direction: column; align-items: center; gap: 5px; cursor: pointer; min-width: 58px; }
.moment-ring {
    width: 58px; height: 58px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    padding: 2.5px;
}
.moment-ring.unseen { background: linear-gradient(135deg, var(--coral), var(--amber)); }
.moment-ring.seen { background: var(--line); }
.moment-ring.add-new { background: var(--line); }
.moment-ring .avatar {
    width: 100%; height: 100%;
    border: 2.5px solid var(--panel);
}
.moment-ring.add-new .avatar { background: var(--paper); color: var(--coral); font-size: 22px; font-weight: 700; }
.moment-avatar-label {
    font-size: 10.5px;
    color: var(--ink-soft);
    max-width: 62px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.moment-viewer {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: #000;
    display: flex;
    flex-direction: column;
}
.moment-progress-row {
    display: flex;
    gap: 4px;
    padding: 10px 10px 0;
}
.moment-progress-track {
    flex: 1;
    height: 3px;
    background: rgba(255,255,255,0.3);
    border-radius: 2px;
    overflow: hidden;
}
.moment-progress-fill { height: 100%; width: 0%; background: #fff; }

.moment-viewer-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    color: #fff;
}
.moment-viewer-header .avatar { width: 32px; height: 32px; font-size: 13px; }
.moment-viewer-name { font-weight: 600; font-size: 13.5px; }
.moment-viewer-time { font-size: 11.5px; color: rgba(255,255,255,0.6); font-family: var(--font-mono); flex: 1; }
.moment-close-btn { background: none; border: none; color: #fff; font-size: 18px; cursor: pointer; }

.moment-viewer-body {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
}
.moment-viewer-body img { max-width: 100%; max-height: 100%; object-fit: contain; }
.moment-tap-zone { position: absolute; top: 0; bottom: 0; width: 30%; z-index: 2; cursor: pointer; }
.moment-tap-zone.left { left: 0; }
.moment-tap-zone.right { right: 0; }

.moment-viewer-footer { padding: 10px 16px 20px; color: #fff; text-align: center; }
.moment-caption { font-size: 14px; margin-bottom: 10px; }
.moment-delete-btn {
    background: rgba(255,255,255,0.12);
    color: #fff;
    border: none;
    border-radius: 20px;
    padding: 8px 18px;
    font-size: 12.5px;
    cursor: pointer;
}

/* =========================================================================
   RESPONSIVE — mobile: 1 layar aktif, chat toggle antara list & percakapan
   ========================================================================= */
@media (max-width: 820px) {
    .sidebar {
        width: 100%;
        min-width: 100%;
        position: absolute;
        inset: 0;
        z-index: 5;
        transition: transform 0.25s ease;
    }
    .chat-panel {
        position: absolute;
        inset: 0;
        z-index: 6;
        transform: translateX(100%);
        transition: transform 0.25s ease;
    }
    .app.chat-open .sidebar { transform: translateX(-100%); }
    .app.chat-open .chat-panel { transform: translateX(0); }
    .back-btn { display: flex; }
    .bubble { max-width: 82%; }
}
