/* ==========================================================================
   CSS GLOBAL - PLATEFORME DE COMMUNICATION UNIFIÉE (NICE CÔTE D'AZUR)
   ========================================================================== */

:root {
    --bg-main: #090d16;
    --bg-card: rgba(15, 23, 42, 0.7);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-color-active: rgba(255, 255, 255, 0.2);
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --accent-blue: #0066cc;
    --accent-green: #10b981;
    --accent-amber: #f59e0b;
    --accent-red: #ef4444;
    --accent-purple: #a855f7;
    
    --font-main: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    
    --header-height: 70px;
}

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

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-main);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

/* Glassmorphism utility */
.glass {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.4);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.glass:hover {
    border-color: var(--border-color-active);
}

/* Scrollbar personnalisé */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Badges & Buttons */
.badge {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    padding: 4px 8px;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
}

.btn {
    font-family: var(--font-main);
    font-weight: 600;
    padding: 10px 16px;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* App Container Layout */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
}

/* HEADER */
.app-header {
    height: var(--header-height);
    background: rgba(10, 15, 30, 0.85);
    border-bottom: 1px solid var(--border-color);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 1000;
    flex-shrink: 0;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-circle {
    width: 24px;
    height: 24px;
    background: linear-gradient(135deg, #0055ff, #00d9ff);
    border-radius: 50%;
    box-shadow: 0 0 15px rgba(0, 85, 255, 0.6);
}

.logo-text h1 {
    font-size: 1.1rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    background: linear-gradient(120deg, #ffffff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-text h2 {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.header-status-panel {
    display: flex;
    align-items: center;
    gap: 20px;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.04);
    padding: 6px 12px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.status-dot.connected {
    background-color: var(--accent-green);
    box-shadow: 0 0 8px var(--accent-green);
}

.status-dot.disconnected {
    background-color: var(--accent-red);
    box-shadow: 0 0 8px var(--accent-red);
}

/* CRISIS BANNER */
.crisis-alert-banner {
    background: linear-gradient(90deg, rgba(239, 68, 68, 0.95), rgba(168, 85, 247, 0.95));
    color: white;
    text-align: center;
    padding: 8px 24px;
    font-weight: 700;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    z-index: 999;
    box-shadow: 0 4px 20px rgba(239, 68, 68, 0.4);
    animation: slideDown 0.3s ease-out;
}

.crisis-alert-banner.hidden {
    display: none;
}

.pulse-warning {
    animation: warningPulse 1.2s infinite alternate;
}

.patch-group-label {
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-family: monospace;
}

/* MAIN GRID LAYOUT */
.app-main-grid {
    flex-grow: 1;
    padding: 16px;
    display: grid;
    grid-template-columns: 360px 1fr 380px;
    gap: 16px;
    height: calc(100vh - var(--header-height));
    overflow: hidden;
}

/* PANEL CARDS SIDEBARS */
.panel-card {
    display: flex;
    flex-direction: column;
    padding: 20px;
    overflow: hidden;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-shrink: 0;
}

.panel-header h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* RIGHT SIDEBAR: CHANNELS */
.channels-grid {
    flex-grow: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-right: 4px;
    margin-bottom: 16px;
}

/* CHANNEL ELEMENT */
.channel-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 14px;
    position: relative;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.channel-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background-color: var(--service-color, var(--accent-blue));
    border-radius: 4px 0 0 4px;
}

.channel-info {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.channel-title h4 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.channel-params {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-family: monospace;
    margin-top: 2px;
}

.channel-indicator-state {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.72rem;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.05em;
}

.state-dot-radio {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--text-muted);
}

/* Transmission states */
.channel-item.transmitting {
    background: rgba(239, 68, 68, 0.05);
    border-color: rgba(239, 68, 68, 0.25);
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.05);
}
.channel-item.transmitting .state-dot-radio {
    background-color: var(--accent-red);
    box-shadow: 0 0 8px var(--accent-red);
    animation: warningPulse 0.8s infinite alternate;
}
.channel-item.transmitting .channel-indicator-state {
    color: var(--accent-red);
}

.channel-item.receiving {
    background: rgba(16, 185, 129, 0.05);
    border-color: rgba(16, 185, 129, 0.25);
}
.channel-item.receiving .state-dot-radio {
    background-color: var(--accent-green);
    box-shadow: 0 0 8px var(--accent-green);
}
.channel-item.receiving .channel-indicator-state {
    color: var(--accent-green);
}

/* Active voice indicator bar inside channel card */
.channel-voice-anim {
    height: 18px;
    display: flex;
    align-items: center;
    gap: 3px;
    margin: 8px 0;
}

.channel-voice-anim span {
    display: inline-block;
    width: 3px;
    height: 3px;
    background-color: var(--service-color);
    border-radius: 1px;
    transition: height 0.15s ease;
}

.channel-item.transmitting .channel-voice-anim span,
.channel-item.receiving .channel-voice-anim span {
    animation: waveBounce 0.6s infinite alternate;
}
.channel-item.transmitting .channel-voice-anim span:nth-child(2) { animation-delay: 0.1s; }
.channel-item.transmitting .channel-voice-anim span:nth-child(3) { animation-delay: 0.2s; }
.channel-item.transmitting .channel-voice-anim span:nth-child(4) { animation-delay: 0.15s; }
.channel-item.transmitting .channel-voice-anim span:nth-child(5) { animation-delay: 0.3s; }

.channel-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 10px;
}

