/*
 * Auftragsverwaltung - Custom Styles
 * Farbschema orientiert am Telematik-Partner Design (telematik-partner.com)
 *
 * Primärfarbe (Akzent): #cad400 (Limettengrün)
 * Sekundärfarbe:        #575756 (Anthrazit-Grau)
 * Akzent:               #ffffff (Weiß)
 * Hintergrund:          #f5f5f5 (Hellgrau)
 */

/* ============================================================================
   CSS Custom Properties
   ============================================================================ */

:root {
    --primary: #cad400;
    --primary-dark: #b4bd00;
    --primary-light: #dde55a;
    --secondary: #575756;
    --secondary-light: #6d6c6b;
    --accent: #ffffff;
    --on-primary: #3a3a39;
    --bg-light: #f5f5f5;
    --surface-alt: #eeeeee;
    --footer-bg: #787878;
    --footer-text: #dddddd;
    --bg-card: #ffffff;
    --text-dark: #3a3a39;
    --text-muted: #787878;
    --border-color: #dddddd;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    --radius: 0.5rem;
    --topbar-height: 42px;
    --navbar-height: 58px;
}

/* ============================================================================
   Grundlegende Anpassungen
   ============================================================================ */

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: var(--surface-alt);
    color: var(--text-dark);
    padding-top: calc(var(--topbar-height) + var(--navbar-height) + 2px);
}

/* ============================================================================
   Navbar
   ============================================================================ */

/* ---- Obere (dunkle) Leiste ---- */
.topbar {
    background-color: var(--secondary);
    color: #cccccc;
    min-height: var(--topbar-height);
    display: flex;
    align-items: center;
    font-size: 0.82rem;
}

.topbar-brand {
    color: #ffffff;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.topbar a {
    color: #cccccc;
}

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

.topbar .topbar-btn {
    color: #cccccc;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.22);
}

.topbar .topbar-btn:hover {
    color: var(--on-primary);
    background-color: var(--primary);
    border-color: var(--primary);
}

/* ---- Hauptmenü (graues Band) ---- */
.navbar {
    background-color: var(--bg-light) !important;
    box-shadow: var(--shadow-sm);
    border-bottom: 1px solid var(--border-color);
    min-height: var(--navbar-height);
}

/* Logo auf weißer Fläche absetzen (Logo-Grafik hat weißen Hintergrund) */
.navbar .navbar-brand {
    background-color: #ffffff;
    padding: 4px 12px 4px 8px;
    border-radius: var(--radius);
}

/* Logo-Bild (Telematik Partner) */
.brand-logo-img {
    height: 38px;
    width: auto;
    display: block;
}

.brand-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 400;
}

.navbar .navbar-nav .nav-link {
    color: var(--secondary);
    transition: color 0.2s;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.5rem 0.85rem;
}

.navbar .navbar-nav .nav-link:hover,
.navbar .navbar-nav .nav-link.active {
    color: var(--primary-dark);
}

.navbar .navbar-nav .nav-link.active {
    border-bottom: 2px solid var(--primary);
}

.navbar .btn-primary {
    background-color: var(--primary);
    border-color: var(--primary);
}

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

/* ============================================================================
   Hauptinhalt
   ============================================================================ */

.main-content {
    min-height: calc(100vh - var(--topbar-height) - var(--navbar-height) - 80px);
    padding-top: 0;
    padding-bottom: 2rem;
}

/* ============================================================================
   Karten (Cards)
   ============================================================================ */

.card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s;
}

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

.card-header {
    background-color: var(--bg-light);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.25rem;
}

.card-header .card-title {
    color: var(--secondary);
    font-size: 1rem;
    font-weight: 600;
}

.card-dashboard {
    border-left: 4px solid var(--primary);
}

/* ============================================================================
   KPI-Icons (Dashboard)
   ============================================================================ */

.kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

/* ============================================================================
   Status-Karten (Dashboard)
   ============================================================================ */

.status-card {
    background-color: var(--bg-light);
    transition: background-color 0.2s, transform 0.2s;
    cursor: default;
}

.status-card:hover {
    background-color: #eee;
    transform: translateY(-1px);
}

/* ============================================================================
   Tabellen
   ============================================================================ */

.table {
    font-size: 0.9rem;
}

.table thead th {
    background-color: var(--surface-alt);
    color: var(--secondary);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border-bottom: 2px solid var(--border-color);
    padding: 0.75rem;
    white-space: nowrap;
}

.table td {
    vertical-align: middle;
    padding: 0.6rem 0.75rem;
}

.table-hover tbody tr:hover {
    background-color: rgba(202, 212, 0, 0.07);
}

/* ============================================================================
   Buttons
   ============================================================================ */

.btn-primary {
    background-color: var(--primary);
    border-color: var(--primary);
    color: var(--on-primary);
}

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

