/**
 * Floodie SOS Operations Command & Triage Styling
 * 009-bkk-flood-public
 */

:root {
    --bg-dark: #090d16;
    --card-bg: #151e2e;
    --card-hover: #1e293b;
    --border-color: #273549;
    --text-primary: #f8fafc;
    --text-muted: #94a3b8;
    --color-danger: #ef4444;
    --color-warning: #f59e0b;
    --color-info: #0284c7;
    --color-success: #10b981;
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Command Header */
.command-header {
    height: 56px;
    background: #0f172a;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 1000;
    flex-shrink: 0;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-title {
    font-size: 15px;
    font-weight: 700;
    color: #f1f5f9;
    display: flex;
    align-items: center;
    gap: 6px;
}

.brand-badge {
    background: #dc2626;
    color: white;
    font-size: 10px;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0.5px;
    animation: beacon-pulse 2s infinite;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-cmd {
    background: #1e293b;
    color: #e2e8f0;
    border: 1px solid #334155;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: all 0.15s ease;
}

.btn-cmd:hover {
    background: #334155;
    color: white;
}

.btn-cmd.active {
    background: #0284c7;
    border-color: #38bdf8;
    color: white;
}

.btn-cmd.btn-cmd-danger {
    background: #dc2626;
    border-color: #ef4444;
    color: white;
}

.btn-cmd.btn-cmd-danger:hover {
    background: #b91c1c;
}

.auth-badge {
    background: #1e293b;
    border: 1px solid #475569;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 11.5px;
    color: #cbd5e1;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
}

.auth-badge.active {
    background: rgba(16, 185, 129, 0.15);
    border-color: #10b981;
    color: #34d399;
}

.auth-badge.admin-badge {
    background: #1e293b;
    border-color: #475569;
    color: #94a3b8;
    transition: all 0.2s ease;
}

.auth-badge.admin-badge:hover {
    border-color: #f59e0b;
    color: #fde68a;
}

.auth-badge.admin-badge.active {
    background: rgba(245, 158, 11, 0.18);
    border-color: #f59e0b;
    color: #fde68a;
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.35);
}

/* Stats Toolbar */
.stats-toolbar {
    height: 40px;
    background: #111827;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    font-size: 12px;
    flex-shrink: 0;
}

.stat-group {
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.stat-num {
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 4px;
    background: #1f2937;
}

.stat-num.critical { color: #f87171; background: rgba(239, 68, 68, 0.2); }
.stat-num.waiting { color: #fbbf24; background: rgba(245, 158, 11, 0.2); }
.stat-num.dispatched { color: #38bdf8; background: rgba(56, 189, 248, 0.2); }

/* Main Split Viewport */
.main-viewport {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;
}

/* Map Pane */
.map-pane {
    flex: 1;
    height: 100%;
    position: relative;
    border-right: 1px solid var(--border-color);
}

#commandMap {
    width: 100%;
    height: 100%;
    background: #090d16;
}

/* List / Queue Pane */
.queue-pane {
    width: 480px;
    height: 100%;
    background: var(--bg-dark);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

/* Queue Controls */
.queue-controls {
    padding: 10px 12px;
    background: #0f172a;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
    overflow-x: hidden;
}

.search-box {
    width: 100%;
    box-sizing: border-box;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 6px;
    color: #f8fafc;
    padding: 7px 10px;
    font-size: 12px;
    outline: none;
    transition: border-color 0.2s ease;
}

.search-box:focus {
    border-color: #38bdf8;
    box-shadow: 0 0 6px rgba(56, 189, 248, 0.25);
}

.filter-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 4px;
    margin-bottom: 2px;
}

.filter-section-title {
    font-size: 10.5px;
    font-weight: 700;
    color: #94a3b8;
    letter-spacing: 0.3px;
}

.filter-divider {
    height: 1px;
    background: linear-gradient(90deg, rgba(56, 189, 248, 0.4) 0%, rgba(51, 65, 85, 0.6) 50%, transparent 100%);
    margin: 6px 0 3px 0;
}

.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    align-items: center;
}

.btn-filter-status, .btn-filter-urgency {
    background: #1e293b;
    color: #94a3b8;
    border: 1px solid #334155;
    padding: 4px 9px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s ease;
}

.btn-filter-status:hover, .btn-filter-urgency:hover {
    background: #334155;
    color: #f1f5f9;
}

.btn-filter-status.active, .btn-filter-urgency.active {
    background: #0284c7;
    color: white;
    border-color: #38bdf8;
    box-shadow: 0 0 8px rgba(56, 189, 248, 0.35);
}

/* Queue Scroll List */
.queue-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Incident Command Card */
.incident-command-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: transform 0.1s ease, background 0.15s ease;
}

.incident-command-card:hover {
    background: var(--card-hover);
}

.incident-command-card.glow-critical {
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.25);
}

.card-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ticket-code-badge {
    color: #ef4444;
    font-size: 13.5px;
    font-weight: 800;
    cursor: pointer;
    letter-spacing: 0.5px;
}

.ticket-code-badge:hover {
    text-decoration: underline;
}

.card-time-ago {
    font-size: 11px;
    color: var(--text-muted);
}

.badge-status {
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 10.5px;
    font-weight: 700;
    color: white;
}

.status-waiting { background: #dc2626; }
.status-dispatched { background: #0284c7; }
.status-resolved { background: #059669; }

.card-info-row {
    font-size: 12px;
    color: #cbd5e1;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
}

.info-label {
    color: var(--text-muted);
}

.info-val {
    font-weight: 600;
    color: #f1f5f9;
}

.depth-val {
    color: #38bdf8;
}

.card-med-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 2px;
}

.tag-pill {
    font-size: 10.5px;
    padding: 1px 6px;
    border-radius: 3px;
    background: #334155;
    color: #e2e8f0;
}

.tag-bedridden { background: rgba(239, 68, 68, 0.2); color: #fca5a5; border: 1px solid rgba(239,68,68,0.4); }
.tag-oxygen { background: rgba(168, 85, 247, 0.2); color: #d8b4fe; border: 1px solid rgba(168,85,247,0.4); }
.tag-infant { background: rgba(236, 72, 153, 0.2); color: #fbcfe8; border: 1px solid rgba(236,72,153,0.4); }
.tag-pet { background: rgba(245, 158, 11, 0.2); color: #fde68a; border: 1px solid rgba(245,158,11,0.4); }

.card-details-box {
    background: #090d16;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 11.5px;
    color: #cbd5e1;
    line-height: 1.4;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.card-notes-box {
    background: rgba(2, 132, 199, 0.1);
    border: 1px dashed #0284c7;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 11.5px;
    color: #e0f2fe;
}

/* Photo Thumbnail in Card */
.card-thumbnail-wrapper {
    position: relative;
    display: inline-block;
    cursor: pointer;
    margin-top: 2px;
}

.card-photo-img {
    height: 70px;
    width: 110px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid #475569;
    transition: opacity 0.15s ease;
}

.card-photo-img:hover {
    opacity: 0.85;
}

.photo-expand-badge {
    position: absolute;
    bottom: 4px;
    right: 4px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 9.5px;
    padding: 1px 4px;
    border-radius: 3px;
}

/* Card Action Footer */
.card-footer-actions {
    display: flex;
    gap: 6px;
    margin-top: 4px;
}

.btn-card-action {
    flex: 1;
    text-align: center;
    padding: 6px 4px;
    border-radius: 5px;
    font-size: 11px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.btn-gmaps-nav {
    background: #2563eb;
    color: white;
}

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

.btn-phone {
    background: #16a34a;
    color: white;
}

.btn-phone:hover {
    background: #15803d;
}

.btn-phone-masked {
    background: #334155;
    color: #94a3b8;
}

.btn-phone-masked:hover {
    background: #475569;
    color: white;
}

.btn-focus-map {
    background: #475569;
    color: white;
}

.btn-focus-map:hover {
    background: #64748b;
}

.btn-copy-gps {
    background: #1e293b;
    color: #cbd5e1;
    border: 1px solid #334155;
}

.btn-copy-gps:hover {
    background: #334155;
    color: white;
}

/* Rescuer Quick Status Controls */
.card-rescuer-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    padding-top: 6px;
    border-top: 1px solid #334155;
    margin-top: 4px;
}

.btn-status-quick {
    background: #1e293b;
    border: 1px solid #475569;
    color: #cbd5e1;
    font-size: 10.5px;
    padding: 2px 6px;
    border-radius: 4px;
    cursor: pointer;
}

.btn-status-quick.active {
    background: #0284c7;
    border-color: #38bdf8;
    color: white;
    font-weight: 700;
}

/* Leaflet Custom Beacon Markers */
.sos-beacon-marker {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sos-pulse-ring {
    position: absolute;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(239, 68, 68, 0.4);
    animation: beacon-ring 1.8s infinite ease-out;
}

.sos-center-dot {
    position: absolute;
    width: 24px;
    height: 24px;
    background: #dc2626;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    box-shadow: 0 0 8px rgba(220, 38, 38, 0.8);
    border: 2px solid white;
}

.sos-beacon-marker.critical .sos-pulse-ring {
    background: rgba(239, 68, 68, 0.6);
    animation: beacon-ring 1.2s infinite ease-out;
}

.sos-beacon-marker.critical .sos-center-dot {
    background: #ef4444;
    width: 26px;
    height: 26px;
}

.sos-beacon-marker.dispatched .sos-pulse-ring {
    background: rgba(2, 132, 199, 0.4);
}

.sos-beacon-marker.dispatched .sos-center-dot {
    background: #0284c7;
    box-shadow: 0 0 8px rgba(2, 132, 199, 0.8);
}

.sos-beacon-marker.resolved .sos-pulse-ring {
    display: none;
}

.sos-beacon-marker.resolved .sos-center-dot {
    background: #059669;
    border-color: #a7f3d0;
    box-shadow: none;
}

.hazard-dot {
    font-size: 18px;
    filter: drop-shadow(0 0 4px rgba(245, 158, 11, 0.8));
}

@keyframes beacon-ring {
    0% { transform: scale(0.5); opacity: 1; }
    100% { transform: scale(1.6); opacity: 0; }
}

@keyframes beacon-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Map Popup Card */
.map-popup-card {
    background: #1e293b;
    color: #f8fafc;
    border-radius: 6px;
    padding: 6px;
    font-family: inherit;
}

.leaflet-popup-content-wrapper {
    background: #1e293b !important;
    color: #f8fafc !important;
    border: 1px solid #475569;
    border-radius: 8px !important;
}

.leaflet-popup-tip {
    background: #1e293b !important;
}

/* Modal Overlay & Card */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 16px;
}

.modal-content-card {
    background: #111827;
    border: 1px solid #374151;
    border-radius: 12px;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
}

.modal-header {
    padding: 14px 18px;
    border-bottom: 1px solid #374151;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 15px;
    font-weight: 700;
}

.btn-modal-close {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 20px;
    cursor: pointer;
}

.modal-body {
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    font-size: 13px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.form-label {
    font-size: 11.5px;
    font-weight: 600;
    color: #94a3b8;
}

.form-input, .form-select, .form-textarea {
    background: #1f2937;
    border: 1px solid #374151;
    border-radius: 6px;
    color: #f9fafb;
    padding: 8px 10px;
    font-size: 13px;
    outline: none;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    border-color: #38bdf8;
}

.checkbox-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #1f2937;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
}

.photo-uploader-controls {
    display: flex;
    gap: 8px;
}

.btn-upload-trigger {
    background: #374151;
    color: #e5e7eb;
    border: 1px solid #4b5563;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* Toast Alert */
.command-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: #1e293b;
    color: #f8fafc;
    border: 1px solid #3b82f6;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    z-index: 3000;
    display: none;
    transition: opacity 0.3s ease;
}

/* Mobile Tab Switcher */
.mobile-view-tabs {
    display: none;
    height: 44px;
    background: #0f172a;
    border-bottom: 1px solid var(--border-color);
}

.btn-mobile-tab {
    flex: 1;
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    border-bottom: 2px solid transparent;
}

.btn-mobile-tab.active {
    color: #38bdf8;
    border-bottom-color: #38bdf8;
}

/* Mobile Responsive */
@media (max-width: 900px) {
    .hide-mobile {
        display: none !important;
    }

    .mobile-view-tabs {
        display: flex;
    }

    .main-viewport {
        flex-direction: column;
    }

    .map-pane {
        width: 100%;
        height: 100%;
        border-right: none;
    }

    .queue-pane {
        width: 100%;
        height: 100%;
    }

    .map-pane.mobile-hidden, .queue-pane.mobile-hidden {
        display: none;
    }
}
