/* xGTO.ai — Mobile-First Camera + Overlay UI */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --primary: #00ff88;
    --danger: #ff4757;
    --bg-dark: #0a0a0f;
    --bg-panel: rgba(10, 10, 15, 0.92);
    --text: #ffffff;
    --text-muted: #8892a0;
    --border: rgba(255, 255, 255, 0.08);
}

body {
    background: var(--bg-dark);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    min-height: 100dvh;
    overflow: hidden;
    user-select: none;
}

/* Camera Viewport */
.camera-container {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
}

/* Guide corner marks */
.guide-frame {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 10;
}

.guide-corner {
    position: absolute;
    width: 40px;
    height: 40px;
    border-color: var(--primary);
    border-style: solid;
    border-width: 0;
}

.guide-corner.tl { top: 20px; left: 20px; border-top-width: 3px; border-left-width: 3px; }
.guide-corner.tr { top: 20px; right: 20px; border-top-width: 3px; border-right-width: 3px; }
.guide-corner.bl { bottom: 200px; left: 20px; border-bottom-width: 3px; border-left-width: 3px; }
.guide-corner.br { bottom: 200px; right: 20px; border-bottom-width: 3px; border-right-width: 3px; }

/* Video element */
#camera-feed {
    width: 100%;
    height: calc(100dvh - 200px);
    object-fit: cover;
    background: #000;
}

/* Bounding boxes overlay */
.detection-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 5;
}

.bbox {
    position: absolute;
    border: 2px solid var(--primary);
    border-radius: 4px;
    background: rgba(0, 255, 136, 0.08);
    transition: all 0.1s ease;
}

.bbox-label {
    position: absolute;
    top: -24px;
    left: -2px;
    background: var(--primary);
    color: #000;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px 4px 0 0;
    white-space: nowrap;
}

.bbox-confidence {
    position: absolute;
    bottom: -20px;
    right: 0;
    font-size: 10px;
    color: var(--text-muted);
}

/* Status bar */
.status-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    padding: 12px 16px;
    background: linear-gradient(to bottom, rgba(0,0,0,0.7), transparent);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 20;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--danger);
}

.status-dot.live {
    background: var(--primary);
    box-shadow: 0 0 8px var(--primary);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Dashboard panel */
.dashboard {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 200px;
    background: var(--bg-panel);
    backdrop-filter: blur(20px);
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 15;
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

.dashboard-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
}

.mock-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--text-muted);
}

.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
    background: rgba(255,255,255,0.1);
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.toggle-switch.active {
    background: var(--primary);
}

.toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
}

.toggle-switch.active::after {
    transform: translateX(20px);
}

/* JSON output */
.json-output {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
}

.json-output pre {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 11px;
    line-height: 1.6;
    color: var(--primary);
    white-space: pre-wrap;
    word-break: break-all;
}

/* Stack cards row */
.stack-row {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    overflow-x: auto;
    border-bottom: 1px solid var(--border);
}

.stack-card {
    min-width: 60px;
    padding: 8px;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border);
    border-radius: 8px;
    text-align: center;
}

.stack-card.detected {
    border-color: var(--primary);
    background: rgba(0, 255, 136, 0.08);
}

.stack-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
}

.stack-pos {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    margin-top: 2px;
}

/* Error/permission states */
.permission-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: calc(100dvh - 200px);
    padding: 40px;
    text-align: center;
    gap: 16px;
}

.permission-error h2 {
    font-size: 18px;
    color: var(--danger);
}

.permission-error p {
    font-size: 13px;
    color: var(--text-muted);
    max-width: 280px;
}

.retry-btn {
    padding: 12px 32px;
    background: var(--primary);
    color: #000;
    font-weight: 700;
    font-size: 14px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}

/* Loading overlay */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-dark);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    gap: 20px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255,255,255,0.1);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    font-size: 14px;
    color: var(--text-muted);
}
/* Footer */
.app-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #0a0a14;
    border-top: 1px solid rgba(255,255,255,0.1);
    padding: 8px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: var(--text-muted);
    z-index: 100;
}
