/* =====================================================
   DLRG Drohneneinheit - Custom Styles
   Dark/Light Theme Support
   ===================================================== */

:root {
    /* Light Theme (Default) */
    --bg-primary: #f5f5f5;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --border-color: #dee2e6;
    --shadow: rgba(0, 0, 0, 0.1);
    --dlrg-red: #e30613;
    --dlrg-red-dark: #b30510;
}

[data-theme="dark"] {
    /* Dark Theme */
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-card: #383838;
    --text-primary: #e9ecef;
    --text-secondary: #adb5bd;
    --border-color: #495057;
    --shadow: rgba(0, 0, 0, 0.5);
    --dlrg-red: #e30613;
    --dlrg-red-dark: #ff1f2e;
}

/* =====================================================
   GLOBAL STYLES
   ===================================================== */

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

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* =====================================================
   HEADER
   ===================================================== */

.app-header {
    background-color: var(--dlrg-red);
    color: white;
    padding: 1rem 2rem;
    box-shadow: 0 2px 8px var(--shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1920px;
    margin: 0 auto;
}

.unit-name {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.datetime-display {
    font-size: 1.1rem;
    font-weight: 400;
    font-variant-numeric: tabular-nums;
}

/* Theme Toggle Button */
.theme-toggle {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    margin-left: 1rem;
    transition: background 0.3s ease;
}

.user-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.admin-back-link {
    color: #fff;
    opacity: 0.9;
    text-decoration: none;
    font-size: 0.9rem;
}

.admin-back-link:hover {
    opacity: 1;
    color: #fff;
}

.theme-toggle:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Geteilter DLRG-Button-Stil (login.html, admin.html) */
.login-submit {
    background-color: var(--dlrg-red);
    border-color: var(--dlrg-red);
    color: #fff;
}

.login-submit:hover {
    background-color: var(--dlrg-red-dark);
    border-color: var(--dlrg-red-dark);
    color: #fff;
}

/* =====================================================
   MAIN CONTAINER
   ===================================================== */

.main-container {
    max-width: 1920px;
    margin: 2rem auto;
    padding: 0 2rem;
}

/* =====================================================
   GRID LAYOUT
   ===================================================== */

/* Video Grid: Hauptvorschau + Buttons + iKAT Sidebar */
.video-grid {
    display: grid;
    grid-template-columns: 1fr auto minmax(300px, 400px);
    gap: 1.5rem;
    margin-bottom: 2rem;
    align-items: stretch;
}

/* Main Preview (links) */
.main-preview {
    background-color: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 4px 12px var(--shadow);
    transition: all 0.3s ease;
    min-height: 500px;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.preview-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
}

.preview-info {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.preview-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border-radius: 4px;
    min-height: 0;
    position: relative;
    overflow: hidden;
}

.preview-placeholder {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* iKAT Sidebar (rechts) */
.ikat-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.ikat-preview {
    background-color: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 4px 12px var(--shadow);
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 240px;
    display: flex;
    flex-direction: column;
}

.ikat-preview:hover {
    border-color: var(--dlrg-red);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px var(--shadow);
}

.ikat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.ikat-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.stream-indicator {
    font-size: 0.8rem;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
}

.ikat-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border-radius: 4px;
    min-height: 150px;
    max-height: 150px;
    overflow: hidden;
}

/* Stop-Button (Vorschau & iKAT) */
.btn-stop {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1rem;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s, background 0.15s;
    line-height: 1;
    flex-shrink: 0;
    padding: 0;
}

.btn-stop:hover {
    color: var(--dlrg-red);
    background: rgba(227, 6, 19, 0.1);
}

/* iKAT Header rechte Seite (Indicator + Stop-Button) */
.ikat-header-right {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

/* =====================================================
   DROHNEN-THUMBNAILS GRID
   ===================================================== */

.thumbnails-section {
    margin-top: 2rem;
}

.section-title {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
    padding-bottom: 0.5rem;
}

.thumbnails-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
}

.thumbnail-card {
    background-color: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 4px 12px var(--shadow);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
}

.thumbnail-card:hover {
    border-color: var(--dlrg-red);
    transform: translateY(-4px);
    box-shadow: 0 8px 20px var(--shadow);
}

.thumbnail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.thumbnail-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.status-badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-weight: 500;
}

.status-active {
    background: #d4edda;
    color: #155724;
}

[data-theme="dark"] .status-active {
    background: #1e4620;
    color: #75d186;
}

.status-inactive {
    background: #f8d7da;
    color: #721c24;
}

[data-theme="dark"] .status-inactive {
    background: #4a1f23;
    color: #e8828a;
}

.thumbnail-content {
    flex: 1;
    background: var(--bg-secondary);
    border-radius: 4px;
    min-height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.thumbnail-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.thumbnail-placeholder {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* =====================================================
   RESPONSIVE
   ===================================================== */

@media (max-width: 1400px) {
    .video-grid {
        grid-template-columns: 1fr 280px;  /* Nur 2 Spalten */
    }
    
    .thumbnails-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* Buttons komplett ausblenden */
    .quick-assign-buttons-vertical {
        display: none !important;
    }
}

@media (max-width: 992px) {
    .video-grid {
        grid-template-columns: 1fr;
    }
    
    .ikat-sidebar {
        flex-direction: row;
    }
    
    .ikat-preview {
        flex: 1;
    }
}

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }
    
    .thumbnails-grid {
        grid-template-columns: 1fr;
    }
    
    .ikat-sidebar {
        flex-direction: column;
    }
}

/* =====================================================
   UTILITIES
   ===================================================== */

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

.no-select {
    user-select: none;
}

/* =====================================================
   TOGGLE SWITCH
   ===================================================== */

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--dlrg-red);
}

