/* ==========================================================================
   SİSTEM SAHNESİ — Pass 3 CSS
   Endüstriyel Piksel Fabrika & Ofis Teması
   ========================================================================== */

:root {
    --bg-main: #f6f1e8;
    --bg-panel: #ede5d8;
    --bg-card: #ffffff;
    --border-color: #d6cbba;
    --text-main: #1f2937;
    --text-dim: #6b7280;
    --color-calisiyor: #10b981;
    --color-uyuyor: #64748b;
    --color-bozuk: #ef4444;
    --color-engelli: #94a3b8;
    --color-accent: #0284c7;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
}

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: var(--font-mono);
    font-size: 14px;
    line-height: 1.4;
    user-select: none;
}

#app-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    position: relative;
}

/* --------------------------------------------------------------------------
   ÜST ÇUBUK (HEADER)
   -------------------------------------------------------------------------- */
#top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    background-color: var(--bg-panel);
    border-bottom: 2px solid var(--border-color);
    flex-wrap: wrap;
    gap: 12px;
    z-index: 20;
    min-height: 48px;
}

.top-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
    font-size: 15px;
    letter-spacing: 0.05em;
    color: #1e293b;
}

.live-tag {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-dim);
    background: #fbf8f2;
    padding: 3px 8px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

.pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--color-calisiyor);
    box-shadow: 0 0 6px var(--color-calisiyor);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.85); }
}

.machine-gauges {
    display: flex;
    align-items: center;
    gap: 12px;
}

.gauge-card {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #fbf8f2;
    padding: 4px 10px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    font-size: 12px;
}

.gauge-label {
    font-weight: 700;
    color: #4b5563;
}

.gauge-bar-bg {
    width: 50px;
    height: 8px;
    background: #e2e8f0;
    border-radius: 3px;
    overflow: hidden;
    border: 1px solid #cbd5e1;
}

.gauge-bar-fill {
    height: 100%;
    background: var(--color-accent);
    transition: width 0.3s ease;
}

.gauge-val {
    font-weight: 700;
    min-width: 32px;
    text-align: right;
    color: #1f2937;
}

.state-counts {
    display: flex;
    align-items: center;
    gap: 8px;
}

.count-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 700;
    background: #fbf8f2;
    border: 1px solid var(--border-color);
}

.pill-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.count-pill.state-calisiyor .pill-dot { background: var(--color-calisiyor); box-shadow: 0 0 6px var(--color-calisiyor); }
.count-pill.state-uyuyor .pill-dot { background: var(--color-uyuyor); }
.count-pill.state-bozuk .pill-dot { background: var(--color-bozuk); box-shadow: 0 0 6px var(--color-bozuk); }
.count-pill.state-engelli .pill-dot { background: var(--color-engelli); }

.pill-num {
    font-size: 13px;
    padding-left: 2px;
    color: #1f2937;
}

.top-controls {
    display: flex;
    gap: 6px;
}

.btn-ctrl {
    background: #fbf8f2;
    color: #1f2937;
    border: 1px solid #cbd5e1;
    padding: 4px 9px;
    border-radius: 4px;
    cursor: pointer;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.15s ease;
}

.btn-ctrl:hover {
    background: #e2e8f0;
    border-color: #94a3b8;
}

/* --------------------------------------------------------------------------
   TOP PANEL (PLAIN HTML) — İLK GÖRÜNEN DURUM ÖZETİ
   -------------------------------------------------------------------------- */
.status-summary-panel {
    background: #fdfbf7;
    border-bottom: 2px solid var(--border-color);
    padding: 8px 16px;
    z-index: 15;
    display: flex;
    flex-direction: column;
    gap: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    transition: padding 0.15s ease;
}

.status-summary-panel.collapsed {
    padding: 5px 14px;
    gap: 0;
}

.status-summary-panel.collapsed #panel-expanded-body,
.status-summary-panel.collapsed #panel-expanded-header {
    display: none !important;
}

.status-summary-panel.collapsed #panel-collapsed-summary {
    display: flex !important;
}

.panel-bar-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
}

.panel-expanded-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.05em;
    color: var(--text-dim);
}

.panel-badge-icon {
    font-size: 13px;
}

.panel-collapsed-line {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 700;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.btn-panel-toggle {
    background: #fbf8f2;
    color: #1f2937;
    border: 1px solid #cbd5e1;
    padding: 3px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-family: inherit;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.15s ease;
    margin-left: auto;
}

.btn-panel-toggle:hover {
    background: #e2e8f0;
    border-color: #94a3b8;
}

.panel-expanded-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 2px;
}

.summary-section {
    padding: 6px 12px;
    border-radius: 6px;
}

.bozuk-wrap {
    background: #fef2f2;
    border: 1.5px solid #fca5a5;
}

