/* Theme & Variables - Midnight Premium */
:root {
    --bg-base: #0F172A;
    /* Slate 900 */
    --bg-panel: #1E293B;
    /* Slate 800 */
    --bg-input: #0B1120;

    --primary: #3B82F6;
    /* Blue 500 */
    --primary-hover: #2563EB;
    /* Blue 600 */
    --secondary: #64748B;
    --accent: #38BDF8;

    --text-main: #F8FAFC;
    /* Slate 50 */
    --text-muted: #94A3B8;
    /* Slate 400 */

    --border: #334155;
    /* Slate 700 */
    --border-light: rgba(59, 130, 246, 0.3);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;

    --font-ui: 'Inter', system-ui, sans-serif;

    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --checkerboard: repeating-conic-gradient(#1E293B 0% 25%, #0F172A 0% 50%) 50% / 20px 20px;
}

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

body {
    background-color: var(--bg-base);
    color: var(--text-main);
    font-family: var(--font-ui);
    line-height: 1.5;
    height: 100vh;
    overflow: hidden;
}

/* Utilities */
.hidden {
    display: none !important;
    opacity: 0;
}

.mt-2 {
    margin-top: 0.5rem;
}

/* Layout */
.app-layout {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Navbar */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

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

.logo-box {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #FFF;
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.4);
}

.brand h1 {
    font-size: 1.2rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-ui);
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.btn-primary {
    background: var(--primary);
    color: #FFF;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-input);
    color: var(--text-main);
    border-color: var(--border);
}

.btn-secondary:hover {
    background: rgba(59, 130, 246, 0.1);
    border-color: var(--border-light);
}

.btn-icon {
    padding: 0.6rem;
}

.btn-icon span {
    display: none;
}

@media (min-width: 768px) {
    .btn-icon span {
        display: inline;
    }
}

/* Main Workspace */
.workspace {
    display: grid;
    grid-template-columns: 340px 1fr;
    flex: 1;
    overflow: hidden;
}

.panel {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.controls-panel {
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    padding: 1.5rem;
    gap: 1.5rem;
    overflow-y: auto;
}

.preview-panel {
    background: var(--bg-base);
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    gap: 1rem;
}

/* Panel Headers */
.panel-header h2 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Controls */
.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.group-label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.row-inputs {
    display: flex;
    gap: 0.75rem;
}

/* Input Wrappers */
.input-wrap {
    display: flex;
    align-items: center;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    flex: 1;
    transition: border-color 0.2s;
    overflow: hidden;
}

.input-wrap:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.input-wrap .prefix {
    padding: 0.5rem 0.75rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    background: rgba(255, 255, 255, 0.05);
    border-right: 1px solid var(--border);
}

.input-wrap input {
    flex: 1;
    min-width: 0;
    padding: 0.6rem;
    background: transparent;
    border: none;
    color: var(--text-main);
    font-family: var(--font-ui);
    font-size: 0.9rem;
    outline: none;
}

.full-input {
    width: 100%;
    padding: 0.6rem 0.75rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    font-family: var(--font-ui);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}

.full-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

/* Color Pickers */
.color-picker-wrap {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    flex: 1;
}

.color-picker-wrap label {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: block;
}

.color-input-container {
    display: flex;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    height: 38px;
    transition: border-color 0.2s;
}

.color-input-container:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.color-input-container input[type="color"] {
    width: 40px;
    height: 100%;
    border: none;
    padding: 0;
    background: transparent;
    cursor: pointer;
}

.color-input-container input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

.color-input-container input[type="color"]::-webkit-color-swatch {
    border: none;
    border-right: 1px solid var(--border);
}

.hex-input {
    flex: 1;
    padding: 0 0.5rem;
    background: transparent;
    border: none;
    color: var(--text-main);
    font-family: monospace;
    font-size: 0.85rem;
    outline: none;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

/* Checkboxes */
.sub-controls {
    display: flex;
    gap: 1rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    accent-color: var(--primary);
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* Preview Area */
.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.resolution-badge {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    font-family: monospace;
}

.preview-actions {
    display: flex;
    gap: 0.5rem;
}

.canvas-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--checkerboard);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: auto;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5);
    padding: 1rem;
}

#render-canvas {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    box-shadow: var(--shadow);
    transition: all 0.2s ease;
}

/* KBD & Helpers */
.kbd-shortcut {
    opacity: 0.5;
    font-size: 0.7rem;
    font-family: var(--font-ui);
    background: var(--bg-input);
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    border: 1px solid var(--border);
}

.helper-text {
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

.kbd {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 0.1rem 0.3rem;
    font-family: monospace;
    font-size: 0.75rem;
    color: var(--text-main);
    box-shadow: 0 1px 0 var(--border);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary);
    color: #FFF;
    padding: 0.6rem 1.25rem;
    border-radius: 20px;
    font-weight: 500;
    box-shadow: var(--shadow);
    transition: opacity 0.3s;
    z-index: 100;
}

@media (max-width: 800px) {
    .workspace {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }

    .controls-panel {
        border-right: none;
        border-bottom: 1px solid var(--border);
        max-height: 50vh;
    }
}