.btn-primary:focus,
.btn-primary:active {
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
    color: var(--on-primary);
    box-shadow: 0 0 0 0.25rem rgba(202, 212, 0, 0.35);
}

.btn-outline-primary {
    color: var(--secondary);
    border-color: var(--primary);
}

.btn-outline-primary:hover {
    background-color: var(--primary);
    border-color: var(--primary);
    color: var(--on-primary);
}

/* ============================================================================
   Formulare
   ============================================================================ */

.form-control:focus,
.form-select:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 0.25rem rgba(202, 212, 0, 0.18);
}

.form-label {
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--secondary);
}

/* ============================================================================
   Badges
   ============================================================================ */

.badge {
    font-weight: 500;
    font-size: 0.75rem;
    padding: 0.35em 0.65em;
    border-radius: 0.35rem;
}

/* ============================================================================
   Alerts
   ============================================================================ */

.alert {
    border-radius: var(--radius);
    border: none;
    font-size: 0.9rem;
}

/* ============================================================================
   Footer
   ============================================================================ */

.footer {
    background-color: var(--footer-bg) !important;
    color: var(--footer-text);
    border-top: 3px solid var(--secondary);
}

.footer small,
.footer .text-muted {
    color: var(--footer-text) !important;
}

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

/* ============================================================================
   Links
   ============================================================================ */

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

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

.card a:hover {
    text-decoration: none;
}

/* ============================================================================
   Dropdown-Menü (hell, graue Hover-Flächen)
   ============================================================================ */

.dropdown-menu {
    border-color: var(--border-color);
    box-shadow: var(--shadow-md);
}

.dropdown-item:hover,
.dropdown-item:focus {
    background-color: var(--bg-light);
    color: var(--secondary);
}

.dropdown-item.active,
.dropdown-item:active {
    background-color: var(--primary);
    color: var(--on-primary);
}

/* ============================================================================
   Seitenüberschrift
   ============================================================================ */

.page-header {
    background: linear-gradient(135deg, var(--secondary) 0%, var(--secondary-light) 100%);
    color: var(--accent);
    border-radius: var(--radius);
    padding: 1.5rem 2rem;
    margin-bottom: 1.5rem;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0;
}

.page-header .breadcrumb {
    margin-bottom: 0;
}

.page-header .breadcrumb-item a {
    color: rgba(255, 255, 255, 0.7);
}

.page-header .breadcrumb-item.active {
    color: rgba(255, 255, 255, 0.9);
}

/* ============================================================================
   Scrollbar (subtil)
   ============================================================================ */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-light);
}

::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #aaa;
}

/* ============================================================================
   Responsive Anpassungen
   ============================================================================ */

@media (max-width: 768px) {
    .main-content {
        padding-top: 0;
    }

    .card-body {
        padding: 0.75rem;
    }

    .kpi-icon {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }

    .table {
        font-size: 0.8rem;
    }

    .table thead th {
        font-size: 0.7rem;
        padding: 0.5rem;
    }

    .table td {
        padding: 0.4rem 0.5rem;
    }

    h1.h3 {
        font-size: 1.2rem;
    }
}

@media (max-width: 576px) {
    .container-fluid {
        padding-left: 12px;
        padding-right: 12px;
    }

    .navbar-brand .brand-subtitle {
        display: none;
    }
}

/* ============================================================================
   Utility-Klassen
   ============================================================================ */

.text-primary {
    color: var(--primary) !important;
}

.bg-primary {
    background-color: var(--primary) !important;
}

.border-primary {
    border-color: var(--primary) !important;
}

.cursor-pointer {
    cursor: pointer;
}

.min-w-0 {
    min-width: 0;
}

/* Auftragstyp-Badges */
.badge-allgemein {
    background-color: #6c757d;
    color: #fff;
}

.badge-stick {
    background-color: #0d6efd;
    color: #fff;
}

.badge-druck {
    background-color: #198754;
    color: #fff;
}

/* ============================================================================
   Werkhallen-Dashboard
   ============================================================================ */

.status-card-werkhalle {
    transition: transform 0.15s, box-shadow 0.15s;
    cursor: pointer;
}

.status-card-werkhalle:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.status-card-werkhalle.active {
    box-shadow: 0 0 0 2px var(--primary), var(--shadow-md);
}

.werkhalle-kachel {
    transition: transform 0.15s, box-shadow 0.15s;
    height: 100%;
    font-size: 0.85rem;
}

