/* ============================================
   Lamson Klantportaal — Premium UI
   ============================================ */
:root {
    --bg:          #eef1f7;
    --bg-elev:     #e4e8f0;
    --surface:     #ffffff;
    --surface-2:   #f5f7fb;
    --surface-3:   #eaedf3;
    --border:      #c4cbda;
    --border-soft: #d8dde8;
    --text:        #1a2033;
    --text-muted:  #5c647a;
    --text-dim:    #8891a8;
    --accent:      #2a5bd7;
    --accent-2:    #4a7bff;
    --accent-soft: rgba(42, 91, 215, 0.10);
    --success:     #16a34a;
    --warning:     #d97706;
    --danger:      #dc2626;
    --info:        #0284c7;
    --violet:      #7c3aed;
    --radius:      12px;
    --radius-sm:   8px;
    --radius-lg:   16px;
    --shadow-sm:   0 1px 2px rgba(15,23,42,.05);
    --shadow-md:   0 4px 12px rgba(15,23,42,.08), 0 0 0 1px rgba(15,23,42,.02);
    --shadow-lg:   0 12px 32px rgba(15,23,42,.12), 0 0 0 1px rgba(15,23,42,.03);
    --sidebar-w:   240px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: 'Inter', system-ui, -apple-system, sans-serif; font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; font-feature-settings: "ss01", "cv11"; }
body { font-variant-numeric: tabular-nums; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-2); }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }

/* ============ Layout ============ */
.app {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    min-height: 100vh;
}

.sidebar {
    background: var(--bg-elev);
    border-right: 1px solid var(--border-soft);
    padding: 1.25rem 0;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}
.sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: .5rem 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-soft);
}
.sidebar-brand-logo { display: block; max-width: 100%; height: auto; max-height: 48px; width: auto; object-fit: contain; }

.sidebar-section-title { padding: 1.25rem 1.25rem .5rem; font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; color: var(--text-dim); font-weight: 600; }
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; padding: 0 .65rem; }
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .6rem .7rem;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-weight: 500;
    font-size: .88rem;
    transition: background 120ms, color 120ms;
}
.sidebar-nav a:hover { background: var(--surface); color: var(--text); }
.sidebar-nav a.active { background: var(--accent-soft); color: var(--accent); }
.sidebar-nav svg { flex: 0 0 auto; }

