/* ============================================================
   DSGVO-Handbuch – Hauptstylesheet
   ============================================================ */

:root {
    --primary: #2c5282;
    --primary-dark: #1a365d;
    --primary-light: #ebf4ff;
    --text: #1a202c;
    --text-muted: #718096;
    --bg: #f7fafc;
    --white: #ffffff;
    --border: #e2e8f0;
    --danger: #c53030;
    --danger-light: #fff5f5;
    --success: #276749;
    --success-light: #f0fff4;
    --warning: #c05621;
    --warning-light: #fffaf0;
    --radius: 4px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
}

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

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 Helvetica, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
}

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

h1, h2, h3 {
    margin-top: 0;
    line-height: 1.3;
}

/* ---- App Layout ---- */
.app-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
    background: var(--primary-dark);
    color: var(--white);
    padding: 1.5rem 0;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 0 1.25rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.15);
}

.sidebar-header h2 {
    margin: 0;
    font-size: 1.1rem;
}

.company-name {
    font-size: 0.8rem;
    opacity: 0.7;
    margin: 0.25rem 0 0;
}

.nav-list {
    list-style: none;
    padding: 0;
    margin: 1rem 0;
    flex: 1;
}

.nav-link {
    display: block;
    padding: 0.6rem 1.25rem;
    color: rgba(255,255,255,0.85);
    transition: background 0.15s;
}
.nav-link:hover {
    background: rgba(255,255,255,0.1);
    text-decoration: none;
    color: var(--white);
}
.nav-link.active {
    background: rgba(255,255,255,0.15);
    color: var(--white);
    border-left: 3px solid var(--white);
    padding-left: calc(1.25rem - 3px);
}

.nav-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,0.15);
    font-size: 0.85rem;
}
.nav-user {
    margin: 0 0 0.5rem;
    opacity: 0.7;
}
.nav-footer .nav-link {
    padding: 0.3rem 0;
    color: rgba(255,255,255,0.6);
}

/* ---- Main Content ---- */
.main-content {
    padding: 2rem 2.5rem;
    max-width: 1200px;
}

.page-subtitle {
    color: var(--text-muted);
    margin-top: -0.5rem;
    margin-bottom: 1.5rem;
}

/* ---- Cards ---- */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
}

.card-header {
    padding: 0.75rem 1.25rem;
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    border-radius: var(--radius) var(--radius) 0 0;
}

.card-body {
    padding: 1.25rem;
    flex: 1;
}

.card-number {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
    margin-bottom: 0.25rem;
}

.card-label {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
}

.card-details {
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 0.85rem;
}
.card-details li {
    padding: 0.15rem 0;
}

.card-footer {
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 0.5rem;
}

/* ---- Info Box ---- */
.info-box {
    background: var(--primary-light);
    border: 1px solid var(--primary);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-top: 2rem;
}
.info-box h3 {
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}
.info-box p {
    margin: 0;
    font-size: 0.9rem;
}

/* ---- Tables ---- */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.data-table th,
.data-table td {
    padding: 0.65rem 1rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}

.data-table th {
    background: var(--bg);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: var(--text-muted);
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tr:hover td {
    background: var(--primary-light);
}

.table-actions {
    white-space: nowrap;
}
.table-actions a {
    margin-right: 0.5rem;
}

/* ---- Forms ---- */
.form-container {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    max-width: 800px;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.3rem;
    font-weight: 600;
    font-size: 0.9rem;
}

.form-hint {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="date"],
.form-group input[type="number"],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-family: inherit;
    color: var(--text);
    background: var(--white);
}

.form-group textarea {
    min-height: 80px;
    resize: vertical;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.form-check input[type="checkbox"] {
    width: auto;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

/* ---- Buttons ---- */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--white);
    color: var(--text);
    font-size: 0.9rem;
    font-family: inherit;
    cursor: pointer;
    text-align: center;
    transition: background 0.15s;
}
.btn:hover {
    background: var(--bg);
    text-decoration: none;
}

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

.btn-danger {
    background: var(--danger);
    color: var(--white);
    border-color: var(--danger);
}
.btn-danger:hover {
    background: #9b2c2c;
}

.btn-small {
    padding: 0.3rem 0.65rem;
    font-size: 0.8rem;
}

.btn-full {
    width: 100%;
}

/* ---- Badges ---- */
.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge-aktiv, .badge-umgesetzt {
    background: var(--success-light);
    color: var(--success);
}
.badge-inaktiv, .badge-gekuendigt {
    background: var(--danger-light);
    color: var(--danger);
}
.badge-entwurf, .badge-geplant {
    background: var(--warning-light);
    color: var(--warning);
}
.badge-teilweise {
    background: #fefcbf;
    color: #975a16;
}

/* ---- Flash Messages ---- */
.flash {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}
.flash-success {
    background: var(--success-light);
    color: var(--success);
    border: 1px solid #c6f6d5;
}
.flash-error {
    background: var(--danger-light);
    color: var(--danger);
    border: 1px solid #fed7d7;
}
.flash-warning {
    background: var(--warning-light);
    color: var(--warning);
    border: 1px solid #feebc8;
}

