/* =====================================================
   Otten Laufzettel – Stylesheet
   Schlank, funktional, professionell
   ===================================================== */

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #f59e0b;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-500: #6b7280;
    --gray-700: #374151;
    --gray-900: #111827;
    --radius: 6px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--gray-900);
    background: var(--gray-50);
}

/* =====================================================
   LOGIN
   ===================================================== */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--gray-100);
}

.login-container {
    background: white;
    padding: 2.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    width: 100%;
    max-width: 380px;
}

.login-container h1 {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

.login-subtitle {
    color: var(--gray-500);
    margin-bottom: 1.5rem;
}

/* =====================================================
   HEADER
   ===================================================== */
.app-header {
    background: white;
    border-bottom: 1px solid var(--gray-200);
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.app-logo {
    font-weight: 700;
    font-size: 1.1rem;
    text-decoration: none;
    color: var(--gray-900);
}

.header-nav {
    display: flex;
    gap: 1rem;
}

.header-nav a {
    color: var(--gray-700);
    text-decoration: none;
    font-size: 0.9rem;
}

.header-nav a:hover { color: var(--primary); }

.header-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-name {
    font-size: 0.85rem;
    color: var(--gray-500);
}

/* =====================================================
   MAIN LAYOUT
   ===================================================== */
.app-main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.5rem;
}

.app-footer {
    text-align: center;
    padding: 2rem;
    color: var(--gray-500);
    font-size: 0.8rem;
}

/* =====================================================
   BUTTONS
   ===================================================== */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.15s;
}

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

.btn-secondary {
    background: white;
    color: var(--gray-700);
    border-color: var(--gray-300);
}
.btn-secondary:hover { background: var(--gray-50); }

.btn-success {
    background: var(--success);
    color: white;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-small { padding: 0.3rem 0.6rem; font-size: 0.8rem; }
.btn-tiny { padding: 0.2rem 0.5rem; font-size: 0.75rem; }
.btn-full { width: 100%; text-align: center; }

/* =====================================================
   FORMS
   ===================================================== */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.3rem;
    color: var(--gray-700);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-family: inherit;
}

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

.form-row {
    display: flex;
    gap: 1rem;
}

.form-group-wide { flex: 2; }
.form-group-small { flex: 0.5; }
.form-group { flex: 1; }

fieldset {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

fieldset legend {
    font-weight: 600;
    font-size: 0.9rem;
    padding: 0 0.5rem;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

/* =====================================================
   ALERTS
   ===================================================== */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.alert-error {
    background: #fef2f2;
    color: var(--danger);
    border: 1px solid #fecaca;
}

.alert-success {
    background: #f0fdf4;
    color: var(--success);
    border: 1px solid #bbf7d0;
}

/* =====================================================
   DASHBOARD
   ===================================================== */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.filter-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding: 0.75rem 1rem;
    background: white;
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
    flex-wrap: wrap;
    gap: 0.5rem;
}

.filter-group, .sort-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
}

.filter-group span, .sort-group span {
    color: var(--gray-500);
    font-weight: 500;
}

.filter-link {
    text-decoration: none;
    color: var(--gray-700);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.filter-link:hover { background: var(--gray-100); }
.filter-link.active {
    background: var(--primary);
    color: white;
}

/* =====================================================
   AUFTRÄGE-LISTE
   ===================================================== */
.auftraege-liste {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.auftrag-card {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    text-decoration: none;
    color: inherit;
    transition: box-shadow 0.15s;
}

.auftrag-card:hover {
    box-shadow: var(--shadow-md);
}

.auftrag-card.dringend {
    border-left: 3px solid var(--warning);
}

.auftrag-card-title strong {
    font-size: 0.95rem;
}

.auftrag-card-title .az {
    color: var(--gray-500);
    font-size: 0.8rem;
    margin-left: 0.5rem;
}

.auftrag-card-details {
    font-size: 0.8rem;
    color: var(--gray-500);
    margin-top: 0.2rem;
}

.auftrag-card-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.3rem;
}

.gutachter-badge {
    font-size: 0.75rem;
    padding: 0.15rem 0.5rem;
    background: var(--gray-100);
    border-radius: 3px;
    font-weight: 500;
}

.termin-badge {
    font-size: 0.75rem;
    color: var(--gray-500);
}

.termin-badge.dringend {
    color: var(--warning);
    font-weight: 600;
}

/* =====================================================
   PROGRESS BAR
   ===================================================== */
.auftrag-card-progress {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 120px;
}

.progress-bar {
    flex: 1;
    height: 6px;
    background: var(--gray-200);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--success);
    border-radius: 3px;
    transition: width 0.3s;
}