.sidebar-footer { margin-top: auto; padding: 1rem 1.25rem; border-top: 1px solid var(--border-soft); }
.sidebar-user { display: flex; align-items: center; gap: .65rem; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent); display: flex; align-items: center; justify-content: center; font-weight: 600; color: white; font-size: .85rem; flex: 0 0 auto; }
.sidebar-user-info { min-width: 0; flex: 1; }
.sidebar-user-name { font-weight: 600; font-size: .82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-mail { font-size: .72rem; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-logout { margin-top: .75rem; display: flex; align-items: center; gap: .4rem; color: var(--text-muted); font-size: .8rem; }
.sidebar-logout:hover { color: var(--danger); }

/* ============ Main ============ */
.main { padding: 2.5rem 3rem; max-width: 1280px; width: 100%; }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 2rem; }
.page-title { font-size: 1.85rem; font-weight: 700; letter-spacing: -0.025em; color: var(--text); }
.page-subtitle { color: var(--text-muted); font-size: .92rem; margin-top: .35rem; }

/* ============ Cards ============ */
.card {
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    padding: 1.25rem 1.4rem;
    box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 1rem; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; gap: 1rem; }
.card-title { font-weight: 600; font-size: 1.05rem; display: flex; align-items: center; gap: .5rem; }
.card-pad { padding: 0; }

/* ============ Ticket list ============ */
.ticket-list { display: flex; flex-direction: column; gap: 10px; }
.ticket-row {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    gap: 1rem;
    align-items: center;
    padding: 1rem 1.25rem;
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    cursor: pointer;
    transition: transform 150ms, border-color 150ms, box-shadow 150ms;
}
.ticket-row:hover { transform: translateY(-1px); border-color: var(--border); box-shadow: var(--shadow-md); }
.ticket-filter { display: flex; gap: .4rem; margin-bottom: 1rem; }
.ticket-filter-btn { display: inline-flex; align-items: center; gap: .5rem; padding: .45rem .9rem; background: var(--surface); color: var(--text-muted); border: 1px solid var(--border-soft); border-radius: 999px; cursor: pointer; font-size: .85rem; transition: color .15s, background .15s, border-color .15s; }
.ticket-filter-btn:hover { color: var(--text); border-color: var(--border); }
.ticket-filter-btn.is-active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.ticket-filter-count { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 .4rem; border-radius: 999px; background: var(--bg-elev); color: var(--text-muted); font-size: .72rem; font-weight: 600; }
.ticket-filter-btn.is-active .ticket-filter-count { background: var(--accent); color: white; }
.ticket-filter-btn svg { opacity: .7; }
.ticket-filter-btn.is-active svg { opacity: 1; }
.ticket-table-wrap { background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
.ticket-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.ticket-table thead th { text-align: left; font-weight: 600; font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; color: var(--text-dim); padding: .9rem 1.25rem; background: var(--surface-2); border-bottom: 1px solid var(--border-soft); }
.ticket-table tbody tr { cursor: pointer; transition: background .14s; border-bottom: 1px solid var(--border-soft); }
.ticket-table tbody tr:last-child { border-bottom: 0; }
.ticket-table tbody tr:hover { background: var(--surface-2); }
.ticket-table td { padding: 1rem 1.25rem; color: var(--text); vertical-align: middle; }
.ticket-table .cell-mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .82rem; color: var(--text-muted); }
.ticket-table .cell-mono strong { color: var(--text); }
.ticket-table .cell-strong { font-weight: 500; }
.ticket-table .cell-chevron { color: var(--text-muted); width: 14px; height: 14px; }
.ticket-table .cell-chevron svg { width: 14px; height: 14px; display: block; }
.ticket-table .cell-ico-row { display: inline-flex; align-items: center; gap: 6px; }
.ticket-table .cell-ico { width: 13px; height: 13px; flex: 0 0 auto; opacity: .75; }
.badge-ico { display: inline-flex; align-items: center; gap: 5px; }
.badge-ico-svg { width: 11px; height: 11px; flex: 0 0 auto; }
.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-bottom: 1.75rem; }
.stat-card { display: flex; align-items: center; gap: 1.1rem; padding: 1.4rem 1.5rem; background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius); box-shadow: var(--shadow-sm); transition: box-shadow .18s, border-color .18s; }
.stat-card:hover { box-shadow: var(--shadow-md); border-color: var(--border); }
.stat-ico { width: 46px; height: 46px; flex: 0 0 auto; display: flex; align-items: center; justify-content: center; border-radius: 12px; }
.stat-ico svg { width: 22px; height: 22px; }
.stat-ico-open   { background: rgba(2,132,199,.09);  color: var(--info); }
.stat-ico-closed { background: rgba(22,163,74,.09);  color: var(--success); }
.stat-ico-total  { background: var(--accent-soft);   color: var(--accent); }
.stat-value { font-size: 1.75rem; font-weight: 700; color: var(--text); line-height: 1; letter-spacing: -.02em; }
.stat-label { font-size: .78rem; color: var(--text-muted); margin-top: .35rem; letter-spacing: .02em; }
.ticket-table .cell-leading { padding-right: 0; }
.row-ico { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border-radius: 8px; }
.row-ico svg { width: 16px; height: 16px; }
.row-ico-open   { background: rgba(2,132,199,.09);   color: var(--info); }
.row-ico-wait   { background: rgba(217,119,6,.09);   color: var(--warning); }
.row-ico-closed { background: rgba(22,163,74,.09);   color: var(--success); }
.ticket-status-dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
.ticket-main { min-width: 0; }
.ticket-subject { font-weight: 600; font-size: .98rem; color: var(--text); margin-bottom: .2rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ticket-meta { font-size: .78rem; color: var(--text-muted); display: flex; gap: .75rem; align-items: center; }
.ticket-nummer { font-family: 'JetBrains Mono', ui-monospace, monospace; }
.ticket-date { }
.ticket-right { display: flex; align-items: center; gap: .6rem; }

/* ============ Badges / Pills ============ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: .74rem;
    font-weight: 600;
    letter-spacing: .01em;
    border: 1px solid transparent;
    white-space: nowrap;
}
.badge-open    { background: rgba(2,132,199,.08);   color: var(--info);    border-color: rgba(2,132,199,.22); }
.badge-wait    { background: rgba(217,119,6,.08);   color: var(--warning); border-color: rgba(217,119,6,.22); }
.badge-closed  { background: rgba(22,163,74,.08);   color: var(--success); border-color: rgba(22,163,74,.22); }
.badge-danger  { background: rgba(220,38,38,.08);   color: var(--danger);  border-color: rgba(220,38,38,.22); }
.badge-muted   { background: var(--surface-2);      color: var(--text-muted); border-color: var(--border-soft); }

.dot-open    { background: var(--info); box-shadow: 0 0 0 3px rgba(56,189,248,.2); }
.dot-wait    { background: var(--warning); box-shadow: 0 0 0 3px rgba(245,158,11,.2); }
.dot-closed  { background: var(--success); box-shadow: 0 0 0 3px rgba(34,197,94,.2); }

/* ============ Buttons ============ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    background: var(--accent);
    color: white;
    border: 0;
    border-radius: var(--radius-sm);
    padding: .6rem 1.1rem;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: filter 120ms, transform 120ms;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--surface-2); filter: none; }
.btn-danger { background: var(--danger); }

/* ============ Forms ============ */
.field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: 1rem; }
.field label { color: var(--text-muted); font-size: .78rem; font-weight: 500; letter-spacing: .02em; }
.input, .textarea {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    padding: .65rem .85rem;
    font: inherit;
    transition: border-color 120ms, box-shadow 120ms;
}
.input:focus, .textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(91,141,255,.15);
}
.textarea { min-height: 120px; resize: vertical; line-height: 1.55; }

