/* Ticketsystem - Basis-Stylesheet
   Bewusst ohne Framework gehalten, damit keine externen Abhaengigkeiten noetig sind. */

:root {
    --c-bg:            #f1f5f9;
    --c-surface:       #ffffff;
    --c-surface-alt:   #f8fafc;
    --c-border:        #e2e8f0;
    --c-border-strong: #cbd5e1;
    --c-text:          #0f172a;
    --c-text-muted:    #64748b;
    --c-primary:       #2563eb;
    --c-primary-dark:  #1d4ed8;
    --c-sidebar:       #0f172a;
    --c-sidebar-muted: #94a3b8;
    --c-success:       #047857;
    --c-success-bg:    #ecfdf5;
    --c-error:         #b91c1c;
    --c-error-bg:      #fef2f2;
    --c-warning:       #b45309;
    --c-warning-bg:    #fffbeb;
    --c-info:          #1e40af;
    --c-info-bg:       #eff6ff;

    --radius:    10px;
    --radius-sm: 6px;
    --shadow:    0 1px 2px rgba(15, 23, 42, .06), 0 4px 12px rgba(15, 23, 42, .04);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
}

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

html, body {
    margin: 0;
    padding: 0;
}

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

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 1.4rem; }
h2 { font-size: 1.05rem; }