.werkhalle-kachel:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* Kompakte Kachel: mehr Aufträge je Bildschirm */
.werkhalle-kachel .card-body {
    padding: 0.6rem 0.7rem;
}
.werkhalle-kachel .fw-bold,
.werkhalle-kachel .fw-semibold {
    font-size: 0.9rem;
}
/* Innenabstände der Kachelblöcke verkleinern */
.werkhalle-kachel .mb-2 {
    margin-bottom: 0.35rem !important;
}
.werkhalle-kachel .mt-2 {
    margin-top: 0.4rem !important;
}
.werkhalle-kachel .pt-2 {
    padding-top: 0.4rem !important;
}
.werkhalle-kachel .gap-2 {
    gap: 0.35rem !important;
}
/* Aktions-Buttons kompakter (Touch-Mindesthöhe greift erst < 768px) */
.werkhalle-kachel .btn {
    padding-top: 0.3rem;
    padding-bottom: 0.3rem;
    font-size: 0.85rem;
}
.werkhalle-kachel .btn-success {
    font-weight: 600;
}

.werkhalle-ueberfaellig {
    background-color: #fff5f5 !important;
    animation: pulse-danger 2s infinite;
}

.werkhalle-dringend {
    background-color: #fffbeb !important;
}

@keyframes pulse-danger {
    0%, 100% { box-shadow: var(--shadow-sm); }
    50% { box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.2), var(--shadow-md); }
}

/* ============================================================================
   Benachrichtigungen
   ============================================================================ */

.list-group-item-light {
    background-color: #f0f7ff !important;
    border-left: 3px solid var(--primary);
}

/* ============================================================================
   Datei-Upload Widget
   ============================================================================ */

#dateien-widget .list-group-item {
    transition: background-color 0.15s;
}

#dateien-widget .list-group-item:hover {
    background-color: var(--bg-light);
}

/* ============================================================================
   Setup-Seite (nur für setup.php)
   ============================================================================ */

.setup-container {
    max-width: 700px;
    margin: 2rem auto;
}

.setup-header {
    text-align: center;
    padding: 2rem 0;
}

.setup-header h1 {
    color: var(--primary);
    font-weight: 700;
}

.setup-step {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
}

.setup-step:last-child {
    border-bottom: none;
}

.setup-step .step-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.step-success .step-icon {
    background-color: #d1e7dd;
    color: #198754;
}

.step-error .step-icon {
    background-color: #f8d7da;
    color: #dc3545;
}

.step-pending .step-icon {
    background-color: #e2e3e5;
    color: #6c757d;
}

/* ============================================================================
   Administration
   ============================================================================ */

.color-swatch {
    display: inline-block;
    width: 22px;
    height: 22px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    vertical-align: middle;
}

.edit-form {
    display: none;
}

.admin-color-picker {
    width: 42px;
    height: 38px;
    padding: 2px;
    cursor: pointer;
}

.admin-color-text {
    max-width: 100px;
    font-family: monospace;
}

/* ============================================================================
   Mobile-Optimierung (Smartphone / Tablet)
   ============================================================================ */

/* Schwung-Scrollen für breite Tabellen auf Touch-Geräten */
.table-responsive {
    -webkit-overflow-scrolling: touch;
}

/* Werkhallen-Statusleiste: auf kleineren Geräten horizontal wischen statt
   in viele winzige Spalten umzubrechen. */
@media (max-width: 991.98px) {
    .werkhalle-status-row {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x proximity;
        padding-bottom: 0.35rem;
    }
    .werkhalle-status-row > .col {
        flex: 0 0 auto;
        width: 9.5rem;
        scroll-snap-align: start;
    }
}

/* Tablet/Smartphone */
@media (max-width: 768px) {
    /* Touch-freundlichere Schaltflächen */
    .btn {
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
    }
    .btn-sm {
        padding-top: 0.4rem;
        padding-bottom: 0.4rem;
    }
    .werkhalle-kachel .btn {
        min-height: 44px;
    }
    /* Dropdown-Menüs nicht über den Bildschirmrand hinaus */
    .dropdown-menu {
        max-width: 92vw;
    }
}

/* Smartphone */
@media (max-width: 576px) {
    /* iOS: Eingabefelder >= 16px verhindern das automatische Hineinzoomen beim Fokus */
    .form-control,
    .form-select,
    .form-control-sm,
    .form-select-sm {
        font-size: 16px;
    }

    /* Seiten-Titel kompakter */
    h1, .h1 { font-size: 1.5rem; }
    h1.h3, .h3 { font-size: 1.2rem; }

    /* Kopfzeilen "Titel + Aktion" dürfen umbrechen statt sich zu quetschen */
    .main-content .d-flex.justify-content-between.align-items-center {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    /* Navbar: Aktionsleiste (Suche/Glocke/Neu/Benutzer) im aufgeklappten Menü umbrechen */
    #mainNav > .d-flex {
        flex-wrap: wrap;
        margin-top: 0.5rem;
    }

    /* Globale Suche im aufgeklappten Menü voll nutzbar */
    #mainNav form[role="search"] {
        width: 100%;
    }

    /* Modale mit etwas Seitenrand */
    .modal-dialog {
        margin: 0.5rem;
    }
}
