/* ============================================================
   style.css – shared styles + light/dark theming
   Light = original palette. Dark = grey palette (Claude-like).
   ============================================================ */

/* ---- Design tokens: light (defaults) ---- */
:root {
    --bg: #f0f2f5;
    --surface: #ffffff;
    --surface-2: #f0f2f5;
    --border: #e2e4e8;
    --input-bg: #ffffff;
    --input-border: #cccccc;
    --text: #1a1a2e;
    --text-muted: #888888;
    --accent: #4e78a7;
    --accent-hover: #42668e;
    --on-accent: #ffffff;
    --shadow: 0 2px 12px rgba(0, 0, 0, .1);
    --shadow-sm: 0 1px 6px rgba(0, 0, 0, .06);
    --error-bg: #fde8e8;   --error-fg: #c0392b;   --error-bd: #f5c6c6;
    --success-bg: #eaffea; --success-fg: #2c662d; --success-bd: #c3e6c3;
    --warn-bg: #fff3cd;    --warn-fg: #856404;    --warn-bd: #ffe69c;
    --badge-active-bg: #eaffea;   --badge-active-fg: #2c662d;
    --badge-inactive-bg: #fde8e8; --badge-inactive-fg: #c0392b;
    --btn-muted: #888888;
}

/* ---- Design tokens: dark (explicit choice) ---- */
:root[data-theme="dark"] {
    --bg: #1f1f1e;
    --surface: #262626;
    --surface-2: #313130;
    --border: #4e4e4c;
    --input-bg: #313130;
    --input-border: #4e4e4c;
    --text: #e2e1da;
    --text-muted: #a0a09a;
    /* accent NOT overridden in dark – chosen accent applies in both modes */
    --on-accent: #ffffff;
    --shadow: 0 2px 12px rgba(0, 0, 0, .45);
    --shadow-sm: 0 1px 6px rgba(0, 0, 0, .35);
    --error-bg: #3a2526;   --error-fg: #f3a7a7;   --error-bd: #5c3a3a;
    --success-bg: #21331f; --success-fg: #a6e0a6; --success-bd: #3a5c3a;
    --warn-bg: #3a3320;    --warn-fg: #e8d28a;    --warn-bd: #5c5333;
    --badge-active-bg: #21331f;   --badge-active-fg: #a6e0a6;
    --badge-inactive-bg: #3a2526; --badge-inactive-fg: #f3a7a7;
    --btn-muted: #5a5a57;
}

/* ---- Design tokens: dark (system default, no explicit choice) ---- */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        --bg: #1f1f1e;
        --surface: #262626;
        --surface-2: #313130;
        --border: #4e4e4c;
        --input-bg: #313130;
        --input-border: #4e4e4c;
        --text: #e2e1da;
        --text-muted: #a0a09a;
        /* accent NOT overridden in dark – chosen accent applies in both modes */
        --on-accent: #ffffff;
        --shadow: 0 2px 12px rgba(0, 0, 0, .45);
        --shadow-sm: 0 1px 6px rgba(0, 0, 0, .35);
        --error-bg: #3a2526;   --error-fg: #f3a7a7;   --error-bd: #5c3a3a;
        --success-bg: #21331f; --success-fg: #a6e0a6; --success-bd: #3a5c3a;
        --warn-bg: #3a3320;    --warn-fg: #e8d28a;    --warn-bd: #5c5333;
        --badge-active-bg: #21331f;   --badge-active-fg: #a6e0a6;
        --badge-inactive-bg: #3a2526; --badge-inactive-fg: #f3a7a7;
        --btn-muted: #5a5a57;
    }
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
}

h1 { font-size: 1.4rem; color: var(--text); }
h2 { font-size: 1.1rem; }

/* ---- Switchers (language + theme) ---- */
.prefs { display: flex; align-items: center; gap: .5rem; }

.lang-switcher { display: flex; gap: .3rem; font-size: .8rem; }
.lang-switcher a, .lang-switcher span {
    text-decoration: none; color: var(--text-muted);
    padding: .15rem .4rem; border-radius: 4px;
}
.lang-switcher a:hover { background: var(--surface-2); color: var(--accent); }
.lang-switcher .lang-current { background: var(--accent); color: var(--on-accent); font-weight: 600; }

.theme-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    width: 1.9rem; height: 1.9rem; border-radius: 4px;
    color: var(--text-muted); text-decoration: none; cursor: pointer;
    border: 1px solid transparent; font-size: .95rem; line-height: 1;
}
.theme-toggle:hover { background: var(--surface-2); color: var(--accent); }
.icon-to-light { display: none; }
.icon-to-dark { display: inline; }
:root[data-theme="dark"] .icon-to-light { display: inline; }
:root[data-theme="dark"] .icon-to-dark { display: none; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) .icon-to-light { display: inline; }
    :root:not([data-theme]) .icon-to-dark { display: none; }
}

