/* ============================================
   Datenexport-Modul - Styling
   ============================================ */

/* Panel */
#datenexport-panel {
    padding: 0;
    /* Sidebar-Tab ist overflow:hidden + flex column → Panel muss selbst scrollen */
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

.datenexport-form {
    padding: 10px;
    /* Extra Platz unten, damit der letzte Button nicht hinter dem Footer verschwindet */
    padding-bottom: 100px;
}

.datenexport-form-group {
    margin-bottom: 12px;
}

.datenexport-form-group > label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary, #555);
    margin-bottom: 4px;
}

/* Layer-Suche */
.datenexport-layer-search-wrap {
    position: relative;
    margin-bottom: 4px;
}

.datenexport-layer-search {
    width: 100%;
    padding: 6px 28px 6px 8px;
    border: 1px solid var(--border-color, #ccc);
    border-radius: 4px;
    font-size: 13px;
    background: #fff;
    box-sizing: border-box;
}

.datenexport-layer-search:focus {
    border-color: var(--primary-color, #8B0000);
    outline: none;
    box-shadow: 0 0 0 2px rgba(139, 0, 0, 0.15);
}

.datenexport-layer-search-clear {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    padding: 2px 4px;
    font-size: 12px;
    line-height: 1;
}

.datenexport-layer-search-clear:hover {
    color: #333;
}

#datenexport-layer-select {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid var(--border-color, #ccc);
    border-radius: 4px;
    font-size: 13px;
    background: #fff;
    cursor: pointer;
}

#datenexport-layer-select[size] {
    height: auto;
    max-height: 140px;
    overflow-y: auto;
}

#datenexport-layer-select:focus {
    border-color: var(--primary-color, #8B0000);
    outline: none;
    box-shadow: 0 0 0 2px rgba(139, 0, 0, 0.15);
}

/* Format-Auswahl */
#datenexport-format-options {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.datenexport-format-label {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    border: 1px solid var(--border-color, #ddd);
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s ease;
    background: #fff;
    user-select: none;
}

.datenexport-format-label:hover {
    border-color: var(--primary-color, #8B0000);
    background: #fafafa;
}

.datenexport-format-label input[type="radio"] {
    display: none;
}

.datenexport-format-label input[type="radio"]:checked + i {
    color: var(--primary-color, #8B0000);
}

.datenexport-format-label:has(input:checked) {
    border-color: var(--primary-color, #8B0000);
    background: rgba(139, 0, 0, 0.05);
    font-weight: 600;
}

.datenexport-format-label i {
    font-size: 13px;
    color: #888;
    width: 16px;
    text-align: center;
}

/* Spalten-Auswahl */
#datenexport-columns-container {
    display: none;
}

.datenexport-columns-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.datenexport-columns-header label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary, #555);
}

.datenexport-columns-header .datenexport-select-all-label {
    font-size: 11px;
    font-weight: 400;
    color: #888;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
}

#datenexport-columns-list {
    max-height: 250px;
    overflow-y: auto;
    border: 1px solid var(--border-color, #ddd);
    border-radius: 4px;
    background: #fff;
}

.datenexport-column-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 8px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 12px;
}

.datenexport-column-item:last-child {
    border-bottom: none;
}

.datenexport-column-item:hover {
    background: #f8f8f8;
}

.datenexport-column-item label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    flex: 1;
    min-width: 0;
}

.datenexport-column-name {
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.datenexport-column-type {
    font-size: 10px;
    color: #999;
    white-space: nowrap;
    margin-left: 8px;
}

.datenexport-badge {
    font-size: 9px;
    padding: 1px 5px;
    border-radius: 3px;
    font-weight: 600;
    white-space: nowrap;
}

.datenexport-badge-geo {
    background: #e3f2fd;
    color: #1565c0;
}

/* Optionen-Bereiche */
#datenexport-csv-options,
#datenexport-geo-options {
    display: none;
    padding: 10px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 4px;
    margin-top: 4px;
}

