/* page.betriebsanweisungen.css */

/* ================================================
   RESET & BASE — Portal Style
   ================================================ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: Montserrat, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    letter-spacing: -0.01em;
    background-color: var(--background) !important;
    color: var(--foreground);
    min-height: 100vh;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* ================================================
   HEADER STYLES
   ================================================ */
h1, h2, h3, h4, h5, h6 {
    color: var(--foreground);
    font-weight: 700;
    letter-spacing: -0.01em;
}

.header {
    background: var(--background);
    color: var(--foreground);
}

.container {
    width: 100%;
    max-width: 1880px;
    margin: 0 auto;
    padding: 0 clamp(16px, 2vw, 36px);
}

/* ================================================
   MAIN CONTENT
   ================================================ */
.main-content {
    color: var(--foreground);
    background: var(--background) !important;
}

/* ================================================
   LANGUAGE SELECTION SCREEN
   ================================================ */
.language-selection-screen {
    display: flex;
    position: fixed !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    flex-direction: column !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 40px !important;
    background-color: var(--background) !important;
    color: var(--foreground) !important;
    text-align: center !important;
    padding: 48px 24px !important;
    z-index: 99999 !important;
    overflow-y: auto !important;
}

.lang-screen-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.company-logo {
    width: 80px;
    height: 80px;
    object-fit: contain;
    filter: drop-shadow(0 0 20px rgba(46, 125, 50, 0.15));
}

.language-selection-screen h1 {
    font-size: 1.2em !important;
    font-weight: 900 !important;
    color: var(--foreground) !important;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

.language-buttons {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    max-width: 700px;
    width: 100%;
}

@media (min-width: 600px) {
    .language-buttons {
        grid-template-columns: repeat(4, 1fr) !important;
    }
}

.language-choice-btn {
    height: 56px !important;
    width: 100% !important;
    cursor: pointer !important;
    border-radius: 9999px !important;
    border: 1px solid rgba(0, 0, 0, 0.08) !important;
    padding: 4px !important;
    background: rgba(245, 245, 245, 0.5) !important;
    backdrop-filter: blur(8px) !important;
    -webkit-backdrop-filter: blur(8px) !important;
    outline: none !important;
    transition: border-color 0.3s ease, background 0.3s ease !important;
}

.language-choice-btn:hover {
    border-color: rgba(46, 125, 50, 0.3) !important;
    background: rgba(230, 245, 230, 0.7) !important;
}

/* ================================================
   LANG CHANGE BAR
   ================================================ */
.lang-change-bar {
    padding: 8px 16px;
    background-color: var(--card);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    border-bottom: 1px solid var(--border);
}

.change-language-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--foreground);
    padding: 8px 12px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    transition: all 0.3s ease;
}

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

/* ================================================
   GEFAHRSTOFFLISTE STYLES
   ================================================ */
.ba-container {
    max-width: none;
    margin: 0 auto;
    padding: 20px 0 32px;
}

/* Sticky Search Bar */
.search-bar-sticky {
    position: sticky;
    top: 0;
    z-index: 100;
    margin-bottom: 20px !important;
}