.progress-text {
    font-size: 0.75rem;
    color: var(--gray-500);
    white-space: nowrap;
}

/* =====================================================
   AUFTRAG DETAIL
   ===================================================== */
.auftrag-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.5rem;
}

.auftrag-header h1 { font-size: 1.4rem; }
.auftrag-header .az {
    color: var(--gray-500);
    font-size: 0.9rem;
    display: block;
}

.auftrag-header-actions {
    display: flex;
    gap: 0.5rem;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.info-card {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 1rem;
}

.info-card h3 {
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--gray-500);
    margin-bottom: 0.5rem;
    letter-spacing: 0.03em;
}

.info-card p {
    font-size: 0.9rem;
    margin-bottom: 0.2rem;
}

/* =====================================================
   LAUFZETTEL (Checkliste)
   ===================================================== */
.laufzettel { margin-bottom: 2rem; }
.laufzettel h2 { margin-bottom: 1rem; }

.amt-gruppe {
    margin-bottom: 1.5rem;
}

.amt-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--gray-200);
    padding-bottom: 0.5rem;
    margin-bottom: 0;
}

.amt-header-actions {
    display: flex;
    gap: 0.4rem;
}

.unterlagen-table {
    width: 100%;
    border-collapse: collapse;
}

.unterlagen-table th,
.unterlagen-table td {
    padding: 0.5rem 0.75rem;
    text-align: left;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--gray-100);
}

.unterlagen-table th {
    font-weight: 500;
    color: var(--gray-500);
    font-size: 0.75rem;
    text-transform: uppercase;
}

.unterlagen-table tr.erledigt {
    opacity: 0.6;
}

.unterlagen-table tr.erledigt .col-typ {
    text-decoration: line-through;
}

.col-status { width: 30px; text-align: center; }
.col-datum { width: 110px; }
.col-actions { width: 100px; text-align: right; }

/* =====================================================
   E-MAIL
   ===================================================== */
.vorlage-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 0.75rem;
    margin-top: 1rem;
}

.vorlage-card {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    padding: 1rem;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    text-decoration: none;
    color: inherit;
}

.vorlage-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow);
}

.amt-badge {
    font-size: 0.7rem;
    color: var(--gray-500);
}

.email-form textarea {
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    line-height: 1.6;
}

/* =====================================================
   VORLAGEN
   ===================================================== */
.help-text {
    font-size: 0.8rem;
    color: var(--gray-500);
    margin-bottom: 1.5rem;
    background: var(--gray-100);
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
}

.help-text code {
    background: white;
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    font-size: 0.75rem;
}

.vorlagen-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.vorlagen-table th,
.vorlagen-table td {
    padding: 0.6rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
    font-size: 0.85rem;
}

.vorlagen-table th {
    font-weight: 600;
    background: var(--gray-50);
}

/* =====================================================
   UNTERLAGEN VERWALTEN (Details/Summary)
   ===================================================== */
.unterlagen-verwalten {
    margin-bottom: 2rem;
}

