/* ============================================================
   events.css — Panel zdarzenia, markery zdarzeń i pojazdów
   Dyspozytornia PSP — Faza 3
   ============================================================ */

/* ================================================================
   PANEL ZDARZENIA — prawy sidebar
   ================================================================ */

#event-panel {
    position:       absolute;
    top:            0;
    right:          0;
    width:          340px;
    height:         100%;
    background:     rgba(11, 18, 35, 0.97);
    border-left:    1px solid rgba(255, 255, 255, 0.07);
    backdrop-filter: blur(8px);
    transform:      translateX(100%);
    transition:     transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
    z-index:        25;
    overflow-y:     auto;
    overflow-x:     hidden;
    display:        flex;
    flex-direction: column;
    pointer-events: none;
}

#event-panel.open {
    transform:     translateX(0);
    pointer-events: auto;
    box-shadow:    -6px 0 32px rgba(0,0,0,0.5);
}

/* Scrollbar */
#event-panel::-webkit-scrollbar { width: 4px; }
#event-panel::-webkit-scrollbar-track { background: transparent; }
#event-panel::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 4px; }

/* ---- Nagłówek panelu ---- */
#ep-header {
    display:        flex;
    align-items:    flex-start;
    gap:            10px;
    padding:        16px 16px 12px;
    border-bottom:  1px solid rgba(255,255,255,0.07);
}

#ep-badge {
    flex:           1;
    font-size:      11px;
    font-weight:    700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding:        5px 10px;
    border-radius:  5px;
    line-height:    1.3;
    background:     #e63946;
    color:          #fff;
}

#ep-close {
    flex-shrink:    0;
    background:     transparent;
    border:         none;
    color:          rgba(255,255,255,0.5);
    font-size:      22px;
    line-height:    1;
    cursor:         pointer;
    padding:        0 4px;
    transition:     color 0.2s;
}
#ep-close:hover { color: #fff; }

/* ---- Treść ---- */
#ep-body {
    padding:  16px;
    flex:     1;
    display:  flex;
    flex-direction: column;
    gap:      14px;
}

#ep-address {
    font-size:   15px;
    font-weight: 600;
    color:       #e8eaf0;
    line-height: 1.4;
}

#ep-description {
    font-size:   13px;
    color:       rgba(220, 225, 240, 0.7);
    line-height: 1.55;
    font-style:  italic;
}

/* Status + czas */
#ep-meta {
    display:     flex;
    align-items: center;
    gap:         10px;
    font-size:   12px;
}

.ep-meta-item {
    display:     flex;
    align-items: center;
    gap:         5px;
    color:       rgba(200,210,230,0.6);
}

.ep-status-label { color: rgba(200,210,230,0.5); }

