/* ============================================================
   Immoscraper -- HA Ingress-compatible styles
   Supports both light and dark themes via CSS custom properties.
   ============================================================ */

:root {
    --bg: #f5f6fa;
    --bg-card: #ffffff;
    --text: #1a1a2e;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Dark mode (HA dark theme) */
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #1a1a2e;
        --bg-card: #16213e;
        --text: #e5e7eb;
        --text-muted: #9ca3af;
        --border: #374151;
        --shadow: 0 1px 3px rgba(0,0,0,0.4);
    }
}

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

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

/* ---- Navbar ---- */
.navbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1.5rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 1.1rem;
}

.nav-icon {
    font-size: 1.3rem;
}

.nav-links {
    display: flex;
    gap: 0.25rem;
    margin-left: 1rem;
}

.nav-link {
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.9rem;
    transition: background 0.15s, color 0.15s;
}

.nav-link:hover {
    background: var(--bg);
    color: var(--text);
}

.nav-link.active {
    background: var(--primary);
    color: #fff;
}

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

/* ---- Scan progress bar (navbar) ---- */
.scan-progress {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 180px;
}
.scan-progress[hidden] {
    display: none;
}
.scan-progress-track {
    flex: 1;
    height: 8px;
    background: var(--border);
    border-radius: 999px;
    overflow: hidden;
}
.scan-progress-fill {
    height: 100%;
    width: 0%;
    background: var(--primary);
    border-radius: 999px;
    transition: width 0.4s ease;
}
.scan-progress-fill.indeterminate {
    width: 35% !important;
    animation: scan-indeterminate 1.2s ease-in-out infinite;
}
.scan-progress-fill.done {
    background: var(--success);
}
@keyframes scan-indeterminate {
    0%   { margin-left: -35%; }
    100% { margin-left: 100%; }
}
.scan-progress-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* ---- Container ---- */
.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* ---- Cards ---- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
}

.card h2 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.card h3 {
    font-size: 0.95rem;
    margin-top: 1.25rem;
    margin-bottom: 0.75rem;
    color: var(--text-muted);
}

/* ---- Page header ---- */
.page-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
}

.page-header .btn-archive {
    margin-left: auto;
}

.page-header h1 {
    font-size: 1.5rem;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.5rem;
    padding: 0.15rem 0.5rem;
    font-size: 0.8rem;
    font-weight: 600;
    background: var(--primary);
    color: #fff;
    border-radius: 999px;
}

/* ---- View toggle ---- */
.view-toggle {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-left: auto;
}

.view-toggle-btn {
    padding: 0.4rem 1rem;
    border: none;
    background: var(--bg-card);
    color: var(--text-muted);
    font-size: 0.85rem;
    font-family: var(--font);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.view-toggle-btn:not(:last-child) {
    border-right: 1px solid var(--border);
}

.view-toggle-btn:hover {
    background: var(--bg);
    color: var(--text);
}

.view-toggle-btn.active {
    background: var(--primary);
    color: #fff;
}

.view-hidden {
    display: none !important;
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-family: var(--font);
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s;
    background: var(--bg-card);
    color: var(--text);
}

.btn:hover {
    background: var(--bg);
}

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

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

.btn-secondary {
    background: var(--bg);
    color: var(--text-muted);
}

.btn-danger {
    background: #dc3545;
    color: #fff;
    border-color: #dc3545;
}

.btn-danger:hover {
    background: #bb2d3b;
    border-color: #bb2d3b;
}

.btn-sm {
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
}

/* ---- Filter (compact bar + expandable panel) ---- */
.filter-card {
    padding: 1rem;
}

.filter-form-drawer {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.5rem;
}

.filter-chips[hidden] {
    display: none;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.45rem 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.75rem;
    line-height: 1.3;
    font-family: inherit;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.filter-chip:hover {
    background: var(--bg-card);
    border-color: var(--primary);
    color: var(--primary);
}

.filter-chip:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 1px;
}

.filter-chip-label {
    max-width: 14rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.filter-chip-remove {
    flex-shrink: 0;
    font-size: 0.95rem;
    line-height: 1;
    color: var(--text-muted);
}

.filter-chip:hover .filter-chip-remove {
    color: var(--primary);
}

.filter-mobile-bar {
    display: none;
    gap: 0.5rem;
}

.filter-mobile-bar .btn {
    flex: 1 1 0;
}

.filter-quick-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.75rem 1rem;
}

.filter-quick-grid {
    display: grid;
    grid-template-columns: minmax(9rem, 1.15fr) minmax(8rem, 1fr) minmax(5.5rem, 0.7fr) minmax(5.5rem, 0.7fr);
    gap: 0.75rem 1rem;
    flex: 1 1 28rem;
    min-width: min(100%, 28rem);
}

.filter-quick-actions {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
    margin-left: auto;
}

.filter-advanced {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    padding: 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
}

.filter-advanced[hidden] {
    display: none;
}

.filter-advanced-header {
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.filter-advanced-title {
    font-weight: 600;
    font-size: 0.95rem;
}

.filter-advanced-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.75rem 1rem;
}

.filter-advanced-grid--mobile-core {
    display: none;
}

.filter-advanced-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem 1rem;
    align-items: end;
}

