/* barox sign – UI im barox-CI (Navy #0d2a4a / Orange #f39200, Helvetica Now)
   Modernisiertes Design: Tiefe, weiche Schatten, abgerundete Flächen, Microinteraktionen. */

@font-face {
    font-family: "Helvetica Now";
    src: url("../fonts/HelveticaNowText-Regular.otf") format("opentype");
    font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
    font-family: "Helvetica Now";
    src: url("../fonts/HelveticaNowText-Medium.otf") format("opentype");
    font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
    font-family: "Helvetica Now";
    src: url("../fonts/HelveticaNowText-Bold.otf") format("opentype");
    font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
    font-family: "Helvetica Now Display";
    src: url("../fonts/HelveticaNowDisplay-Bd.otf") format("opentype");
    font-weight: 700; font-style: normal; font-display: swap;
}

:root {
    --navy: #0d2a4a;
    --navy-700: #143a63;
    --navy-900: #081d35;
    --orange: #f39200;
    --orange-600: #d97f00;
    --ink: #1d2733;
    --muted: #6b7785;
    --line: #e6ebf2;
    --bg: #eef2f7;
    --white: #fff;
    --danger: #d23b2c;
    --danger-600: #b8301f;
    --ok: #1e8e5a;

    --radius: 14px;
    --radius-lg: 18px;
    --radius-sm: 10px;

    --shadow-sm: 0 1px 2px rgba(13,42,74,.06), 0 1px 3px rgba(13,42,74,.05);
    --shadow-md: 0 6px 18px rgba(13,42,74,.08), 0 2px 6px rgba(13,42,74,.05);
    --shadow-lg: 0 18px 50px rgba(13,42,74,.16);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: "Helvetica Now", "Helvetica Neue", Arial, sans-serif;
    color: var(--ink);
    background:
        radial-gradient(1100px 460px at 78% -8%, rgba(243,146,0,.10), transparent 60%),
        radial-gradient(900px 500px at 0% 0%, rgba(13,42,74,.07), transparent 55%),
        var(--bg);
    background-attachment: fixed;
    line-height: 1.55;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: "Helvetica Now Display", "Helvetica Now", sans-serif; color: var(--navy); margin: 0 0 .4em; letter-spacing: -.01em; }
h1 { font-size: 1.85rem; }
h2 { font-size: 1.2rem; }
a { color: var(--navy-700); text-underline-offset: 2px; }
.muted { color: var(--muted); }