.btn-ptt {
    flex-grow: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
}

.btn-ptt:hover {
    background: rgba(255, 255, 255, 0.1);
}

.btn-ptt.active-dispatch {
    background: linear-gradient(135deg, var(--accent-red), #b91c1c);
    border-color: var(--accent-red);
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.4);
    color: white;
}

.btn-ptt.channel-busy {
    background: rgba(245, 158, 11, 0.15) !important;
    border-color: rgba(245, 158, 11, 0.3) !important;
    color: #f59e0b !important;
    cursor: not-allowed !important;
    opacity: 0.8;
}

.channel-ptt-user {
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    max-width: 140px;
    font-style: italic;
}

/* Patched Channels Graphic State */
.channel-item.patched-crisis {
    border-color: rgba(168, 85, 247, 0.4);
    background: rgba(168, 85, 247, 0.02);
    box-shadow: 0 0 10px rgba(168, 85, 247, 0.08);
}
.channel-item.patched-crisis::after {
    content: '🔗 PATCH';
    position: absolute;
    right: 8px;
    bottom: 8px;
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--accent-purple);
    background: rgba(168, 85, 247, 0.15);
    padding: 1px 6px;
    border-radius: 4px;
}

/* CRISIS CONFIG SECTION */
.crisis-config-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 16px;
    flex-shrink: 0;
}

.crisis-config-card h4 {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.section-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.patch-selection-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
    max-height: 100px;
    overflow-y: auto;
}

.patch-select-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    cursor: pointer;
    user-select: none;
    color: var(--text-secondary);
}

.patch-select-item input {
    cursor: pointer;
    accent-color: var(--accent-purple);
}

.btn-crisis {
    width: 100%;
    background: rgba(168, 85, 247, 0.15);
    border: 1px solid rgba(168, 85, 247, 0.3);
    color: #e9d5ff;
}

.btn-crisis:hover:not(:disabled) {
    background: var(--accent-purple);
    color: white;
    box-shadow: 0 0 15px rgba(168, 85, 247, 0.4);
}

.btn-crisis.dissolve-state {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

.btn-crisis.dissolve-state:hover {
    background: var(--accent-red);
    color: white;
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.4);
}


/* CENTER COLUMN MAP + LOGS */
.center-layout-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow: hidden;
}

.map-wrapper {
    flex-grow: 1;
    position: relative;
    overflow: hidden;
    min-height: 300px;
}

#map {
    width: 100%;
    height: 100%;
    border-radius: 16px;
    background-color: #1a1e2a;
}

/* Custom dark styling to Leaflet overlays */
.leaflet-container {
    background: #111422 !important;
}

.leaflet-bar {
    border: 1px solid var(--border-color) !important;
    box-shadow: none !important;
}

.leaflet-bar a {
    background-color: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border-bottom: 1px solid var(--border-color) !important;
}

