/* HaarVisie Dashboard — Mobile-First CSS */
:root {
    --hv-bg: #2a2a22;
    --hv-bg-light: #3a3a30;
    --hv-bg-card: #33332b;
    --hv-gold: #b5a67d;
    --hv-gold-light: #d4c9a8;
    --hv-gold-dark: #9a8d68;
    --hv-text: #f5f0e8;
    --hv-text-muted: #b0a998;
    --hv-green: #4caf50;
    --hv-red: #e74c3c;
    --hv-gray: #888;
    --hv-radius: 12px;
    --hv-radius-sm: 8px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--hv-bg);
    color: var(--hv-text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ===== PIN SCREEN ===== */
.pin-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.pin-container {
    text-align: center;
    max-width: 320px;
    width: 100%;
}

.pin-logo {
    font-family: 'Playfair Display', serif;
    font-size: 32px;
    font-weight: 700;
    color: var(--hv-gold);
    margin-bottom: 8px;
}

.pin-container h2 {
    font-family: 'Inter', sans-serif;
    font-size: 18px;
    font-weight: 500;
    color: var(--hv-text-muted);
    margin-bottom: 24px;
}

.pin-container p {
    color: var(--hv-text-muted);
    font-size: 14px;
    margin-bottom: 20px;
}

.pin-input-group {
    display: flex;
    gap: 10px;
}

.pin-input-group input {
    flex: 1;
    padding: 14px 16px;
    border: 2px solid var(--hv-bg-light);
    border-radius: var(--hv-radius-sm);
    background: var(--hv-bg-light);
    color: var(--hv-text);
    font-size: 18px;
    text-align: center;
    letter-spacing: 4px;
    outline: none;
    transition: border-color 0.2s;
}

.pin-input-group input:focus {
    border-color: var(--hv-gold);
}

.btn-gold {
    padding: 14px 24px;
    background: var(--hv-gold);
    color: var(--hv-bg);
    border: none;
    border-radius: var(--hv-radius-sm);
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-gold:hover { background: var(--hv-gold-light); }

.pin-error {
    color: var(--hv-red);
    font-size: 14px;
    margin-top: 12px;
}

/* ===== HEADER ===== */
.header {
    padding: 20px 16px 12px;
    border-bottom: 1px solid var(--hv-bg-light);
}

.header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header h1 {
    font-family: 'Playfair Display', serif;
    font-size: 24px;
    color: var(--hv-gold);
}

.header-sub {
    font-size: 13px;
    color: var(--hv-text-muted);
    margin-top: 2px;
}

.btn-icon {
    width: 40px;
    height: 40px;
    border: 1px solid var(--hv-bg-light);
    border-radius: 50%;
    background: transparent;
    color: var(--hv-gold);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-icon:hover { background: var(--hv-bg-light); }

/* ===== STATS ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    padding: 16px;
}

.stat-card {
    background: var(--hv-bg-card);
    border-radius: var(--hv-radius-sm);
    padding: 12px 8px;
    text-align: center;
}

.stat-number {
    font-size: 24px;
    font-weight: 700;
    color: var(--hv-gold);
}

.stat-label {
    font-size: 11px;
    color: var(--hv-text-muted);
    margin-top: 2px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ===== FILTERS ===== */
.filters {
    padding: 0 16px 12px;
}

.filter-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.filter-select {
    flex: 1;
    padding: 10px 12px;
    background: var(--hv-bg-card);
    border: 1px solid var(--hv-bg-light);
    border-radius: var(--hv-radius-sm);
    color: var(--hv-text);
    font-size: 13px;
    font-family: 'Inter', sans-serif;
    outline: none;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23b0a998' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

.filter-select:focus { border-color: var(--hv-gold); }

.search-input {
    width: 100%;
    padding: 10px 14px;
    background: var(--hv-bg-card);
    border: 1px solid var(--hv-bg-light);
    border-radius: var(--hv-radius-sm);
    color: var(--hv-text);
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    outline: none;
    transition: border-color 0.2s;
}

.search-input::placeholder { color: var(--hv-text-muted); opacity: 0.6; }
.search-input:focus { border-color: var(--hv-gold); }

/* ===== APPOINTMENT CARDS ===== */
.afspraken-list {
    padding: 0 16px 16px;
}

.loading {
    text-align: center;
    color: var(--hv-text-muted);
    padding: 40px 0;
    font-size: 14px;
}

.empty-state {
    text-align: center;
    color: var(--hv-text-muted);
    padding: 40px 0;
    font-size: 14px;
}

.afspraak-card {
    background: var(--hv-bg-card);
    border-radius: var(--hv-radius);
    padding: 14px 16px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.2s;
    border-left: 4px solid var(--hv-gold);
}

.afspraak-card:hover { background: var(--hv-bg-light); }
.afspraak-card:active { transform: scale(0.99); }

.afspraak-card.status-bevestigd { border-left-color: var(--hv-green); }
.afspraak-card.status-geannuleerd { border-left-color: var(--hv-red); }
.afspraak-card.status-afgehandeld { border-left-color: var(--hv-gray); }

.card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.card-name {
    font-weight: 600;
    font-size: 15px;
    color: var(--hv-text);
}

.status-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-nieuw { background: rgba(181,166,125,0.2); color: var(--hv-gold); }
.badge-bevestigd { background: rgba(76,175,80,0.2); color: var(--hv-green); }
.badge-geannuleerd { background: rgba(231,76,60,0.2); color: var(--hv-red); }
.badge-afgehandeld { background: rgba(136,136,136,0.2); color: var(--hv-gray); }

.card-details {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
    font-size: 13px;
    color: var(--hv-text-muted);
}

.card-detail-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.card-detail-item .icon {
    font-size: 12px;
    opacity: 0.7;
}

.card-time {
    font-size: 11px;
    color: var(--hv-text-muted);
    opacity: 0.6;
    margin-top: 6px;
}

.intake-badge {
    display: inline-block;
    background: rgba(231,76,60,0.2);
    color: var(--hv-red);
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 6px;
    vertical-align: middle;
}

/* ===== LOAD MORE ===== */
.load-more-container {
    padding: 0 16px 24px;
    text-align: center;
}

.btn-outline {
    padding: 10px 32px;
    background: transparent;
    border: 1px solid var(--hv-gold);
    border-radius: var(--hv-radius-sm);
    color: var(--hv-gold);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-outline:hover {
    background: rgba(181,166,125,0.1);
}

/* ===== MODAL ===== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    z-index: 1000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

.modal-content {
    background: var(--hv-bg);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    border-radius: 20px 20px 0 0;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--hv-bg-light);
    position: sticky;
    top: 0;
    background: var(--hv-bg);
    z-index: 1;
}

.modal-header h2 {
    font-family: 'Playfair Display', serif;
    font-size: 20px;
    color: var(--hv-gold);
}

.btn-close {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--hv-bg-light);
    border-radius: 50%;
    color: var(--hv-text);
    font-size: 22px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-body {
    padding: 20px;
}

/* Detail rows */
.detail-section {
    margin-bottom: 20px;
}

.detail-section-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--hv-gold);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--hv-bg-light);
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 14px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}

.detail-label {
    color: var(--hv-text-muted);
    flex-shrink: 0;
    margin-right: 12px;
}

.detail-value {
    color: var(--hv-text);
    font-weight: 500;
    text-align: right;
}

/* Status & notes controls */
.detail-actions {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--hv-bg-light);
}

.action-group {
    margin-bottom: 14px;
}

.action-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--hv-gold);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.status-select {
    width: 100%;
    padding: 12px;
    background: var(--hv-bg-card);
    border: 1px solid var(--hv-bg-light);
    border-radius: var(--hv-radius-sm);
    color: var(--hv-text);
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
}