.bozuk-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 800;
    color: #991b1b;
    margin-bottom: 4px;
    letter-spacing: 0.04em;
}

.bozuk-sentences {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.bozuk-sentences li {
    font-size: 13px;
    line-height: 1.5;
    color: #450a0a;
    padding-left: 12px;
    position: relative;
}

.bozuk-sentences li::before {
    content: "•";
    position: absolute;
    left: 0;
    color: #ef4444;
    font-size: 16px;
}

.bozuk-label {
    font-weight: 700;
    color: #991b1b;
}

.bozuk-duration {
    font-weight: 600;
    color: #b91c1c;
}

.bozuk-reason {
    color: #7f1d1d;
    font-style: italic;
}

.all-ok-wrap {
    background: #ecfdf5;
    border: 1.5px solid #a7f3d0;
    padding: 8px 12px;
}

.all-ok-badge {
    font-size: 14px;
    font-weight: 800;
    color: #047857;
    letter-spacing: 0.04em;
}

.summary-secondary {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    font-size: 13px;
    padding: 2px 4px;
}

.summary-line {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #4b5563;
}

.engelli-line {
    color: #374151;
}

.uyuyor-line {
    color: #6b7280;
}

/* --------------------------------------------------------------------------
   CANVAS ALANI VE GÖRSEL SAHNE
   -------------------------------------------------------------------------- */
#canvas-wrapper {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: #f6f1e8;
    touch-action: none;
}

#sahne-canvas {
    width: 100%;
    height: 100%;
    display: block;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    cursor: grab;
}

#sahne-canvas:active {
    cursor: grabbing;
}

/* --------------------------------------------------------------------------
   SAHNE KÖR & TARİHSEL BİLDİRİMLER
   -------------------------------------------------------------------------- */
.kor-banner {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(246, 241, 232, 0.92);
    backdrop-filter: blur(4px);
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: center;
}

.kor-content {
    background: #ffffff;
    border: 2px solid #ef4444;
    padding: 24px 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
}

.kor-icon {
    font-size: 36px;
}

.kor-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.kor-text strong {
    color: #ef4444;
    font-size: 18px;
    letter-spacing: 0.05em;
}

.kor-text span {
    color: #4b5563;
    font-size: 14px;
}

.history-banner {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    background: #d97706;
    color: #fff;
    padding: 8px 18px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 25;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

.btn-return-live {
    background: #fbf8f2;
    color: #1f2937;
    border: 1px solid #f59e0b;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 700;
}

/* --------------------------------------------------------------------------
   DETAY KARTI (INSPECTOR)
   -------------------------------------------------------------------------- */
.inspector {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 320px;
    background: #fdfbf7;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 14px;
    z-index: 28;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    gap: 10px;
    color: #1f2937;
}

.inspector-header {
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid #e5ddcf;
    padding-bottom: 8px;
}

.insp-icon {
    font-size: 24px;
}

.insp-title-group {
    flex: 1;
}

.insp-label {
    font-weight: 800;
    font-size: 15px;
    color: #1f2937;
}

.insp-id {
    display: none !important;
}

.insp-close {
    background: none;
    border: none;
    color: #6b7280;
    font-size: 20px;
    cursor: pointer;
}

.insp-close:hover {
    color: #111827;
}

.inspector-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
}

.insp-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
}

.insp-k {
    color: #6b7280;
    font-size: 12px;
}

.insp-v {
    color: #111827;
    font-weight: 600;
    text-align: right;
    word-break: break-all;
}

.state-badge {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

.state-badge.calisiyor { background: #d1fae5; color: #065f46; }
.state-badge.uyuyor { background: #f1f5f9; color: #475569; }
.state-badge.bozuk { background: #fee2e2; color: #991b1b; }
.state-badge.engelli { background: #f3f4f6; color: #4b5563; }

.tag-engel {
    background: #fed7aa;
    color: #9a3412;
    padding: 2px 6px;
    border-radius: 3px;
}

.insp-members-box {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 4px;
    padding: 6px;
    background: #f4efe6;
    border: 1px solid #e5ddcf;
    border-radius: 4px;
    max-height: 140px;
    overflow-y: auto;
}

.member-item {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
}

/* --------------------------------------------------------------------------
   LEJAND REHBER MODALI
   -------------------------------------------------------------------------- */
.legend-box {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 440px;
    background: #fdfbf7;
    border: 2px solid var(--color-accent);
    border-radius: 8px;
    padding: 16px;
    z-index: 29;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.15);
    color: #1f2937;
}

.legend-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e5ddcf;
    padding-bottom: 8px;
    margin-bottom: 12px;
    font-size: 15px;
    color: var(--color-accent);
}

.legend-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 13px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.leg-color {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    flex-shrink: 0;
}

.leg-color.calisiyor { background: var(--color-calisiyor); }
.leg-color.uyuyor { background: var(--color-uyuyor); }
.leg-color.bozuk { background: var(--color-bozuk); }
.leg-color.engelli { background: var(--color-engelli); }

.legend-divider {
    height: 1px;
    background: #e5ddcf;
    margin: 4px 0;
}

/* --------------------------------------------------------------------------
   ALT ZAMAN ÇİZELGESİ STRİPİ
   -------------------------------------------------------------------------- */
#timeline-bar {
    background: var(--bg-panel);
    border-top: 2px solid var(--border-color);
    padding: 8px 16px;
    z-index: 20;
}

.timeline-header {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    margin-bottom: 6px;
    color: var(--text-dim);
}

.timeline-title {
    font-weight: 700;
    color: #1f2937;
}

#timeline-track-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}

.timeline-time-label {
    font-size: 11px;
    color: #6b7280;
    font-weight: 700;
}

#timeline-track {
    flex: 1;
    height: 12px;
    background: #e5ddcf;
    border-radius: 6px;
    position: relative;
    cursor: pointer;
    border: 1px solid #c7bcab;
}

#timeline-markers {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
}

