/* ============================================
   MAPTAK - DEFENCE SOFTWARE STYLE
   Tactical Command & Control Interface
   ============================================ */

/* Import tactical font */
@import url('https://fonts.googleapis.com/css2?family=Share+Tech+Mono&family=Orbitron:wght@400;500;700&display=swap');

/* Prevent page zooming - only map should be zoomable */
html, body {
    touch-action: pan-x pan-y;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

/* Map container should allow zooming */
#map {
    touch-action: none; /* Leaflet handles touch events */
}

/* CSS Custom Properties - Defence Theme */
:root {
    --bg-primary: #0a0e14;
    --bg-secondary: #0f1419;
    --bg-panel: rgba(10, 14, 20, 0.92);
    --bg-panel-hover: rgba(15, 25, 35, 0.95);
    
    --border-primary: #1a3a4a;
    --border-accent: #00d4aa;
    --border-warning: #ff6b35;
    --border-danger: #ff3366;
    
    --text-primary: #e0f0e8;
    --text-secondary: #8ba89e;
    --text-accent: #00ffcc;
    --text-warning: #ffaa00;
    --text-danger: #ff4466;
    
    --accent-cyan: #00d4aa;
    --accent-blue: #0099ff;
    --accent-green: #00ff88;
    --accent-amber: #ffaa00;
    
    --glow-cyan: 0 0 10px rgba(0, 212, 170, 0.5), 0 0 20px rgba(0, 212, 170, 0.2);
    --glow-strong: 0 0 15px rgba(0, 212, 170, 0.6), 0 0 30px rgba(0, 212, 170, 0.3);
    
    --font-mono: 'Share Tech Mono', 'Courier New', monospace;
    --font-display: 'Orbitron', 'Share Tech Mono', sans-serif;
    
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
}

/* Reset & Base */
* {
    box-sizing: border-box;
}

html,
body,
#map {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background: var(--bg-primary);
}

body {
    font-family: var(--font-mono);
    color: var(--text-primary);
}

/* Scanline overlay effect */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 9999;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 20, 30, 0.03) 2px,
        rgba(0, 20, 30, 0.03) 4px
    );
}

/* ============================================
   CONTROL PANEL - Bottom HUD
   ============================================ */
#controls-wrapper {
    position: absolute;
    bottom: 15px;
    left: 15px;
    z-index: 1001;
    max-width: calc(100vw - 30px);
}

#controls {
    background: var(--bg-panel);
    padding: 12px 16px;
    border: 1px solid var(--border-primary);
    border-left: 3px solid var(--accent-cyan);
    box-shadow: 
        var(--glow-cyan),
        inset 0 0 30px rgba(0, 212, 170, 0.03);
    font-family: var(--font-mono);
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    align-items: center;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    animation: panelFadeIn 0.5s ease-out;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-cyan, #00d4aa) transparent;
}

/* Custom Scrollbar für Controls */
#controls::-webkit-scrollbar {
    height: 6px;
}

#controls::-webkit-scrollbar-track {
    background: rgba(10, 14, 20, 0.5);
    border-radius: 3px;
}

#controls::-webkit-scrollbar-thumb {
    background: var(--accent-cyan, #00d4aa);
    border-radius: 3px;
    box-shadow: 0 0 4px rgba(0, 212, 170, 0.5);
}

#controls::-webkit-scrollbar-thumb:hover {
    background: var(--accent-green, #00ff88);
    box-shadow: 0 0 6px rgba(0, 255, 136, 0.7);
}

@keyframes panelFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Corner accents for panel - fixed to visible right edge */
#controls-wrapper::before,
#controls-wrapper::after {
    content: '';
    position: absolute;
    width: 12px;
    height: 12px;
    border-color: var(--accent-cyan);
    pointer-events: none;
    z-index: 1002;
    right: -1px;
}

#controls-wrapper::before {
    top: -1px;
    border-top: 2px solid;
    border-right: 2px solid;
}

#controls-wrapper::after {
    bottom: -1px;
    border-bottom: 2px solid;
    border-right: 2px solid;
}

