/* ========================================
   Schema to Types — Premium Dark Theme
   ======================================== */

/* --- Design Tokens --- */
:root {
    --primary: #6366F1;
    --primary-light: #818CF8;
    --primary-dark: #4F46E5;
    --accent: #22D3EE;
    --accent-light: #67E8F9;
    --bg-base: #0F172A;
    --bg-surface: #1E293B;
    --bg-elevated: #334155;
    --bg-glass: rgba(30, 41, 59, 0.6);
    --text-primary: #F1F5F9;
    --text-secondary: #94A3B8;
    --text-muted: #64748B;
    --border: rgba(148, 163, 184, 0.12);
    --border-focus: rgba(99, 102, 241, 0.5);
    --error: #F87171;
    --success: #34D399;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
    --transition: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.15);
}

/* --- Reset --- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-base);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

/* Subtle animated gradient background */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 60% 50% at 20% 20%, rgba(99, 102, 241, 0.08), transparent),
        radial-gradient(ellipse 50% 40% at 80% 80%, rgba(34, 211, 238, 0.06), transparent);
    pointer-events: none;
    z-index: 0;
}

/* --- Layout --- */
.app-container {
    position: relative;
    z-index: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* --- Header --- */
.app-header {
    padding: 24px 0 16px;
    border-bottom: 1px solid var(--border);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.logo-group {
    display: flex;
    align-items: center;
    gap: 14px;
}

.logo-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--primary), var(--accent));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
    box-shadow: var(--shadow-glow);
}

.app-header h1 {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--text-primary), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    letter-spacing: 0.02em;
    margin-top: 2px;
}

/* --- Main Content --- */
.main-content {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 0;
    align-items: start;
    padding: 24px 0;
}

/* --- Panel --- */
.panel {
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    transition: box-shadow var(--transition);
}

.panel:hover {
    box-shadow: var(--shadow-lg);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    gap: 12px;
    flex-wrap: wrap;
}

.panel-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    white-space: nowrap;
}

/* --- Tabs --- */
.tab {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: 0.78rem;
    font-weight: 500;
    padding: 5px 12px;
    border-radius: var(--radius-xs);
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.tab:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.tab:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.tab.active {
    color: var(--primary-light);
    background: rgba(99, 102, 241, 0.12);
    border-color: rgba(99, 102, 241, 0.25);
}

.input-format-tabs,
.output-lang-tabs {
    display: flex;
    gap: 4px;
}

/* --- Editor --- */
.editor-wrap {
    position: relative;
}

.code-editor {
    width: 100%;
    min-height: 420px;
    max-height: 60vh;
    padding: 16px 18px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.82rem;
    line-height: 1.7;
    resize: vertical;
    outline: none;
    overflow: auto;
    tab-size: 2;
}

.code-editor::placeholder {
    color: var(--text-muted);
}

.code-output {
    white-space: pre;
    margin: 0;
    cursor: text;
    user-select: text;
    color: var(--accent-light);
}

.code-output:empty::before {
    content: '// Output will appear here after conversion...';
    color: var(--text-muted);
    font-style: italic;
}

.editor-actions {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 6px;
    opacity: 0;
    transition: opacity var(--transition);
}

.editor-wrap:hover .editor-actions,
.code-editor:focus~.editor-actions {
    opacity: 1;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-sans);
    font-size: 0.82rem;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 0.75rem;
}

.btn-ghost {
    background: rgba(255, 255, 255, 0.04);
    border-color: var(--border);
    color: var(--text-secondary);
}

.btn-ghost:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border-color: rgba(148, 163, 184, 0.2);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border: none;
    box-shadow: var(--shadow-sm), 0 0 16px rgba(99, 102, 241, 0.25);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    box-shadow: var(--shadow-md), 0 0 24px rgba(99, 102, 241, 0.35);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-accent {
    background: rgba(34, 211, 238, 0.12);
    color: var(--accent);
    border-color: rgba(34, 211, 238, 0.25);
}

.btn-accent:hover {
    background: rgba(34, 211, 238, 0.2);
    border-color: rgba(34, 211, 238, 0.4);
}

/* --- Convert Section --- */
.convert-section {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 16px;
    align-self: center;
}

.btn-convert {
    padding: 14px 28px;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: var(--radius);
}

/* --- Error --- */
.error-msg {
    padding: 0 18px;
    font-size: 0.78rem;
    color: var(--error);
    min-height: 0;
    max-height: 0;
    overflow: hidden;
    transition: all var(--transition);
}

.error-msg.visible {
    padding: 10px 18px;
    min-height: 36px;
    max-height: 200px;
}

/* --- Toast --- */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--bg-elevated);
    color: var(--success);
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 500;
    border: 1px solid rgba(52, 211, 153, 0.2);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transition: all 300ms ease;
    pointer-events: none;
    z-index: 100;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* --- Footer --- */
.app-footer {
    padding: 16px 0;
    border-top: 1px solid var(--border);
    text-align: center;
}

.app-footer p {
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* --- Responsive --- */
@media (max-width: 900px) {
    .main-content {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .convert-section {
        padding: 4px 0;
    }

    .btn-convert {
        width: 100%;
        justify-content: center;
    }

    .panel-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .code-editor {
        min-height: 280px;
    }
}

@media (max-width: 480px) {
    .app-container {
        padding: 0 12px;
    }

    .header-content {
        flex-direction: column;
        align-items: flex-start;
    }

    .input-format-tabs,
    .output-lang-tabs {
        flex-wrap: wrap;
    }

    .tab {
        font-size: 0.72rem;
        padding: 4px 9px;
    }

    .subtitle {
        font-size: 0.68rem;
    }
}

/* --- Scrollbar Custom --- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.2);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.35);
}

/* --- Selection --- */
::selection {
    background: rgba(99, 102, 241, 0.3);
    color: white;
}

/* --- Focus visible --- */
*:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}