.section-toggle {
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    padding: 0.75rem 1rem;
    background: var(--gray-100);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.section-toggle::-webkit-details-marker {
    display: none;
}

.section-toggle::before {
    content: '▶';
    font-size: 0.7rem;
    transition: transform 0.2s;
}

details[open] > .section-toggle::before {
    transform: rotate(90deg);
}

.section-toggle:hover {
    background: var(--gray-200);
}

.unterlagen-checkboxen {
    padding: 1rem;
    border: 1px solid var(--gray-200);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
}

/* =====================================================
   DOKUMENTE
   ===================================================== */
.dokumente-section { margin-bottom: 2rem; }

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.dokumente-table {
    width: 100%;
    border-collapse: collapse;
}

.dokumente-table th,
.dokumente-table td {
    padding: 0.5rem 0.75rem;
    text-align: left;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--gray-100);
}

.dokumente-table th {
    font-weight: 500;
    color: var(--gray-500);
    font-size: 0.75rem;
    text-transform: uppercase;
}

.dokument-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.dokument-link:hover { text-decoration: underline; }

.datei-groesse {
    color: var(--gray-500);
    margin-left: 0.3rem;
}

.empty-hint {
    color: var(--gray-500);
    font-size: 0.85rem;
    font-style: italic;
}

.form-hint {
    display: block;
    margin-top: 0.3rem;
    font-size: 0.75rem;
    color: var(--gray-500);
}

.upload-form input[type="file"] {
    padding: 0.5rem;
    border: 1px dashed var(--gray-300);
    border-radius: var(--radius);
    width: 100%;
}

/* =====================================================
   E-MAIL LOG
   ===================================================== */
.email-log { margin-top: 2rem; }
.email-log h2 { margin-bottom: 0.75rem; }

.log-table {
    width: 100%;
    border-collapse: collapse;
}

.log-table th,
.log-table td {
    padding: 0.5rem 0.75rem;
    text-align: left;
    font-size: 0.8rem;
    border-bottom: 1px solid var(--gray-100);
}

.log-table th {
    color: var(--gray-500);
    font-weight: 500;
}

/* =====================================================
   EMPTY STATE
   ===================================================== */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--gray-500);
}

.empty-state p { margin-bottom: 1rem; }

/* =====================================================
   CHECKBOXEN (Unterlagen-Auswahl)
   ===================================================== */
.help-text-inline {
    font-size: 0.8rem;
    color: var(--gray-500);
    margin-bottom: 1rem;
}

.checkbox-gruppe {
    margin-bottom: 1rem;
}

.checkbox-gruppe-label {
    display: block;
    font-size: 0.8rem;
    color: var(--gray-700);
    margin-bottom: 0.4rem;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid var(--gray-200);
}

.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.3rem 1rem;
    padding: 0.5rem 0;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    cursor: pointer;
    padding: 0.2rem 0;
}

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

.checkbox-actions {
    margin-top: 0.75rem;
    display: flex;
    gap: 0.5rem;
}

.objekt-gleich-label {
    margin-bottom: 1rem;
    font-weight: 500;
}

.hidden {
    display: none;
}

/* =====================================================
   BENUTZERVERWALTUNG
   ===================================================== */
.benutzer-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.benutzer-table th,
.benutzer-table td {
    padding: 0.6rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
    font-size: 0.85rem;
}

.benutzer-table th {
    font-weight: 600;
    background: var(--gray-50);
    font-size: 0.75rem;
    text-transform: uppercase;
}

.benutzer-table tr.inaktiv {
    opacity: 0.5;
}

.rolle-badge {
    font-size: 0.7rem;
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    font-weight: 600;
    text-transform: uppercase;
}

.rolle-admin { background: #fef3c7; color: #92400e; }
.rolle-gutachter { background: #dbeafe; color: #1e40af; }
.rolle-service { background: #e5e7eb; color: #374151; }

/* =====================================================
   RESPONSIVE
   ===================================================== */
@media (max-width: 768px) {
    .form-row { flex-direction: column; gap: 0; }
    .auftrag-card { grid-template-columns: 1fr; }
    .info-grid { grid-template-columns: 1fr; }
    .filter-bar { flex-direction: column; align-items: flex-start; }
    .auftrag-header { flex-direction: column; gap: 1rem; }
}