/* ============================================
   BUTTONS - Tactical Style
   ============================================ */
#controls button,
#controls a {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    padding: 8px 14px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, rgba(20, 35, 45, 0.9) 0%, rgba(10, 20, 30, 0.95) 100%);
    color: var(--text-primary);
    border: 1px solid var(--border-primary);
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
    box-sizing: border-box;
    flex-shrink: 0;
    white-space: nowrap;
}

#controls button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(0, 212, 170, 0.1), transparent);
    transition: left 0.4s ease;
}

#controls button:hover::before {
    left: 100%;
}

#controls button:hover,
#controls a:hover {
    background: linear-gradient(180deg, rgba(0, 50, 60, 0.9) 0%, rgba(0, 30, 40, 0.95) 100%);
    border-color: var(--accent-cyan);
    color: var(--text-accent);
    box-shadow: var(--glow-cyan);
    transform: translateY(-1px);
}

#controls button:active {
    transform: translateY(0);
    box-shadow: inset 0 0 10px rgba(0, 212, 170, 0.3);
}

/* Position Info Anzeige */
.position-info {
    margin-left: 12px;
    padding-left: 12px;
    border-left: 1px solid var(--border-primary);
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 10px;
    line-height: 1.2;
    color: var(--text-secondary);
    font-family: 'Share Tech Mono', monospace;
    white-space: nowrap;
}

.position-info-line {
    display: flex;
    gap: 6px;
    align-items: baseline;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 2px;
    transition: all var(--transition-fast);
}

.position-info-line:hover {
    background: rgba(0, 212, 170, 0.1);
    border: 1px solid var(--accent-cyan);
}

.position-label {
    color: var(--accent-cyan, #00d4aa);
    font-weight: bold;
    min-width: 35px;
}

.position-value {
    color: var(--text-primary);
    font-family: 'Courier New', monospace;
    letter-spacing: 0.5px;
}

/* Active tool indicator */
#controls button.active {
    background: linear-gradient(180deg, rgba(0, 60, 50, 0.9) 0%, rgba(0, 40, 35, 0.95) 100%);
    border-color: var(--accent-cyan);
    color: var(--text-accent);
    box-shadow: var(--glow-cyan);
}

#controls button.active::after {
    content: '';
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    height: 2px;
    background: var(--accent-cyan);
    box-shadow: 0 0 8px var(--accent-cyan);
}

/* GPS Control Button - Passend zu Leaflet Controls */
.gps-control {
    margin-top: 10px !important;
    border: 1px solid var(--border-primary) !important;
    box-shadow: var(--glow-cyan) !important;
    border-radius: 0 !important;
    overflow: hidden;
    background: var(--bg-panel) !important;
}

.gps-button {
    width: 30px;
    height: 30px;
    line-height: 30px;
    text-align: center;
    display: block;
    text-decoration: none;
    color: var(--text-primary) !important;
    background: linear-gradient(180deg, rgba(20, 35, 45, 0.9) 0%, rgba(10, 20, 30, 0.95) 100%) !important;
    border: none !important;
    border-bottom: 1px solid var(--border-primary) !important;
    font-size: 16px;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: var(--font-mono);
}

.gps-button:last-child {
    border-bottom: none !important;
}

.gps-button:hover {
    background: linear-gradient(180deg, rgba(0, 50, 60, 0.9) 0%, rgba(0, 30, 40, 0.95) 100%) !important;
    color: var(--text-accent) !important;
    box-shadow: var(--glow-cyan);
}

.gps-button.gps-found {
    color: var(--accent-green) !important;
    background: linear-gradient(180deg, rgba(0, 40, 30, 0.9) 0%, rgba(0, 25, 20, 0.95) 100%) !important;
    box-shadow: 0 0 8px rgba(0, 255, 136, 0.4);
    animation: gpsPulse 2s ease-in-out infinite;
}

.gps-button.gps-found:hover {
    background: linear-gradient(180deg, rgba(0, 60, 45, 0.9) 0%, rgba(0, 40, 30, 0.95) 100%) !important;
    box-shadow: 0 0 15px rgba(0, 255, 136, 0.7);
}