/* ---------- Topbar ---------- */
.topbar {
    position: sticky; top: 0; z-index: 50;
    display: flex; align-items: center; gap: 1.5rem;
    background: linear-gradient(180deg, var(--navy) 0%, var(--navy-900) 100%);
    color: #fff;
    padding: .7rem 1.6rem;
    border-bottom: 3px solid var(--orange);
    box-shadow: 0 6px 24px rgba(8,29,53,.28);
}
/* An der Schrift-Grundlinie ausrichten: "sign" sitzt auf der barox-Grundlinie. */
.brand { display: flex; align-items: baseline; gap: .55rem; color: #fff; text-decoration: none; font-weight: 700; }
.brand img { align-self: baseline; }
.brand span { color: var(--orange); font-size: 1.1rem; letter-spacing: .05em; line-height: 1; }
.nav { display: flex; gap: .3rem; margin-left: 1rem; }
.nav a {
    color: #c7d4e3; text-decoration: none; font-size: .94rem; font-weight: 500;
    padding: .42rem .8rem; border-radius: 999px; transition: background .15s, color .15s;
}
.nav a:hover { color: #fff; background: rgba(255,255,255,.08); }
.nav a.active { color: #fff; background: rgba(243,146,0,.18); box-shadow: inset 0 0 0 1px rgba(243,146,0,.35); }
.user { margin-left: auto; display: flex; align-items: center; gap: .85rem; }
.user-chip { display: flex; align-items: center; gap: .55rem; }
.avatar {
    width: 34px; height: 34px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: .8rem; font-weight: 700; color: #fff;
    background: linear-gradient(135deg, var(--orange), var(--orange-600));
    box-shadow: 0 2px 8px rgba(243,146,0,.4);
}
.user-name { color: #e3ebf4; font-size: .9rem; }

/* ---------- Layout ---------- */
.container { width: 100%; max-width: 1060px; margin: 2.4rem auto; padding: 0 1.4rem; flex: 1; }
.container.wide { max-width: 1260px; }

.page-head { margin-bottom: 1.6rem; }
.page-head h1 { margin-bottom: .15rem; }
.page-head .subtitle { color: var(--muted); font-size: 1rem; margin: 0; }

.card {
    background: var(--white); border: 1px solid var(--line);
    border-radius: var(--radius-lg); box-shadow: var(--shadow-md);
    padding: 1.7rem; margin-bottom: 1.3rem;
}
.section-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 1rem; margin-bottom: .4rem; }
.section-head h2 { margin: 0; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
    background: linear-gradient(180deg, var(--orange), var(--orange-600));
    color: #fff; border: none;
    padding: .62rem 1.15rem; border-radius: var(--radius-sm); font: inherit; font-weight: 600;
    cursor: pointer; text-decoration: none; white-space: nowrap;
    box-shadow: 0 4px 12px rgba(243,146,0,.28);
    transition: transform .12s ease, box-shadow .12s ease, background .15s ease, opacity .15s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(243,146,0,.36); }
.btn:active { transform: translateY(0); }
.btn-secondary { background: linear-gradient(180deg, var(--navy-700), var(--navy)); box-shadow: 0 4px 12px rgba(13,42,74,.28); }
.btn-secondary:hover { box-shadow: 0 8px 20px rgba(13,42,74,.34); }
.btn-ghost { background: transparent; border: 1px solid rgba(255,255,255,.35); color: #fff; box-shadow: none; }
.btn-ghost:hover { background: rgba(255,255,255,.12); transform: none; box-shadow: none; }
.btn-danger { background: linear-gradient(180deg, var(--danger), var(--danger-600)); box-shadow: 0 4px 12px rgba(210,59,44,.26); }
.btn-light { background: #eef1f6; color: var(--navy); box-shadow: none; }
.btn-light:hover { background: #e2e7ee; box-shadow: none; }
.btn-sm { padding: .38rem .72rem; font-size: .85rem; border-radius: 8px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }

/* ---------- Quick-Action-Kacheln ---------- */
.quick-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin-bottom: 1.3rem; }
.action-tile {
    display: flex; align-items: center; gap: .9rem;
    background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 1.05rem 1.15rem; text-decoration: none; color: var(--ink);
    box-shadow: var(--shadow-sm);
    transition: transform .14s ease, box-shadow .14s ease, border-color .14s;
}
.action-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: #d7e0ec; }
.tile-icon {
    flex: 0 0 auto; width: 44px; height: 44px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(243,146,0,.12); color: var(--orange);
}
.tile-icon.navy { background: rgba(13,42,74,.09); color: var(--navy); }
.tile-icon svg { width: 22px; height: 22px; }
.tile-text strong { display: block; font-weight: 600; color: var(--navy); }
.tile-text span { font-size: .87rem; color: var(--muted); }

/* ---------- Forms ---------- */
label { display: block; font-weight: 600; margin-bottom: .35rem; color: var(--navy); }
.hint { font-size: .85rem; color: var(--muted); margin-top: -.5rem; margin-bottom: 1rem; }

/* Gestylte Datei-Auswahl (überlagert das native Feld transparent) */
.file-drop {
    position: relative; display: block; margin-bottom: 1rem;
    border: 1.5px dashed #c7d2e0; border-radius: var(--radius-sm);
    background: #f7f9fc; padding: 1.05rem 1.15rem; cursor: pointer;
    transition: border-color .15s, background .15s, box-shadow .15s;
}
.file-drop:hover, .file-drop.dragover { border-color: var(--orange); background: #fffaf2; box-shadow: 0 4px 14px rgba(243,146,0,.12); }
.file-drop input[type=file] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.file-drop-inner { display: flex; align-items: center; gap: .9rem; pointer-events: none; }
.file-drop-icon {
    flex: 0 0 auto; width: 42px; height: 42px; border-radius: 11px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(243,146,0,.12); color: var(--orange);
}
.file-drop-icon svg { width: 21px; height: 21px; }
.file-drop-title { display: block; color: var(--navy); font-weight: 600; }
.file-name { color: var(--muted); font-size: .88rem; }
.file-name.has-file { color: var(--ok); font-weight: 600; }

/* ---------- Alerts ---------- */
.alert { position: relative; padding: .85rem 1rem .85rem 1.1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; font-size: .95rem; border: 1px solid transparent; }
.alert-error { background: #fdecea; color: #9c2a1e; border-color: #f5c6c0; }
.alert-ok { background: #e7f6ee; color: #176c46; border-color: #bfe6cf; }
.alert-info { background: #eef4fc; color: var(--navy); border-color: #d3e2f5; }

/* ---------- Tabellen ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: .75rem .6rem; border-bottom: 1px solid var(--line); font-size: .93rem; vertical-align: middle; }
.table th { color: var(--muted); font-weight: 600; font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: #f7f9fc; }
.table tbody tr:last-child td { border-bottom: none; }
.badge { display: inline-flex; align-items: center; gap: .35rem; padding: .2rem .6rem; border-radius: 999px; font-size: .76rem; font-weight: 600; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-signed { background: #e7f6ee; color: var(--ok); }
.badge-uploaded { background: #eef4fc; color: var(--navy-700); }
.row-actions { display: flex; gap: .5rem; align-items: center; }
.row-actions form { margin: 0; }

/* ---------- Empty-State ---------- */
.empty-state { text-align: center; padding: 2.4rem 1rem; }
.empty-icon {
    width: 64px; height: 64px; margin: 0 auto .9rem; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: rgba(13,42,74,.06); color: var(--navy);
}
.empty-icon svg { width: 30px; height: 30px; }
.empty-state p { color: var(--muted); margin: 0 0 1.1rem; }

/* ---------- Login ---------- */
.login-wrap { display: flex; align-items: center; justify-content: center; flex: 1; padding: 2rem 1rem; }
.login-card {
    background: var(--white); border-radius: 20px; box-shadow: var(--shadow-lg);
    padding: 2.8rem 2.6rem; max-width: 430px; width: 100%; text-align: center;
    border: 1px solid var(--line);
    position: relative; overflow: hidden;
}
.login-card::before { content: ""; position: absolute; left: 0; top: 0; right: 0; height: 4px; background: linear-gradient(90deg, var(--orange), var(--orange-600)); }
.login-card img { margin-bottom: 1.4rem; }
.login-card h1 { margin-bottom: .3rem; }

/* ---------- Modal ---------- */
.modal-backdrop {
    position: fixed; inset: 0; z-index: 1000;
    display: flex; align-items: center; justify-content: center;
    background: rgba(8,29,53,.55); backdrop-filter: blur(2px);
    padding: 1.2rem; opacity: 0; visibility: hidden; transition: opacity .15s ease;
}
.modal-backdrop.open { opacity: 1; visibility: visible; }
.modal {
    background: var(--white); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
    width: 100%; max-width: 440px; padding: 1.7rem 1.7rem 1.4rem;
    transform: translateY(10px) scale(.97); transition: transform .16s ease;
}
.modal-backdrop.open .modal { transform: none; }
.modal-icon {
    width: 46px; height: 46px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.45rem; font-weight: 700; color: #fff; margin-bottom: .9rem;
    background: var(--orange); font-family: "Helvetica Now Display", sans-serif;
}
.modal-icon.danger { background: var(--danger); }
.modal-title { margin: 0 0 .4rem; font-size: 1.2rem; }
.modal-message { margin: 0 0 1.4rem; color: var(--ink); }
.modal-actions { display: flex; justify-content: flex-end; gap: .6rem; flex-wrap: wrap; }

/* ---------- Signier-Ansicht ---------- */
.extra-text-row { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: .5rem; }
.extra-text-row label { margin: 0; white-space: nowrap; }
.extra-text-row select,
.extra-text-row input[type=text] {
    padding: .55rem .7rem; border: 1px solid var(--line); border-radius: var(--radius-sm);
    font: inherit; background: #fff; color: var(--ink);
}
.extra-text-row select { max-width: 220px; }
.extra-text-row input[type=text] { flex: 1 1 220px; min-width: 180px; }
/* Modus-Umschalter Unterschrift / Visa-Stempel */
.mode-switch { display: inline-flex; gap: .25rem; padding: .25rem; margin-bottom: .9rem;
    background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.mode-switch .mode-option { display: inline-flex; align-items: center; gap: .4rem; margin: 0;
    padding: .4rem .8rem; border-radius: var(--radius-sm); cursor: pointer; font-weight: 600; color: var(--muted); }
.mode-switch .mode-option:has(input:checked) { background: var(--white); color: var(--navy); box-shadow: var(--shadow-sm); }

/* Visa-Stempel: Eingabe-Tabelle */
.visa-form { border-collapse: collapse; width: 100%; max-width: 640px; margin-bottom: .6rem; }
.visa-form th, .visa-form td { border: 1px solid var(--line); padding: .4rem .55rem; text-align: left; }
.visa-form thead th { background: var(--bg); color: var(--navy); font-size: .9rem; text-align: center; }
.visa-form tbody th { font-weight: 600; color: var(--ink); white-space: nowrap; }
.visa-form select, .visa-form input[type=text] {
    width: 100%; padding: .4rem .5rem; border: 1px solid var(--line); border-radius: var(--radius-sm);
    font: inherit; background: #fff; color: var(--ink); box-sizing: border-box;
}
.visa-form td:nth-child(3), .visa-form td:nth-child(4) { width: 22%; }

/* Freigabe-Link */
.share-row { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.share-link { flex: 1 1 320px; min-width: 220px; padding: .5rem .7rem; border: 1px solid var(--line);
    border-radius: var(--radius-sm); font: inherit; background: #fff; color: var(--ink); }

.sign-toolbar { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.pdf-stage { background: #2f3a47; border-radius: var(--radius); padding: 1rem; overflow: auto; max-height: 75vh; box-shadow: inset 0 2px 12px rgba(0,0,0,.25); }
.pdf-page-wrap { position: relative; margin: 0 auto 1rem; box-shadow: 0 6px 24px rgba(0,0,0,.35); width: max-content; border-radius: 4px; overflow: hidden; }
.pdf-page-wrap canvas { display: block; }
.pdf-overlay { position: absolute; inset: 0; cursor: crosshair; }
.sign-rect { position: absolute; border: 2px solid var(--orange); background: rgba(243,146,0,.18); pointer-events: none; box-shadow: 0 0 0 1px rgba(255,255,255,.5); }
.sign-rect-label { position: absolute; top: -1.5rem; left: 0; background: var(--orange); color: #fff; font-size: .72rem; font-weight: 600; padding: .08rem .45rem; border-radius: 5px; white-space: nowrap; }

/* ---------- Unterschriften-Editor (Zuschneiden + Freistellen) ---------- */
.sig-editor { max-width: 980px; }
.sig-editor-hint { margin: 0 0 1rem; color: var(--muted); font-size: .9rem; }
.sig-editor-body { display: flex; gap: 1.3rem; align-items: flex-start; flex-wrap: wrap; }
.sig-editor-source { flex: 1 1 420px; min-width: 300px; }
.sig-editor-side { flex: 0 1 280px; min-width: 240px; display: flex; flex-direction: column; gap: .3rem; }
.sig-editor-side label { margin-bottom: .1rem; font-size: .88rem; }
.sig-editor-side select, .sig-editor-side input[type=range] { margin-bottom: .7rem; }
.sig-editor-side select {
    padding: .5rem .65rem; border: 1px solid var(--line); border-radius: var(--radius-sm);
    font: inherit; background: #fff; color: var(--ink);
}
.sig-editor-side input[type=range] { accent-color: var(--orange); width: 100%; }
.sig-check { display: flex; align-items: center; gap: .5rem; font-weight: 500; font-size: .88rem; color: var(--ink); margin-top: .3rem; }
.sig-check input { accent-color: var(--orange); }
.sig-page-nav { display: flex; align-items: center; gap: .6rem; margin-bottom: .5rem; }
.sig-page-nav span { font-size: .86rem; color: var(--muted); font-weight: 600; }
.sig-crop-stage {
    position: relative; display: inline-block; max-width: 100%;
    background: #2f3a47; border-radius: var(--radius-sm); padding: 0;
    box-shadow: inset 0 2px 12px rgba(0,0,0,.25);
    touch-action: none;
}
.sig-src-canvas { display: block; border-radius: var(--radius-sm); max-width: 100%; }
.sig-crop-overlay { position: absolute; inset: 0; cursor: crosshair; }
.sig-crop-rect { cursor: move; pointer-events: auto; }
.sig-preview {
    border: 1px solid var(--line); border-radius: var(--radius-sm);
    padding: .6rem; margin-bottom: .8rem; min-height: 70px;
    display: flex; align-items: center; justify-content: center;
    background-image:
        linear-gradient(45deg, #e3e8ef 25%, transparent 25%, transparent 75%, #e3e8ef 75%),
        linear-gradient(45deg, #e3e8ef 25%, transparent 25%, transparent 75%, #e3e8ef 75%);
    background-size: 16px 16px; background-position: 0 0, 8px 8px;
    background-color: #fff;
}
.sig-preview canvas { max-width: 100%; }

/* ---------- Empfänger-Typeahead ---------- */
.combo { position: relative; }
.combo-list {
    position: absolute; top: calc(100% - .8rem); left: 0; right: 0; z-index: 60;
    background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg); max-height: 260px; overflow: auto; display: none;
}
.combo-list.open { display: block; }
.combo-item { padding: .5rem .75rem; cursor: pointer; display: flex; flex-direction: column; gap: .05rem; border-bottom: 1px solid #f1f4f8; }
.combo-item:last-child { border-bottom: none; }
.combo-item.active, .combo-item:hover { background: #f4f8fc; }
.combo-item .ci-name { font-weight: 600; color: var(--navy); font-size: .92rem; }
.combo-item .ci-email { font-size: .82rem; color: var(--muted); }

/* ---------- Versand-Anzeige (Signierte PDFs) ---------- */
.send-entry { margin-bottom: .4rem; }
.send-entry:last-child { margin-bottom: 0; }
.send-date { display: inline-flex; align-items: center; gap: .3rem; font-size: .82rem; font-weight: 600; color: var(--ok); }
.send-rcpts { display: block; font-size: .8rem; color: var(--muted); max-width: 260px; word-break: break-word; }

/* ---------- Verifikations-Ergebnis ---------- */
.verify-result {
    display: flex; gap: 1.1rem; align-items: flex-start;
    background: var(--white); border: 1px solid var(--line); border-left-width: 5px;
    border-radius: var(--radius); box-shadow: var(--shadow-md);
    padding: 1.5rem 1.6rem; margin-bottom: 1.3rem;
}
.verify-result.ok   { border-left-color: var(--ok); }
.verify-result.warn { border-left-color: var(--orange); }
.verify-result.none { border-left-color: var(--muted); }
.verify-badge {
    flex: 0 0 auto; width: 44px; height: 44px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem; font-weight: 700; color: #fff;
    font-family: "Helvetica Now Display", sans-serif;
}
.verify-badge.ok   { background: var(--ok); }
.verify-badge.warn { background: var(--orange); }
.verify-badge.none { background: var(--muted); }
.verify-meta { display: grid; grid-template-columns: auto 1fr; gap: .3rem 1.2rem; margin: 0; }
.verify-meta dt { color: var(--muted); font-size: .88rem; }
.verify-meta dd { margin: 0; font-size: .92rem; }
.verify-meta code { background: #f4f6f9; padding: .05rem .35rem; border-radius: 5px; }

/* ---------- Footer ---------- */
.footer { margin-top: auto; padding: 1.3rem 1.6rem; background: #fff; border-top: 1px solid var(--line);
    display: flex; justify-content: space-between; flex-wrap: wrap; gap: .5rem; font-size: .82rem; color: var(--muted); }

@media (max-width: 680px) {
    .topbar { flex-wrap: wrap; gap: .6rem; padding: .6rem 1rem; }
    .nav { margin-left: 0; order: 3; width: 100%; overflow-x: auto; }
    .user { margin-left: auto; }
    .user-name { display: none; }
    .container { margin: 1.5rem auto; }
    .card { padding: 1.3rem; }
    .footer { flex-direction: column; }
    h1 { font-size: 1.5rem; }
}