.leaflet-bar a:hover {
    background-color: rgba(255, 255, 255, 0.1) !important;
}

.leaflet-popup-content-wrapper {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
    backdrop-filter: blur(10px) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 12px !important;
}

.leaflet-popup-tip {
    background: var(--bg-card) !important;
    border: 1px solid var(--border-color) !important;
}

.popup-agent-info h4 {
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.popup-agent-info p {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin: 2px 0;
}

.agent-battery-gauge {
    display: inline-block;
    width: 40px;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    vertical-align: middle;
    margin-left: 5px;
    overflow: hidden;
}

.agent-battery-fill {
    height: 100%;
    background-color: var(--accent-green);
}

.agent-battery-fill.low {
    background-color: var(--accent-red);
}

/* Map Markers */
.custom-map-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
}

.marker-pin {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background-color: var(--marker-color, var(--accent-blue));
    border: 2px solid white;
    box-shadow: 0 0 8px var(--marker-color);
    position: relative;
    transition: transform 0.25s ease, background-color 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
}

.custom-map-icon.transmitting .marker-pin {
    animation: mapPinEmit 0.8s infinite alternate;
}

.custom-map-icon.sos-active .marker-pin {
    background-color: var(--accent-red) !important;
    border-color: #ffcccc !important;
    width: 26px;
    height: 26px;
    animation: mapPinSos 0.5s infinite alternate;
    box-shadow: 0 0 20px var(--accent-red);
}

/* FLOATING SOS OVERLAY */
.sos-floating-alert {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1500;
    width: 90%;
    max-width: 450px;
    animation: slideDown 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sos-floating-alert.hidden {
    display: none;
}

.sos-card {
    background: rgba(220, 38, 38, 0.85);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(248, 113, 113, 0.4);
    border-radius: 14px;
    padding: 16px;
    color: white;
    box-shadow: 0 10px 40px rgba(220, 38, 38, 0.5);
}

.sos-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.sos-flash {
    font-weight: 800;
    font-size: 0.95rem;
    letter-spacing: 0.05em;
    animation: warningPulse 0.5s infinite alternate;
}

.btn-close-sos {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
}

.btn-close-sos:hover {
    color: white;
}

.sos-body p {
    font-size: 0.85rem;
    line-height: 1.4;
    margin-bottom: 12px;
    font-weight: 500;
}

.sos-actions {
    display: flex;
    justify-content: flex-end;
}

.btn-sos-ack {
    background: white;
    color: #b91c1c;
    padding: 6px 14px;
    font-size: 0.8rem;
}

.btn-sos-ack:hover {
    background: #fca5a5;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.3);
}

/* LOGS FEED PANEL */
.logs-wrapper {
    height: 250px;
    display: flex;
    flex-direction: column;
    padding: 16px;
    flex-shrink: 0;
}

.log-filters {
    display: flex;
    gap: 8px;
}

.log-filter {
    font-size: 0.75rem;
    color: var(--text-secondary);
    cursor: pointer;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 2px 10px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.log-filter:hover {
    background: rgba(255, 255, 255, 0.08);
}

.log-filter.active {
    background: rgba(0, 85, 255, 0.15);
    border-color: var(--accent-blue);
    color: white;
    font-weight: 600;
}

.logs-feed {
    flex-grow: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-right: 4px;
    margin-top: 10px;
}

.log-item {
    background: rgba(255, 255, 255, 0.01);
    border: 1px solid rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 0.8rem;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    animation: slideUp 0.25s ease-out;
}

.log-time {
    color: var(--text-muted);
    font-family: monospace;
    font-size: 0.72rem;
    margin-top: 2px;
    flex-shrink: 0;
}

.log-badge-service {
    font-weight: 700;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    color: white;
    background-color: var(--log-service-color, var(--text-muted));
    flex-shrink: 0;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.log-content {
    flex-grow: 1;
}

.log-user {
    font-weight: 600;
    color: var(--text-primary);
}

.log-transcription {
    color: var(--text-secondary);
    margin-top: 2px;
}

.log-item.log-sos {
    background: rgba(239, 68, 68, 0.06);
    border-color: rgba(239, 68, 68, 0.2);
}

.log-item.log-sos .log-transcription {
    color: #fca5a5;
    font-weight: 500;
}

.log-item.log-sip {
    background: rgba(56, 189, 248, 0.03);
    border-color: rgba(56, 189, 248, 0.1);
}


/* LEFT SIDEBAR: SIP TELEPHONY */
#sip-panel {
    display: flex;
    flex-direction: column;
}

.sip-active-calls-section {
    flex-grow: 1;
    overflow-y: auto;
    margin-bottom: 16px;
    padding-right: 4px;
}

.sip-active-calls-section h4,
.voice-activity-section h4 {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 10px;
    flex-shrink: 0;
}

.active-calls-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.no-calls {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
    margin-top: 15px;
    font-style: italic;
}

/* SIP CALL ITEM */
.call-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 12px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    animation: scaleIn 0.25s ease-out;
}

.call-item-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.call-icon-name {
    display: flex;
    align-items: center;
    gap: 8px;
}

.call-avatar {
    width: 28px;
    height: 28px;
    background: rgba(0, 85, 255, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    color: var(--accent-blue);
}

.call-details h5 {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
}

.call-details p {
    font-size: 0.72rem;
    color: var(--text-secondary);
}

.call-badge-status {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
}

.call-badge-status.ringing {
    background: rgba(239, 68, 68, 0.15);
    color: var(--accent-red);
    animation: warningPulse 0.5s infinite alternate;
}

.call-badge-status.active {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-green);
}

.call-badge-status.hold {
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent-amber);
}