.filter-advanced-options .filter-sort {
    grid-column: 1 / -1;
}

.filter-advanced-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: flex-end;
}

.filter-group .filter-dropdown {
    width: 100%;
}

.filter-collapsed-footer {
    display: flex;
    justify-content: flex-end;
}

.filter-collapsed-footer[hidden] {
    display: none;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
}

.filter-group > label:not(.checkbox-label) {
    min-height: auto;
    line-height: 1.2;
}

.filter-group input[type="text"],
.filter-group input[type="number"],
.filter-group select {
    width: 100%;
    max-width: 100%;
}

.filter-group select {
    text-overflow: ellipsis;
}

.filter-checkbox .checkbox-label {
    font-size: 0.85rem;
    line-height: 1.35;
    font-weight: 400;
    text-transform: none;
    letter-spacing: normal;
    color: var(--text);
}

.filter-group label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.filter-sort-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.filter-sort-controls select {
    flex: 1 1 8rem;
    min-width: 0;
    text-overflow: ellipsis;
}

.filter-checkbox .filter-hint {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.1rem;
}

/* List toolbar + column show/hide menu */
.list-toolbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 0.5rem;
}

.column-toggle {
    position: relative;
}

.column-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 0.25rem);
    z-index: 1200; /* above Leaflet panes (~700) and controls (1000) in map view */
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
    padding: 0.5rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 160px;
}

/* The class rule above would otherwise override the [hidden] default,
   keeping the menu permanently open; this makes the hidden state win. */
.column-menu[hidden] {
    display: none;
}

.column-menu .checkbox-label {
    font-size: 0.85rem;
    font-weight: 400;
    white-space: nowrap;
}

/* Generic filter dropdown (Objektart, Quelle): a button + popup checkbox menu. */
.filter-dropdown {
    position: relative;
    width: auto;
}

.dropdown-toggle {
    width: 100%;
    min-width: 0;
    justify-content: space-between;
    white-space: nowrap;
}

.dropdown-menu {
    position: absolute;
    left: 0;
    top: calc(100% + 0.25rem);
    z-index: 1200; /* above Leaflet panes (~700) and controls (1000) in map view */
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
    padding: 0.5rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 170px;
}

/* Same specificity trick as .column-menu[hidden]: let the hidden state win. */
.dropdown-menu[hidden] {
    display: none;
}

.dropdown-menu .checkbox-label {
    font-size: 0.85rem;
    font-weight: 400;
    white-space: nowrap;
}

/* Column visibility: toggled by JS via .hide-col-N on the table. */
.listing-table.hide-col-1 th:nth-child(1), .listing-table.hide-col-1 td:nth-child(1),
.listing-table.hide-col-2 th:nth-child(2), .listing-table.hide-col-2 td:nth-child(2),
.listing-table.hide-col-3 th:nth-child(3), .listing-table.hide-col-3 td:nth-child(3),
.listing-table.hide-col-4 th:nth-child(4), .listing-table.hide-col-4 td:nth-child(4),
.listing-table.hide-col-5 th:nth-child(5), .listing-table.hide-col-5 td:nth-child(5),
.listing-table.hide-col-6 th:nth-child(6), .listing-table.hide-col-6 td:nth-child(6),
.listing-table.hide-col-7 th:nth-child(7), .listing-table.hide-col-7 td:nth-child(7),
.listing-table.hide-col-8 th:nth-child(8), .listing-table.hide-col-8 td:nth-child(8),
.listing-table.hide-col-9 th:nth-child(9), .listing-table.hide-col-9 td:nth-child(9),
.listing-table.hide-col-10 th:nth-child(10), .listing-table.hide-col-10 td:nth-child(10),
.listing-table.hide-col-11 th:nth-child(11), .listing-table.hide-col-11 td:nth-child(11),
.listing-table.hide-col-12 th:nth-child(12), .listing-table.hide-col-12 td:nth-child(12) {
    display: none;
}

/* Objektart multi-select: compact vertical list of checkboxes. */
.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.checkbox-group .checkbox-label {
    font-size: 0.8rem;
    font-weight: 400;
}

.filter-group > .filter-hint {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.1rem;
}

.btn-archive {
    margin-left: 0.5rem;
    background: var(--bg);
    color: var(--text-muted);
}

.btn-archive:hover {
    background: var(--warning);
    color: #fff;
    border-color: var(--warning);
}

