/*
 * KCC app – base styles following www.menicon.nl (see docs/styleguide.md).
 * Calm, light, flat: grey-blue surfaces, slate accents, pill buttons, Noto Sans.
 */
:root {
    /* Colours measured on menicon.nl */
    --mc-slate: #515d69;          /* footer, primary buttons, button text */
    --mc-slate-dark: #3f4952;     /* hover on slate (derived) */
    --mc-teal: #627873;           /* labels like "POPULAIR", small accents */
    --mc-blue: #4c6580;           /* links/secondary accent */
    --mc-mist: #d1dcde;           /* hero and light card backgrounds */
    --mc-mist-light: #edf1f2;     /* page sections, table stripes */
    --mc-mint: #c2d1ce;           /* soft highlight */
    --mc-border: #c4cfd1;         /* button and input borders */
    --mc-line: #e0e0e1;           /* dividers */
    --mc-text: #323232;           /* main text */
    --mc-text-muted: #5f5f5f;     /* secondary text, nav */
    --mc-text-soft: #727171;      /* subheadings */
    --mc-white: #ffffff;

    /* Status colours for the app (not on menicon.nl; muted to match) */
    --kcc-ok: #5f8a6e;
    --kcc-warning: #c58a2c;
    --kcc-danger: #b5473c;

    --font-sans: "Noto Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
    --radius-pill: 28px;
    --radius-small: 4px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--mc-white);
    color: var(--mc-text);
    font-family: var(--font-sans);
    font-size: 16px;
    font-weight: 500;
    line-height: 1.5;
}

h1, h2, h3, h4 {
    font-weight: 300;
    line-height: 1.25;
    color: var(--mc-text);
}

h1 { font-size: 2rem; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.5rem; color: var(--mc-text-soft); }

a {
    color: var(--mc-blue);
}

.label {
    color: var(--mc-teal);
    font-weight: 700;
}

/* Buttons: pill-shaped like menicon.nl */
.btn {
    display: inline-block;
    padding: 7px 24px 9px;
    border: 1px solid var(--mc-border);
    border-radius: var(--radius-pill);
    background: var(--mc-white);
    color: var(--mc-slate);
    font: 700 1rem/1.5 var(--font-sans);
    text-decoration: none;
    cursor: pointer;
}

.btn:hover {
    border-color: var(--mc-slate);
}

.btn-primary {
    border-color: var(--mc-slate);
    background: var(--mc-slate);
    color: var(--mc-white);
}

.btn-primary:hover {
    border-color: var(--mc-slate-dark);
    background: var(--mc-slate-dark);
}

.surface {
    background: var(--mc-mist-light);
}

.surface-strong {
    background: var(--mc-mist);
}

/* ------------------------------------------------------------------ */
/* Generic                                                             */
/* ------------------------------------------------------------------ */

.muted { color: var(--mc-text-soft); }
.small { font-size: .85rem; }
.empty { padding: 2rem; background: var(--mc-mist-light); color: var(--mc-text-muted); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

input[type="text"], input[type="email"], input[type="password"], input[type="search"], input[type="date"], select, textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--mc-border);
    border-radius: var(--radius-small);
    background: var(--mc-white);
    color: var(--mc-text);
    font: 500 1rem/1.4 var(--font-sans);
}
input:focus, select:focus, textarea:focus, .btn:focus-visible, a:focus-visible {
    outline: 2px solid var(--mc-blue);
    outline-offset: 1px;
}
label { display: block; font-size: .9rem; color: var(--mc-text-muted); }
label > input, label > select, label > textarea { margin-top: 4px; }
.stack { display: grid; gap: 12px; }
.stack + .stack { margin-top: 16px; }
.narrow { max-width: 420px; }
.inline-form { margin-bottom: 12px; }

.flash { padding: 10px 14px; margin-bottom: 16px; border-left: 4px solid var(--mc-teal); background: var(--mc-mist-light); }
.flash-error { border-color: var(--kcc-danger); background: #f8ecea; }
.flash-success { border-color: var(--kcc-ok); }

.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: var(--radius-pill);
    background: var(--mc-mist);
    color: var(--mc-slate);
    font-size: .8rem;
    font-weight: 700;
    white-space: nowrap;
}
.badge-quiet { background: var(--mc-mist-light); color: var(--mc-text-muted); }
.badge-warning { background: #f6ead6; color: #7a5412; }
.badge-danger { background: var(--kcc-danger); color: var(--mc-white); }
.status-new { background: var(--mc-slate); color: var(--mc-white); }
.status-open { background: var(--mc-mint); color: #2f4540; }
.status-pending-customer, .status-pending-internal, .status-on-hold { background: var(--mc-mist-light); color: var(--mc-text-muted); }
.status-solved, .status-closed, .status-ignored { background: var(--mc-line); color: var(--mc-text-soft); }

/* ------------------------------------------------------------------ */
/* App shell                                                           */
/* ------------------------------------------------------------------ */

.brand { color: var(--mc-white); font-size: 1.25rem; font-weight: 300; text-decoration: none; letter-spacing: .02em; }
.brand span { font-weight: 700; }
.brand-dark { color: var(--mc-slate); }

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 10px 24px;
    background: var(--mc-slate);
    color: var(--mc-white);
}
.topbar-search { flex: 1; max-width: 520px; }
.topbar-search input { border-color: transparent; border-radius: var(--radius-pill); padding: 6px 16px; }
.topbar-user { display: flex; gap: 16px; align-items: center; margin-left: auto; font-size: .9rem; }
.topbar-user a { color: var(--mc-white); opacity: .85; text-decoration: none; }
.topbar-user a:hover { opacity: 1; text-decoration: underline; }
.user-name { font-weight: 700; }

.shell { display: grid; grid-template-columns: 240px 1fr; min-height: calc(100vh - 52px); }
.sidebar { padding: 20px 12px; background: var(--mc-mist-light); border-right: 1px solid var(--mc-line); }
.sidebar a {
    display: flex;
    justify-content: space-between;
    padding: 7px 12px;
    border-radius: var(--radius-pill);
    color: var(--mc-text);
    text-decoration: none;
}
.sidebar a:hover { background: var(--mc-mist); }
.sidebar a.active { background: var(--mc-slate); color: var(--mc-white); font-weight: 700; }
.sidebar-heading { margin: 20px 12px 6px; font-size: .75rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--mc-teal); }
.count { min-width: 1.6em; text-align: right; font-weight: 700; color: var(--mc-text-muted); }
.sidebar a.active .count { color: var(--mc-white); }
.count-danger { color: var(--kcc-danger); }