.call-badge-status.patched {
    background: rgba(168, 85, 247, 0.15);
    color: var(--accent-purple);
}

.call-actions-row {
    display: flex;
    gap: 6px;
}

.btn-call-action {
    flex-grow: 1;
    padding: 6px;
    font-size: 0.75rem;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.15s ease;
}

.btn-call-accept {
    background: var(--accent-green);
    color: white;
}
.btn-call-accept:hover { background: #059669; }

.btn-call-decline {
    background: var(--accent-red);
    color: white;
}
.btn-call-decline:hover { background: #dc2626; }

.btn-call-hold {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.05);
}
.btn-call-hold:hover { background: rgba(255, 255, 255, 0.15); }

.btn-call-patch {
    background: rgba(168, 85, 247, 0.2);
    color: #e9d5ff;
    border: 1px solid rgba(168, 85, 247, 0.3);
}
.btn-call-patch:hover { background: var(--accent-purple); color: white; }

/* SIP patch dropdown select element */
.call-patch-dropdown {
    display: flex;
    gap: 4px;
    margin-top: 4px;
}

.call-patch-select {
    flex-grow: 1;
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    font-family: var(--font-main);
    font-size: 0.72rem;
    padding: 4px;
    border-radius: 6px;
}

.btn-confirm-patch {
    background: var(--accent-purple);
    color: white;
    border: none;
    padding: 4px 10px;
    font-size: 0.72rem;
    border-radius: 6px;
    cursor: pointer;
}

/* VOICE ACTIVITY MICROPHONE METERS */
.voice-activity-section {
    background: rgba(255, 255, 255, 0.01);
    border: 1px solid rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 16px;
    flex-shrink: 0;
}

.audio-visualizer-container {
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-bottom: 6px;
}

.wave-bar {
    width: 4px;
    height: 6px;
    background-color: var(--accent-blue);
    border-radius: 2px;
    transition: height 0.15s ease, background-color 0.3s ease;
}

/* Active audio bar configurations */
.app-container.transmitting-mic .wave-bar {
    background-color: var(--accent-red);
    animation: waveBounce 0.5s infinite alternate;
}
.app-container.receiving-radio .wave-bar {
    background-color: var(--accent-green);
    animation: waveBounce 0.4s infinite alternate;
}

.app-container.transmitting-mic .wave-bar:nth-child(2n),
.app-container.receiving-radio .wave-bar:nth-child(2n) { animation-delay: 0.15s; }
.app-container.transmitting-mic .wave-bar:nth-child(3n),
.app-container.receiving-radio .wave-bar:nth-child(3n) { animation-delay: 0.3s; }
.app-container.transmitting-mic .wave-bar:nth-child(4n),
.app-container.receiving-radio .wave-bar:nth-child(4n) { animation-delay: 0.08s; }

.active-ptt-display {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* DIALER */
.sip-dialer-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 14px;
    padding: 14px;
    flex-shrink: 0;
}

.dialer-display {
    display: flex;
    background: #0f172a;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 6px 10px;
    margin-bottom: 12px;
    align-items: center;
}

.dialer-display input {
    background: none;
    border: none;
    color: white;
    font-family: var(--font-main);
    font-size: 1rem;
    width: 100%;
    outline: none;
    font-weight: 600;
}

.dialer-display button {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.9rem;
    cursor: pointer;
}

.dialer-display button:hover {
    color: white;
}

.dialer-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}