@keyframes gpsPulse {
    0%, 100% {
        box-shadow: 0 0 8px rgba(0, 255, 136, 0.4);
    }
    50% {
        box-shadow: 0 0 15px rgba(0, 255, 136, 0.7);
    }
}

/* ============================================
   COLOR PICKER - Tactical Style
   ============================================ */
#color-picker-container {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 40px;
    padding: 4px 8px;
    background: linear-gradient(180deg, rgba(20, 35, 45, 0.9) 0%, rgba(10, 20, 30, 0.95) 100%);
    border: 1px solid var(--border-primary);
    box-sizing: border-box;
    flex-shrink: 0;
    white-space: nowrap;
}

#color-picker-container label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-right: 6px;
}

#color-picker {
    width: 28px;
    height: 28px;
    padding: 0;
    border: 2px solid var(--border-primary);
    background: var(--bg-secondary);
    cursor: pointer;
    transition: border-color var(--transition-fast);
}

#color-picker:hover {
    border-color: var(--accent-cyan);
}

/* ============================================
   ROOM NAME - Status Display (Clickable)
   ============================================ */
#room-name {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-secondary);
    padding: 6px 12px;
    background: rgba(0, 212, 170, 0.08);
    border: 1px solid var(--border-primary);
    border-left: 2px solid var(--accent-green);
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all var(--transition-fast);
    user-select: none;
}

#room-name:hover {
    background: rgba(0, 212, 170, 0.15);
    border-color: var(--accent-cyan);
    color: var(--text-accent);
    box-shadow: 0 0 8px rgba(0, 212, 170, 0.3);
}

#room-name:active {
    transform: scale(0.98);
    box-shadow: inset 0 0 10px rgba(0, 212, 170, 0.2);
}

/* Sidebar styles are in icon_navbar.css */

/* ============================================
   CONNECTION STATUS - Warning Indicator
   ============================================ */
#connection-status {
    position: fixed;
    z-index: 1002;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    transition: opacity 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(255, 68, 102, 0.15);
    border: 1px solid var(--border-danger);
    border-top: 3px solid var(--text-danger);
    color: var(--text-danger);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

#connection-status.visible {
    opacity: 1;
    animation: warningPulse 2s ease-in-out infinite;
}

@keyframes warningPulse {
    0%, 100% { 
        box-shadow: 0 0 10px rgba(255, 68, 102, 0.3);
    }
    50% { 
        box-shadow: 0 0 20px rgba(255, 68, 102, 0.5);
    }
}

#connection-status i {
    font-size: 1.2rem;
}

#connection-status::after {
    content: 'VERBINDUNG UNTERBROCHEN';
}


/* ============================================
   MODAL - Tactical Dialog
   ============================================ */
.modal {
    background: var(--bg-panel) !important;
    border: 1px solid var(--border-primary) !important;
    border-top: 3px solid var(--accent-cyan) !important;
    box-shadow: 
        var(--glow-strong),
        0 20px 60px rgba(0, 0, 0, 0.6) !important;
    border-radius: 0 !important;
    max-width: 450px;
    max-height: 90vh; /* Desktop: angemessene Höhe */
}

/* iOS Safari spezifische Fixes */
@supports (-webkit-touch-callout: none) {
    .modal {
        max-height: 100dvh; /* iOS: volle Höhe */
    }
    
    @supports (height: -webkit-fill-available) {
        .modal {
            max-height: -webkit-fill-available;
        }
    }
}

.modal::before {
    content: '◢ SYSTEM INPUT ◣';
    position: absolute;
    top: 8px;
    left: 16px;
    font-family: var(--font-display);
    font-size: 0.65rem;
    color: var(--accent-cyan);
    letter-spacing: 2px;
    opacity: 0.7;
}

.modal-content {
    padding: 30px 24px 16px;
    max-height: calc(90vh - 100px); /* Desktop: angemessene Höhe */
    overflow-y: auto;
    box-sizing: border-box;
}

