/* NEXO — dark, modern, discreet. Geen overdreven gradients, geen
   dating-site-uitstraling. Systeemlettertype: snel, geen externe fonts. */

:root {
    --bg: #0a0a0f;
    --surface: #14141c;
    --surface-raised: #1b1b26;
    --border: #26262f;
    --text: #e9e9ee;
    --text-muted: #8b8b99;
    --accent: #8b5cf6;
    --accent-strong: #a78bfa;
    --accent-contrast: #0a0a0f;
    --danger: #f2555a;
    --success: #35d399;
    --radius: 10px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--accent-strong);
}

.wordmark {
    margin: 0 0 8px;
    font-size: 28px;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--text);
    text-shadow: 0 0 24px rgba(139, 92, 246, 0.35);
}

.wordmark--small {
    margin: 0;
    font-size: 18px;
}

/* --- Overlays (18+ gate, onboarding) --- */

.overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: radial-gradient(circle at 50% 20%, #17111f 0%, var(--bg) 65%);
    z-index: 100;
}

.overlay--hidden {
    display: none;
}

.hidden {
    display: none;
}

.overlay__panel {
    width: 100%;
    max-width: 420px;
    padding: 32px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    max-height: 90vh;
    overflow-y: auto;
}

.overlay__panel--wide {
    max-width: 520px;
}

.overlay__actions--wrap {
    flex-wrap: wrap;
}

.overlay__title {
    margin: 0 0 12px;
    font-size: 22px;
}

.overlay__text {
    margin: 0 0 24px;
    color: var(--text-muted);
}

.overlay__actions {
    display: flex;
    gap: 12px;
}

.overlay__footnote {
    margin: 20px 0 0;
    font-size: 12px;
    color: var(--text-muted);
}

/* --- Formulieren --- */

.form {
    display: flex;
    flex-direction: column;
}

.form__label {
    margin: 14px 0 6px;
    font-size: 13px;
    color: var(--text-muted);
}

.form__input {
    padding: 10px 12px;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: inherit;
    font-size: 15px;
}

.form__input--narrow {
    width: 80px;
    flex: none;
}

.form__input:focus {
    outline: none;
    border-color: var(--accent);
}

.form__hint {
    margin: 6px 0 0;
    font-size: 12px;
    color: var(--text-muted);
}

.form__error {
    margin: 16px 0 0;
    color: var(--danger);
    font-size: 13px;
}

.form__section {
    margin: 14px 0 0;
    padding: 12px 0 0;
    border: none;
    border-top: 1px solid var(--border);
}

.form__section .form__label {
    margin-top: 0;
}

/* --- Locatiekaart (fullscreen, Leaflet, wereldwijd pan/zoombaar) --- */

.location-map-fullscreen {
    display: flex;
    flex-direction: column;
    width: 100vw;
    /* 100vh op mobiel telt de adresbalk soms mee als "beschikbare" hoogte
       (klopt dan pas na scrollen) — dvh volgt de echte zichtbare hoogte;
       vh blijft staan als fallback voor oudere browsers. */
    height: 100vh;
    height: 100dvh;
    background: var(--surface);
}

.location-map-fullscreen__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

.location-map-fullscreen__map {
    flex: 1;
    min-height: 0;
    cursor: crosshair;
}

.location-map-fullscreen__hint {
    margin: 0;
    padding: 8px 16px;
    font-size: 12px;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
}

#location-map-overlay.overlay {
    align-items: stretch;
    justify-content: stretch;
    padding: 0;
}

/* --- Interesses --- */

.interest-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.interest-chip {
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface-raised);
    color: var(--text-muted);
    font-size: 13px;
    cursor: pointer;
    user-select: none;
}

.interest-chip.is-selected {
    border-color: var(--accent);
    color: var(--text);
    background: rgba(139, 92, 246, 0.16);
}

/* --- Profielfoto's --- */

.photo-list {
    list-style: none;
    margin: 10px 0 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.photo-list li {
    position: relative;
    width: 96px;
    height: 96px;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
}

.photo-list img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.photo-list__status {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 2px 6px;
    font-size: 10px;
    text-align: center;
    color: #fff;
    background: rgba(0, 0, 0, 0.6);
}

.photo-list__remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 20px;
    height: 20px;
    line-height: 18px;
    text-align: center;
    padding: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 14px;
}

.directory-row__avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    margin-right: 10px;
}

.directory-row__main {
    display: flex;
    align-items: center;
}

/* --- Knoppen --- */

.btn {
    padding: 10px 18px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.btn--primary {
    background: var(--accent);
    color: #ffffff;
}

.btn--primary:hover {
    background: var(--accent-strong);
}

.btn--ghost {
    background: transparent;
    border-color: var(--border);
    color: var(--text-muted);
}

.btn--ghost:hover {
    color: var(--text);
    border-color: var(--accent);
}

.btn--icon {
    background: var(--surface-raised);
    border-color: var(--border);
    color: var(--text);
}

.btn--mobile-only {
    display: none;
}

/* --- App-layout --- */

.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
}