.dial-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    color: white;
    font-family: var(--font-main);
    font-size: 1rem;
    font-weight: 600;
    padding: 8px 0;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.dial-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.dial-btn:active {
    background: rgba(255, 255, 255, 0.2);
}

.btn-call {
    width: 100%;
    background: var(--accent-blue);
    color: white;
}

.btn-call:hover {
    background: #0055d0;
    box-shadow: 0 0 15px rgba(0, 102, 204, 0.4);
}


/* ==========================================================================
   ANIMATIONS & KEYFRAMES
   ========================================================================== */

@keyframes slideDown {
    from { transform: translate(-50%, -30px); opacity: 0; }
    to { transform: translate(-50%, 0); opacity: 1; }
}

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

@keyframes scaleIn {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

@keyframes warningPulse {
    from { opacity: 0.4; }
    to { opacity: 1; }
}

@keyframes waveBounce {
    from { height: 4px; }
    to { height: 28px; }
}

@keyframes mapPinEmit {
    from { transform: scale(1); box-shadow: 0 0 4px var(--marker-color); }
    to { transform: scale(1.3); box-shadow: 0 0 20px var(--marker-color); }
}

@keyframes mapPinSos {
    from { transform: scale(1); box-shadow: 0 0 4px var(--accent-red); background-color: var(--accent-red); }
    to { transform: scale(1.6); box-shadow: 0 0 35px var(--accent-red); background-color: #ff3333; }
}

/* ==========================================================================
   ROLE SELECTOR, MUTED STATES & AGENT VIEW
   ========================================================================== */

.header-dropdown-select {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 0.82rem;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 8px;
    outline: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.header-dropdown-select:hover {
    border-color: rgba(255, 255, 255, 0.25);
    background: rgba(0, 0, 0, 0.4);
}

.header-dropdown-select option {
    background-color: #0b0f19;
    color: var(--text-primary);
}

.btn-mute {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    font-size: 0.8rem;
    padding: 6px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-mute:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.2);
}

.btn-mute.is-muted {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

.channel-item.muted-card {
    opacity: 0.45;
    filter: grayscale(30%);
    border-color: rgba(255, 255, 255, 0.02) !important;
}

.channel-item.muted-card .channel-voice-anim span {
    animation: none !important;
    height: 3px !important;
}

.agent-view-active .sip-dialer-card {
    display: none;
}

/* -------------------------------------------------------------
   ADMINISTRATION LAYOUT & DASHBOARD STYLES
   ------------------------------------------------------------- */

/* HEADER VIEW SWITCHER */
.view-toggle-container {
    display: flex;
    gap: 8px;
    margin-right: 12px;
    padding-right: 12px;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.btn-header-view {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
    font-size: 0.85rem;
    padding: 6px 14px;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.25s ease;
}

.btn-header-view:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

.btn-header-view.active {
    background: rgba(0, 85, 255, 0.15);
    border-color: rgba(0, 85, 255, 0.4);
    color: #38bdf8;
    box-shadow: 0 0 10px rgba(0, 85, 255, 0.2);
}

/* ADMIN CONTAINER */
.admin-layout-container {
    display: flex;
    height: calc(100vh - var(--header-height));
    overflow: hidden;
}

.admin-sidebar {
    width: 250px;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    background: rgba(10, 20, 40, 0.2);
    flex-shrink: 0;
}

.admin-sidebar h4 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding-left: 10px;
}

.admin-tabs {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.admin-tab {
    padding: 12px 16px;
    border-radius: 10px;
    color: var(--text-muted);
    cursor: pointer;
    font-weight: 500;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.admin-tab:hover {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
}

.admin-tab.active {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border-left: 3px solid #38bdf8;
    padding-left: 13px;
}

.admin-content {
    flex-grow: 1;
    padding: 30px;
    overflow-y: auto;
}

.admin-tab-content {
    display: flex;
    flex-direction: column;
    gap: 24px;
    animation: adminFadeIn 0.3s ease-out;
}

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

.admin-section-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 16px;
}

.admin-section-header h3 {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* FLEET ADMIN SPLIT */
.admin-fleet-split {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 24px;
    align-items: start;
}

.admin-form-card, .admin-table-card {
    background: rgba(255, 255, 255, 0.01);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    padding: 20px;
}

.admin-form-card h4, .admin-table-card h4 {
    font-size: 0.95rem;
    color: var(--text-primary);
    margin-bottom: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 10px;
}

/* FORM ELEMENTS */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.form-group-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.form-group label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.form-group input, .form-group select {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    color: var(--text-primary);
    padding: 10px 12px;
    font-family: inherit;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.25s ease;
}

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

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

.btn-submit {
    background: #0055ff;
    color: white;
    font-weight: 600;
    flex-grow: 1;
    border: none;
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.25s;
}

.btn-submit:hover {
    background: #0044cc;
}

.btn-cancel {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    padding: 10px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-cancel:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* TABLES STYLING */
.table-wrapper {
    overflow-x: auto;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.admin-table th {
    padding: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
}

.admin-table td {
    padding: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    font-size: 0.9rem;
}

.admin-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background 0.2s;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.08);
}

/* SERVICES SETTINGS */
.services-admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 20px;
}

.service-admin-card {
    background: rgba(255, 255, 255, 0.01);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    padding: 20px;
    border-left: 4px solid var(--svc-color, #38bdf8);
}

.service-admin-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 10px;
}

.service-admin-card-header h4 {
    font-size: 1rem;
    color: var(--text-primary);
}

.service-admin-card-header .svc-tg-badge {
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 8px;
    border-radius: 6px;
    font-family: monospace;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* GPS TAB CONFIG */
.gps-config-dashboard {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 24px;
    align-items: start;
}

.gps-status-card {
    background: rgba(255, 255, 255, 0.01);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.gps-indicator-row {
    display: flex;
    align-items: center;
    gap: 16px;
}

.gps-pulse-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4);
    animation: gpsPulse 1.8s infinite;
}

@keyframes gpsPulse {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    }
    70% {
        transform: scale(1);
        box-shadow: 0 0 0 8px rgba(16, 185, 129, 0);
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

.gps-indicator-row h4 {
    font-size: 0.95rem;
    font-weight: 600;
}

.desc-small {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.gps-telemetry-stats {
    display: flex;
    gap: 16px;
}

.stat-box {
    flex-grow: 1;
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 12px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.stat-box .value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #38bdf8;
}

.stat-box .label {
    font-size: 0.65rem;
    text-transform: uppercase;
    color: var(--text-muted);
}

.gps-trackers-log-card {
    background: rgba(255, 255, 255, 0.01);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    padding: 20px;
    display: flex;
    flex-direction: column;
}

.gps-trackers-log-card h4 {
    margin-bottom: 12px;
    font-size: 0.95rem;
}

.gps-log-feed {
    height: 300px;
    overflow-y: auto;
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 10px;
    font-family: monospace;
    font-size: 0.8rem;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.gps-log-item {
    color: var(--text-muted);
    border-bottom: 1px solid rgba(255, 255, 255, 0.02);
    padding-bottom: 4px;
}

.gps-log-item .time {
    color: #38bdf8;
}

.gps-log-item .callsign {
    color: #e2e8f0;
    font-weight: 600;
}

/* SIDEBAR LAYOUT WRAPPER */
.left-sidebar-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
    height: 100%;
    overflow: hidden;
}

#sip-panel {
    flex: 1;
    min-height: 0;
}

#dispatchers-panel {
    height: 260px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    padding: 20px;
    overflow: hidden;
}

.dispatchers-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    flex: 1;
    padding-right: 4px;
}

.dispatcher-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 12px;
    padding: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s ease-in-out;
}

.dispatcher-item:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.08);
}