.status-select:focus { border-color: var(--hv-gold); }

.notes-textarea {
    width: 100%;
    padding: 12px;
    background: var(--hv-bg-card);
    border: 1px solid var(--hv-bg-light);
    border-radius: var(--hv-radius-sm);
    color: var(--hv-text);
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    outline: none;
    resize: vertical;
    min-height: 80px;
    transition: border-color 0.2s;
}

.notes-textarea:focus { border-color: var(--hv-gold); }

.btn-save {
    width: 100%;
    padding: 14px;
    background: var(--hv-gold);
    color: var(--hv-bg);
    border: none;
    border-radius: var(--hv-radius-sm);
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    transition: background 0.2s;
    margin-top: 8px;
}

.btn-save:hover { background: var(--hv-gold-light); }
.btn-save:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== PHOTO THUMBNAILS ===== */
.photo-thumbs {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.photo-thumb-container {
    flex: 1;
    min-width: 120px;
    max-width: 200px;
}

.photo-thumb-label {
    font-size: 11px;
    color: var(--hv-text-muted);
    text-transform: uppercase;
    margin-bottom: 6px;
    letter-spacing: 0.5px;
}

.photo-thumb-link {
    display: block;
    border-radius: var(--hv-radius-sm);
    overflow: hidden;
    border: 2px solid var(--hv-bg-light);
    transition: border-color 0.2s;
}

.photo-thumb-link:hover {
    border-color: var(--hv-gold);
}

.photo-thumb-img {
    width: 100%;
    height: auto;
    display: block;
    min-height: 80px;
    background: var(--hv-bg-light);
}

.photo-thumb-fallback {
    display: block;
    padding: 20px 12px;
    text-align: center;
    font-size: 12px;
    color: var(--hv-gold);
    background: var(--hv-bg-light);
    border-radius: var(--hv-radius-sm);
}

/* ===== TOAST ===== */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--hv-bg-card);
    color: var(--hv-text);
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 14px;
    font-weight: 500;
    z-index: 2000;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
    border: 1px solid var(--hv-gold);
    animation: fadeIn 0.3s ease;
}