/* ---- Detail View ---- */
.detail-view {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.detail-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.detail-header h2 {
    margin: 0;
}

.detail-row {
    display: grid;
    grid-template-columns: 200px 1fr;
    border-bottom: 1px solid var(--border);
}
.detail-row:last-child {
    border-bottom: none;
}

.detail-label {
    padding: 0.65rem 1.25rem;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-muted);
    background: var(--bg);
}

.detail-value {
    padding: 0.65rem 1.25rem;
    white-space: pre-line;
}

/* ---- Auth Pages ---- */
.auth-page {
    background: var(--primary-dark);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-container {
    width: 100%;
    max-width: 400px;
    padding: 1rem;
}

.auth-box {
    background: var(--white);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.auth-box h1 {
    text-align: center;
    color: var(--primary-dark);
    margin-bottom: 0.25rem;
}

.auth-subtitle {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.auth-footer {
    text-align: center;
    color: rgba(255,255,255,0.5);
    font-size: 0.8rem;
    margin-top: 1.5rem;
}

.auth-hint {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 1rem;
}

.otp-input {
    text-align: center;
    font-size: 1.5rem;
    letter-spacing: 0.5em;
    font-weight: 700;
}

/* ---- Page Header ---- */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}
.page-header h1 {
    margin: 0;
}

/* ---- Section Header (TOM grouped) ---- */
.section-header {
    background: var(--primary-light);
    padding: 0.5rem 1rem;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--primary-dark);
    border: 1px solid var(--border);
    border-bottom: none;
    margin-top: 1.5rem;
}
.section-header:first-of-type {
    margin-top: 0;
    border-radius: var(--radius) var(--radius) 0 0;
}

/* ---- Print Header (hidden on screen) ---- */
.print-header,
.print-footer {
    display: none;
}

/* ---- Schweregrad Badges (Datenpannen) ---- */
.badge-schwere-gering {
    background: var(--success-light);
    color: var(--success);
}
.badge-schwere-mittel {
    background: #fefcbf;
    color: #975a16;
}
.badge-schwere-hoch {
    background: var(--warning-light);
    color: var(--warning);
}
.badge-schwere-kritisch {
    background: var(--danger-light);
    color: var(--danger);
    font-weight: 700;
}

/* ---- Status Badges (neue Module) ---- */
.badge-offen {
    background: var(--danger-light);
    color: var(--danger);
}
.badge-in_bearbeitung, .badge-eingegangen {
    background: var(--warning-light);
    color: var(--warning);
}
.badge-gemeldet, .badge-beantwortet {
    background: #ebf4ff;
    color: var(--primary);
}
.badge-abgeschlossen {
    background: var(--success-light);
    color: var(--success);
}
.badge-abgelehnt {
    background: #e2e8f0;
    color: #4a5568;
}
.badge-eingeladen {
    background: var(--warning-light);
    color: var(--warning);
}
.badge-bestaetigt {
    background: var(--success-light);
    color: var(--success);
}

/* ---- Frist-Warnungen (Betroffenenrechte) ---- */
.badge-frist-abgelaufen {
    background: var(--danger);
    color: var(--white);
    font-size: 0.7rem;
    padding: 0.1rem 0.4rem;
}
.badge-frist-warnung {
    background: var(--warning);
    color: var(--white);
    font-size: 0.7rem;
    padding: 0.1rem 0.4rem;
}

/* ---- Tabellenzeilen-Hervorhebung ---- */
.row-danger td {
    background: var(--danger-light) !important;
}
.row-warning td {
    background: var(--warning-light) !important;
}

/* ---- Zeitstrahl (Datenpannen-Detailansicht) ---- */
.timeline {
    display: flex;
    justify-content: space-between;
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    position: relative;
}
.timeline::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 2.5rem;
    right: 2.5rem;
    height: 2px;
    background: var(--border);
    transform: translateY(-50%);
    z-index: 0;
}
.timeline-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    position: relative;
    z-index: 1;
    flex: 1;
}
.timeline-marker {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--border);
    border: 3px solid var(--white);
    box-shadow: 0 0 0 2px var(--border);
    margin-bottom: 0.5rem;
}
.timeline-done .timeline-marker {
    background: var(--success);
    box-shadow: 0 0 0 2px var(--success);
}
.timeline-skip .timeline-marker {
    background: var(--text-muted);
    box-shadow: 0 0 0 2px var(--text-muted);
}
.timeline-content {
    font-size: 0.8rem;
    max-width: 150px;
}
.timeline-content strong {
    display: block;
    font-size: 0.85rem;
    margin-bottom: 0.15rem;
}

/* ---- Form Section Headers ---- */
.form-container h3 {
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
    font-size: 1rem;
    color: var(--primary-dark);
}
.form-container h3:first-of-type {
    margin-top: 0;
}

/* ---- datetime-local input ---- */
.form-group input[type="datetime-local"] {
    width: 100%;
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-family: inherit;
    color: var(--text);
    background: var(--white);
}
.form-group input[type="datetime-local"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
}

/* ---- Richtlinien-Dokument ---- */
.richtlinie-dokument {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    max-width: 900px;
}