.btn-unarchive {
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.3);
    color: var(--success);
}

.btn-unarchive:hover {
    background: var(--success);
    color: #fff;
    border-color: var(--success);
}

/* ---- Form elements ---- */
input[type="text"],
input[type="number"],
input[type="password"],
select {
    padding: 0.45rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    width: 100%;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(59,130,246,0.15);
}

/* ---- Table ---- */
.table-responsive {
    overflow-x: auto;
}

.listing-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.listing-table th {
    text-align: left;
    padding: 0.6rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

.th-sortable {
    cursor: default;
}

.th-sort-link {
    color: inherit;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    padding: 0.15rem 0.25rem;
    margin: -0.15rem -0.25rem;
    border-radius: 4px;
    transition: background 0.15s, color 0.15s;
}

.th-sort-link:hover {
    color: var(--primary);
    background: rgba(59, 130, 246, 0.1);
}

.th-sort-active {
    color: var(--primary);
}

.th-sort-icon {
    font-size: 0.85em;
    opacity: 0.9;
}

.listing-table td {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.listing-table tbody tr:hover {
    background: var(--bg);
}

.th-images,
.col-images {
    text-align: center;
    white-space: nowrap;
}

.th-travel,
.col-travel {
    white-space: nowrap;
}

.img-indicator {
    display: inline-block;
    font-size: 0.85rem;
    font-weight: 600;
}

.img-indicator.img-yes {
    color: #10b981;
}

.img-indicator.img-no {
    color: var(--text-muted, #9ca3af);
    font-weight: 400;
}

.listing-title a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.listing-title a:hover {
    text-decoration: underline;
}

/* Angesehene Inserate: grüner Titel statt blau */
.listing-title a.listing-viewed {
    color: var(--success);
}

.listing-title a.listing-viewed:hover {
    color: #059669;
}

.text-right {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* ---- Tags ---- */
.tag {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    font-size: 0.75rem;
    border-radius: 999px;
    background: var(--bg);
    border: 1px solid var(--border);
    white-space: nowrap;
}

.tag-source {
    background: rgba(59,130,246,0.1);
    border-color: rgba(59,130,246,0.2);
    color: var(--primary);
}

.tag-success {
    background: rgba(16,185,129,0.1);
    border-color: rgba(16,185,129,0.2);
    color: var(--success);
}

.tag-error {
    background: rgba(239,68,68,0.1);
    border-color: rgba(239,68,68,0.2);
    color: var(--error);
}

/* ---- Pagination ---- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 1rem 0 0.5rem;
}

.pagination-top {
    padding-top: 0;
    padding-bottom: 0.5rem;
}

.pagination-info {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* ---- Detail page ---- */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.detail-description,
.detail-meta,
.detail-travel,
.detail-map {
    grid-column: 1 / -1;
}

.home-marker {
    font-size: 22px;
    line-height: 28px;
    text-align: center;
    background: none;
    border: none;
}

.description-text {
    font-size: 0.9rem;
    line-height: 1.65;
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 600px;
    overflow-y: auto;
    padding: 0.75rem;
    background: var(--bg);
    border-radius: 6px;
    border: 1px solid var(--border);
}

.detail-fields {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.detail-field {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--border);
}

.detail-field .label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.detail-field .value {
    font-size: 0.9rem;
    text-align: right;
}

.value-price {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--success);
}

.maps-link {
    color: var(--primary);
    text-decoration: none;
}

.maps-link::before {
    content: "\1F4CD";
    margin-right: 0.3rem;
}

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

.detail-actions {
    margin-top: 1rem;
}

.mono {
    font-family: "SF Mono", Monaco, "Cascadia Mono", monospace;
    font-size: 0.8rem;
}

/* ---- Settings ---- */
.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.settings-form .form-group {
    margin-bottom: 1rem;
}

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

.settings-form small {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

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

.form-row .form-group {
    flex: 1;
}

.settings-form .scraper-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.settings-form .scraper-row .checkbox-label {
    flex: 1;
    min-width: 0;
}

.settings-form .scraper-row .scan-scraper-btn {
    flex-shrink: 0;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 400 !important;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    accent-color: var(--primary);
}

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

/* ---- Status ---- */
.status-info {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.status-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
}

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 0.4rem;
}

.status-ok {
    background: var(--success);
}

.status-err {
    background: var(--error);
}

.error-msg {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.8rem;
    color: var(--error);
}

.runs-table td,
.runs-table th {
    font-size: 0.8rem;
    padding: 0.4rem 0.5rem;
}

/* ---- Empty state ---- */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.empty-state h2 {
    border: none;
    margin-bottom: 0.5rem;
}

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

/* ---- Footer ---- */
.footer {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 1.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
}

/* ---- Platform-specific source tags ---- */
.tag-zvg_portal {
    background: rgba(59,130,246,0.1);
    border-color: rgba(59,130,246,0.3);
    color: #2563eb;
}

.tag-zvg_online {
    background: rgba(16,185,129,0.1);
    border-color: rgba(16,185,129,0.3);
    color: #059669;
}

.tag-zvg_com {
    background: rgba(168,85,247,0.1);
    border-color: rgba(168,85,247,0.3);
    color: #7c3aed;
}

/* ---- Platform-specific buttons ---- */
.btn-source {
    font-size: 0.75rem;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    text-decoration: none;
    display: inline-block;
    margin: 1px;
    border: 1px solid transparent;
}

.btn-zvg_portal {
    background: #2563eb;
    color: #fff;
    border-color: #1d4ed8;
}

.btn-zvg_portal:hover {
    background: #1d4ed8;
}

.btn-zvg_online {
    background: #059669;
    color: #fff;
    border-color: #047857;
}

.btn-zvg_online:hover {
    background: #047857;
}

.btn-zvg_com {
    background: #7c3aed;
    color: #fff;
    border-color: #6d28d9;
}

.btn-zvg_com:hover {
    background: #6d28d9;
}

/* ZVG24: eigene Farbe, da sonst wie Kartenhintergrund (bg-card) */
.btn-zvg24 {
    background: #0d9488;
    color: #fff;
    border-color: #0f766e;
}

.btn-zvg24:hover {
    background: #0f766e;
}

/* Portal-ZVG: eigene Farbe, da sonst wie Kartenhintergrund (bg-card) */
.btn-portal_zvg {
    background: #ea580c;
    color: #fff;
    border-color: #c2410c;
}

.btn-portal_zvg:hover {
    background: #c2410c;
}

/* DGA: eigene Farbe, da sonst wie Kartenhintergrund (bg-card) */
.btn-dga {
    background: #be123c;
    color: #fff;
    border-color: #9f1239;
}

.btn-dga:hover {
    background: #9f1239;
}

/* Dinsob: eigene Farbe, da sonst wie Kartenhintergrund (bg-card) */
.btn-dinsob {
    background: #4f46e5;
    color: #fff;
    border-color: #4338ca;
}

.btn-dinsob:hover {
    background: #4338ca;
}

.source-links {
    white-space: nowrap;
}

/* ---- Detail actions with multiple buttons ---- */
.detail-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
}

.detail-actions .btn-source {
    font-size: 0.85rem;
    padding: 0.5rem 1rem;
}

/* ---- Image gallery ---- */
.detail-gallery {
    grid-column: 1 / -1;
}

/* Documents list (Gutachten / Exposé / Bekanntmachung) */
.document-list {
    list-style: none;
    margin: 0.5rem 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.document-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    text-decoration: none;
    color: var(--text);
    transition: background 0.15s, border-color 0.15s;
}

.document-link:hover {
    background: var(--bg);
    border-color: var(--primary);
}

.document-icon {
    font-size: 1.1rem;
}

.document-type {
    font-weight: 600;
}

.document-label {
    color: var(--text-muted);
    font-size: 0.85rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.document-ext {
    margin-left: auto;
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.05rem 0.35rem;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.75rem;
    margin-top: 0.75rem;
}

.gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg);
    aspect-ratio: 4 / 3;
}

.gallery-link {
    display: block;
    width: 100%;
    height: 100%;
}

.gallery-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.2s ease;
}

