/* Main Canvas Styles */

#main-viewport {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
    background: var(--canvas-bg);
    z-index: 1;  /* Behind all panels */
}

#simulation-canvas {
    width: 100%;
    height: 100%;
    cursor: crosshair;
    image-rendering: crisp-edges;
    image-rendering: -webkit-crisp-edges;
}

#simulation-canvas.panning {
    cursor: grab;
}

#simulation-canvas.panning:active {
    cursor: grabbing;
}

#simulation-canvas.placing-device {
    cursor: copy;
}

#simulation-canvas.drawing-wall {
    cursor: crosshair;
}

/* Grid Overlay Effect (handled via canvas drawing) */
.grid-visible {
    position: relative;
}

.grid-visible::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        linear-gradient(var(--canvas-grid-major) 1px, transparent 1px),
        linear-gradient(90deg, var(--canvas-grid-major) 1px, transparent 1px),
        linear-gradient(var(--canvas-grid) 0.5px, transparent 0.5px),
        linear-gradient(90deg, var(--canvas-grid) 0.5px, transparent 0.5px);
    background-size:
        125px 125px,
        125px 125px,
        25px 25px,
        25px 25px;
    pointer-events: none;
    opacity: 0.3;
}

/* Zoom Controls */
.zoom-controls {
    position: absolute;
    bottom: 2rem;
    right: 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    background: var(--bg-panel);
    padding: 0.5rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
}

.zoom-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 1rem;
    transition: all var(--transition-fast);
}

.zoom-btn:hover {
    background: var(--bg-hover);
    color: var(--primary-blue);
    border-color: var(--primary-blue);
}

.zoom-btn:active {
    transform: scale(0.95);
}

/* Pan & Zoom Toggle */
.pan-zoom-btn.active {
    background: var(--primary-blue);
    color: #fff;
    border-color: var(--primary-blue);
    box-shadow: 0 0 8px rgba(79, 116, 229, 0.4);
}

.pan-zoom-btn.active:hover {
    background: var(--primary-blue-hover, #3b5cbd);
    color: #fff;
}

.zoom-divider {
    width: 100%;
    height: 1px;
    background: var(--border-color);
}

.zoom-level {
    text-align: center;
    padding: 0.25rem 0;
    border-top: 1px solid var(--border-color);
    margin-top: 0.25rem;
}

#zoom-display {
    font-size: 0.813rem;
    font-weight: 600;
    color: var(--accent-teal);
}

/* Elenium Logo */
.elenium-logo {
    position: absolute;
    bottom: 2rem;
    right: 2rem;
    width: 120px;
    height: auto;
    opacity: 0.8;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 100;
    /* Position below zoom controls */
    margin-top: 12rem;
}

.elenium-logo img {
    width: 100%;
    height: auto;
    display: block;
}

.elenium-tagline {
    display: block;
    text-align: center;
    font-size: 0.5rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.8);
    letter-spacing: 0.5px;
    margin-top: 0.25rem;
    white-space: nowrap;
}

/* Adjust zoom controls to make space for logo */
.zoom-controls {
    bottom: 10rem !important; /* Move zoom controls up to make room for logo */
}

/* Live Statistics Overlay */
.live-stats-overlay {
    position: absolute;
    top: 1rem;
    left: 1rem;
    width: 280px;
    height: 520px;
    max-height: calc(100% - 2rem);
    background: rgba(22, 24, 35, 0.92);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    z-index: 200;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-size: 12px;
}

.live-stats-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.25);
    flex-shrink: 0;
}

.live-stats-title {
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.live-stats-title i {
    color: var(--primary-blue);
}

.live-stats-close {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.7rem;
    transition: all 0.15s;
}

.live-stats-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.live-stats-body {
    padding: 0.5rem 0.75rem 0.75rem;
    overflow-y: auto;
    flex: 1;
}

.live-stats-section {
    margin-bottom: 0.6rem;
}

.live-stats-section:last-child {
    margin-bottom: 0;
}

.live-stats-section-title {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0 0 0.35rem 0;
}

.live-stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.35rem;
}