.toast.success { border-color: var(--hv-green); }
.toast.error { border-color: var(--hv-red); }

/* ===== RESPONSIVE ===== */
@media (min-width: 600px) {
    .stats-grid { gap: 12px; padding: 20px 24px; }
    .stat-card { padding: 16px 12px; }
    .stat-number { font-size: 28px; }
    .filters { padding: 0 24px 16px; }
    .afspraken-list { padding: 0 24px 24px; }
    .header { padding: 24px 24px 16px; }
    .modal-content { border-radius: 20px; max-height: 85vh; margin-bottom: 20px; }
}

@media (max-width: 380px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .filter-row { flex-direction: column; }
}

/* ===== AI ADVIES SECTIE ===== */
.ai-advies-section {
    border: 2px solid #c9a94e;
    border-radius: var(--hv-radius);
    background: rgba(201, 169, 78, 0.08);
    padding: 16px;
    margin-bottom: 16px;
}

.ai-advies-title {
    color: #c9a94e !important;
    font-weight: 700;
    margin-bottom: 12px;
}

.ai-advies-textarea {
    width: 100%;
    min-height: 140px;
    background: var(--hv-bg);
    color: var(--hv-text);
    border: 1px solid rgba(201, 169, 78, 0.3);
    border-radius: var(--hv-radius-sm);
    padding: 12px;
    font-size: 14px;
    line-height: 1.6;
    resize: vertical;
    font-family: inherit;
    margin-bottom: 12px;
}

.ai-advies-textarea:focus {
    outline: none;
    border-color: #c9a94e;
}

.btn-stuur-advies {
    width: 100%;
    background: #c9a94e;
    color: #1c1c18;
    border: none;
    border-radius: var(--hv-radius-sm);
    padding: 14px 20px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    margin-bottom: 8px;
    transition: background 0.2s, transform 0.1s;
}

.btn-stuur-advies:hover { background: #b5973d; }
.btn-stuur-advies:active { transform: scale(0.98); }
.btn-stuur-advies:disabled { opacity: 0.6; cursor: not-allowed; }

.ai-advies-hint {
    font-size: 12px;
    color: var(--hv-text-muted);
    text-align: center;
}

/* ===== TAB NAVIGATION ===== */
.tab-nav {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--hv-bg-light);
    padding: 0 16px;
}

.tab-btn {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--hv-text-muted);
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 500;
    padding: 10px 16px;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
    margin-bottom: -1px;
}

.tab-btn:hover { color: var(--hv-text); }
.tab-btn.active { color: var(--hv-gold); border-bottom-color: var(--hv-gold); }

/* ===== INBOX ===== */
.inbox-container {
    display: flex;
    height: calc(100vh - 140px);
    gap: 0;
}

.inbox-list {
    width: 300px;
    min-width: 200px;
    border-right: 1px solid var(--hv-bg-light);
    overflow-y: auto;
    flex-shrink: 0;
}

.inbox-list-item {
    padding: 14px 16px;
    border-bottom: 1px solid var(--hv-bg-light);
    cursor: pointer;
    transition: background 0.2s;
}

.inbox-list-item:hover,
.inbox-list-item.active {
    background: var(--hv-bg-card);
}

.inbox-list-item .contact-name {
    font-weight: 600;
    color: var(--hv-gold);
    font-size: 14px;
}