/* ============ Thread ============ */
.thread { display: flex; flex-direction: column; gap: 1rem; }
.reply { display: flex; gap: .85rem; }
.reply-avatar { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: .85rem; color: white; flex: 0 0 auto; }
.reply-avatar.klant { background: linear-gradient(135deg, #5b8dff, #7dd3fc); }
.reply-avatar.mw    { background: linear-gradient(135deg, #a78bfa, #5b8dff); }
.reply-body { flex: 1; min-width: 0; }
.reply-header { display: flex; align-items: center; gap: .5rem; margin-bottom: .35rem; font-size: .82rem; flex-wrap: wrap; }
.reply-author { font-weight: 600; }
.reply-tag { color: var(--text-muted); font-size: .72rem; padding: 2px 6px; border-radius: 4px; background: var(--surface-2); }
.reply-date { color: var(--text-dim); font-size: .78rem; margin-left: auto; }
.reply-bubble {
    background: var(--surface-2);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    padding: .75rem 1rem;
    white-space: pre-wrap;
    word-wrap: break-word;
}
.reply.is-klant .reply-bubble { background: rgba(91,141,255,.08); border-color: rgba(91,141,255,.2); }

/* ============ Meta row (ticket detail) ============ */
.ticket-hero {
    display: flex;
    flex-direction: column;
    gap: .6rem;
}
.ticket-hero-top { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.ticket-hero-nummer { font-family: 'JetBrains Mono', ui-monospace, monospace; color: var(--text-muted); font-size: .9rem; }
.ticket-hero-meta { display: flex; gap: 1.25rem; color: var(--text-muted); font-size: .85rem; flex-wrap: wrap; }
.ticket-hero-meta-item { display: flex; align-items: center; gap: .35rem; }
.ticket-omschrijving {
    margin-top: 1rem;
    padding: 1rem 1.15rem;
    background: var(--bg);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    white-space: pre-wrap;
    line-height: 1.6;
}

/* ============ Alerts ============ */
.alert { padding: .75rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; display: flex; gap: .6rem; align-items: flex-start; }
.alert-error { background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.25); color: #fca5a5; }
.alert-info  { background: rgba(56,189,248,.08); border: 1px solid rgba(56,189,248,.2); color: #7dd3fc; }

/* ============ Empty ============ */
.empty { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.empty-icon { width: 48px; height: 48px; margin: 0 auto .75rem; opacity: .5; }
.empty-title { font-weight: 600; color: var(--text); margin-bottom: .25rem; }

/* ============ Auth (login/activate) ============ */
.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.5rem;
    background:
        radial-gradient(ellipse at top left, rgba(91,141,255,.08), transparent 40%),
        radial-gradient(ellipse at bottom right, rgba(167,139,250,.06), transparent 40%),
        var(--bg);
}
.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-lg);
}
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: .65rem; margin-bottom: 1.5rem; }
.auth-brand img { height: 56px; width: auto; max-width: 180px; object-fit: contain; }
.auth-brand-title { font-size: 1.1rem; font-weight: 700; }
.auth-brand-sub { font-size: .78rem; color: var(--text-muted); letter-spacing: .06em; text-transform: uppercase; }
.auth-h1 { font-size: 1.25rem; font-weight: 600; margin-bottom: .25rem; }
.auth-sub { color: var(--text-muted); font-size: .88rem; margin-bottom: 1.25rem; }
.auth-footer { margin-top: 1.25rem; text-align: center; font-size: .82rem; color: var(--text-muted); }
.auth-link { font-size: .82rem; color: var(--text-muted); text-decoration: none; }
.auth-link:hover { color: var(--text); text-decoration: underline; }

/* Helpers */
.muted { color: var(--text-muted); }
.dim { color: var(--text-dim); }
.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; }
.row { display: flex; align-items: center; gap: .5rem; }
.row-end { display: flex; align-items: center; justify-content: flex-end; gap: .5rem; }

/* New ticket */
.new-ticket-card { max-width: 720px; margin: 0 auto; padding: 1.75rem 1.9rem 1.6rem; }
.new-ticket-head { display: flex; align-items: flex-start; gap: 1rem; margin-bottom: 1.5rem; padding-bottom: 1.25rem; border-bottom: 1px solid var(--border-soft); }
.new-ticket-icon { flex: 0 0 auto; width: 44px; height: 44px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; }
.new-ticket-icon svg { width: 22px; height: 22px; }
.new-ticket-title { font-size: 1.35rem; font-weight: 700; margin: 0 0 .25rem; color: var(--text); }
.new-ticket-sub { font-size: .9rem; color: var(--text-muted); line-height: 1.5; }
.new-ticket-actions { display: flex; align-items: center; justify-content: flex-end; gap: .6rem; margin-top: 1rem; padding-top: 1.1rem; border-top: 1px solid var(--border-soft); }
.field-hint { font-size: .78rem; color: var(--text-muted); margin-top: .35rem; }
.field label .req { color: #e05b5b; font-weight: 600; margin-left: .15rem; }
.field-optional { color: var(--text-muted); font-weight: 400; font-size: .82em; margin-left: .25rem; }
.spacer { flex: 1; }

/* Bijlagen */
.attach-list { list-style: none; padding: 0; margin: .6rem 0 0; display: flex; flex-direction: column; gap: .35rem; }
.attach-list li { display: flex; align-items: center; gap: .55rem; padding: .45rem .7rem; border: 1px solid var(--border-soft); border-radius: 8px; background: var(--bg-elev); }
.attach-list .attach-name { flex: 1; font-size: .88rem; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-list .attach-size { font-size: .75rem; color: var(--text-muted); }
.attach-list .attach-remove { border: 0; background: transparent; color: var(--text-muted); font-size: 1.1rem; line-height: 1; cursor: pointer; padding: .1rem .3rem; border-radius: 4px; }
.attach-list .attach-remove:hover { background: var(--accent-soft); color: var(--text); }
.attach-chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .9rem; }
.attach-chips-reply { margin-top: .5rem; }
.attach-chip { display: inline-flex; align-items: center; gap: .4rem; padding: .3rem .6rem; border: 1px solid var(--border-soft); border-radius: 999px; background: var(--bg-elev); color: var(--text); font-size: .82rem; text-decoration: none; transition: border-color .15s, background .15s; }
.attach-chip:hover { border-color: var(--accent); background: var(--accent-soft); }
.attach-chip-size { color: var(--text-muted); font-size: .72rem; }

/* Icons helpers */
.icon { width: 16px; height: 16px; flex: 0 0 auto; }
.icon-sm { width: 14px; height: 14px; }
.icon-lg { width: 20px; height: 20px; }