/* ---- Cards / forms / buttons / notices ---- */
.card {
    background: var(--surface);
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    padding: 1.75rem;
}

label { display: block; font-size: .85rem; font-weight: 600; color: var(--text); margin-bottom: .3rem; }

input[type="text"], input[type="password"], select {
    width: 100%; padding: .55rem .7rem;
    border: 1px solid var(--input-border); border-radius: 5px;
    background: var(--input-bg); color: var(--text);
    font-size: 1rem; margin-bottom: 1rem;
}
input:focus, select:focus { outline: none; border-color: var(--accent); }

button, .btn {
    padding: .6rem 1.2rem; background: var(--accent); color: var(--on-accent);
    border: none; border-radius: 5px; font-size: .95rem; font-weight: 600; cursor: pointer;
}
button:hover, .btn:hover { background: var(--accent-hover); }
button.small { padding: .3rem .7rem; font-size: .8rem; }
button.danger { background: #c0392b; }

.notice { border-radius: 5px; padding: .65rem .85rem; font-size: .875rem; margin-bottom: 1.1rem; }
.notice.error   { background: var(--error-bg);   color: var(--error-fg);   border: 1px solid var(--error-bd); }
.notice.success { background: var(--success-bg); color: var(--success-fg); border: 1px solid var(--success-bd); }
.notice.timeout { background: var(--warn-bg);    color: var(--warn-fg);    border: 1px solid var(--warn-bd); }

/* ---- Login page ---- */
.page-login { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 1rem; }
.page-login .card { box-shadow: var(--shadow); padding: 2.5rem 2rem; width: 100%; max-width: 380px; }
.page-login h1 { margin-bottom: 1.75rem; }
.page-login .header-actions { display: flex; justify-content: flex-end; margin-bottom: 1rem; }
.page-login input { margin-bottom: 1.1rem; }
.page-login button[type="submit"] { width: 100%; padding: .7rem; font-size: 1rem; }

/* ---- Admin page ---- */
.page-admin { padding: 2rem 1rem; }
.page-admin .wrap { max-width: 980px; margin: 0 auto; }
.page-admin td { vertical-align: top; }
.page-admin th, .page-admin td { padding: .65rem .6rem; }
.row-actions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.manage-link {
    display: inline-block; background: var(--accent); color: var(--on-accent);
    text-decoration: none; padding: .3rem .7rem; border-radius: 5px;
    font-size: .8rem; font-weight: 600;
}
.manage-link:hover { background: var(--accent-hover); }
.page-admin .card { margin-bottom: 1.5rem; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; gap: 1rem; flex-wrap: wrap; }
.header-right { display: flex; align-items: center; gap: 1rem; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .5rem; border-bottom: 1px solid var(--border); }
.badge { display: inline-block; padding: .15rem .5rem; border-radius: 4px; font-size: .75rem; }
.badge.active { background: var(--badge-active-bg); color: var(--badge-active-fg); }
.badge.inactive { background: var(--badge-inactive-bg); color: var(--badge-inactive-fg); }
.inline-settings, .inline-logo { display: flex; align-items: center; gap: .4rem; margin: 0; flex-wrap: wrap; }
.inline-settings select, .inline-settings input[type="text"] { width: auto; margin: 0; padding: .25rem .4rem; font-size: .8rem; }
.inline-settings input[type="text"] { width: 5.5rem; }
.inline-settings input[type="color"], .color-field input[type="color"] {
    padding: 0; margin: 0; border: 1px solid var(--input-border); border-radius: 4px;
    background: none; cursor: pointer;
}
.inline-settings input[type="color"] { width: 1.8rem; height: 1.8rem; }
.inline-logo { flex-direction: column; align-items: flex-start; }
.inline-logo input[type="file"] { font-size: .75rem; max-width: 170px; margin-bottom: 0; }

/* Color picker + hex field pair (create form) */
.color-field { display: flex; align-items: center; gap: .5rem; margin-bottom: 1rem; }
.color-field input[type="color"] { width: 2.4rem; height: 2.4rem; }
.color-field input[type="text"] { width: auto; flex: 1; margin: 0; }

/* File inputs + upload hint + logo thumbnail */
input[type="file"] { margin-bottom: .5rem; max-width: 100%; }
.inline-logo input[type="file"] { margin-bottom: 0; }
.hint { display: block; font-size: .8rem; color: var(--text-muted); margin: 0 0 1rem; }
.logo-thumb {
    display: block; height: 32px; width: auto; margin-bottom: .4rem;
    background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: 2px;
}
.no-logo { display: block; color: var(--text-muted); font-size: .8rem; margin-bottom: .4rem; }

/* ---- Customer page ---- */
.page-customer { min-height: 100vh; display: flex; flex-direction: column; }
.page-customer header {
    background: var(--surface); border-bottom: 1px solid var(--border);
    padding: 1rem 1.5rem; display: flex; align-items: center; justify-content: space-between;
    gap: 1rem; flex-wrap: wrap;
}
.header-left { display: flex; align-items: center; gap: .85rem; }
.header-left img { height: 40px; width: auto; }
.header-left h1 { font-size: 1.15rem; font-weight: 600; }
.logout-btn {
    background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
    border-radius: 5px; padding: .5rem 1rem; font-size: .85rem; font-weight: 600;
    cursor: pointer; text-decoration: none;
}
.logout-btn:hover { background: var(--border); }
.page-customer main { flex: 1; max-width: 900px; width: 100%; margin: 0 auto; padding: 2.5rem 1.5rem; }
.section { background: var(--surface); border-radius: 8px; box-shadow: var(--shadow-sm); padding: 1.75rem; margin-bottom: 1.5rem; }
.section h2 { margin-bottom: 1.1rem; }
.document-list { list-style: none; }
.document-list li {
    display: flex; justify-content: space-between; align-items: center;
    padding: .7rem 0; border-bottom: 1px solid var(--border); gap: .75rem;
}
.document-list li:last-child { border-bottom: none; }
.document-name { display: flex; align-items: center; gap: .6rem; font-size: .92rem; }
.document-size { color: var(--text-muted); font-size: .8rem; }
.download-btn {
    background: var(--accent); color: var(--on-accent); text-decoration: none;
    padding: .4rem .9rem; border-radius: 5px; font-size: .82rem; font-weight: 600; white-space: nowrap;
}
.download-btn:hover { background: var(--accent-hover); }
.empty-notice { color: var(--text-muted); font-size: .9rem; padding: .5rem 0; }
.additional-link {
    display: inline-flex; align-items: center; gap: .4rem;
    color: var(--accent); text-decoration: none; font-weight: 600; font-size: .95rem;
}
.additional-link:hover { text-decoration: underline; }
.page-customer footer {
    background: var(--surface); border-top: 1px solid var(--border);
    padding: 1.25rem 1.5rem; text-align: center; font-size: .8rem; color: var(--text-muted);
}
.page-customer footer a { color: var(--text-muted); text-decoration: underline; }

/* ---- Customer hub (home.php) ---- */
.page-heading { font-size: 1.3rem; margin-bottom: 1.25rem; }
.hub { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1.25rem; }
.hub-tile {
    display: flex; flex-direction: column; gap: .4rem;
    background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
    box-shadow: var(--shadow-sm); padding: 1.5rem;
    text-decoration: none; color: var(--text);
    transition: transform .1s ease, box-shadow .1s ease, border-color .1s ease;
}
.hub-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--accent); }
.hub-tile-label { font-size: 1.1rem; font-weight: 600; color: var(--accent); }
.hub-tile-desc { font-size: .88rem; color: var(--text-muted); }
.back-link { display: inline-block; margin-bottom: 1.25rem; color: var(--accent); text-decoration: none; font-size: .9rem; }
.back-link:hover { text-decoration: underline; }

/* ---- Impressum ---- */
.page-impressum { max-width: 700px; margin: 3rem auto; padding: 1.5rem; line-height: 1.6; }
.page-impressum h1 { margin-bottom: 1.5rem; }
.page-impressum h2 { font-size: 1rem; margin: 1.5rem 0 .5rem; }
.page-impressum a { color: var(--accent); }
.page-impressum .header-actions { display: flex; justify-content: flex-end; margin-bottom: 1rem; }
.page-impressum .back { display: inline-block; margin-top: 2rem; font-size: .9rem; }

/* ---- Responsive ---- */
@media (max-width: 640px) {
    .page-admin { padding: 1rem .75rem; }
    .card, .section { padding: 1.25rem; }
    .page-customer header { padding: .85rem 1rem; }
    .header-left h1 { font-size: 1rem; }
    .page-customer main { padding: 1.5rem 1rem; }
    .document-list li { flex-direction: column; align-items: flex-start; }
    table { min-width: 520px; }
    .topbar { flex-direction: column; align-items: stretch; }
}