/* iOS Safari spezifische Fixes */
@supports (-webkit-touch-callout: none) {
    .modal-content {
        max-height: calc(100dvh - 100px); /* iOS: volle Höhe */
    }
    
    @supports (height: -webkit-fill-available) {
        .modal-content {
            max-height: calc(-webkit-fill-available - 100px);
        }
    }
}

.modal-content h4 {
    font-family: var(--font-display);
    font-size: 1.1rem;
    color: var(--text-accent);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-primary);
}

.modal-content p {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.modal-content input[type="text"] {
    background: var(--bg-secondary) !important;
    border: 1px solid var(--border-primary) !important;
    border-left: 3px solid var(--accent-cyan) !important;
    color: var(--text-primary) !important;
    font-family: var(--font-mono) !important;
    font-size: 0.9rem !important;
    padding: 12px !important;
    margin-bottom: 0 !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    transition: all var(--transition-fast);
}

.modal-content input[type="text"]:focus {
    border-color: var(--accent-cyan) !important;
    box-shadow: var(--glow-cyan) !important;
}

.modal-content input[type="text"]::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

.modal-footer {
    background: rgba(0, 30, 40, 0.5) !important;
    padding: 12px 16px !important;
    border-top: 1px solid var(--border-primary) !important;
}

.modal-footer .btn {
    background: linear-gradient(180deg, rgba(0, 60, 50, 0.9) 0%, rgba(0, 40, 35, 0.95) 100%) !important;
    border: 1px solid var(--accent-cyan) !important;
    color: var(--text-accent) !important;
    font-family: var(--font-mono) !important;
    text-transform: uppercase !important;
    letter-spacing: 1px !important;
    box-shadow: var(--glow-cyan) !important;
    border-radius: 0 !important;
    transition: all var(--transition-fast);
}

.modal-footer .btn:hover {
    background: linear-gradient(180deg, rgba(0, 80, 70, 0.9) 0%, rgba(0, 60, 50, 0.95) 100%) !important;
    box-shadow: var(--glow-strong) !important;
}

/* Modal overlay */
.modal-overlay {
    background: rgba(0, 10, 15, 0.85) !important;
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */
.toast {
    background: var(--bg-panel) !important;
    border: 1px solid var(--border-primary) !important;
    border-left: 3px solid var(--accent-cyan) !important;
    color: var(--text-primary) !important;
    font-family: var(--font-mono) !important;
    font-size: 0.8rem !important;
    border-radius: 0 !important;
    box-shadow: var(--glow-cyan) !important;
}

/* ============================================
   LEAFLET MAP CUSTOMIZATION
   ============================================ */
.leaflet-container {
    background: var(--bg-primary);
    font-family: var(--font-mono);
}

/* Leaflet Controls */
.leaflet-control-zoom {
    border: 1px solid var(--border-primary) !important;
    box-shadow: var(--glow-cyan) !important;
    border-radius: 0 !important;
    overflow: hidden;
}

.leaflet-control-zoom a {
    background: var(--bg-panel) !important;
    color: var(--text-accent) !important;
    border: none !important;
    border-bottom: 1px solid var(--border-primary) !important;
    font-family: var(--font-mono) !important;
    transition: all var(--transition-fast);
}

.leaflet-control-zoom a:last-child {
    border-bottom: none !important;
}

.leaflet-control-zoom a:hover {
    background: rgba(0, 50, 60, 0.9) !important;
    color: var(--text-accent) !important;
}

/* Leaflet Attribution */
.leaflet-control-attribution {
    background: var(--bg-panel) !important;
    color: var(--text-secondary) !important;
    font-family: var(--font-mono) !important;
    font-size: 0.65rem !important;
    padding: 2px 8px !important;
    border-top: 1px solid var(--border-primary) !important;
    border-left: 1px solid var(--border-primary) !important;
}

.leaflet-control-attribution a {
    color: var(--accent-cyan) !important;
}

/* Leaflet Popup */
.leaflet-popup-content-wrapper {
    background: var(--bg-panel) !important;
    border: 1px solid var(--border-primary) !important;
    border-radius: 0 !important;
    box-shadow: var(--glow-cyan) !important;
}

.leaflet-popup-content {
    color: var(--text-primary) !important;
    font-family: var(--font-mono) !important;
    font-size: 0.8rem !important;
}

.leaflet-popup-tip {
    background: var(--bg-panel) !important;
    border: 1px solid var(--border-primary) !important;
    box-shadow: none !important;
}

/* Leaflet Tooltip */
.leaflet-tooltip {
    background: var(--bg-panel) !important;
    border: 1px solid var(--border-primary) !important;
    border-radius: 0 !important;
    color: var(--text-accent) !important;
    font-family: var(--font-mono) !important;
    font-size: 0.7rem !important;
    padding: 4px 8px !important;
    box-shadow: var(--glow-cyan) !important;
    white-space: nowrap;
}

.leaflet-tooltip::before {
    border-bottom-color: var(--border-primary) !important;
}

/* ============================================
   RESPONSIVE - Mobile Tactical View
   ============================================ */
@media (max-width: 600px) {
    #controls-wrapper {
        bottom: 12px;
        left: 8px;
        right: 8px;
        max-width: calc(100vw - 16px);
    }
    
    #controls {
        justify-content: flex-start;
        padding: 10px 12px;
        gap: 6px;
        overflow-x: auto;
        overflow-y: hidden;
    }

    #controls button {
        font-size: 0.7rem;
        padding: 6px 10px;
        height: 36px;
        flex-shrink: 0;
    }
    
    #color-picker-container {
        height: 36px;
        flex-shrink: 0;
    }

    #room-name {
        font-size: 0.65rem;
        padding: 4px 8px;
        width: 100%;
        text-align: center;
        order: -1;
    }
    
    #connection-status {
        font-size: 0.65rem;
        padding: 6px 12px;
    }
    
    #connection-status::after {
        content: 'OFFLINE';
    }

    .modal {
        width: calc(100vw - 16px) !important;
        max-width: none !important;
        max-height: calc(100dvh - 16px);
        margin: 0 8px !important;
    }
    
    .modal-content {
        padding: 20px 16px !important;
        max-height: calc(100dvh - 120px);
        overflow-y: auto;
        box-sizing: border-box;
    }
    
    /* iOS Safari spezifische Fixes */
    @supports (-webkit-touch-callout: none) {
        .modal {
            max-height: calc(-webkit-fill-available - 16px) !important;
        }
        
        .modal-content {
            max-height: calc(-webkit-fill-available - 120px) !important;
        }
    }
    
    .modal-content h4 {
        font-size: 0.9rem !important;
        padding: 12px 16px !important;
        margin-bottom: 12px !important;
    }
    
    .modal-content p {
        font-size: 0.8rem !important;
        margin-bottom: 10px !important;
    }
    
    .modal-content input[type="text"] {
        padding: 10px 12px !important;
        font-size: 0.85rem !important;
        width: 100% !important;
    }
    
    .modal-footer {
        padding: 12px 16px !important;
        flex-direction: column !important;
        gap: 8px !important;
    }
    
    .modal-footer .btn {
        width: 100% !important;
        padding: 12px 16px !important;
        font-size: 0.85rem !important;
    }
    
    /* Join Session Modal spezifisch */
    #join-room-modal .modal-content {
        padding: 16px !important;
    }
    
    #join-room-modal input[type="text"] {
        margin-bottom: 12px !important;
    }
}

/* ============================================
   SCROLLBAR - Tactical Style
   ============================================ */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-primary);
    border: 1px solid var(--accent-cyan);
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 212, 170, 0.3);
}

/* Firefox scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--border-primary) var(--bg-secondary);
}

/* ============================================
   SELECTION STYLE
   ============================================ */
::selection {
    background: rgba(0, 212, 170, 0.3);
    color: var(--text-accent);
}

/* ============================================
   GRID OVERLAY (Optional - Subtle)
   ============================================ */
#map::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 500;
    background-image: 
        linear-gradient(rgba(0, 212, 170, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 212, 170, 0.02) 1px, transparent 1px);
    background-size: 50px 50px;
}