.dispatcher-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.dispatcher-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.dispatcher-status {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.dispatcher-actions {
    display: flex;
    gap: 8px;
}

.btn-dispatcher-action {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-dispatcher-action:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.btn-dispatcher-action:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-dispatcher-action.active-call {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.3);
    color: #ef4444;
}

.btn-dispatcher-action.ringing-call {
    background: rgba(245, 158, 11, 0.2);
    border-color: rgba(245, 158, 11, 0.3);
    color: #f59e0b;
    animation: pulse 1s infinite alternate;
}

/* CITIZEN ALERTS & EMERGENCY PORTAL STYLING */

#citizen-alerts-panel {
    height: 240px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    padding: 20px;
    overflow: hidden;
}

.citizen-alerts-list::-webkit-scrollbar {
    width: 6px;
}
.citizen-alerts-list::-webkit-scrollbar-track {
    background: transparent;
}
.citizen-alerts-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.citizen-alert-item {
    transition: all 0.25s ease-in-out;
}
.citizen-alert-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Floating Citizen Comm Card */
.citizen-comm-card {
    position: absolute;
    right: 24px;
    bottom: 90px;
    width: 350px;
    height: 480px;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUpFade 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.citizen-comm-card.hidden {
    display: none !important;
}

.citizen-comm-header {
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: grab;
    user-select: none;
}
.citizen-comm-header:active {
    cursor: grabbing;
}

.citizen-comm-header h4 {
    margin: 0;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 0.03em;
}

.btn-close-citizen-comm {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    margin: 0;
    transition: color 0.2s;
}
.btn-close-citizen-comm:hover {
    color: #ef4444;
}

.citizen-comm-body {
    padding: 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    gap: 12px;
}

.citizen-chat-history {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-right: 4px;
}

.citizen-chat-history::-webkit-scrollbar {
    width: 4px;
}
.citizen-chat-history::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 2px;
}