.datenexport-options-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary, #555);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.datenexport-option-row {
    display: flex;
    gap: 10px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.datenexport-option-row:last-child {
    margin-bottom: 0;
}

.datenexport-option-group {
    flex: 1;
    min-width: 100px;
}

.datenexport-option-group label {
    display: block;
    font-size: 11px;
    color: #666;
    margin-bottom: 3px;
}

.datenexport-option-group select,
.datenexport-option-group input[type="text"],
.datenexport-option-group input[type="number"] {
    width: 100%;
    padding: 4px 6px;
    border: 1px solid #ccc;
    border-radius: 3px;
    font-size: 12px;
    background: #fff;
}

.datenexport-checkbox-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    cursor: pointer;
}

/* SRID-Buttons */
.datenexport-srid-row {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-wrap: wrap;
}

.datenexport-srid-row input {
    width: 80px !important;
    flex-shrink: 0;
}

.datenexport-srid-btn {
    padding: 3px 6px;
    font-size: 10px;
    border: 1px solid #ccc;
    border-radius: 3px;
    background: #fff;
    cursor: pointer;
    white-space: nowrap;
}

.datenexport-srid-btn:hover {
    border-color: var(--primary-color, #8B0000);
    color: var(--primary-color, #8B0000);
}

/* Info-Zeile */
#datenexport-info {
    font-size: 11px;
    color: #888;
    padding: 4px 0;
    min-height: 20px;
}

/* Export-Button */
#datenexport-btn {
    width: 100%;
    padding: 9px 16px;
    background: var(--primary-color, #8B0000);
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.15s ease;
}

#datenexport-btn:hover:not(:disabled) {
    background: var(--primary-hover, #d90000);
}

#datenexport-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Loading / Exporting */
#datenexport-loading,
#datenexport-exporting {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    font-size: 12px;
    color: #666;
}

#datenexport-loading .spinner,
#datenexport-exporting .spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #ddd;
    border-top-color: var(--primary-color, #8B0000);
    border-radius: 50%;
    animation: datenexport-spin 0.6s linear infinite;
}

@keyframes datenexport-spin {
    to { transform: rotate(360deg); }
}

/* Meldungen */
.datenexport-message {
    display: none;
    padding: 8px 10px;
    border-radius: 4px;
    font-size: 12px;
    margin-bottom: 8px;
}

.datenexport-message-success {
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #c8e6c9;
}

.datenexport-message-error {
    background: #fbe9e7;
    color: #c62828;
    border: 1px solid #ffccbc;
}

.datenexport-message-warning {
    background: #fff8e1;
    color: #f57f17;
    border: 1px solid #ffecb3;
}

.datenexport-message-info {
    background: #e3f2fd;
    color: #1565c0;
    border: 1px solid #bbdefb;
}

/* BBox / Räumlicher Filter */
.datenexport-bbox-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.datenexport-bbox-btn {
    padding: 5px 10px;
    font-size: 12px;
    border: 1px solid var(--border-color, #ccc);
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.15s ease;
}

.datenexport-bbox-btn:hover {
    border-color: var(--primary-color, #8B0000);
    color: var(--primary-color, #8B0000);
}

.datenexport-bbox-btn.active {
    border-color: var(--primary-color, #8B0000);
    background: rgba(139, 0, 0, 0.08);
    color: var(--primary-color, #8B0000);
    font-weight: 600;
}

.datenexport-bbox-btn-clear {
    padding: 5px 7px;
    color: #c62828;
    border-color: #e57373;
}

.datenexport-bbox-btn-clear:hover {
    background: #fbe9e7;
    border-color: #c62828;
    color: #c62828;
}

.datenexport-bbox-info {
    font-size: 11px;
    color: var(--primary-color, #8B0000);
    font-weight: 600;
    white-space: nowrap;
}

/* Trennlinie */
.datenexport-divider {
    border: none;
    border-top: 1px solid #e9ecef;
    margin: 10px 0;
}
