/* style.css - Einheitliches Design für das Ausleihsystem */
/* Standard-Hauptfarbe; die Mandantenfarbe kommt per <style>:root aus pwa_head.php und überschreibt dies (:where = Spezifität 0). */
:where(:root) { --farbe-haupt: rgb(0,95,140); --farbe-haupt-rgb: 0,95,140; }
/* Hauptfarbe: var(--farbe-haupt) | Akzentfarbe: rgb(195,0,60) */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: #f2f4f8;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 20px;
}

.container, .login-container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    padding: 25px 30px;
    border-radius: 48px;
    box-shadow: 0 20px 40px rgba(0, 20, 40, 0.12);
    border: 1px solid rgba(0,0,0,0.02);
}

.login-container {
    max-width: 400px;
    text-align: center;
}

/* Überschriften */
h1, h2, h3 {
    color: var(--farbe-haupt);
    font-weight: 600;
}

h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

h2 {
    margin: 1.5rem 0 1rem;
    font-size: 1.8rem;
}

h3 {
    margin-top: 2rem;
    margin-bottom: 1rem;
    font-size: 1.4rem;
}

/* Header mit Statistik und Logout */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 10px;
}

.stats {
    font-weight: bold;
    color: #1f2a44;
    font-size: 1.1rem;
    background-color: #e9ecf2;
    padding: 8px 20px;
    border-radius: 60px;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.05);
}

.logout {
    background: rgb(195, 0, 60);
    color: white;
    padding: 8px 24px;
    border-radius: 60px;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.2s, transform 0.1s;
    display: inline-block;
    box-shadow: 0 8px 16px rgba(195, 0, 60, 0.25);
}

.logout:hover {
    background: rgb(150, 0, 45);
}

.logout:active {
    transform: scale(0.97);
}

/* Formulare */
label {
    display: block;
    margin-top: 20px;
    font-weight: 600;
    color: #1f2a44;
}

input[type="text"],
input[type="number"],
input[type="tel"],
input[type="email"],
input[type="password"],
textarea,
select {
    width: 100%;
    padding: 16px 20px;
    margin-top: 8px;
    border: 2px solid #b0c0da;
    border-radius: 60px;
    font-size: 1rem;
    outline: none;
    background: white;
    transition: border-color 0.2s;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--farbe-haupt);
}

textarea {
    border-radius: 30px;
    min-height: 100px;
}

/* Buttons allgemein */
button, .button {
    background: var(--farbe-haupt);
    color: white;
    border: none;
    padding: 16px 32px;
    margin-top: 30px;
    border-radius: 60px;
    font-size: 1.2rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 10px 20px rgba(var(--farbe-haupt-rgb), 0.25);
    transition: background 0.2s, transform 0.1s;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

button:hover, .button:hover {
    background: rgb(0, 70, 115);
}

button:active, .button:active {
    transform: scale(0.97);
}

.button.small {
    padding: 8px 20px;
    font-size: 1rem;
    margin-top: 0;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

/* Spezielle Buttons in der Tabelle (z.B. Zurücknehmen) */
td button {
    background: var(--farbe-haupt);
    padding: 8px 16px;
    font-size: 0.95rem;
    margin-top: 0;
    box-shadow: 0 4px 8px rgba(var(--farbe-haupt-rgb), 0.2);
}

td button:hover {
    background: rgb(0, 70, 115);
}

/* Tabellen */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 25px 0 10px;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 30px;
    overflow: hidden;
    box-shadow: 0 8px 20px rgba(0, 20, 40, 0.06);
}

th {
    background: var(--farbe-haupt);
    color: white;
    font-weight: 600;
    padding: 14px 10px;
    text-align: left;
    font-size: 0.95rem;
}

td {
    padding: 12px 10px;
    border-bottom: 1px solid #e2e8f0;
    vertical-align: middle;
}

tr:last-child td {
    border-bottom: none;
}

tr:nth-child(even) {
    background: #f9fafc;
}

/* Meldungen (Success / Error) */
.success, .erfolg {
    background: #d4edda;
    border-left: 6px solid #155724;
    color: #155724;
    padding: 16px 20px;
    border-radius: 30px;
    margin: 20px 0;
    font-weight: 500;
}

.error, .fehler {
    background: #fee2e2;
    border-left: 6px solid #b91c1c;
    color: #b91c1c;
    padding: 16px 20px;
    border-radius: 30px;
    margin: 20px 0;
    font-weight: 500;
}

.error ul, .fehler ul {
    margin-left: 20px;
}

/* Links */
a {
    color: var(--farbe-haupt);
    text-decoration: none;
    font-weight: 500;
}

a:hover {
    text-decoration: underline;
}

/* Admin-Link (optional) */
.admin-link {
    background: rgb(195, 0, 60);
    color: white;
    padding: 8px 16px;
    border-radius: 60px;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.2s, transform 0.1s;
    display: inline-block;
    box-shadow: 0 8px 16px rgba(195, 0, 60, 0.25);
}
.admin-link:hover {
    background: rgb(150, 0, 45);
}
.admin-link:active {
    transform: scale(0.97);
}

/* Abstand unten für Container */
.container p {
    margin: 1rem 0;
}

/* Responsive Anpassungen */
@media (max-width: 600px) {
    body {
        padding: 10px;
    }
    .container, .login-container {
        padding: 20px 15px;
        border-radius: 30px;
    }
    h1 {
        font-size: 1.8rem;
    }
    button, .button {
        width: 100%;
    }
    .header {
        flex-direction: column;
        align-items: stretch;
    }
    .stats, .logout {
        text-align: center;
    }
}

@media (max-width: 768px) {
    table {
        min-width: 600px;  /* horizontales Scrollen auf kleinen Geräten */
    }
}

/* Spezielle Felder (aus dem ursprünglichen CSS übernommen) */
input[name^="reihenfolge"] {
    width: 100px !important;
    text-align: center;
    font-size: 1.4rem;
    padding: 10px 5px;
    border: 2px solid var(--farbe-haupt);
    border-radius: 60px;
    background: white;
    color: #000000;
    font-weight: bold;
    box-sizing: border-box;
}

.empty-field {
    color: #8a9bb8;
    font-style: italic;
}
/* Antwortoptionen vertikal anordnen */
.question-block .options label {
    display: block;
    margin-bottom: 8px;
    cursor: pointer;
}
/* Antwortoptionen vertikal */
.options label {
    display: block;
    margin-bottom: 10px;
}
/* Logo-Header */
.logo-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.logo-header img {
    max-height: 80px;
    width: auto;
}
/* ===== PWA / Mobile-Optimierung ===== */
html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}
body {
    -webkit-tap-highlight-color: rgba(var(--farbe-haupt-rgb), 0.15);
    /* Notch / Home-Indikator im Vollbild-Modus (installierte App) berücksichtigen */
    padding-left: max(20px, env(safe-area-inset-left));
    padding-right: max(20px, env(safe-area-inset-right));
    padding-top: max(20px, env(safe-area-inset-top));
    padding-bottom: max(20px, env(safe-area-inset-bottom));
}
img, video { max-width: 100%; height: auto; }
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }

@media (max-width: 600px) {
    body {
        padding-left: max(10px, env(safe-area-inset-left));
        padding-right: max(10px, env(safe-area-inset-right));
    }
    /* 16px verhindert das automatische Hineinzoomen von iOS in Eingabefelder */
    input[type="text"], input[type="number"], input[type="tel"], input[type="email"],
    input[type="password"], input[type="date"], input[type="time"], input[type="search"],
    select, textarea {
        font-size: 16px;
    }
}

/* Touch-Geräte: ausreichend große Bedienelemente */
@media (pointer: coarse) {
    button, .button, select, input[type="text"], input[type="password"],
    input[type="email"], input[type="number"], input[type="tel"] {
        min-height: 44px;
    }
}

/* Installierte App (Standalone): kein Pull-to-Refresh-Überscrollen auf der ganzen Seite */
@media (display-mode: standalone) {
    body { overscroll-behavior-y: contain; }
}

/* ===== Mobile-Layout für Unterseiten (Handy / installierte App) ===== */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }

@media (max-width: 640px) {
    body { padding-top: max(8px, env(safe-area-inset-top)); padding-bottom: max(12px, env(safe-area-inset-bottom));
           padding-left: max(8px, env(safe-area-inset-left)); padding-right: max(8px, env(safe-area-inset-right)); }
    .container, .login-container {
        padding: 18px 14px;
        border-radius: 24px;
        box-shadow: 0 6px 18px rgba(0, 20, 40, 0.10);
        width: 100%;
    }
    h1 { font-size: 1.45rem; line-height: 1.25; }
    h2 { font-size: 1.2rem; margin: 1.2rem 0 0.8rem; }
    h3 { font-size: 1.05rem; margin: 1.4rem 0 0.7rem; }

    .logo-header { justify-content: center; margin-bottom: 12px; }
    .logo-header img { max-height: 52px; }

    /* Kopfbereich: Statistik oben, Buttons nebeneinander in voller Breite */
    .header { gap: 10px; margin-bottom: 16px; }
    .header > div { display: flex !important; gap: 8px !important; width: 100%; flex-wrap: wrap; }
    .header .button, .header .logout, .header button { flex: 1 1 auto; width: auto; text-align: center; margin-top: 0; }
    .stats { font-size: 0.95rem; padding: 8px 16px; text-align: center; }
    .logout { padding: 8px 18px; }

    /* Formulare */
    input[type="text"], input[type="number"], input[type="tel"], input[type="email"], input[type="password"],
    input[type="date"], input[type="time"], input[type="search"], textarea, select {
        padding: 13px 16px;
    }
    label { margin-top: 14px; }
    button, .button { font-size: 1.05rem; padding: 14px 24px; margin-top: 20px; }
    .success, .error, .erfolg, .fehler { padding: 12px 16px; border-radius: 20px; }

    /* Tabellen als Karten */
    table.m-cards { display: block; min-width: 0 !important; background: transparent; box-shadow: none; border-radius: 0; }
    table.m-cards thead { display: none; }
    table.m-cards tbody { display: block; }
    table.m-cards tr {
        display: block; background: #fff !important; border: 1px solid #e2e8f0; border-radius: 18px;
        padding: 6px 14px; margin-bottom: 12px; box-shadow: 0 3px 10px rgba(0, 20, 40, 0.06);
    }
    table.m-cards td {
        display: flex; justify-content: space-between; align-items: center; gap: 14px;
        padding: 9px 0; border-bottom: 1px solid #eef1f6; text-align: right; word-break: break-word;
    }
    table.m-cards td:last-child { border-bottom: none; }
    table.m-cards td::before {
        content: attr(data-label); flex: 0 0 38%; max-width: 38%; text-align: left;
        font-weight: 600; font-size: 0.85rem; color: var(--farbe-haupt);
    }
    table.m-cards td[data-label=""]::before { display: none; }
    table.m-cards td form { flex: 1; margin: 0; }
    table.m-cards td button, table.m-cards td .button, table.m-cards td .btn-small { width: 100%; margin-top: 0; }
}