/* Chat bubble styling */
.chat-msg {
    max-width: 80%;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 0.78rem;
    line-height: 1.4;
    word-break: break-word;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.chat-msg.dispatcher {
    align-self: flex-end;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: white;
    border-bottom-right-radius: 2px;
}

.chat-msg.citizen {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border-bottom-left-radius: 2px;
}

.chat-msg .time {
    font-size: 0.62rem;
    color: rgba(255, 255, 255, 0.5);
    align-self: flex-end;
}
.chat-msg.citizen .time {
    color: var(--text-muted);
}

.citizen-chat-input-row {
    display: flex;
    gap: 8px;
}

.citizen-chat-input-row input {
    flex: 1;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.8rem;
    outline: none;
    transition: border-color 0.2s;
}
.citizen-chat-input-row input:focus {
    border-color: var(--accent-blue);
}

.citizen-chat-input-row button {
    background: var(--accent-blue);
    color: white;
    border: none;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}
.citizen-chat-input-row button:hover {
    background: #2563eb;
}

/* Leaflet pulsing red marker for active emergency */
.citizen-pulse-marker {
    background: transparent;
    border: none;
}

.citizen-pulse-pin {
    width: 28px;
    height: 28px;
    background: #ef4444;
    border: 3px solid white;
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    position: relative;
}

.citizen-pulse-pin::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: #ef4444;
    animation: markerPulse 1.8s infinite ease-out;
    opacity: 0.6;
    z-index: -1;
    top: -3px;
    left: -3px;
    border: 3px solid transparent;
}

.citizen-pulse-pin.acknowledged {
    background: #f59e0b;
}
.citizen-pulse-pin.acknowledged::after {
    display: none;
}

@keyframes markerPulse {
    0% {
        transform: scale(1);
        opacity: 0.6;
    }
    100% {
        transform: scale(2.8);
        opacity: 0;
    }
}

@keyframes slideUpFade {
    0% {
        transform: translateY(20px);
        opacity: 0;
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}