.timeline-marker {
    position: absolute;
    top: 1px;
    width: 4px;
    height: 8px;
    border-radius: 2px;
    transform: translateX(-50%);
}

.timeline-marker.bozuk { background: #ef4444; }
.timeline-marker.engelli { background: #94a3b8; }
.timeline-marker.calisiyor { background: #10b981; }
.timeline-marker.uyuyor { background: #64748b; }

#timeline-thumb {
    position: absolute;
    top: -4px;
    left: 100%;
    width: 12px;
    height: 20px;
    background: var(--color-accent);
    border-radius: 3px;
    transform: translateX(-50%);
    box-shadow: 0 0 8px rgba(2, 132, 199, 0.7);
    cursor: grab;
}

/* --------------------------------------------------------------------------
   TELEFON GÖRÜNÜMÜ: ODALAR KART LİSTESİ (MOBİL)
   -------------------------------------------------------------------------- */
.mobile-rooms-list {
    display: none;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
    overflow-y: auto;
    background: var(--bg-main);
    z-index: 18;
}

.room-card {
    background: #fdfbf7;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.room-card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e5ddcf;
    padding-bottom: 6px;
}

.room-card-title {
    font-weight: 800;
    font-size: 13px;
    letter-spacing: 0.05em;
    color: #1f2937;
}

.room-card-badge {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
}

.room-card-members {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 11px;
}

.room-member-chip {
    display: flex;
    align-items: center;
    gap: 4px;
    background: #f4efe6;
    padding: 2px 6px;
    border-radius: 3px;
    border: 1px solid #e5ddcf;
    color: #1f2937;
}

.chip-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.chip-dot.calisiyor { background: var(--color-calisiyor); }
.chip-dot.uyuyor { background: var(--color-uyuyor); }
.chip-dot.bozuk { background: var(--color-bozuk); }
.chip-dot.engelli { background: var(--color-engelli); }

.hidden {
    display: none !important;
}

/* --------------------------------------------------------------------------
   RESPONSIVE (DAR EKRANLAR: <= 1150px)
   -------------------------------------------------------------------------- */
@media (max-width: 1150px) {
    #top-bar {
        padding: 6px 10px;
        gap: 8px;
    }
    .machine-gauges {
        gap: 6px;
    }
    .gauge-card {
        padding: 2px 6px;
        font-size: 11px;
    }
    .gauge-bar-bg {
        width: 36px;
        height: 6px;
    }
    .state-counts {
        gap: 4px;
    }
    .count-pill {
        padding: 2px 6px;
        font-size: 11px;
    }
}

/* --------------------------------------------------------------------------
   RESPONSIVE (TELEFON GENİŞLİĞİ: <= 768px veya 430px)
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
    body, html {
        overflow-y: auto;
    }

    #app-container {
        height: auto;
        min-height: 100vh;
    }

    #top-bar {
        padding: 6px 8px;
    }

    .machine-gauges {
        display: none; /* Mobilde yerden tasarruf */
    }

    .state-counts {
        gap: 4px;
    }

    .count-pill {
        padding: 3px 6px;
        font-size: 11px;
    }

    .top-controls {
        display: none;
    }

    .status-summary-panel {
        padding: 6px 10px;
    }

    .status-summary-panel.collapsed {
        padding: 4px 8px;
    }

    .panel-collapsed-line {
        font-size: 11.5px;
    }

    .btn-panel-toggle {
        padding: 2px 6px;
        font-size: 11px;
    }

    .mobile-rooms-list {
        display: flex;
        max-height: 480px;
    }

    #canvas-wrapper {
        height: 420px;
        flex: none;
        border-top: 2px solid var(--border-color);
    }

    .inspector {
        top: 10px;
        left: 10px;
        right: 10px;
        width: auto;
    }
}