.inbox-list-item .last-msg {
    font-size: 12px;
    color: var(--hv-text-muted);
    margin-top: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.inbox-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

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

.msg-bubble {
    max-width: 70%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
}

.msg-inbound {
    background: var(--hv-bg-card);
    color: var(--hv-text);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.msg-outbound {
    background: var(--hv-gold-dark);
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.msg-time {
    font-size: 11px;
    color: rgba(255,255,255,0.6);
    margin-top: 4px;
}

.msg-inbound .msg-time {
    color: var(--hv-text-muted);
}

.chat-input-area {
    padding: 12px 16px;
    border-top: 1px solid var(--hv-bg-light);
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.chat-input-area textarea {
    flex: 1;
    background: var(--hv-bg-card);
    border: 1px solid var(--hv-bg-light);
    color: var(--hv-text);
    border-radius: var(--hv-radius-sm);
    padding: 10px 12px;
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    resize: none;
    height: 44px;
    outline: none;
    transition: border-color 0.2s;
}

.chat-input-area textarea:focus {
    border-color: var(--hv-gold);
}

.chat-input-area button {
    background: var(--hv-gold);
    color: var(--hv-bg);
    border: none;
    border-radius: var(--hv-radius-sm);
    padding: 0 20px;
    height: 44px;
    font-weight: 700;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s;
    flex-shrink: 0;
}

.chat-input-area button:hover { background: var(--hv-gold-light); }
.chat-input-area button:disabled { opacity: 0.5; cursor: not-allowed; }

.inbox-empty {
    color: var(--hv-text-muted);
    text-align: center;
    padding: 40px 16px;
    font-size: 14px;
}

@media (max-width: 600px) {
    .inbox-container { flex-direction: column; height: auto; }
    .inbox-list { width: 100%; border-right: none; border-bottom: 1px solid var(--hv-bg-light); max-height: 220px; }
    .inbox-chat { min-height: 400px; }
    .tab-nav { padding: 0 10px; }
    .tab-btn { padding: 10px 10px; font-size: 13px; }
}

/* ===== TEMPLATE PICKER ===== */
.chat-input-area {
    position: relative;
}

.btn-template-picker {
    background: none;
    border: 1px solid var(--hv-gold);
    color: var(--hv-gold);
    border-radius: var(--hv-radius-sm);
    padding: 0 10px;
    font-size: 16px;
    cursor: pointer;
    flex-shrink: 0;
    height: 44px;
    transition: background 0.2s;
}
.btn-template-picker:hover { background: rgba(181,166,125,0.15); }

.template-picker-modal {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 0;
    right: 0;
    background: var(--hv-bg-card);
    border: 1px solid rgba(181,166,125,0.3);
    border-radius: var(--hv-radius);
    z-index: 100;
    flex-direction: column;
    max-height: 320px;
    overflow: hidden;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.4);
}
.template-picker-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(181,166,125,0.2);
    font-weight: 600;
    color: var(--hv-gold);
    font-size: 13px;
    flex-shrink: 0;
}
.btn-close-modal {
    background: none;
    border: none;
    color: var(--hv-text-muted);
    cursor: pointer;
    font-size: 14px;
    padding: 2px 6px;
    line-height: 1;
}
.btn-close-modal:hover { color: var(--hv-text); }

.template-list {
    overflow-y: auto;
    flex: 1;
}
.template-item {
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid rgba(181,166,125,0.1);
    transition: background 0.15s;
}
.template-item:last-child { border-bottom: none; }
.template-item:hover { background: rgba(181,166,125,0.1); }
.template-item-name { font-weight: 600; color: var(--hv-gold); font-size: 13px; }
.template-item-preview {
    color: var(--hv-text-muted);
    font-size: 12px;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.template-item-vars { color: var(--hv-gold-dark); font-size: 11px; margin-top: 2px; }

/* Template variabelen editor */
.template-var-editor {
    background: var(--hv-bg-card);
    border: 1px solid rgba(181,166,125,0.3);
    border-radius: var(--hv-radius);
    padding: 12px 14px;
    margin: 0 0 8px 0;
}
.tve-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    color: var(--hv-gold);
    font-size: 13px;
    margin-bottom: 8px;
}
.tve-preview {
    background: var(--hv-bg);
    border-radius: var(--hv-radius-sm);
    padding: 8px 10px;
    color: var(--hv-text);
    font-size: 12px;
    margin-bottom: 10px;
    line-height: 1.4;
    white-space: pre-wrap;
    max-height: 80px;
    overflow-y: auto;
}
.tve-fields {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 10px;
}
.tve-field label {
    font-size: 11px;
    color: var(--hv-gold-dark);
    margin-bottom: 2px;
    display: block;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.tve-input {
    width: 100%;
    background: var(--hv-bg);
    border: 1px solid rgba(181,166,125,0.3);
    border-radius: var(--hv-radius-sm);
    padding: 6px 10px;
    color: var(--hv-text);
    font-size: 13px;
    font-family: 'Inter', sans-serif;
    box-sizing: border-box;
    outline: none;
    transition: border-color 0.2s;
}
.tve-input:focus { border-color: var(--hv-gold); }
.tve-use {
    width: 100%;
    padding: 8px;
    font-size: 13px;
}
