/**
 * Enhanced Sidebar Styles - Adaptiert von Standalone-Global
 * Enthält: Einklappbare Sidebar, Collapsible Sektionen, Warnungen, Chronik
 */

/* ===== Sidebar Collapse Toggle ===== */
.sidebar-collapse-toggle {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    background: var(--primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    transition: transform 0.3s ease, background 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.sidebar-collapse-toggle:hover {
    background: var(--primary-hover);
}

.sidebar-collapse-toggle i {
    font-size: 12px;
    color: white;
    transition: transform 0.3s ease;
}

/* Sidebar needs relative positioning for the toggle */
.sidebar-left {
    position: relative;
    padding-top: 40px;
    transition: width 0.3s ease, min-width 0.3s ease;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}

.sidebar-left::-webkit-scrollbar {
    display: none; /* Chrome/Safari/Opera */
}

/* ===== Collapsed Sidebar State ===== */
.sidebar-left.collapsed {
    width: 50px !important;
    min-width: 50px !important;
}

.sidebar-left.collapsed .sidebar-collapse-toggle i {
    transform: rotate(180deg);
}

.sidebar-left.collapsed .sidebar-section {
    padding: 0;
}

.sidebar-left.collapsed .sidebar-header {
    padding: 12px 0;
    justify-content: center;
}

.sidebar-left.collapsed .sidebar-header h2 {
    font-size: 0;
    overflow: hidden;
}

.sidebar-left.collapsed .sidebar-header h2 i {
    font-size: 16px;
    margin: 0;
}

.sidebar-left.collapsed .sidebar-header-actions,
.sidebar-left.collapsed .collapsible-content,
.sidebar-left.collapsed .btn-collapse,
.sidebar-left.collapsed .operations-list,
.sidebar-left.collapsed .layers-list,
.sidebar-left.collapsed .wind-display,
.sidebar-left.collapsed .visibility-controls,
.sidebar-left.collapsed .warnings-content,
.sidebar-left.collapsed .chronik-list,
.sidebar-left.collapsed .dispersion-timeline-sidebar,
.sidebar-left.collapsed .dispersion-no-data,
.sidebar-left.collapsed .saved-plumes-section {
    display: none !important;
}

.sidebar-left.collapsed .sidebar-header.collapsible-header {
    cursor: pointer;
}

.sidebar-left.collapsed .sidebar-header.collapsible-header:hover {
    background: var(--bg-tertiary);
}

/* Update grid when sidebar is collapsed */
.main-content:has(.sidebar-left.collapsed) {
    grid-template-columns: 50px 1fr;
}

/* ===== Collapsible Sidebar Sections ===== */
.sidebar-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.collapsible-header {
    cursor: pointer;
    user-select: none;
}

.collapsible-header:hover {
    background: rgba(255, 255, 255, 0.03);
}

.btn-collapse {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    width: 28px;
    height: 28px;
}

.btn-collapse:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-collapse i {
    transition: transform 0.3s ease;
}

.collapsible-content {
    padding: 0 15px 15px 15px;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease, opacity 0.3s ease;
    max-height: 1000px;
    opacity: 1;
}

.sidebar-section.collapsed .collapsible-content {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    opacity: 0;
}

.sidebar-section.collapsed .btn-collapse i {
    transform: rotate(-90deg);
}

/* ===== Warnings Section ===== */
.warnings-status {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    margin-bottom: 10px;
    font-size: 12px;
}

.status-online {
    color: var(--success-color);
}

.status-offline {
    color: var(--danger-color);
}

.status-online i,
.status-offline i {
    font-size: 8px;
    margin-right: 4px;
}

#warnings-last-update {
    color: var(--text-muted);
}

.warnings-controls {
    margin-top: 8px;
}

.sub-controls {
    margin-left: 20px;
    padding-left: 10px;
    border-left: 2px solid var(--border-color);
}

.sub-item {
    font-size: 12px;
    opacity: 0.9;
}

/* ===== Chronik (History Log) Section ===== */
.chronik-list {
    padding: 5px 0;
    max-height: 400px;
    overflow-y: auto;
}

.chronik-entry {
    display: flex;
    gap: 10px;
    padding: 8px;
    border-bottom: 1px solid var(--border-color);
    font-size: 12px;
}

.chronik-entry:last-child {
    border-bottom: none;
}

.chronik-time {
    color: var(--text-muted);
    font-size: 11px;
    min-width: 70px;
    flex-shrink: 0;
}

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

.chronik-action {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    margin-right: 6px;
}

.chronik-action.action-create {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
}

.chronik-action.action-update {
    background: rgba(59, 130, 246, 0.2);
    color: #3b82f6;
}

.chronik-action.action-delete {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.chronik-action.action-move {
    background: rgba(168, 85, 247, 0.2);
    color: #a855f7;
}

.chronik-action.action-import {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
}

.chronik-action.action-export {
    background: rgba(249, 115, 22, 0.2);
    color: #f97316;
}

.chronik-target {
    color: var(--text-primary);
}

.chronik-details {
    color: var(--text-muted);
    font-size: 11px;
    margin-top: 3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ===== Selected Unit Section ===== */
.selected-unit-section {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.selected-unit-header {
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.selected-unit-header h3 {
    font-size: 12px;
    color: #9ca3af;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.selected-unit-header .btn-icon {
    background: transparent;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    padding: 4px;
    font-size: 12px;
    transition: color 0.2s ease;
}

.selected-unit-header .btn-icon:hover {
    color: #ef4444;
}

.selected-unit-content {
    background: rgba(255, 255, 255, 0.02);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 12px;
}

.selected-unit-symbol {
    text-align: center;
    margin-bottom: 12px;
}

.selected-unit-symbol img {
    max-width: 80px;
    max-height: 80px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    padding: 8px;
}

.selected-unit-symbol .emoji-symbol {
    font-size: 48px;
}

.selected-unit-details {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.selected-unit-detail {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.selected-unit-detail label {
    font-size: 10px;
    color: #9ca3af;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.selected-unit-detail span {
    font-size: 13px;
    color: #e2e8f0;
}

.selected-unit-actions {
    margin-top: 12px;
    display: flex;
    gap: 8px;
}

.selected-unit-actions button {
    flex: 1;
    padding: 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.selected-unit-edit {
    background: rgba(59, 130, 246, 0.2);
    border: 1px solid rgba(59, 130, 246, 0.4);
    color: #60a5fa;
}

.selected-unit-edit:hover {
    background: rgba(59, 130, 246, 0.3);
    border-color: rgba(59, 130, 246, 0.6);
}

.selected-unit-delete {
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #f87171;
}

.selected-unit-delete:hover {
    background: rgba(239, 68, 68, 0.3);
    border-color: rgba(239, 68, 68, 0.6);
}

/* ===== Tiles Left (vertical, left side of map) ===== */
.tiles-left {
    display: grid;
    grid-template-rows: repeat(auto-fit, minmax(90px, 1fr));
    gap: 8px;
    width: clamp(110px, 8vw, 140px);
    overflow: hidden;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px;
}

.tiles-left .tile {
    width: 100%;
    height: 100%;
    min-height: 90px;
}

/* ===== Enhanced Visibility Controls ===== */
.visibility-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.visibility-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: var(--bg-tertiary);
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s;
}

.visibility-item:hover {
    background: #3b4a5f;
}

.visibility-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.visibility-item span {
    flex: 1;
}

/* ===== Operation Actions (Edit/Delete buttons) ===== */
.operation-actions {
    display: flex;
    gap: 4px;
    align-items: center;
}

.operation-delete-btn,
.operation-edit-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.operation-delete-btn:hover {
    background: #dc2626;
    color: white;
}

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

/* ===== Map Controls Enhanced ===== */
.map-control-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* ===== Responsive Adjustments ===== */
@media (max-width: 1200px) {
    .tiles-left {
        display: none;
    }
}

@media (max-width: 768px) {
    .sidebar-collapse-toggle {
        display: none;
    }

    .sidebar-left.collapsed {
        width: var(--sidebar-width) !important;
        min-width: var(--sidebar-width) !important;
    }

    .sidebar-left.collapsed .sidebar-header-actions,
    .sidebar-left.collapsed .collapsible-content,
    .sidebar-left.collapsed .btn-collapse {
        display: flex !important;
    }
}