.search-bar {
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    background: rgba(245, 245, 245, 0.5);
    padding: 15px;
    border-radius: var(--radius);
    border: 1px solid rgba(0, 0, 0, 0.08);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.search-input {
    flex: 1;
    padding: 12px 20px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 1rem;
    font-size: 16px;
    background: rgba(245, 245, 245, 0.6);
    color: var(--foreground);
    font-family: inherit;
    transition: all 0.3s ease;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.search-input::placeholder {
    color: #999999;
    opacity: 0.7;
}

.search-input:focus {
    outline: none;
    border-color: rgba(46, 125, 50, 0.4);
    box-shadow: 0 0 0 4px rgba(46, 125, 50, 0.08);
}

/* Cards Container */
.gefahrstoffe-cards-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
}

/* Individual Card */
.gefahrstoff-card {
    display: flex;
    gap: 16px;
    padding: 18px;
    background: rgba(245, 245, 245, 0.5);
    border-radius: 1rem;
    border: 1px solid rgba(0, 0, 0, 0.08);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
    transition: all 0.3s ease;
    align-items: flex-start;
    flex-direction: column;
}

.gefahrstoff-card:hover {
    background: rgba(230, 245, 230, 0.6);
    border-color: rgba(46, 125, 50, 0.2);
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

.gefahrstoff-card-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    min-width: 60px;
    border-radius: 0.875rem;
    background: linear-gradient(135deg, rgba(46, 125, 50, 0.08), rgba(46, 125, 50, 0.04));
    border: 1px solid rgba(46, 125, 50, 0.15);
    font-size: 28px;
    flex-shrink: 0;
}

.gefahrstoff-card-content {
    flex: 1;
    min-width: 0;
}

.gefahrstoff-card-number {
    display: inline-block;
    background: rgba(46, 125, 50, 0.1);
    color: var(--primary);
    padding: 3px 8px;
    border-radius: 9999px;
    font-size: 0.75em;
    font-weight: 700;
    margin-bottom: 8px;
}

.gefahrstoff-card-name {
    font-size: 1.05em;
    font-weight: 700;
    color: var(--foreground);
    margin-bottom: 6px;
    word-break: break-word;
}

.gefahrstoff-card-company {
    font-size: 0.9em;
    color: var(--muted-foreground);
    margin-bottom: 10px;
}

.gefahrstoff-card-labels {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.gefahrstoff-card-label {
    display: inline-block;
    background: rgba(46, 125, 50, 0.1);
    color: var(--primary);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8em;
    font-weight: 500;
}

.gefahrstoff-card-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.card-btn {
    padding: 6px 10px;
    font-size: 13px;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
}

.card-btn-sdb {
    background: var(--primary);
    color: var(--primary-foreground);
}

.card-btn-sdb:hover {
    background: var(--chart-2);
    transform: translateY(-2px);
}

.card-btn-empty {
    background: transparent;
    color: var(--muted-foreground);
}

.action-buttons {
    display: flex;
    gap: 8px;
}

.btn-upload, .btn-download {
    padding: 6px 10px;
    font-size: 13px;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
}

.btn-upload {
    background: color-mix(in srgb, var(--secondary) 95%, black);
    color: var(--foreground);
    border: 1px solid var(--border);
}

.btn-upload:hover {
    background: color-mix(in srgb, var(--secondary) 85%, black);
}

.btn-download {
    background: var(--primary);
    color: var(--primary-foreground);
}

.btn-download:hover {
    background: var(--chart-2);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(46, 125, 50, 0.15);
}

.substance-badge {
    display: inline-block;
    background: var(--muted);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.85em;
    font-weight: 500;
}

.loading-indicator {
    text-align: center;
    padding: 40px;
    color: var(--muted-foreground);
}

/* Modal for File Upload */
.upload-modal .modal-body {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.file-input-wrapper {
    position: relative;
    border: 2px dashed var(--input);
    border-radius: var(--radius);
    padding: 30px;
    text-align: center;
    transition: border-color 0.3s;
    margin-bottom: 15px;
}

.file-input-wrapper:hover {
    border-color: var(--primary);
}

.file-input-wrapper input[type="file"] {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.submit-upload-btn {
    background: var(--primary);
    color: var(--primary-foreground);
    border: none;
    padding: 12px 20px;
    border-radius: var(--radius);
    font-size: 16px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s;
    width: 100%;
}

.submit-upload-btn:hover {
    background: var(--chart-2);
}

.alert {
    padding: 10px 15px;
    border-radius: var(--radius);
    margin-bottom: 15px;
    font-weight: 500;
}

.alert-success {
    background: color-mix(in srgb, var(--primary) 15%, transparent);
    color: var(--primary);
    border: 1px solid var(--primary);
}

.alert-error {
    background: color-mix(in srgb, var(--destructive) 15%, transparent);
    color: var(--destructive);
    border: 1px solid var(--destructive);
}

/* ================================================
   GEFAHRSTOFF-TABELLE
   ================================================ */
.search-bar-sticky {
    display: grid;
    grid-template-columns: minmax(280px, 1fr) minmax(180px, 230px) auto;
}

.type-filter {
    min-height: 46px;
    padding: 10px 36px 10px 14px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 1rem;
    background: var(--card, #fff);
    color: var(--foreground);
    font: inherit;
    cursor: pointer;
}

.type-filter:focus {
    outline: none;
    border-color: rgba(46, 125, 50, 0.45);
    box-shadow: 0 0 0 4px rgba(46, 125, 50, 0.08);
}

.result-count {
    min-width: 150px;
    color: var(--muted-foreground);
    font-size: 0.85rem;
    font-weight: 700;
    text-align: right;
    white-space: nowrap;
}

.ba-table-wrap {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--border, rgba(0, 0, 0, 0.1));
    border-radius: 16px;
    background: var(--card, #fff);
    box-shadow: 0 10px 28px rgba(16, 58, 55, 0.07);
}

.ba-table {
    width: 100%;
    min-width: 760px;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed;
    color: var(--foreground);
    font-size: 0.84rem;
}

.ba-table th,
.ba-table td {
    padding: 10px 9px;
    border-right: 1px solid var(--border, #dde5e1);
    border-bottom: 1px solid var(--border, #dde5e1);
    vertical-align: top;
    line-height: 1.42;
    overflow-wrap: anywhere;
}

.ba-table th:last-child,
.ba-table td:last-child {
    border-right: 0;
}

.ba-table tbody tr:last-child td {
    border-bottom: 0;
}

.ba-table thead th {
    position: sticky;
    top: 0;
    z-index: 4;
    background: #145e55;
    color: #fff;
    text-align: left;
    font-size: 0.76rem;
    letter-spacing: 0.025em;
}

.ba-table tbody tr:nth-child(even) td {
    background: color-mix(in srgb, var(--card, #fff) 94%, #dcebe6);
}

.ba-table tbody tr:hover td {
    background: color-mix(in srgb, var(--card, #fff) 86%, #b8dfd1);
}

.table-sort-button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    font-weight: 800;
    text-align: left;
    cursor: pointer;
}

.table-sort-button span {
    color: #bfe7dc;
    font-size: 0.68rem;
}

.ba-table .col-number { width: 6%; text-align: center; }
.ba-table .col-product { width: 38%; font-weight: 750; }
.ba-table .col-type { width: 16%; }
.ba-table .col-version { width: 8%; text-align: center; }
.ba-table .col-banr { width: 12%; white-space: nowrap; }
.ba-table .col-document { width: 14%; text-align: center; }

.ba-stand-row { display: flex; justify-content: flex-end; margin-bottom: 8px; }
.ba-stand {
    padding: 5px 12px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--card, #fff) 88%, #b8dfd1);
    color: var(--muted-foreground);
    font-size: 0.82rem;
    font-weight: 800;
    white-space: nowrap;
}

.type-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 800;
    white-space: nowrap;
}
.type-badge.is-general { background: #e0edf7; color: #1f5379; }
.type-badge.is-hazard { background: #fde3e1; color: #a9241c; }
.type-badge.is-psa { background: #e4f3e2; color: #2c6a2a; }
.type-badge.is-bio { background: #fff0c7; color: #7b5400; }
.type-badge.is-waste { background: #ece6f5; color: #5a3d86; }

.document-link {
    display: inline-flex;
    min-width: 92px;
    min-height: 34px;
    align-items: center;
    justify-content: center;
    padding: 7px 10px;
    border-radius: 9px;
    background: var(--primary, #2e7d32);
    color: #fff;
    font-size: 0.76rem;
    font-weight: 800;
    text-decoration: none;
    transition: transform 0.2s ease, filter 0.2s ease;
}

.document-link--ba { background: #285d86; }
.document-link:hover { color: #fff; filter: brightness(0.92); transform: translateY(-1px); }
.document-missing { color: var(--muted-foreground); font-size: 0.75rem; }
.statement-details summary { color: #285d86; font-weight: 700; cursor: pointer; }
.statement-full-text { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border, #dde5e1); white-space: pre-line; }
.table-empty { padding: 48px 20px !important; color: var(--muted-foreground); text-align: center; }

/* Große PC-Bildschirme: verfügbare Breite ausnutzen und die Liste kompakt halten. */
@media (min-width: 1400px) {
    .main-content > .container {
        max-width: none;
        padding-right: clamp(24px, 2.2vw, 48px);
        padding-left: clamp(24px, 2.2vw, 48px);
    }

    .main-content .header {
        max-width: 1080px;
        margin-right: auto;
        margin-bottom: 20px !important;
        margin-left: auto;
    }

    .ba-container {
        width: 100%;
        padding-top: 10px;
    }

    .search-bar {
        padding: 12px 14px;
    }

    .ba-table {
        min-width: 0;
        font-size: 0.8rem;
    }

    .ba-table th,
    .ba-table td {
        padding: 9px 8px;
    }
}

@media (max-width: 850px) {
    .ba-container { padding: 12px; }
    .search-bar-sticky { grid-template-columns: 1fr; gap: 10px; }
    .result-count { min-width: 0; text-align: left; }
    .ba-table { min-width: 700px; font-size: 0.8rem; }
    .ba-table th, .ba-table td { padding: 10px 9px; }
}

@media print {
    .search-bar, .lang-change-bar { display: none !important; }
    .ba-container { max-width: none; padding: 0; }
    .ba-table-wrap { overflow: visible; border: 0; box-shadow: none; }
    .ba-table { min-width: 0; table-layout: auto; font-size: 7pt; }
    .ba-table thead th { position: static; color: #000; background: #dce8e3 !important; }
    .ba-table th, .ba-table td { padding: 4px; }
}

/* ===== Handy: Liste als Karten (700 px und schmaler) ===== */
@media (max-width: 700px) {
    .ba-table-wrap { overflow: visible; border: 0; box-shadow: none; background: transparent; max-height: none; }
    .ba-table, .ba-table tbody, .ba-table tr, .ba-table td { display: block; width: 100% !important; min-width: 0 !important; }
    .ba-table thead { display: none; }
    .ba-table { border: 0; font-size: 0.92rem; }
    .ba-table tbody tr {
        position: relative;
        margin-bottom: 14px;
        overflow: hidden;
        border: 1px solid rgba(22, 90, 80, .22);
        border-radius: 14px;
        background: #fff;
        box-shadow: 0 6px 18px rgba(0, 0, 0, .07);
    }
    .ba-table tbody tr:nth-child(even) td, .ba-table tbody tr:hover td { background: transparent; }
    .ba-table th, .ba-table td { border-right: 0; }
    .ba-table td {
        display: grid;
        grid-template-columns: 108px minmax(0, 1fr);
        gap: 8px;
        align-items: start;
        padding: 9px 13px;
        border-bottom: 1px solid rgba(0, 0, 0, .07);
        text-align: left !important;
        overflow-wrap: anywhere;
    }
    .ba-table td::before {
        content: attr(data-label);
        padding-top: 2px;
        color: #6b7f79;
        font-size: .66rem;
        font-weight: 900;
        letter-spacing: .06em;
        text-transform: uppercase;
    }
    .ba-table td:last-child { border-bottom: 0; }
    /* Kopf der Karte: Nr. + Produktname */
    .ba-table td.col-number { grid-template-columns: 1fr; padding: 8px 13px 0; background: #e8f1ee; color: #165a50; font-weight: 900; font-size: .78rem; }
    .ba-table td.col-number::before { content: "Nr. "; display: inline; }
    .ba-table td.col-number { display: block; }
    .ba-table td.col-product { grid-template-columns: 1fr; padding: 0 13px 10px; background: #e8f1ee; border-bottom: 1px solid rgba(22, 90, 80, .15); font-size: 1.05rem; line-height: 1.3; }
    .ba-table td.col-product::before { content: none; }
    .ba-table td.col-document { display: grid; }
    .ba-table .document-link, .ba-table .document-missing { justify-self: start; }
}

/* ===== Kompakter Kopfbereich (weniger Platz über der Liste) ===== */
.main-content .header {
    margin-bottom: 0 !important;
    padding: 8px 12px 6px !important;
    border-bottom: 0 !important;
}
.main-content .header h2 {
    margin: 0 0 2px !important;
    font-size: 1.35rem !important;
    line-height: 1.2;
}
.main-content .header p {
    margin: 0 !important;
    font-size: 0.85rem !important;
    line-height: 1.3 !important;
}
.main-content .content {
    padding: 6px 15px 14px !important;
    min-height: 0 !important;
}
@media (max-width: 700px) {
    .main-content .header h2 { font-size: 1.15rem !important; }
    .main-content .header p { font-size: 0.78rem !important; }
}
.ba-stand-row { margin-bottom: 4px; }

/* ===== Zebra-Streifen: eine Zeile heller, eine dunkler ===== */
.ba-table tbody tr:nth-child(odd) td { background: #ffffff; }
.ba-table tbody tr:nth-child(even) td { background: #e4eee9; }
.ba-table tbody tr:hover td { background: #cfe3da; }
@media (max-width: 700px) {
    .ba-table tbody tr:nth-child(odd) td,
    .ba-table tbody tr:nth-child(even) td,
    .ba-table tbody tr:hover td { background: transparent; }
    .ba-table tbody tr:nth-child(odd) { background: #ffffff; }
    .ba-table tbody tr:nth-child(even) { background: #e9f1ed; }
    .ba-table td.col-number, .ba-table td.col-product { background: #d6e6df !important; }
}

/* Tabellen-Text: gleiche Schrift, Farbe und Groesse wie die Dienst-Namen im Portal */
.ba-table, .ba-table td, .ba-table .col-product { font-family: Montserrat, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 0.96rem; font-weight: 700; color: #111827; letter-spacing: -0.005em; line-height: 1.4; }
.ba-table thead th { font-family: Montserrat, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 0.84rem; }
html.dark .ba-table td, html.dark .ba-table .col-product { color: #f3f4f6; }
