/* ══════════════════════════════════════════════════════════════
   UV Studio shared design system: tokens, controls and overlays.
══════════════════════════════════════════════════════════════ */

:root {
    --bg: #fafbfc;
    --surface: #ffffff;
    --border: #e5e7eb;
    --text: #111827;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --success: #10b981;
    --error: #ef4444;
    --error-hover: #b22222;
    --focus-ring: #1d4ed8;
    --radius: 8px;
    color-scheme: light;
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-header: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --font-mono: 'SF Mono', Monaco, 'Cascadia Code', ui-monospace, monospace;
}

[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0f172a;
    --surface: #1e293b;
    --border: #334155;
    --text: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --success: #10b981;
    --error: #ef4444;
    --error-hover: #b22222;
    --focus-ring: #93c5fd;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
    transition: background 0.2s, color 0.2s;
}

/* Buttons — brushed-aluminium in light, premium alu in dark */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    height: 36px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    background: linear-gradient(160deg, #f9fafb 0%, #e5e7eb 100%);
    border: 1px solid #9ca3af;
    color: #374151;
    box-shadow: 0 2px 4px rgba(0,0,0,0.12), inset 0 1px 0 rgba(255,255,255,0.9);
}
.btn:hover:not(:disabled) {
    background: linear-gradient(160deg, #fff 0%, #f3f4f6 100%);
    border-color: #2563eb;
    color: #1d4ed8;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0,0,0,0.15), 0 0 6px rgba(37,99,235,0.15), inset 0 1px 0 #fff;
}
.btn:active {
    transform: translateY(1px);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.12);
    background: linear-gradient(160deg, #e5e7eb 0%, #d1d5db 100%);
}
.btn.primary {
    background: linear-gradient(160deg, #3b82f6 0%, #2563eb 100%);
    border-color: #2563eb;
    color: #fff;
    box-shadow: 0 2px 6px rgba(37,99,235,0.35), inset 0 1px 0 rgba(255,255,255,0.2);
}
.btn.primary:hover:not(:disabled) {
    background: linear-gradient(160deg, #60a5fa 0%, #3b82f6 100%);
    border-color: #3b82f6;
    color: #fff;
    box-shadow: 0 3px 10px rgba(37,99,235,0.45), inset 0 1px 0 rgba(255,255,255,0.25);
    transform: translateY(-1px);
}
.btn.danger {
    background: linear-gradient(160deg, #f87171 0%, #ef4444 100%);
    border-color: #dc2626;
    color: #fff;
    box-shadow: 0 2px 6px rgba(239,68,68,0.3), inset 0 1px 0 rgba(255,255,255,0.2);
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

[data-theme="dark"] .btn {
    background: linear-gradient(170deg, #2e3d50 0%, #1e2d3d 60%, #253040 100%);
    border: 1px solid #3a4d62;
    color: #cbd5e1;
    box-shadow: 0 2px 6px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.06);
}
[data-theme="dark"] .btn:hover:not(:disabled) {
    background: linear-gradient(170deg, #3d5068 0%, #2a3d52 100%);
    border-color: #4a6a8a;
    color: #e2e8f0;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.5), 0 0 8px rgba(59,130,246,0.15), inset 0 1px 0 rgba(255,255,255,0.1);
}
[data-theme="dark"] .btn.primary {
    background: linear-gradient(135deg, #2563eb, #3b82f6);
    border-color: #3b82f6;
    color: #fff;
    box-shadow: 0 2px 8px rgba(59,130,246,0.4), inset 0 1px 0 rgba(255,255,255,0.15);
}
[data-theme="dark"] .btn.primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #3b82f6, #60a5fa);
    box-shadow: 0 4px 12px rgba(59,130,246,0.5), inset 0 1px 0 rgba(255,255,255,0.2);
    transform: translateY(-1px);
}

/* Select */
select {
    height: 36px;
    padding: 0 28px 0 12px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    appearance: none;
    -webkit-appearance: none;
    background:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%239ca3af'/%3E%3C/svg%3E")
        no-repeat right 10px center,
        linear-gradient(160deg, #f9fafb 0%, #e5e7eb 100%);
    border: 1px solid #9ca3af;
    color: #374151;
    box-shadow: 0 2px 4px rgba(0,0,0,0.12), inset 0 1px 0 rgba(255,255,255,0.9);
}
select:hover { border-color: #2563eb; color: #1d4ed8; }
select:focus { border-color: #2563eb; }
[data-theme="dark"] select {
    background:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%2364748b'/%3E%3C/svg%3E")
        no-repeat right 10px center,
        linear-gradient(170deg, #2e3d50 0%, #1e2d3d 60%, #253040 100%);
    border: 1px solid #3a4d62;
    color: #cbd5e1;
    box-shadow: 0 2px 6px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.06);
}

/* Shared overlays */
.notifications {
    position: fixed;
    top: 80px;
    right: 24px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.notification {
    padding: 12px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    box-shadow: var(--shadow-lg);
    max-width: 300px;
    animation: slideIn 0.3s ease;
}

.notification.success { border-left: 3px solid var(--success); color: var(--success); }
.notification.error { border-left: 3px solid var(--error); color: var(--error); }
.notification.warning { border-left: 3px solid #f59e0b; color: #f59e0b; }
.notification.info { border-left: 3px solid var(--accent); color: var(--accent); }

@keyframes slideIn {
    from { transform: translateX(16px); opacity: 0; }
}

@keyframes slideOut {
    to { transform: translateX(100%); opacity: 0; }
}

.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal.show { display: flex; }

.modal-content {
    background: var(--surface);
    border-radius: 12px;
    max-width: 500px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    padding: 24px 24px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title { font-size: 18px; font-weight: 600; }

.modal-close {
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
}

.modal-close:hover { color: var(--text); }
.modal-body { padding: 24px; }
#helpModal .section { margin-bottom: 24px; }
#helpModal .section:last-child { margin-bottom: 0; }

#helpModal .section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#helpModal .shortcuts { display: grid; gap: 8px; }

#helpModal .shortcut {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
}

#helpModal .shortcut-key {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    background: var(--bg);
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid var(--border);
}

#helpModal .shortcut-desc {
    color: var(--text-secondary);
    font-size: 13px;
}

:where(button, a, input, select, textarea, [tabindex]:not([tabindex="-1"])):focus-visible {
    outline: 3px solid var(--focus-ring);
    outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