.ep-status-val {
    font-weight:  700;
    padding:      2px 8px;
    border-radius: 4px;
    font-size:    11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.ep-status-val.status-nowe        { background: #1a3060; color: #90c0ff; }
.ep-status-val.status-przydzielone { background: #2d1a00; color: #f77f00; }
.ep-status-val.status-w_trakcie   { background: #1a0014; color: #f72585; }
.ep-status-val.status-zakonczone  { background: #0a2012; color: #2ecc71; }
.ep-status-val.status-anulowane   { background: #1a1a1a; color: #888; }

/* Czas */
#ep-time {
    font-size: 11px;
    color:     rgba(200,210,230,0.45);
    margin-left: auto;
}

/* Separator sekcji */
.ep-section {
    border-top:  1px solid rgba(255,255,255,0.06);
    padding-top: 14px;
}

.ep-section-title {
    font-size:      11px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color:          rgba(200,210,230,0.4);
    margin-bottom:  10px;
    font-weight:    600;
}

/* Alert w panelu */
.ep-alert {
    font-size:    13px;
    padding:      8px 12px;
    border-radius: 5px;
    display:      none;
}
.ep-alert-success { background: rgba(46,204,113,0.15); color: #2ecc71; border: 1px solid rgba(46,204,113,0.25); }
.ep-alert-error   { background: rgba(230, 57, 70, 0.15); color: #e63946; border: 1px solid rgba(230,57,70,0.25); }

/* ---- Lista pojazdów do dyspozycji ---- */
#ep-vehicles-list {
    display:       flex;
    flex-direction: column;
    gap:           6px;
    max-height:    220px;
    overflow-y:    auto;
    margin-bottom: 12px;
}
#ep-vehicles-list::-webkit-scrollbar { width: 3px; }
#ep-vehicles-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); }

.vehicle-check-item {
    display:        flex;
    align-items:    center;
    gap:            8px;
    padding:        8px 10px;
    background:     rgba(255,255,255,0.04);
    border:         1px solid rgba(255,255,255,0.06);
    border-radius:  6px;
    cursor:         pointer;
    transition:     background 0.15s, border-color 0.15s;
    user-select:    none;
}
.vehicle-check-item:not(.disabled):hover {
    background:    rgba(255,255,255,0.08);
    border-color:  rgba(255,255,255,0.12);
}
.vehicle-check-item.disabled {
    opacity:  0.45;
    cursor:   not-allowed;
}
.vehicle-check-item input[type="checkbox"] {
    accent-color: #e63946;
    width:  14px;
    height: 14px;
    flex-shrink: 0;
}

.vc-name {
    flex:        1;
    font-size:   13px;
    font-weight: 600;
    color:       #cdd5e0;
    white-space: nowrap;
    overflow:    hidden;
    text-overflow: ellipsis;
}
.vc-type {
    font-size:      11px;
    color:          rgba(200,210,230,0.4);
    background:     rgba(255,255,255,0.05);
    padding:        2px 6px;
    border-radius:  3px;
    white-space:    nowrap;
}
.vc-status {
    font-size:      10px;
    font-weight:    700;
    padding:        2px 7px;
    border-radius:  3px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space:    nowrap;
}
.vc-status.vm-dostepny    { background: rgba(46,204,113,0.15);  color: #2ecc71; }
.vc-status.vm-w_drodze    { background: rgba(230,57,70,0.15);   color: #e63946; }
.vc-status.vm-na_miejscu  { background: rgba(247,127,0,0.15);   color: #f77f00; }
.vc-status.vm-powrot      { background: rgba(52,152,219,0.15);  color: #3498db; }
.vc-status.vm-niedostepny { background: rgba(136,136,136,0.12); color: #888; }

.ep-no-vehicles {
    font-size:  13px;
    color:      rgba(200,210,230,0.4);
    text-align: center;
    padding:    16px 0;
}

/* Przyciski akcji */
.btn-dispatch,
.btn-finish {
    width:          100%;
    padding:        11px;
    border:         none;
    border-radius:  7px;
    font-family:    inherit;
    font-size:      13px;
    font-weight:    700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    cursor:         pointer;
    transition:     background 0.2s, opacity 0.2s;
}
.btn-dispatch {
    background: #e63946;
    color:      #fff;
}
.btn-dispatch:hover:not(:disabled) { background: #c8303b; }
.btn-dispatch:disabled             { opacity: 0.5; cursor: not-allowed; }

.btn-finish {
    background: rgba(46,204,113,0.15);
    color:      #2ecc71;
    border:     1px solid rgba(46,204,113,0.3);
}
.btn-finish:hover:not(:disabled) {
    background: rgba(46,204,113,0.25);
}
.btn-finish:disabled { opacity: 0.5; cursor: not-allowed; }

/* ================================================================
   LICZNIK ZDARZEŃ — HUD
   ================================================================ */

#hud-events {
    display:     flex;
    align-items: center;
    gap:         6px;
    padding:     0 14px;
    font-size:   13px;
    color:       rgba(200,210,230,0.5);
    transition:  color 0.3s;
    cursor:      default;
}

#hud-events.has-events {
    color: #f77f00;
}

#events-count {
    font-size:   20px;
    font-weight: 700;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.hud-events-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.07em;
}

/* Pulsowanie gdy są aktywne zdarzenia */
#hud-events.has-events #events-count {
    animation: hud-blink 1.4s ease-in-out infinite;
}
@keyframes hud-blink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.55; }
}

/* ================================================================
   MARKERY ZDARZEŃ
   ================================================================ */

/* NIE ustawiamy position:relative na .event-marker — Mapbox GL JS
   wymaga, by własne elementy markerów nie miały ustawionego position,
   aby mógł sam je absolutnie pozycjonować na mapie. */
.event-marker {
    cursor: pointer;
}

/* Wrapper wewnętrzny dostarcza kontekst pozycjonowania dla pulse */
.em-wrapper {
    position: relative;
    width:    36px;
    height:   36px;
    display:  flex;
    align-items:    center;
    justify-content: center;
}

.em-inner {
    width:           32px;
    height:          32px;
    border-radius:   50%;
    display:         flex;
    align-items:     center;
    justify-content: center;
    border:          2.5px solid rgba(255,255,255,0.9);
    box-shadow:      0 3px 12px rgba(0,0,0,0.5);
    position:        relative;
    z-index:         2;
    transition:      transform 0.15s;
    flex-shrink:     0;
}
.event-marker:hover .em-inner {
    transform: scale(1.15);
}

/* Pulsujący pierścień */
.em-pulse {
    position:  absolute;
    top:       50%;
    left:      50%;
    transform: translate(-50%, -50%);
    width:     32px;
    height:    32px;
    border-radius: 50%;
    background: var(--em-color, #e63946);
    opacity:   0;
    z-index:   1;
    animation: em-pulse-anim 2s ease-out infinite;
}
.em-cat-I    .em-pulse { animation-duration: 1.2s; }
.em-cat-II   .em-pulse { animation-duration: 1.8s; }
.em-cat-III  .em-pulse { animation-duration: 2.5s; }

@keyframes em-pulse-anim {
    0%   { transform: translate(-50%,-50%) scale(1);   opacity: 0.65; }
    100% { transform: translate(-50%,-50%) scale(3.5); opacity: 0; }
}

/* ================================================================
   MARKERY POJAZDÓW
   ================================================================ */

/* Podobnie jak dla zdarzeń — NIE ustawiamy position na .vehicle-marker */
.vehicle-marker {
    cursor: default;
    filter: drop-shadow(0 2px 5px rgba(0,0,0,0.5));
    transition: filter 0.2s;
    line-height: 1;
}

.vm-icon {
    display: block;
    width:   32px;
    height:  20px;
}

.vm-label {
    display:        block;
    font-size:      9px;
    font-weight:    700;
    letter-spacing: 0.04em;
    line-height:    1;
    margin-top:     2px;
    text-shadow:    0 1px 3px rgba(0,0,0,0.8);
    white-space:    nowrap;
    text-align:     center;
}

/* Pulsowanie dla pojazdu w drodze */
.vehicle-marker.vm-w_drodze {
    animation: vm-pulse 1.8s ease-in-out infinite;
}
@keyframes vm-pulse {
    0%, 100% { filter: drop-shadow(0 2px 5px rgba(0,0,0,0.5)) brightness(1); }
    50%       { filter: drop-shadow(0 0 8px currentColor)      brightness(1.4); }
}

/* ================================================================
   TOAST — powiadomienie o nowym zdarzeniu
   ================================================================ */

.event-toast {
    position:       fixed;
    bottom:         80px;
    right:          20px;
    width:          300px;
    background:     rgba(11, 18, 35, 0.95);
    border:         1px solid rgba(255,255,255,0.1);
    border-left:    3px solid var(--ep-color, #e63946);
    border-radius:  8px;
    padding:        12px 14px;
    display:        flex;
    align-items:    center;
    gap:            12px;
    cursor:         pointer;
    z-index:        200;
    box-shadow:     0 6px 24px rgba(0,0,0,0.5);
    animation:      toast-in 0.4s cubic-bezier(0.22, 1, 0.36, 1);
    transition:     opacity 0.4s, transform 0.4s;
    backdrop-filter: blur(10px);
}
.event-toast:hover {
    background: rgba(20, 30, 55, 0.97);
}
.event-toast.toast-out {
    opacity:   0;
    transform: translateX(20px);
}

@keyframes toast-in {
    from { opacity: 0; transform: translateX(30px); }
    to   { opacity: 1; transform: translateX(0); }
}

.toast-badge {
    flex-shrink:    0;
    font-size:      9px;
    font-weight:    700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding:        4px 7px;
    border-radius:  4px;
    line-height:    1.4;
}

.toast-body { flex: 1; min-width: 0; }

.toast-type {
    font-size:    13px;
    font-weight:  700;
    color:        #e8eaf0;
    white-space:  nowrap;
    overflow:     hidden;
    text-overflow: ellipsis;
}

.toast-addr {
    font-size:    11px;
    color:        rgba(200,210,230,0.55);
    white-space:  nowrap;
    overflow:     hidden;
    text-overflow: ellipsis;
    margin-top:   3px;
}