a { color: var(--c-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------------------------------------------------------------- Anmeldeseite */

.page-guest {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
    background: linear-gradient(160deg, #0f172a 0%, #1e293b 55%, #334155 100%);
}

.guest-card {
    width: 100%;
    max-width: 400px;
    padding: 36px 32px;
    background: var(--c-surface);
    border-radius: 14px;
    box-shadow: 0 24px 60px rgba(2, 6, 23, .45);
}

.guest-card__header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 26px;
}

.guest-card__header h1 { font-size: 1.25rem; }

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    font-size: .8rem;
    font-weight: 700;
    letter-spacing: .04em;
    color: #fff;
    background: var(--c-primary);
    border-radius: 9px;
    flex-shrink: 0;
}

/* ---------------------------------------------------------------- Grundgeruest */

.shell {
    display: grid;
    grid-template-columns: 248px 1fr;
    min-height: 100vh;
}

.sidebar {
    display: flex;
    flex-direction: column;
    background: var(--c-sidebar);
    color: #e2e8f0;
    padding: 20px 16px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 6px 20px;
}

.sidebar__brand-text { font-weight: 600; font-size: .98rem; }

.nav { flex: 1; overflow-y: auto; }

.nav__title {
    margin: 18px 8px 6px;
    font-size: .68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .09em;
    color: var(--c-sidebar-muted);
}

.nav__link {
    display: block;
    padding: 8px 10px;
    margin-bottom: 1px;
    border-radius: var(--radius-sm);
    color: #cbd5e1;
    font-size: .9rem;
}

.nav__link:hover { background: rgba(148, 163, 184, .14); color: #fff; text-decoration: none; }
.nav__link--active { background: var(--c-primary); color: #fff; }
.nav__link--active:hover { background: var(--c-primary-dark); }

.sidebar__footer { border-top: 1px solid rgba(148, 163, 184, .2); padding-top: 14px; }

.sidebar__user { padding: 0 8px 12px; display: flex; flex-direction: column; }
.sidebar__user-name { font-size: .9rem; font-weight: 600; }
.sidebar__user-role { font-size: .75rem; color: var(--c-sidebar-muted); }

.main {
    padding: 26px 30px 60px;
    max-width: 1500px;
    width: 100%;
}

.main__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.main__profile { font-size: .85rem; color: var(--c-text-muted); }

/* ---------------------------------------------------------------- Meldungen */

.flash-stack { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }

.flash {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: .9rem;
    border: 1px solid transparent;
}

.flash--success { background: var(--c-success-bg); color: var(--c-success); border-color: #a7f3d0; }
.flash--error   { background: var(--c-error-bg);   color: var(--c-error);   border-color: #fecaca; }
.flash--info    { background: var(--c-info-bg);    color: var(--c-info);    border-color: #bfdbfe; }

.notice {
    padding: 14px 16px;
    margin-bottom: 18px;
    background: var(--c-info-bg);
    border: 1px solid #bfdbfe;
    border-radius: var(--radius);
    color: var(--c-info);
    font-size: .9rem;
}

.notice--warning { background: var(--c-warning-bg); border-color: #fde68a; color: var(--c-warning); }
.notice--muted { background: var(--c-surface-alt); border-color: var(--c-border); color: var(--c-text-muted); }
.notice__list { margin: 8px 0 0; padding-left: 18px; }
.notice a { color: inherit; font-weight: 600; text-decoration: underline; }

/* ---------------------------------------------------------------- Kacheln */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}

.stat {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-left: 3px solid var(--c-border-strong);
    border-radius: var(--radius);
    padding: 14px 16px;
    box-shadow: var(--shadow);
}

.stat__value { margin: 0; font-size: 1.7rem; font-weight: 600; line-height: 1.1; }
.stat__label { margin: 2px 0 0; font-size: .82rem; color: var(--c-text-muted); }

.stat--blue   { border-left-color: #2563eb; }
.stat--amber  { border-left-color: #d97706; }
.stat--violet { border-left-color: #7c3aed; }
.stat--green  { border-left-color: #059669; }
.stat--grey   { border-left-color: #94a3b8; }

/* ---------------------------------------------------------------- Panels */

.panel {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    overflow: hidden;
}

.panel--narrow { max-width: 620px; }

.panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--c-border);
    background: var(--c-surface-alt);
}

.panel__body { padding: 18px; }

.panel__intro {
    margin: 0;
    padding: 14px 18px;
    font-size: .88rem;
    line-height: 1.55;
    color: var(--c-text-muted);
    background: var(--c-surface-alt);
    border-bottom: 1px solid var(--c-border);
}

.empty {
    margin: 0;
    padding: 26px 18px;
    text-align: center;
    color: var(--c-text-muted);
    font-size: .9rem;
}

/* ---------------------------------------------------------------- Tabellen */

.table { width: 100%; border-collapse: collapse; font-size: .88rem; }

.table th {
    text-align: left;
    font-weight: 600;
    font-size: .74rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--c-text-muted);
    padding: 9px 18px;
    border-bottom: 1px solid var(--c-border);
    white-space: nowrap;
}

.table td {
    padding: 10px 18px;
    border-bottom: 1px solid var(--c-border);
    vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--c-surface-alt); }

.table--report th[scope="row"] {
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0;
    font-size: .88rem;
    color: inherit;
    white-space: nowrap;
}
.table--report td {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.table--report .table__total th,
.table--report .table__total td {
    font-weight: 600;
    background: var(--c-surface-alt);
}

.table__title { max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table__muted { color: var(--c-text-muted); white-space: nowrap; }
.table__actions { text-align: right; white-space: nowrap; }
.table__actions form { display: inline-block; margin-left: 6px; vertical-align: middle; }
.table__actions form:first-child { margin-left: 0; }

.panel__header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}
.panel__header-actions form { margin: 0; }

.link-mono { font-family: var(--font-mono); font-size: .82rem; }

/* ---------------------------------------------------------------- Badges */

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: .74rem;
    font-weight: 600;
    background: #e2e8f0;
    color: #334155;
    white-space: nowrap;
}

.badge--new      { background: #dbeafe; color: #1e40af; }
.badge--open     { background: #fef3c7; color: #92400e; }
.badge--pending  { background: #ede9fe; color: #5b21b6; }
.badge--resolved { background: #d1fae5; color: #065f46; }
.badge--closed   { background: #e2e8f0; color: #475569; }
.badge--ok       { background: #d1fae5; color: #065f46; }
.badge--fail     { background: #fee2e2; color: #991b1b; }
.badge--muted    { background: #f1f5f9; color: #64748b; }
.badge--lock     { background: #fee2e2; color: #991b1b; margin-left: 6px; }

.dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-right: 6px;
    border-radius: 50%;
    vertical-align: middle;
}

/* ---------------------------------------------------------------- Formulare */

.form { padding: 18px; }
.form--guest { padding: 0; }

.field { margin-bottom: 16px; }

.field label {
    display: block;
    margin-bottom: 5px;
    font-size: .84rem;
    font-weight: 600;
    color: #334155;
}

.field__hint { margin: 5px 0 0; font-size: .78rem; color: var(--c-text-muted); }

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="search"],
select,
textarea {
    width: 100%;
    padding: 9px 11px;
    font: inherit;
    font-size: .9rem;
    color: var(--c-text);
    background: #fff;
    border: 1px solid var(--c-border-strong);
    border-radius: var(--radius-sm);
    transition: border-color .12s, box-shadow .12s;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--c-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
}

textarea { resize: vertical; min-height: 110px; font-family: var(--font); }

.field-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0 16px;
}

.field-check { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: .88rem; }
.field-check input { width: auto; }

.field-group-label {
    margin: 12px 0 6px;
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--c-text-muted);
}

.form__actions {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-top: 8px;
    border-top: 1px solid var(--c-border);
    margin-top: 18px;
    padding-top: 16px;
}

fieldset {
    border: 1px solid var(--c-border);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    margin: 0 0 18px;
}

legend { padding: 0 6px; font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--c-text-muted); }

/* ---------------------------------------------------------------- Schaltflaechen */

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 15px;
    font: inherit;
    font-size: .88rem;
    font-weight: 500;
    line-height: 1.2;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: #fff;
    color: var(--c-text);
    text-decoration: none;
    transition: background .12s, border-color .12s;
}

.button:hover { text-decoration: none; }
.button:disabled { opacity: .55; cursor: not-allowed; }

.button--primary { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }
.button--primary:hover:not(:disabled) { background: var(--c-primary-dark); border-color: var(--c-primary-dark); }

.button--ghost { border-color: var(--c-border-strong); color: #334155; }
.button--ghost:hover:not(:disabled) { background: var(--c-surface-alt); }

.button--danger { border-color: #fca5a5; color: var(--c-error); background: #fff; }
.button--danger:hover:not(:disabled) { background: var(--c-error-bg); }

.button--small { padding: 5px 10px; font-size: .8rem; }
.button--block { width: 100%; }

.sidebar__logout .button--ghost {
    background: transparent;
    border-color: rgba(148, 163, 184, .35);
    color: #cbd5e1;
}
.sidebar__logout .button--ghost:hover { background: rgba(148, 163, 184, .14); color: #fff; }

/* ---------------------------------------------------------------- Testergebnis */

.test-result {
    margin-top: 12px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    font-size: .85rem;
    display: none;
}

.test-result--visible { display: block; }
.test-result--ok   { background: var(--c-success-bg); color: var(--c-success); border: 1px solid #a7f3d0; }
.test-result--fail { background: var(--c-error-bg);   color: var(--c-error);   border: 1px solid #fecaca; }
.test-result--busy { background: var(--c-surface-alt); color: var(--c-text-muted); border: 1px solid var(--c-border); }

.test-result__log {
    margin: 8px 0 0;
    padding: 8px 10px;
    background: rgba(15, 23, 42, .05);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: .76rem;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 220px;
    overflow: auto;
}

/* ---------------------------------------------------------------- Fehlerseite */

.error-panel { padding: 34px; text-align: center; }
.error-panel__status { margin: 0; font-size: 2.4rem; font-weight: 700; color: var(--c-text-muted); }
.error-panel__message { margin: 6px 0 20px; }

/* ---------------------------------------------------------------- Hilfsklassen */

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 10px;
    margin-bottom: 18px;
}

.toolbar .field { margin-bottom: 0; min-width: 150px; flex: 1 1 150px; }
.toolbar__spacer { flex: 1; }

.ticket-filters {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 14px 16px;
}

.pager {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 4px 0 20px;
}

.muted { color: var(--c-text-muted); }
.mono  { font-family: var(--font-mono); font-size: .82rem; }

.signature-preview {
    margin: 0;
    padding: 12px 14px;
    background: var(--c-surface-alt);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-sm);
    white-space: pre-wrap;
    font-size: .85rem;
    line-height: 1.45;
}

/* ---------------------------------------------------------------- Ticketansicht */

.ticket {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 20px;
    align-items: start;
}

.ticket__side { position: sticky; top: 16px; }

.ticket-meta { padding: 16px 18px; }
.ticket-meta__row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
}
.ticket-meta__number { margin: 0 0 4px; color: var(--c-text-muted); }
.ticket-meta__title { font-size: 1.15rem; margin-bottom: 6px; }
.ticket-meta__badges { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: flex-end; }

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

.article {
    padding: 16px 18px;
    border-bottom: 1px solid var(--c-border);
}
.article:last-child { border-bottom: none; }
.article--internal { background: #f8fafc; }
.article--note { border-left: 3px solid #7c3aed; }
.article--system { background: var(--c-surface-alt); }
.article--email_out { border-left: 3px solid #2563eb; }
.article--email_forward { border-left: 3px solid #d97706; }
.article--email_in { border-left: 3px solid #059669; }

.article__actions { margin: 12px 0 0; }
.article-source { margin-top: 10px; }
.article-source summary {
    cursor: pointer;
    color: var(--c-text-muted);
    font-size: .82rem;
    font-weight: 600;
}
.article-source pre {
    margin: 8px 0 0;
    padding: 10px 12px;
    max-height: 320px;
    overflow: auto;
    background: #0f172a;
    color: #e2e8f0;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: .74rem;
    white-space: pre-wrap;
    word-break: break-all;
}

.article__head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 8px;
}
.article__from { font-weight: 600; }
.article__time { margin-left: auto; font-size: .82rem; }
.article__subject { margin: 0 0 6px; font-weight: 600; }
.article__meta { margin: 0 0 6px; font-size: .82rem; }
.article__body {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font-size: .92rem;
}
.article__files {
    margin: 12px 0 0;
    padding: 0;
    list-style: none;
    font-size: .85rem;
}
.article__files li { display: flex; gap: 8px; align-items: baseline; }

.ticket-composer--blocked { opacity: .85; }
.ticket-composer textarea { min-height: 220px; }

.form--compact { padding-top: 0; }
.form--compact .form__actions { margin-top: 8px; padding-top: 10px; }

.meta-list {
    margin: 0;
    padding: 14px 18px 6px;
}
.meta-list > div {
    display: grid;
    grid-template-columns: 96px 1fr;
    gap: 8px;
    margin-bottom: 8px;
    font-size: .86rem;
}
.meta-list dt { color: var(--c-text-muted); font-weight: 500; }
.meta-list dd { margin: 0; }

.ticket-side-actions .button--block { margin-top: 8px; }
.ticket-side-actions .field__hint { margin-bottom: 12px; }

.form--inline { margin: 0; }
.form--inline select { width: 100%; max-width: 100%; }

.ticket-history {
    list-style: none;
    margin: 0;
    padding: 0 16px 12px;
    max-height: 280px;
    overflow-y: auto;
}
.ticket-history__item {
    padding: 8px 0;
    border-bottom: 1px solid var(--c-border, #e3e6ea);
    font-size: .86rem;
}
.ticket-history__item:last-child { border-bottom: 0; }
.ticket-history__meta {
    color: var(--c-text-muted);
    font-size: .78rem;
    margin-bottom: 2px;
}

.page-guest--install {
    align-items: flex-start;
    padding: 40px 24px;
}
.guest-card--wide {
    max-width: 820px;
}
.guest-card__sub {
    margin: 2px 0 0;
    font-size: .82rem;
    color: var(--c-text-muted);
}
.install-block {
    margin: 0 0 22px;
}
.install-block h2 {
    margin-bottom: 8px;
}
.install-block .table th {
    text-transform: none;
    letter-spacing: 0;
}
.install-log {
    margin: 0 0 18px;
    padding-left: 18px;
    color: var(--c-text-muted);
    font-size: .9rem;
}

@media (max-width: 1100px) {
    .ticket { grid-template-columns: 1fr; }
    .ticket__side { position: static; }
}

@media (max-width: 900px) {
    .shell { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; }
    .main { padding: 18px; }
    .ticket-meta__row { flex-direction: column; }
    .ticket-meta__badges { justify-content: flex-start; }
}