.app--hidden {
    display: none;
}

.app__header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 20px;
    padding-top: calc(12px + env(safe-area-inset-top));
    padding-left: calc(20px + env(safe-area-inset-left));
    padding-right: calc(20px + env(safe-area-inset-right));
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.app__header .status {
    margin-right: auto;
}

.app__body {
    flex: 1;
    display: grid;
    grid-template-columns: 220px 1fr 320px;
    min-height: 0;
}

/* Terwijl een gesprek open is, is de online-directory (middenkolom) niet
   nodig — die ruimte teruggeven aan het chatpaneel geeft de invoerbalk en
   bijlage-knoppen veel meer breedte, zonder de chat zelf te verplaatsen
   (blijft hetzelfde paneel, gewoon breder). */
.app__body--chat-open {
    grid-template-columns: 220px 1fr;
}

.app__body--chat-open .panel--directory {
    display: none;
}

.panel {
    min-height: 0;
    overflow-y: auto;
    border-right: 1px solid var(--border);
}

.panel--directory {
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    padding: 16px;
}

.directory-search {
    margin-bottom: 14px;
}

.directory-list {
    flex: 1;
    overflow-y: auto;
}

.directory-group__title {
    margin: 18px 0 8px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.directory-group__title:first-child {
    margin-top: 0;
}

.directory-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
}

.directory-row:hover {
    color: var(--accent-strong);
}

.directory-row__meta {
    font-size: 12px;
    color: var(--text-muted);
}

.directory-row__distance {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
}

.directory-row__test-badge {
    margin-left: 6px;
    padding: 1px 6px;
    border-radius: 999px;
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    vertical-align: middle;
}

.directory-row__premium-badge {
    margin-left: 6px;
    padding: 1px 6px;
    border-radius: 999px;
    background: linear-gradient(135deg, #f5b942, #f2905a);
    color: #1a1a1a;
    font-size: 10px;
    font-weight: 600;
    vertical-align: middle;
}

.directory-row__avatar {
    cursor: pointer;
}

.directory-empty {
    color: var(--text-muted);
    font-size: 13px;
    padding: 20px 0;
}

.panel--users {
    padding: 16px;
}

.panel--private {
    border-right: none;
    padding: 16px;
    display: flex;
    flex-direction: column;
    /* Overschrijft .panel's overflow-y:auto: dit paneel zelf mag niet
       scrollen, alleen de berichtenlijst erbinnen (.message-list) — anders
       kan de invoerbalk buiten het zichtbare gedeelte terechtkomen op
       mobiel. */
    overflow: hidden;
}

/* :not(.hidden) is nodig omdat een kale #id-regel hier anders altijd zou
   winnen van .hidden{display:none} (ID-specificiteit > class-specificiteit)
   — daardoor bleef deze lijst zichtbaar (met een lege ruimte erboven het
   actieve gesprek) ook nadat de "hidden"-class was toegevoegd bij het
   openen van een gesprek. */
#conversation-list-view:not(.hidden) {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1;
}

#conversation-list-view .conversation-list {
    min-height: 0;
}

.panel--hidden {
    display: none;
}

