/* ========== INTERACTIVE 3-PANEL DEMO — Light Theme ========== */

/* === Overlay === */
.demo-overlay {
    position: fixed; inset: 0; z-index: 9990;
    background: var(--bg-page, #f5f7fa);
    display: flex; flex-direction: column;
    opacity: 0; transition: opacity 0.5s ease;
    overflow: hidden;
}
.demo-overlay.active { opacity: 1; }

/* Ensure modals + toasts above demo */
.demo-overlay ~ #modal-overlay,
#modal-overlay { z-index: 9995 !important; }

/* === Topbar === */
.demo-topbar {
    height: 50px; display: flex; align-items: center; justify-content: space-between;
    padding: 0 24px; flex-shrink: 0; position: relative; z-index: 2;
    background: var(--bg-white, #fff);
    border-bottom: 1px solid var(--border, #e5e7eb);
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.demo-topbar-brand {
    font-size: 17px; font-weight: 800; color: var(--text-primary, #111827);
    display: flex; align-items: center; gap: 8px;
}
.demo-topbar-brand i { color: var(--primary, #4f46e5); font-size: 15px; }
.demo-topbar-brand span { color: var(--primary, #4f46e5); }
.demo-topbar-center {
    position: absolute; left: 50%; transform: translateX(-50%);
    font-size: 12px; color: var(--text-secondary, #6b7280);
    display: flex; align-items: center; gap: 8px;
}
.demo-topbar-center .dtc-live {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 2px 10px; border-radius: 10px;
    background: var(--success-light, #f0fdf4);
    color: var(--success, #16a34a);
    font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
    border: 1px solid rgba(22,163,74,0.15);
}
.demo-topbar-center .dtc-live::before {
    content: ''; width: 5px; height: 5px; border-radius: 50%;
    background: var(--success, #16a34a); animation: livePulse 1.5s ease infinite;
}
@keyframes livePulse { 0%,100%{opacity:1} 50%{opacity:0.3} }
.demo-close {
    width: 34px; height: 34px; border-radius: var(--radius-sm, 8px);
    border: 1px solid var(--border, #e5e7eb);
    background: var(--bg-white, #fff); color: var(--text-muted, #9ca3af);
    font-size: 13px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s ease;
}
.demo-close:hover {
    background: var(--danger-light, #fef2f2); color: var(--danger, #dc2626);
    border-color: rgba(220,38,38,0.2);
}

/* === 3-Device Stage === */
.demo-stage {
    flex: 1; display: flex; gap: 12px; align-items: stretch;
    padding: 12px 16px; min-height: 0; position: relative; z-index: 1;
}

/* === Device Containers === */
.demo-device {
    display: flex; flex-direction: column; min-width: 0; position: relative;
    transition: flex 0.45s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                opacity 0.3s ease, filter 0.3s ease;
    will-change: flex-basis;
    contain: layout style;
}
.demo-device.ipad { flex: 0 0 32%; }
.demo-device.monitor { flex: 1; }
.demo-device.desktop { flex: 0 0 26%; }

/* Expand / Collapse states */
.demo-device.demo-expanded { flex: 7 !important; z-index: 5; }
.demo-device.demo-collapsed { flex: 1 !important; }

/* Collapsed: hide real content, show placeholder */
.demo-device.demo-collapsed .demo-ipad-screen > *,
.demo-device.demo-collapsed .demo-monitor-screen > *,
.demo-device.demo-collapsed .demo-desktop-screen > * {
    display: none !important;
}
.demo-collapsed-placeholder {
    display: none;
    flex: 1;
    flex-direction: column; align-items: center; justify-content: center; gap: 10px;
    color: var(--text-muted, #9ca3af);
    text-align: center; padding: 16px;
}
.demo-device.demo-collapsed .demo-collapsed-placeholder { display: flex !important; }
.demo-collapsed-placeholder i {
    font-size: 28px; opacity: 0.4;
}
.demo-collapsed-placeholder span {
    font-size: 10px; font-weight: 600; letter-spacing: 0.3px;
    text-transform: uppercase; opacity: 0.5;
}

/* === Device Labels === */
.demo-device-label {
    text-align: center; margin-bottom: 6px;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    transition: opacity 0.3s;
}
.demo-device-label .dl-badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 12px; border-radius: var(--radius-sm, 8px);
    font-size: 10px; font-weight: 700; letter-spacing: 0.3px; text-transform: uppercase;
    border: 1px solid var(--border, #e5e7eb);
    background: var(--bg-white, #fff);
    box-shadow: var(--shadow-xs);
}
.demo-device-label .dl-badge i { font-size: 10px; }
.demo-device-label .dl-badge .dl-dot {
    width: 5px; height: 5px; border-radius: 50%; background: var(--success, #16a34a);
    animation: dlPulse 2s ease infinite;
}
@keyframes dlPulse { 0%,100%{opacity:1} 50%{opacity:0.3} }

.demo-device.ipad .dl-badge { color: var(--primary, #4f46e5); border-color: rgba(79,70,229,0.15); background: var(--primary-light, #eef2ff); }
.demo-device.monitor .dl-badge { color: var(--orange, #ea580c); border-color: rgba(234,88,12,0.15); background: var(--orange-light, #fff7ed); }
.demo-device.desktop .dl-badge { color: var(--success, #16a34a); border-color: rgba(22,163,74,0.15); background: var(--success-light, #f0fdf4); }

/* === Shared Frame Style === */
.demo-ipad-frame,
.demo-monitor-frame,
.demo-desktop-frame {
    flex: 1; display: flex; flex-direction: column;
    background: var(--bg-white, #fff);
    border-radius: var(--radius, 12px);
    border: 1px solid var(--border, #e5e7eb);
    box-shadow: var(--shadow-md);
    overflow: hidden; min-height: 0;
    transition: box-shadow 0.4s ease, border-color 0.4s ease;
}

/* iPad specific */
.demo-ipad-frame { border-radius: 18px; }

/* Expanded glow */
.demo-device.demo-expanded .demo-ipad-frame {
    border-color: rgba(79,70,229,0.3);
    box-shadow: 0 4px 24px rgba(79,70,229,0.1), var(--shadow-lg);
}
.demo-device.demo-expanded .demo-monitor-frame {
    border-color: rgba(234,88,12,0.3);
    box-shadow: 0 4px 24px rgba(234,88,12,0.08), var(--shadow-lg);
}
.demo-device.demo-expanded .demo-desktop-frame {
    border-color: rgba(22,163,74,0.3);
    box-shadow: 0 4px 24px rgba(22,163,74,0.08), var(--shadow-lg);
}

/* Frame top bars */
.demo-ipad-notch {
    height: 18px; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
    background: var(--bg-light, #f0f2f5); border-bottom: 1px solid var(--border-light, #f0f0f0);
}
.demo-ipad-cam {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--border, #e5e7eb);
}
.demo-monitor-top, .demo-desktop-top {
    height: 24px; display: flex; align-items: center; padding: 0 10px; flex-shrink: 0;
    background: var(--bg-light, #f0f2f5); border-bottom: 1px solid var(--border-light, #f0f0f0);
    gap: 5px;
}
.demo-monitor-dot { width: 7px; height: 7px; border-radius: 50%; }
.demo-monitor-dot.r { background: #ff5f57; }
.demo-monitor-dot.y { background: #ffbd2e; }
.demo-monitor-dot.g { background: #28c840; }

/* Screens */
.demo-ipad-screen,
.demo-monitor-screen,
.demo-desktop-screen {
    flex: 1; overflow-y: auto; overflow-x: hidden; min-height: 0;
    background: var(--bg-page, #f5f7fa);
    contain: content;
}

/* iPad bottom */
.demo-ipad-home {
    height: 14px; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
    background: var(--bg-light, #f0f2f5); border-top: 1px solid var(--border-light, #f0f0f0);
}
.demo-ipad-homebar { width: 48px; height: 3px; border-radius: 2px; background: var(--border, #e5e7eb); }

/* Monitor stand */
.demo-monitor-stand {
    height: 8px; display: flex; justify-content: center; flex-shrink: 0;
    background: var(--bg-light, #f0f2f5); border-top: 1px solid var(--border-light, #f0f0f0);
}
.demo-monitor-neck { width: 36px; height: 100%; background: var(--border, #e5e7eb); border-radius: 0 0 3px 3px; }

/* === Flow Bridges === */
.demo-flow-bridge {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    width: 24px; flex-shrink: 0; position: relative;
    transition: width 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94), opacity 0.3s;
}
.demo-stage:has(.demo-expanded) .demo-flow-bridge { width: 10px; opacity: 0.2; }

.demo-flow-line {
    width: 1px; height: 50px;
    background: linear-gradient(180deg, transparent, var(--border, #e5e7eb), transparent);
}
.demo-flow-arrows { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.demo-flow-arr {
    width: 5px; height: 5px;
    border-right: 1.5px solid var(--primary, #4f46e5);
    border-bottom: 1.5px solid var(--primary, #4f46e5);
    transform: rotate(-45deg); opacity: 0.25;
    animation: flowArrow 2s ease infinite;
}
.demo-flow-arr:nth-child(2) { animation-delay: 0.25s; }
.demo-flow-arr:nth-child(3) { animation-delay: 0.5s; }
@keyframes flowArrow {
    0%,100% { opacity: 0.15; transform: rotate(-45deg) scale(0.8); }
    50% { opacity: 0.5; transform: rotate(-45deg) scale(1.1); }
}
.demo-flow-bridge.active .demo-flow-arr { border-color: var(--success, #16a34a); opacity: 0.6; }
.demo-flow-bridge.active .demo-flow-line {
    background: linear-gradient(180deg, transparent, rgba(22,163,74,0.3), transparent);
}

/* === Status Bar === */
.demo-statusbar {
    height: 36px; display: flex; align-items: center; padding: 0 24px; gap: 16px;
    border-top: 1px solid var(--border, #e5e7eb);
    background: var(--bg-white, #fff);
    flex-shrink: 0; font-size: 10px; color: var(--text-muted, #9ca3af);
    position: relative; z-index: 2;
}
.demo-statusbar .dsb-item {
    display: flex; align-items: center; gap: 5px;
    padding: 2px 8px; border-radius: var(--radius-xs, 6px);
    background: var(--bg-light, #f0f2f5);
}
.demo-statusbar .dsb-dot { width: 5px; height: 5px; border-radius: 50%; }
.demo-statusbar .dsb-dot.on { background: var(--success, #16a34a); }
.demo-statusbar .dsb-hint {
    margin-left: auto; color: var(--text-muted, #9ca3af);
    display: flex; align-items: center; gap: 5px;
}

/* === Scrollbars === */
.demo-ipad-screen::-webkit-scrollbar,
.demo-monitor-screen::-webkit-scrollbar,
.demo-desktop-screen::-webkit-scrollbar { width: 4px; }
.demo-ipad-screen::-webkit-scrollbar-track,
.demo-monitor-screen::-webkit-scrollbar-track,
.demo-desktop-screen::-webkit-scrollbar-track { background: transparent; }
.demo-ipad-screen::-webkit-scrollbar-thumb,
.demo-monitor-screen::-webkit-scrollbar-thumb,
.demo-desktop-screen::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 2px; }

/* ===== Real View Overrides Inside Panels ===== */

.demo-ipad-screen > div,
.demo-monitor-screen > div,
.demo-desktop-screen > div { padding: 10px; }

/* --- Normal State: Compact layouts --- */
.demo-ipad-screen .gt-floor-grid { grid-template-columns: repeat(3, 1fr) !important; gap: 8px !important; }
.demo-ipad-screen .gt-salon-header { flex-direction: column !important; gap: 6px !important; }
.demo-ipad-screen .gt-salon-stats { justify-content: center !important; }
.demo-ipad-screen .gt-table-card { padding: 10px 6px !important; }
.demo-ipad-screen .gt-order-layout { flex-direction: column !important; }
.demo-ipad-screen .gt-order-left { max-height: 45% !important; overflow-y: auto !important; }
.demo-ipad-screen .gt-order-right { max-height: 55% !important; overflow-y: auto !important; }
.demo-ipad-screen .gt-menu-grid { grid-template-columns: repeat(2, 1fr) !important; }

.demo-monitor-screen .kitchen-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)) !important; }
.demo-monitor-screen .kpi-grid,
.demo-monitor-screen .flex.gap-16 { flex-wrap: wrap !important; }

.demo-desktop-screen .accounting-grid { grid-template-columns: 1fr !important; }
.demo-desktop-screen .dashboard-grid { grid-template-columns: 1fr !important; }
.demo-desktop-screen .grid-3 { grid-template-columns: 1fr 1fr 1fr !important; gap: 6px !important; }
.demo-desktop-screen .kpi-grid { grid-template-columns: repeat(2, 1fr) !important; }
.demo-desktop-screen .chart-container { height: 150px !important; }

.demo-ipad-screen .infra-bar,
.demo-monitor-screen .infra-bar,
.demo-desktop-screen .infra-bar {
    flex-wrap: wrap !important; padding: 6px 8px !important;
    gap: 4px 10px !important; font-size: 10px !important;
}

/* --- Expanded State: Fuller layouts --- */
.demo-device.demo-expanded .demo-ipad-screen .gt-floor-grid { grid-template-columns: repeat(4, 1fr) !important; gap: 10px !important; }
.demo-device.demo-expanded .demo-ipad-screen .gt-salon-header { flex-direction: row !important; }
.demo-device.demo-expanded .demo-ipad-screen .gt-order-layout { flex-direction: row !important; }
.demo-device.demo-expanded .demo-ipad-screen .gt-order-left { max-height: none !important; flex: 1 !important; }
.demo-device.demo-expanded .demo-ipad-screen .gt-order-right { max-height: none !important; flex: 0 0 320px !important; }
.demo-device.demo-expanded .demo-ipad-screen .gt-menu-grid { grid-template-columns: repeat(3, 1fr) !important; }
.demo-device.demo-expanded .demo-monitor-screen .kitchen-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)) !important; }
.demo-device.demo-expanded .demo-desktop-screen .accounting-grid { grid-template-columns: repeat(3, 1fr) !important; }
.demo-device.demo-expanded .demo-desktop-screen .dashboard-grid { grid-template-columns: repeat(2, 1fr) !important; }
.demo-device.demo-expanded .demo-desktop-screen .kpi-grid { grid-template-columns: repeat(4, 1fr) !important; }
.demo-device.demo-expanded .demo-desktop-screen .chart-container { height: 220px !important; }

/* === Mobile Responsive === */
@media (max-width: 768px) {
    .demo-stage { flex-direction: column; padding: 8px; gap: 8px; overflow-y: auto; }
    .demo-device.ipad, .demo-device.monitor, .demo-device.desktop { flex: none; min-height: 300px; }
    .demo-device.demo-collapsed { min-height: 60px; }
    .demo-topbar { padding: 0 12px; height: 44px; }
    .demo-topbar-center { display: none; }
    .demo-topbar-brand { font-size: 14px; }
    .demo-device-label .dl-badge { font-size: 9px; padding: 3px 8px; }
}

/* Expand hint */
.demo-expand-hint {
    position: absolute; bottom: 8px; right: 8px;
    width: 26px; height: 26px; border-radius: var(--radius-xs, 6px);
    background: var(--bg-white, #fff); border: 1px solid var(--border, #e5e7eb);
    box-shadow: var(--shadow-sm);
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted, #9ca3af); font-size: 10px; pointer-events: none;
    opacity: 0; transition: opacity 0.3s; z-index: 10;
}
.demo-device:hover .demo-expand-hint { opacity: 1; }
.demo-device.demo-expanded .demo-expand-hint { opacity: 0; }