.live-stats-grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.live-stat-item {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    padding: 0.4rem 0.5rem;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 5px;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.live-stat-label {
    font-size: 0.6rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.live-stat-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.2;
}

/* Passenger Detail Overlay */
.pax-detail-overlay {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 310px;
    height: 540px;
    max-height: calc(100% - 2rem);
    background: rgba(22, 24, 35, 0.94);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
    z-index: 210;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-size: 12px;
}

.pax-detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.55rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.25);
    flex-shrink: 0;
    cursor: grab;
}

.pax-detail-header:active {
    cursor: grabbing;
}

.pax-detail-title {
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.pax-detail-title i {
    color: #f59e0b;
}

.pax-detail-close {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.7rem;
    transition: all 0.15s;
}

.pax-detail-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.pax-detail-body {
    padding: 0.5rem 0.75rem 0.75rem;
    overflow-y: auto;
    flex: 1;
}

.pax-detail-section {
    margin-bottom: 0.55rem;
}

.pax-detail-section:last-child {
    margin-bottom: 0;
}

.pax-detail-section-title {
    font-size: 0.62rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0 0 0.3rem 0;
    padding-bottom: 0.2rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.pax-detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.2rem 0;
    gap: 0.5rem;
}

.pax-detail-label {
    font-size: 0.68rem;
    color: var(--text-muted);
    flex-shrink: 0;
    min-width: 90px;
}

.pax-detail-value {
    font-size: 0.72rem;
    color: var(--text-primary);
    text-align: right;
    word-break: break-word;
    line-height: 1.3;
}

.pax-detail-progress-wrap {
    position: relative;
    height: 14px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    overflow: hidden;
    min-width: 80px;
}

.pax-detail-progress-bar {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    border-radius: 4px;
    transition: width 0.25s ease;
}

.pax-detail-progress-text {
    position: relative;
    z-index: 1;
    font-size: 0.6rem;
    font-weight: 600;
    color: #fff;
    width: 100%;
    text-align: center;
    line-height: 14px;
}

/* Mouse Controls Help */
.mouse-controls-help {
    position: absolute;
    top: 2rem;
    right: 2rem;
    background: var(--bg-panel);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    font-size: 0.75rem;
    opacity: 0.7;
    transition: opacity 0.3s ease;
    z-index: 100;
    min-width: 180px;
}

.mouse-controls-help:hover {
    opacity: 0.95;
}

.mouse-controls-help .controls-header {
    color: var(--text-primary);
    font-weight: 600;
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.mouse-controls-help .control-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.25rem 0;
    color: var(--text-secondary);
}

.mouse-controls-help .control-action {
    font-weight: 500;
    color: var(--text-primary);
}

.mouse-controls-help .control-keys {
    font-size: 0.7rem;
    color: var(--accent-color);
    background: var(--bg-hover);
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    white-space: nowrap;
}

/* Scale Indicator */
.scale-indicator {
    position: absolute;
    bottom: 2rem;
    left: 2rem;
    background: var(--bg-panel);
    padding: 0.75rem 1rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.scale-bar {
    width: 25px;
    height: 2px;
    background: var(--primary-blue);
    position: relative;
}

.scale-bar::before,
.scale-bar::after {
    content: '';
    position: absolute;
    width: 2px;
    height: 8px;
    background: var(--primary-blue);
    top: -3px;
}

.scale-bar::before {
    left: 0;
}

.scale-bar::after {
    right: 0;
}

.scale-text {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
}

/* Simulation Stats Indicator */
.simulation-stats-indicator {
    position: absolute;
    top: 5rem;
    right: 1rem;
    background: var(--bg-panel);
    padding: 0.75rem 1rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    font-size: 0.813rem;
    color: var(--text-secondary);
    min-width: 150px;
}

.stats-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.25rem 0;
}

.stats-row i {
    color: var(--primary-teal);
    width: 16px;
    text-align: center;
    font-size: 0.875rem;
}

.stats-row span {
    color: var(--primary-blue);
    font-weight: 600;
    font-family: 'Courier New', monospace;
    flex: 1;
    text-align: right;
}

#mouse-position {
    min-width: 120px;
}