.content { padding: 24px 32px; min-width: 0; }
.page-head { margin-bottom: 20px; }
.page-head h1 { margin: 0 0 4px; }

/* ------------------------------------------------------------------ */
/* Ticket list                                                         */
/* ------------------------------------------------------------------ */

.ticket-table { width: 100%; border-collapse: collapse; }
.ticket-table th { padding: 8px 10px; border-bottom: 2px solid var(--mc-mist); text-align: left; font-size: .8rem; font-weight: 700; color: var(--mc-text-muted); }
.ticket-table td { padding: 10px; border-bottom: 1px solid var(--mc-line); vertical-align: top; }
.ticket-table tbody tr:hover { background: var(--mc-mist-light); }
.ticket-table .row-escalated { background: #fbf1ef; }
.col-flag { width: 28px; text-align: center; }
.flag { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; font-size: .8rem; font-weight: 700; }
.flag-escalated { background: var(--kcc-danger); color: var(--mc-white); }
.flag-soon { background: #f6ead6; color: #7a5412; }
.ticket-link { display: block; color: var(--mc-text); text-decoration: none; }
.ticket-link:hover .ticket-subject { text-decoration: underline; }
.ticket-number { display: block; font-size: .8rem; color: var(--mc-text-soft); }
.ticket-subject { font-weight: 700; }

/* ------------------------------------------------------------------ */
/* Ticket page                                                         */
/* ------------------------------------------------------------------ */

.ticket-head .ticket-number { margin: 0; }
.ticket-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; align-items: start; }
.message { margin-bottom: 16px; padding: 16px 20px; border: 1px solid var(--mc-line); background: var(--mc-white); }
.message-outbound { background: var(--mc-mist-light); border-color: var(--mc-mist); }
.message-internal-note { background: #eef4f2; border-color: var(--mc-mint); border-left: 4px solid var(--mc-teal); }
.message-head { display: flex; justify-content: space-between; gap: 12px; }
.message-meta { margin: 2px 0 0; font-size: .85rem; }
.message-body { margin-top: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.attachments { margin: 12px 0 0; padding: 0; list-style: none; }
.attachments li { margin-top: 4px; }
.note-form { margin-top: 24px; padding: 16px 20px; background: var(--mc-mist-light); }
.reply-form { margin-top: 24px; padding: 16px 20px; border: 1px solid var(--mc-border); background: var(--mc-white); }
.reply-form h2 { margin: 0; font-size: 1.1rem; font-weight: 700; color: var(--mc-slate); }
.reply-form p { margin: 0; }
.send-status { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 6px; }
.send-status form.inline { display: inline; }
.btn-small { padding: 2px 14px 3px; font-size: .85rem; }
.quoted { margin-top: 10px; font-size: .9rem; color: var(--mc-text-muted); }
.quoted summary { cursor: pointer; color: var(--mc-blue); }

.ticket-side .panel { margin-bottom: 16px; padding: 16px; background: var(--mc-mist-light); }
.panel h2 { margin: 0 0 10px; font-size: .8rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--mc-teal); }
.panel p { margin: 0 0 10px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; font-size: .9rem; }
.facts dt { color: var(--mc-text-soft); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.history { margin: 0; padding: 0; list-style: none; font-size: .9rem; }
.history li { display: grid; padding: 6px 0; border-bottom: 1px solid var(--mc-line); }
.history-note { font-style: italic; color: var(--mc-text-muted); }

/* ------------------------------------------------------------------ */
/* Login                                                               */
/* ------------------------------------------------------------------ */

.login-page { display: grid; place-items: center; min-height: 100vh; background: var(--mc-mist); }
.login-card { width: min(400px, calc(100% - 32px)); padding: 32px; background: var(--mc-white); }
.login-card h1 { margin: 16px 0 4px; }
.login-card .muted { margin-top: 0; }

/* ------------------------------------------------------------------ */
/* Small screens                                                       */
/* ------------------------------------------------------------------ */

@media (max-width: 900px) {
    .shell { grid-template-columns: 1fr; }
    .sidebar { display: flex; gap: 6px; overflow-x: auto; padding: 10px 16px; border-right: 0; border-bottom: 1px solid var(--mc-line); }
    .sidebar a { flex: none; gap: 8px; }
    .sidebar-heading { display: none; }
    .content { padding: 16px; }
    .ticket-layout { grid-template-columns: 1fr; }
    .topbar { flex-wrap: wrap; gap: 10px; padding: 10px 16px; }
    .topbar-search { order: 3; flex-basis: 100%; max-width: none; }
    .ticket-table thead { display: none; }
    .ticket-table tr { display: grid; grid-template-columns: 28px 1fr; padding: 8px 0; border-bottom: 1px solid var(--mc-line); }
    .ticket-table td { padding: 2px 6px; border: 0; }
    .ticket-table td:nth-child(n+3) { grid-column: 2; font-size: .9rem; }
}