.richtlinie-section {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border);
}
.richtlinie-section:last-child {
    border-bottom: none;
}

.richtlinie-section h2 {
    color: var(--primary-dark);
    font-size: 1.15rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.4rem;
    border-bottom: 2px solid var(--primary-light);
}

.richtlinie-section h3 {
    font-size: 0.95rem;
    color: var(--text);
    margin-top: 1rem;
    margin-bottom: 0.5rem;
}

.richtlinie-section p {
    margin-bottom: 0.75rem;
    line-height: 1.7;
}

.richtlinie-section ul {
    margin: 0.5rem 0 1rem 1.5rem;
    line-height: 1.7;
}
.richtlinie-section ul li {
    margin-bottom: 0.3rem;
}

.richtlinie-unterschrift {
    margin-top: 2rem;
}

.richtlinie-bestaetigung {
    background: var(--bg);
}

/* ---- Gesamtberichte ---- */
.report-entry-title {
    color: var(--primary-dark);
    border-bottom: 2px solid var(--primary);
    padding-bottom: 0.4rem;
    margin-top: 2rem;
    margin-bottom: 1rem;
}

.report-summary {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.report-footer {
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 2px solid var(--border);
    font-size: 0.85rem;
    color: var(--text-muted);
}

.report-footer p {
    margin: 0.2rem 0;
}

.page-break {
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px dashed var(--border);
}

.page-break-soft {
    margin-top: 1.5rem;
    padding-top: 0.5rem;
}

/* ---- Gesamtbericht-Button ---- */
.btn-print-report {
    background: var(--primary);
    color: var(--white) !important;
    border: none;
}
.btn-print-report:hover {
    background: var(--primary-dark);
    text-decoration: none;
}

/* ---- Utilities ---- */
.text-muted { color: var(--text-muted); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.mt-1 { margin-top: 1rem; }
.mb-1 { margin-bottom: 1rem; }
.mb-2 { margin-bottom: 2rem; }

/* ---- Oeffentliche Seite (Kunden-AVV) ---- */
.public-page {
    background: var(--bg);
    min-height: 100vh;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 2rem 1rem;
}

.public-container {
    width: 100%;
    max-width: 900px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    padding: 2.5rem;
}

.public-header {
    text-align: center;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 2px solid var(--primary);
}

.public-header h1 {
    color: var(--primary-dark);
    margin-bottom: 0.25rem;
}

.public-header p {
    color: var(--text-muted);
    margin: 0;
    font-size: 0.9rem;
}

.public-footer {
    text-align: center;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
    font-size: 0.8rem;
    color: var(--text-muted);
}

.public-footer a {
    color: var(--primary);
}

/* ---- AVV-Vertrag (Druck/Anzeige) ---- */
.avv-vertrag {
    max-width: 900px;
}

.avv-title {
    text-align: center;
    color: var(--primary-dark);
    margin-bottom: 0.5rem;
}

.avv-subtitle {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 2rem;
}

.avv-parteien {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
    padding: 1.25rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.avv-partei h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    border: none;
    padding: 0;
}

.avv-feld {
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

.avv-feld strong {
    font-weight: 600;
}

.avv-section {
    margin-bottom: 1.5rem;
}

.avv-section h2 {
    color: var(--primary-dark);
    font-size: 1.05rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid var(--primary-light);
}

.avv-section p {
    margin-bottom: 0.75rem;
    line-height: 1.7;
}

.avv-section ul, .avv-section ol {
    margin: 0.5rem 0 1rem 1.5rem;
    line-height: 1.7;
}
.avv-section ul li, .avv-section ol li {
    margin-bottom: 0.3rem;
}

.avv-hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 2rem 0;
}

.avv-unterschriften {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
    margin-top: 3rem;
    padding-top: 1rem;
}

.avv-linie {
    border-top: 1px solid var(--text);
    padding-top: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 4rem;
}

.avv-bestaetigung {
    margin-top: 2rem;
    padding: 1.5rem;
    background: var(--success-light);
    border: 1px solid #c6f6d5;
    border-radius: var(--radius);
}

.avv-bestaetigung h3 {
    color: var(--success);
    margin-bottom: 0.5rem;
}

.avv-volltext {
    margin-top: 1rem;
    margin-bottom: 2rem;
}

/* ---- Checkbox Label (OTP / AVV) ---- */
.checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    font-weight: normal;
    cursor: pointer;
    line-height: 1.5;
}

.checkbox-label input[type="checkbox"] {
    margin-top: 0.25rem;
    width: auto;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .app-layout {
        grid-template-columns: 1fr;
    }
    .sidebar {
        position: fixed;
        top: 0;
        left: -260px;
        width: 260px;
        height: 100vh;
        z-index: 100;
        transition: left 0.2s;
    }
    .main-content {
        padding: 1.5rem;
    }
    .form-row {
        grid-template-columns: 1fr;
    }
    .detail-row {
        grid-template-columns: 1fr;
    }
    .detail-label {
        border-bottom: none;
    }
    .avv-parteien {
        grid-template-columns: 1fr;
    }
    .avv-unterschriften {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
    .public-container {
        padding: 1.5rem;
    }
}