.panel__title {
    margin: 0 0 12px;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

/* --- Statusindicator --- */

.status {
    font-size: 12px;
    color: var(--text-muted);
}

.status::before {
    content: "●";
    margin-right: 6px;
}

.status--online::before {
    color: var(--success);
}

.status--offline::before {
    color: var(--danger);
}

/* --- Gebruikerslijst --- */

.user-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.user-list li {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    display: flex;
    flex-direction: column;
}

.user-list li:hover {
    color: var(--accent-strong);
}

.user-list .user-list__meta {
    font-size: 12px;
    color: var(--text-muted);
}

/* --- Berichtenlijst --- */

.message-list {
    flex: 1;
    list-style: none;
    margin: 0;
    padding: 16px 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.message {
    max-width: 70%;
    padding: 8px 12px;
    border-radius: var(--radius);
    background: var(--surface-raised);
    border: 1px solid var(--border);
}

.message--own {
    align-self: flex-end;
    background: rgba(139, 92, 246, 0.16);
    border-color: rgba(139, 92, 246, 0.4);
}

.message__meta {
    display: flex;
    gap: 8px;
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.message__body {
    white-space: pre-wrap;
    word-break: break-word;
}

.message__image {
    max-width: 100%;
    border-radius: 8px;
    margin-top: 6px;
    display: block;
}

/* --- Invoerbalk --- */

.composer {
    display: flex;
    flex-shrink: 0;
    gap: 10px;
    padding: 12px 20px;
    /* Voorkomt dat de invoerbalk onder de homebar/gebaarbalk van moderne
       telefoons schuift (viewport-fit=cover staat aan in de meta-tag). */
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--border);
}

.composer > .btn {
    flex-shrink: 0;
}

.composer__input {
    flex: 1;
    /* Zonder min-width:0 gebruikt een flex-item de intrinsieke
       content-breedte als ondergrens (flexbox-default) — op smalle
       mobiele schermen duwde dat het invoerveld buiten beeld i.p.v. het
       netjes te laten meekrimpen. */
    min-width: 0;
    min-height: 40px;
    resize: none;
    padding: 10px 12px;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    max-height: 120px;
}

.composer__input:focus {
    outline: none;
    border-color: var(--accent);
}

/* --- Privéchat --- */

.conversation-list {
    list-style: none;
    margin: 0;
    padding: 0;
    flex: 1;
    overflow-y: auto;
}

.conversation-list li {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
}

.conversation-list li:hover {
    color: var(--accent-strong);
}

.conversation-list__unread {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 7px;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    font-size: 11px;
}

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

.conversation-active--hidden {
    display: none;
}

.conversation-active__title {
    font-weight: 600;
    margin: 12px 0;
}

.conversation-active__header {
    display: flex;
    flex-shrink: 0;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
}

/* --- Inkomende oproep: nooit automatisch camera/mic activeren, altijd
     eerst een expliciete bevestiging (zie SECURITY.md). --- */

.incoming-call {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    margin-bottom: 10px;
    background: rgba(139, 92, 246, 0.16);
    border: 1px solid rgba(139, 92, 246, 0.4);
    border-radius: var(--radius);
}

.incoming-call.hidden {
    display: none;
}

.incoming-call__text {
    margin: 0;
    font-size: 14px;
}

.incoming-call__actions {
    display: flex;
    gap: 8px;
}

/* --- Videobellen --- */

.call-panel {
    position: relative;
    margin-bottom: 12px;
    background: #000;
    border-radius: var(--radius);
    overflow: hidden;
}

.call-panel__remote {
    width: 100%;
    max-height: 280px;
    display: block;
    background: #000;
}

.call-panel__local {
    position: absolute;
    right: 10px;
    bottom: 44px;
    width: 90px;
    border-radius: 6px;
    border: 1px solid var(--border);
}

.call-panel__status {
    position: absolute;
    top: 8px;
    left: 10px;
    margin: 0;
    color: #fff;
    font-size: 12px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

.call-panel .btn {
    position: absolute;
    bottom: 8px;
    left: 10px;
}

.conversation-active__header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.conversation-more {
    position: relative;
}

.conversation-more__menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    min-width: 200px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.conversation-more__menu.hidden {
    display: none;
}

.conversation-more__menu .btn {
    text-align: left;
    width: 100%;
}

.conversation-disappearing {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-muted);
}

.conversation-list__pin {
    color: var(--accent);
}

.conversation-typing,
.conversation-read-receipt {
    margin: 0;
    padding: 0 20px 6px;
    font-size: 11px;
    color: var(--text-muted);
}

.conversation-typing.hidden,
.conversation-read-receipt.hidden {
    display: none;
}

.conversation-search {
    padding: 10px 20px;
    border-bottom: 1px solid var(--border);
}

.conversation-search.hidden {
    display: none;
}

.message-list--search {
    max-height: 200px;
    padding: 10px 0 0;
}

.message-list__empty {
    color: var(--text-muted);
    font-size: 13px;
}

.message__audio {
    max-width: 100%;
    margin-top: 6px;
    display: block;
}

#conversation-pin.is-active {
    color: var(--accent);
}

#conversation-audio-button.is-recording {
    background: var(--danger);
    color: #fff;
}

#push-toggle.is-active {
    color: var(--accent-strong);
}

.badge {
    display: inline-block;
    min-width: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    font-size: 11px;
    text-align: center;
}

.badge--hidden {
    display: none;
}

/* --- Mobiel --- */

@media (max-width: 860px) {
    .app__body {
        grid-template-columns: 1fr;
    }

    .panel--users,
    .panel--private {
        position: fixed;
        /* --header-height wordt in JS bijgehouden (ResizeObserver op
           .app__header) zodat dit klopt ongeacht of de header op één of
           twee regels staat — een vast getal hier brak zodra er genoeg
           knoppen bijkwamen dat de header ging wrappen. */
        top: var(--header-height, 57px);
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 50;
        background: var(--bg);
        border-right: none;
    }

    .btn--mobile-only {
        display: inline-block;
    }

    .app__header {
        flex-wrap: wrap;
        gap: 6px;
        padding: 10px 12px;
    }

    .app__header .btn {
        padding: 8px 10px;
        font-size: 13px;
    }

    .composer {
        padding: 10px 12px;
        gap: 6px;
    }

    .composer #conversation-image-button {
        font-size: 0;
    }

    .composer #conversation-image-button::before {
        content: '📷';
        font-size: 16px;
    }

    .composer .btn {
        padding: 8px 10px;
    }
}
