/* ═══════════════════════════════════════════
   Эшелон-Z — UX Systems
   Toast, Alert, WS Banner, Hotkeys, Confirm
   ═══════════════════════════════════════════ */


/* ═══════════════════════════════════════════
   TOAST NOTIFICATIONS
   ═══════════════════════════════════════════ */

.toast-stack {
    position: fixed;
    bottom: 64px;
    right: 16px;
    z-index: 800;
    display: flex;
    flex-direction: column-reverse;
    gap: 6px;
    max-width: 360px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 12px;
    background: rgba(10, 14, 20, 0.95);
    border: 1px solid var(--border);
    border-left: 3px solid var(--cyan);
    border-radius: 2px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    pointer-events: auto;
    opacity: 0;
    transform: translateX(40px);
    transition: opacity 0.25s ease, transform 0.25s ease;
    max-width: 360px;
}

.toast-visible {
    opacity: 1;
    transform: translateX(0);
}

.toast-exit {
    opacity: 0;
    transform: translateX(40px) scale(0.95);
}

/* Level colors */
.toast-info    { border-left-color: var(--cyan); }
.toast-warning { border-left-color: var(--orange); }
.toast-critical {
    border-left-color: var(--red);
    background: rgba(255, 23, 68, 0.08);
    border-color: rgba(255, 23, 68, 0.25);
    border-left-color: var(--red);
}

.toast-icon {
    font-size: 13px;
    flex-shrink: 0;
    line-height: 1;
    margin-top: 1px;
}
.toast-info .toast-icon    { color: var(--cyan); }
.toast-warning .toast-icon { color: var(--orange); }
.toast-critical .toast-icon { color: var(--red); }

.toast-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.toast-msg {
    font-family: var(--font-mono);
    font-size: 10px;
    line-height: 1.5;
    color: var(--text-primary);
    word-break: break-word;
}

.toast-detail {
    font-size: 9px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 10px;
    cursor: pointer;
    padding: 0 2px;
    flex-shrink: 0;
    transition: color 0.15s;
    line-height: 1;
}
.toast-close:hover {
    color: var(--text-primary);
}


/* ═══════════════════════════════════════════
   ALERT BANNER (critical, top of screen)
   ═══════════════════════════════════════════ */

.alert-banner-wrap {
    position: fixed;
    top: 64px;
    left: 0;
    right: 0;
    z-index: 400;
    display: flex;
    flex-direction: column;
    pointer-events: none;
}

.alert-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.05em;
    pointer-events: auto;
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.3s, transform 0.3s;
}

.alert-banner.alert-visible {
    opacity: 1;
    transform: translateY(0);
}

.alert-critical {
    background: rgba(255, 23, 68, 0.12);
    border-bottom: 1px solid rgba(255, 23, 68, 0.35);
    color: var(--red);
}

.alert-warning {
    background: rgba(255, 145, 0, 0.1);
    border-bottom: 1px solid rgba(255, 145, 0, 0.3);
    color: var(--orange);
}

.alert-icon {
    font-size: 14px;
    flex-shrink: 0;
    animation: alert-pulse 1.5s ease infinite;
}

@keyframes alert-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.alert-msg {
    flex: 1;
    font-weight: 600;
}

.alert-dismiss {
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: inherit;
    font-size: 10px;
    width: 24px;
    height: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    flex-shrink: 0;
}
.alert-dismiss:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
}


/* ═══════════════════════════════════════════
   WS CONNECTION BANNER
   ═══════════════════════════════════════════ */

.ws-banner {
    position: fixed;
    top: 64px;
    left: 0;
    right: 0;
    z-index: 450;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 8px 20px;
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.06em;
    opacity: 0;
    transform: translateY(-100%);
    transition: opacity 0.3s, transform 0.3s;
    pointer-events: none;
}

.ws-banner.ws-banner-visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.ws-banner-disconnected {
    background: rgba(255, 23, 68, 0.12);
    border-bottom: 1px solid rgba(255, 23, 68, 0.3);
    color: var(--red);
}

.ws-banner-reconnecting {
    background: rgba(255, 145, 0, 0.1);
    border-bottom: 1px solid rgba(255, 145, 0, 0.25);
    color: var(--orange);
}

.ws-banner-restored {
    background: rgba(0, 230, 118, 0.1);
    border-bottom: 1px solid rgba(0, 230, 118, 0.3);
    color: var(--green);
}

.ws-banner-icon {
    font-size: 14px;
    animation: ws-icon-pulse 1s ease infinite;
}
.ws-banner-restored .ws-banner-icon {
    animation: none;
}

@keyframes ws-icon-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.ws-banner-msg {
    font-weight: 600;
}

.ws-banner-detail {
    font-size: 9px;
    color: var(--text-secondary);
    opacity: 0.8;
}

/* Body class for stale-data dimming */
body.ws-offline .hud-left,
body.ws-offline .hud-right {
    opacity: 0.5;
    transition: opacity 0.5s;
}
body.ws-offline .hud-left::after,
body.ws-offline .hud-right::after {
    content: 'ДАННЫЕ УСТАРЕЛИ';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: var(--font-display);
    font-size: 9px;
    letter-spacing: 0.15em;
    color: var(--red);
    opacity: 0.7;
    z-index: 10;
    pointer-events: none;
}