/* Passenger Type Legend */
.passenger-legend {
    position: absolute;
    bottom: 6rem; /* Position above scale indicator */
    left: 2rem;
    background: var(--bg-panel);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    min-width: 180px;
}

.legend-title {
    font-size: 0.813rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.legend-items {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3);
    flex-shrink: 0;
}

.legend-item span {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Device Overlays on Canvas */
.device-overlay {
    position: absolute;
    border: 2px solid var(--primary-blue);
    border-radius: 4px;
    background: rgba(79, 116, 229, 0.1);
    pointer-events: all;
    cursor: move;
    transition: all var(--transition-fast);
}

.device-overlay:hover {
    border-color: var(--accent-teal);
    background: rgba(75, 192, 186, 0.15);
    box-shadow: 0 0 10px rgba(75, 192, 186, 0.3);
}

.device-overlay.selected {
    border-color: var(--accent-amber);
    background: rgba(254, 190, 16, 0.15);
    box-shadow: 0 0 15px rgba(254, 190, 16, 0.4);
}

.device-overlay .device-label {
    position: absolute;
    top: -24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-panel);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.688rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    border: 1px solid var(--border-color);
}

/* Queue Visualization */
.queue-line {
    position: absolute;
    height: 2px;
    background: linear-gradient(90deg,
        var(--primary-blue) 0%,
        var(--primary-blue) 50%,
        transparent 50%,
        transparent 100%);
    background-size: 10px 2px;
    animation: queue-flow 1s linear infinite;
}

@keyframes queue-flow {
    0% {
        background-position: 0 0;
    }
    100% {
        background-position: 10px 0;
    }
}

/* Passenger Sprites */
.passenger {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    transition: transform 0.1s linear;
    pointer-events: none;
    z-index: 50;
}

.passenger.business {
    background: var(--primary-blue);
    box-shadow: 0 0 4px rgba(79, 116, 229, 0.5);
}

.passenger.regular {
    background: var(--text-primary);
    box-shadow: 0 0 4px rgba(255, 255, 255, 0.3);
}

.passenger.family {
    background: var(--accent-teal);
    box-shadow: 0 0 4px rgba(75, 192, 186, 0.5);
}

.passenger.elderly {
    background: var(--text-secondary);
    box-shadow: 0 0 4px rgba(168, 179, 207, 0.5);
}

.passenger.late {
    background: var(--danger);
    box-shadow: 0 0 6px rgba(231, 76, 60, 0.7);
    animation: pulse-urgent 0.5s infinite;
}

.passenger.disabled {
    background: var(--accent-amber);
    box-shadow: 0 0 4px rgba(254, 190, 16, 0.5);
}

@keyframes pulse-urgent {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2);
    }
}

/* Waypoint Markers */
.waypoint {
    position: absolute;
    width: 20px;
    height: 20px;
    background: var(--primary-blue);
    border: 2px solid var(--text-primary);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    cursor: pointer;
    z-index: 40;
}

.waypoint::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 6px;
    height: 6px;
    background: var(--text-primary);
    border-radius: 50%;
}

.waypoint.entry {
    background: var(--success);
}

.waypoint.exit {
    background: var(--danger);
}

/* Wall Elements */
.wall {
    position: absolute;
    background: var(--border-color);
    opacity: 0.8;
}

.wall.horizontal {
    height: 4px;
    cursor: ns-resize;
}

.wall.vertical {
    width: 4px;
    cursor: ew-resize;
}

.wall:hover {
    background: var(--primary-blue);
    opacity: 1;
}

/* Floor Plan Overlay */
.floor-plan-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0.3;
    z-index: 1;
}

/* Selection Box */
.selection-box {
    position: absolute;
    border: 1px dashed var(--primary-blue);
    background: rgba(79, 116, 229, 0.1);
    pointer-events: none;
}

/* Measurement Tool */
.measurement-line {
    position: absolute;
    background: var(--accent-amber);
    height: 2px;
    transform-origin: left center;
    pointer-events: none;
}

.measurement-label {
    position: absolute;
    background: var(--bg-panel);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    color: var(--accent-amber);
    border: 1px solid var(--accent-amber);
    white-space: nowrap;
}