@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Space+Mono:wght@400;700&display=swap');

:root {
    --primary-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    --bg-color: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent: #818cf8;
    --accent-dark: #4f46e5;
    --border: rgba(255, 255, 255, 0.1);
    --shadow-premium: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 10px 10px -5px rgba(0, 0, 0, 0.15);
    --panel-bg: rgba(255, 255, 255, 0.03);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 2rem;
}

/* ── Background Blobs ── */
.bg-blobs {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    overflow: hidden;
}

.blob {
    position: absolute;
    width: 700px;
    height: 700px;
    background: var(--primary-gradient);
    filter: blur(160px);
    opacity: 0.12;
    border-radius: 50%;
    top: -200px;
    left: -200px;
    animation: blobFloat 15s ease-in-out infinite alternate;
}

.blob-2 {
    bottom: -200px;
    right: -200px;
    top: auto;
    left: auto;
    background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
    animation-delay: -7s;
}

@keyframes blobFloat {
    from { transform: translate(0, 0) scale(1); }
    to { transform: translate(40px, 25px) scale(1.06); }
}

/* ── Container ── */
.tool-container {
    width: 100%;
    max-width: 1200px;
    background: var(--card-bg);
    backdrop-filter: blur(24px);
    border: 1px solid var(--border);
    border-radius: 28px;
    padding: 2.5rem;
    box-shadow: var(--shadow-premium);
    margin: 1rem auto;
}

/* ── Header ── */
.header {
    text-align: center;
    margin-bottom: 2rem;
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 800;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    margin-bottom: 0.5rem;
}

.header p {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* ── Controls Bar ── */
.controls-bar {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
    padding: 1rem 1.5rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: 18px;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.control-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

select {
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    border-radius: 10px;
    outline: none;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
}

select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.minify-toggle {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    cursor: pointer;
    user-select: none;
}

.minify-toggle input {
    display: none;
}

.toggle-track {
    width: 42px;
    height: 22px;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 100px;
    position: relative;
    transition: background 0.25s;
    flex-shrink: 0;
}

.minify-toggle input:checked ~ .toggle-track {
    background: var(--accent-dark);
}

.toggle-thumb {
    position: absolute;
    left: 3px;
    top: 3px;
    width: 16px;
    height: 16px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.25s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

.minify-toggle input:checked ~ .toggle-track .toggle-thumb {
    transform: translateX(20px);
}

/* ── Editor Layout ── */
.editor-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.editor-panel {
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    min-height: 450px;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.panel-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-secondary);
}

.panel-actions {
    display: flex;
    gap: 0.6rem;
}

textarea {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: 'Space Mono', monospace;
    font-size: 0.88rem;
    resize: none;
    outline: none;
    line-height: 1.6;
}

textarea::placeholder {
    color: rgba(148, 163, 184, 0.3);
}

/* ── Buttons ── */
.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s;
    border: 1px solid transparent;
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--border);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--text-secondary);
}

.btn-outline {
    background: transparent;
    border-color: var(--border);
    color: var(--text-secondary);
}

.btn-outline:hover {
    color: var(--text-primary);
    border-color: var(--text-secondary);
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.75rem;
    border-radius: 8px;
}

.copy-btn.copied {
    background: #10b981;
    border-color: #10b981;
    color: white;
}

/* ── Error & Stats ── */
.error-box {
    padding: 1rem 1.5rem;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 12px;
    color: #f87171;
    font-family: 'Space Mono', monospace;
    font-size: 0.85rem;
    margin-bottom: 1.5rem;
    display: none;
    white-space: pre-wrap;
}

.stats-container {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-top: 1.5rem;
    padding: 1rem;
    border-top: 1px solid var(--border);
}

.stat-item {
    text-align: center;
}

.stat-val {
    display: block;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    font-family: 'Space Mono', monospace;
}

.stat-lbl {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ── Responsive ── */
@media (max-width: 968px) {
    .editor-layout {
        grid-template-columns: 1fr;
    }
    
    .editor-panel {
        min-height: 350px;
    }
}

@media (max-width: 640px) {
    .tool-container {
        padding: 1.5rem;
    }
    
    .header h1 {
        font-size: 1.8rem;
    }
    
    .controls-bar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .control-group {
        justify-content: space-between;
    }
}