/* ═══════════════════════════════════════════
   HOTKEY CHEATSHEET OVERLAY
   ═══════════════════════════════════════════ */

.hk-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.2s;
}
.hk-overlay.hk-visible {
    opacity: 1;
}

.hk-modal {
    width: 420px;
    max-width: 95vw;
    max-height: 80vh;
    background: rgba(10, 14, 20, 0.97);
    border: 1px solid var(--border-accent);
    box-shadow: 0 0 40px rgba(0, 229, 255, 0.06);
    display: flex;
    flex-direction: column;
}

.hk-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-accent);
    background: linear-gradient(180deg, rgba(0,229,255,0.04) 0%, transparent 100%);
}

.hk-title {
    font-family: var(--font-display);
    font-size: 13px;
    letter-spacing: 0.15em;
    color: var(--text-primary);
}

.hk-close {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    width: 24px;
    height: 24px;
    font-size: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
.hk-close:hover {
    border-color: var(--red);
    color: var(--red);
}

.hk-body {
    padding: 12px 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

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

.hk-cat {
    font-family: var(--font-display);
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.2em;
    color: var(--cyan);
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(0, 229, 255, 0.1);
}

.hk-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 3px 0;
}

.hk-keys {
    display: flex;
    align-items: center;
    gap: 3px;
    min-width: 80px;
    justify-content: flex-end;
}

.hk-kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 3px;
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1;
}

.hk-plus {
    font-size: 9px;
    color: var(--text-dim);
}

.hk-label {
    font-size: 10px;
    color: var(--text-secondary);
    letter-spacing: 0.04em;
}

.hk-footer {
    padding: 8px 16px;
    border-top: 1px solid var(--border);
    font-size: 9px;
    color: var(--text-dim);
    text-align: center;
}
.hk-footer .hk-kbd {
    font-size: 9px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
}


/* ═══════════════════════════════════════════
   CONFIRM BUTTON STATE
   ═══════════════════════════════════════════ */

.hud-btn.btn-confirm-pending {
    background: rgba(255, 23, 68, 0.15) !important;
    border-color: var(--red) !important;
    color: var(--red) !important;
    animation: confirm-flash 0.8s ease infinite;
}

@keyframes confirm-flash {
    0%, 100% { box-shadow: 0 0 0 rgba(255,23,68,0); }
    50% { box-shadow: 0 0 12px rgba(255,23,68,0.3); }
}

/* Progress bar inside confirm button */
.btn-confirm-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 2px;
    background: var(--red);
    transition: width linear;
}


/* ═══════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════ */

@media (max-width: 767px) {
    .toast-stack {
        right: 8px;
        left: 8px;
        bottom: 56px;
        max-width: none;
    }
    .toast {
        max-width: none;
    }
    .alert-banner-wrap {
        top: 40px;
    }
    .ws-banner {
        top: 40px;
        font-size: 10px;
        padding: 6px 12px;
    }
    .hk-modal {
        width: 90vw;
    }
}

@media (max-width: 1024px) and (min-width: 768px) {
    .alert-banner-wrap {
        top: 50px;
    }
    .ws-banner {
        top: 50px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .toast,
    .alert-banner,
    .ws-banner {
        transition-duration: 0.01ms !important;
    }
    .alert-icon,
    .ws-banner-icon {
        animation: none !important;
    }
    @keyframes confirm-flash { 0%, 100% { box-shadow: none; } }
}

/* ═══════════════════════════════════════════
   Map Style Switcher
   ═══════════════════════════════════════════ */

.btn-map-style {
    position: relative;
    font-size: 10px;
    white-space: nowrap;
}
.btn-map-style.active {
    background: var(--cyan-dim);
    color: var(--cyan);
}

.map-style-dropdown {
    display: none;
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-panel);
    border: 1px solid var(--border-accent);
    border-radius: var(--panel-radius);
    overflow: hidden;
    z-index: 900;
    min-width: 160px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}
.map-style-dropdown.visible {
    display: block;
}

.map-style-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    cursor: pointer;
    font: 10px var(--font-mono);
    color: var(--text-secondary);
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}
.map-style-option:hover {
    background: rgba(0, 229, 255, 0.08);
    color: var(--text-primary);
}
.map-style-option.active {
    background: var(--cyan-dim);
    color: var(--cyan);
}
.mso-icon {
    font-size: 14px;
    width: 20px;
    text-align: center;
}
.mso-label {
    letter-spacing: 0.5px;
}

/* ═══════════════════════════════════════════
   Urban Zones overlay
   ═══════════════════════════════════════════ */

.urban-legend {
    position: absolute;
    bottom: 64px;
    left: 16px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--panel-radius);
    padding: 6px 10px;
    font: 9px var(--font-mono);
    color: var(--text-secondary);
    z-index: 100;
    pointer-events: none;
    opacity: 0.7;
}
.urban-legend-dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--orange);
    opacity: 0.5;
    margin-right: 4px;
    vertical-align: middle;
}

@media (max-width: 767px) {
    .map-style-dropdown {
        bottom: calc(100% + 4px);
        min-width: 140px;
    }
    .map-style-option {
        padding: 10px 12px;
    }
    .urban-legend {
        bottom: 56px;
        left: 8px;
    }
}