.gallery-thumb:hover {
    transform: scale(1.05);
}

/* ---- Lightbox overlay ---- */
.lightbox-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    cursor: pointer;
}

.lightbox-overlay.active {
    display: flex;
}

.lightbox-overlay img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    transition: background 0.2s;
}

.lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.3);
}

.lightbox-prev {
    left: 1rem;
}

.lightbox-next {
    right: 1rem;
}

.lightbox-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem 0.75rem;
    border-radius: 8px;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

@media (max-width: 1100px) and (min-width: 769px) {
    .filter-quick-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .filter-quick-actions {
        width: 100%;
        margin-left: 0;
        justify-content: flex-end;
    }

    .filter-advanced-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .filter-mobile-bar {
        display: flex;
    }

    .filter-quick-bar {
        display: none;
    }

    .filter-advanced-header {
        display: flex;
    }

    .filter-advanced-grid--mobile-core {
        display: grid;
        grid-template-columns: 1fr;
    }

    .filter-advanced-grid {
        grid-template-columns: 1fr;
    }

    .filter-advanced-options {
        grid-template-columns: 1fr;
    }

    .filter-advanced-actions .btn {
        flex: 1 1 calc(50% - 0.25rem);
    }

    .filter-collapsed-footer {
        display: none;
    }

    .detail-grid,
    .settings-grid {
        grid-template-columns: 1fr;
    }

    .navbar {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .nav-actions {
        width: 100%;
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }
}