.section-title {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.filter-toggle {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.filter-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    user-select: none;
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border-color);
    transition: 0.3s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--dlrg-red);
}

input:checked + .slider:before {
    transform: translateX(26px);
}

.slider:hover {
    opacity: 0.9;
}

/* =====================================================
   STREAM ASSIGNER
   ===================================================== */

/* Quick-Assign Buttons (vertikal zwischen Vorschau und Sidebar) */
.quick-assign-buttons-vertical {
    display: flex;
    flex-direction: column;
    justify-content: space-around;  /* ← Verteilt Buttons auf Höhe */
    align-items: center;
    width: 50px;  /* ← Schmaler */
    height: 100%;
    padding: 2rem 0;  /* ← Etwas Abstand oben/unten */
}

.btn-assign-vertical {
    width: 45px;  /* ← Kleiner */
    height: 45px;
    background: var(--dlrg-red);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.5rem;  /* ← Kleinerer Pfeil */
    font-weight: 700;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(227, 6, 19, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 0;
    line-height: 1;  /* ← Wichtig für vertikale Zentrierung */
}

.btn-assign-vertical:hover {
    background: var(--dlrg-red-dark);
    transform: scale(1.15);
    box-shadow: 0 6px 16px rgba(227, 6, 19, 0.6);
}

.btn-assign-vertical:active {
    transform: scale(0.95);
}

.btn-assign-vertical:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    transform: none;
}

.btn-assign-vertical .arrow {
    display: block;
    line-height: 1;
    margin-top: -2px;  /* ← Feintuning für optische Zentrierung */
}

/* Drag & Drop */
.thumbnail-card {
    cursor: grab;
}

.thumbnail-card.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.ikat-preview.drag-over {
    outline: 3px dashed var(--primary);
    background: rgba(0, 123, 255, 0.1);
}

/* Kontext-Menü */
.context-menu {
    position: fixed;
    background: var(--bg-card);       /* war: var(--card-bg) */
    border: 2px solid var(--dlrg-red);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    padding: 0.25rem 0;
    min-width: 220px;
    z-index: 9999;
    display: none;
}

.context-menu.active {
    display: block;
}

.context-menu-item {
    padding: 0.5rem 1rem;
    cursor: pointer;
    transition: background 0.15s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-primary);
    background: var(--bg-card);       /* war: var(--card-bg) */
}

.context-menu-item:hover {
    background: var(--dlrg-red);
    color: white;
}

.context-menu-item.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: var(--bg-card);       /* war: var(--card-bg) */
}

.context-menu-item.disabled:hover {
    background: var(--bg-card);       /* war: var(--card-bg) */
    color: var(--text-primary);
}

.stream-status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.stream-status-indicator.online {
    background: var(--success);
    box-shadow: 0 0 4px var(--success);
}

.stream-status-indicator.offline {
    background: var(--border);
}

/* Footer */
.app-footer {
    text-align: center;
    padding: 2rem;
    margin-top: 2rem;
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.download-link {
    color: var(--dlrg-red);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.3s ease;
}

.download-link:hover {
    text-decoration: underline;
    color: var(--dlrg-red-dark);
}
