/* ============================================
   HCL ↔ JSON Converter — Styles
   Theme: Dark mode with Electric Indigo palette
   ============================================ */

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

:root {
    --primary: #6366F1;
    --primary-hover: #7B7EFF;
    --secondary: #818CF8;
    --accent: #F59E0B;
    --accent-hover: #FBBF24;
    --bg: #0F1219;
    --bg-card: rgba(16, 20, 32, 0.85);
    --bg-input: rgba(20, 26, 42, 0.8);
    --border: rgba(99, 102, 241, 0.2);
    --border-hover: rgba(99, 102, 241, 0.4);
    --text: #E0E4F0;
    --text-muted: #9098B0;
    --text-dim: #5A6280;
    --error: #EF4444;
    --success: #22C55E;
    --radius: 12px;
    --radius-sm: 8px;
    --font: 'Inter', system-ui, sans-serif;
    --mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
    --transition: 200ms ease;
    --shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    --glass: blur(12px);
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

.hidden {
    display: none !important;
}

/* --- Header --- */
.app-header {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(245, 158, 11, 0.04));
    border-bottom: 1px solid var(--border);
    backdrop-filter: var(--glass);
    padding: 1rem 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.7rem;
}

.logo h1 {
    font-size: 1.15rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.tagline {
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* --- Main --- */
.app-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* --- Direction Bar --- */
.direction-bar {
    display: flex;
    gap: 0.25rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.25rem;
    width: fit-content;
    margin: 0 auto;
}

.dir-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0.5rem 1.25rem;
    font-size: 0.85rem;
    font-family: var(--font);
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
}

.dir-btn.active {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.dir-btn:hover:not(.active) {
    color: var(--text);
    background: rgba(99, 102, 241, 0.1);
}

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

/* --- Editor Layout --- */
.editor-layout {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 1rem;
    align-items: stretch;
}

.editor-panel {
    display: flex;
    flex-direction: column;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.panel-header h2 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.panel-actions {
    display: flex;
    gap: 0.3rem;
}

.editor-container {
    position: relative;
    flex: 1;
    min-height: 400px;
}

.editor {
    width: 100%;
    height: 100%;
    min-height: 400px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    padding: 1rem;
    font-family: var(--mono);
    font-size: 0.85rem;
    line-height: 1.7;
    resize: vertical;
    tab-size: 2;
    white-space: pre;
    overflow: auto;
    transition: border-color var(--transition);
}

.editor:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.editor.output {
    color: var(--secondary);
    cursor: default;
}

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

.syntax-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 1rem;
    font-family: var(--mono);
    font-size: 0.85rem;
    line-height: 1.7;
    pointer-events: none;
    overflow: hidden;
    white-space: pre;
    border-radius: var(--radius);
    display: none;
    /* Using textarea colors for simplicity */
}

/* --- Convert Button --- */
.convert-actions {
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-convert {
    writing-mode: horizontal-tb;
    padding: 0.7rem 1.25rem;
    font-size: 0.9rem;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.45rem 0.85rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-family: var(--font);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff;
    font-weight: 600;
    box-shadow: 0 2px 10px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.5);
    transform: translateY(-1px);
}

.btn-ghost {
    background: transparent;
    color: var(--text-dim);
    border: 1px solid transparent;
}

.btn-ghost:hover {
    color: var(--text-muted);
    background: rgba(99, 102, 241, 0.08);
}

.btn-sm {
    padding: 0.3rem 0.5rem;
    font-size: 0.78rem;
}

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

/* --- Error Bar --- */
.error-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.25);
    border-radius: var(--radius-sm);
    padding: 0.6rem 1rem;
    font-size: 0.85rem;
    color: var(--error);
    animation: fadeIn 200ms ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- Footer --- */
.app-footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-dim);
    font-size: 0.8rem;
    border-top: 1px solid var(--border);
    margin-top: 2rem;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .editor-layout {
        grid-template-columns: 1fr;
    }

    .convert-actions {
        padding: 0.25rem 0;
    }

    .btn-convert {
        writing-mode: horizontal-tb;
        width: 100%;
        justify-content: center;
    }

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

    .app-header {
        padding: 0.75rem 1rem;
    }

    .app-main {
        padding: 1rem;
    }

    .editor-container {
        min-height: 250px;
    }

    .editor {
        min-height: 250px;
    }
}