/* --- CSS Variables --- */
:root {
    --bg: #faf9f7;
    --bg-elevated: #ffffff;
    --card: #ffffff;
    --border: #e5e3df;
    --border-hover: #d4d1cb;
    --fg: #1a1817;
    --muted: #6b6560;
    --accent: #6366f1;
    --accent-light: #e0e7ff;
    --accent-glow: rgba(99, 102, 241, 0.15);
    --secondary: #14b8a6;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --input-bg: #ffffff;
    --pattern-opacity: 0.3;
    --code-bg: #1e1e2e;
    --code-text: #34d399;
}

[data-theme="dark"] {
    --bg: #0a0a0f;
    --bg-elevated: #12121a;
    --card: #16161f;
    --border: #2a2a3a;
    --border-hover: #3a3a4a;
    --fg: #e8e8ed;
    --muted: #6b6b7a;
    --accent: #818cf8;
    --accent-light: rgba(129, 140, 248, 0.15);
    --accent-glow: rgba(129, 140, 248, 0.2);
    --secondary: #2dd4bf;
    --success: #34d399;
    --warning: #fbbf24;
    --danger: #f87171;
    --input-bg: #0f0f14;
    --pattern-opacity: 0.05;
    --code-bg: #0f0f14;
    --code-text: #34d399;
}

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

body {
    font-family: 'Space Grotesk', sans-serif;
    background-color: var(--bg);
    color: var(--fg);
    min-height: 100vh;
    overflow-x: hidden;
    transition: background-color 0.4s ease, color 0.4s ease;
}

/* --- Background --- */
.bg-decoration { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.bg-pattern { position: absolute; inset: 0; background-image: radial-gradient(circle, var(--muted) 1px, transparent 1px); background-size: 24px 24px; opacity: var(--pattern-opacity); }
.gradient-orb { position: absolute; border-radius: 50%; filter: blur(80px); opacity: 0.4; animation: float 20s ease-in-out infinite; }
.orb-1 { width: 500px; height: 500px; background: linear-gradient(135deg, #a5b4fc, #818cf8); top: -150px; right: -100px; }
.orb-2 { width: 400px; height: 400px; background: linear-gradient(135deg, #5eead4, #2dd4bf); bottom: -100px; left: -100px; animation-delay: -5s; }
[data-theme="dark"] .orb-1 { background: var(--accent); opacity: 0.15; }
[data-theme="dark"] .orb-2 { background: var(--secondary); opacity: 0.15; }
@keyframes float { 0%, 100% { transform: translate(0, 0) scale(1); } 50% { transform: translate(30px, 20px) scale(1.05); } }

/* --- Layout --- */
.container { max-width: 1200px; margin: 0 auto; padding: 2rem 1rem; }
.main-grid { display: grid; grid-template-columns: 1fr; gap: 1.5rem; }
@media (min-width: 900px) { .main-grid { grid-template-columns: 1fr 1fr; } }

/* --- Header --- */
header { text-align: center; margin-bottom: 2rem; }
.header-top { display: flex; justify-content: center; margin-bottom: 1rem; }
.status-badge { display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px; border-radius: 50px; border: 1px solid var(--border); background: var(--card); font-size: 14px; color: var(--muted); }
.pulse-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); animation: pulse 2s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
h1 { font-size: 2.5rem; font-weight: 700; letter-spacing: -1px; margin-bottom: 0.5rem; }
h1 span { color: var(--accent); }
.subtitle { color: var(--muted); font-size: 1.1rem; }

/* --- Theme Toggle --- */
.theme-toggle { position: fixed; top: 1.5rem; right: 1.5rem; z-index: 100; width: 48px; height: 48px; border-radius: 50%; background: var(--card); border: 2px solid var(--border); cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.3s ease; box-shadow: 0 4px 12px rgba(0,0,0,0.05); }
.theme-toggle:hover { transform: rotate(15deg) scale(1.1); border-color: var(--accent); background: var(--accent-light); }
.theme-toggle svg { width: 24px; height: 24px; stroke: var(--fg); fill: none; stroke-width: 2; }

/* --- Panel --- */
.panel { background: var(--card); border: 1px solid var(--border); border-radius: 20px; padding: 1.5rem; box-shadow: 0 4px 24px rgba(0,0,0,0.03); display: flex; flex-direction: column; gap: 1rem; }
.panel-header { display: flex; justify-content: space-between; align-items: center; }
.label { display: flex; align-items: center; gap: 10px; font-size: 0.85rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); }
.label svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; }

/* --- Input Groups --- */
.input-group { display: flex; flex-direction: column; gap: 0.5rem; }
.input-group label { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; font-weight: 600; color: var(--fg); }
.input-group label svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; }
.input-group label small { color: var(--muted); font-weight: 400; font-size: 0.8rem; }

.input-field { width: 100%; background: var(--input-bg); border: 2px solid var(--border); border-radius: 12px; padding: 12px 16px; font-size: 14px; color: var(--fg); font-family: inherit; transition: all 0.2s; }
.input-field:focus { outline: none; border-color: var(--accent); }
.input-field::placeholder { color: var(--muted); opacity: 0.6; }

.input-area { width: 100%; background: var(--input-bg); border: 2px solid var(--border); border-radius: 12px; padding: 12px 16px; font-size: 14px; color: var(--fg); font-family: inherit; transition: all 0.2s; resize: vertical; min-height: 80px; }
.input-area:focus { outline: none; border-color: var(--accent); }
.input-area::placeholder { color: var(--muted); opacity: 0.6; }

.input-meta { display: flex; justify-content: space-between; align-items: center; }
.hint { font-size: 0.75rem; color: var(--muted); }
.counter { font-size: 0.75rem; font-family: 'JetBrains Mono', monospace; color: var(--muted); }
.counter.warning { color: var(--warning); }
.counter.success { color: var(--success); }
.counter.danger { color: var(--danger); }

/* --- Stats --- */
.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat-box { background: var(--bg); border-radius: 12px; padding: 12px; text-align: center; }
.stat-label { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; }
.stat-value { font-size: 1.5rem; font-weight: 700; font-family: 'JetBrains Mono', monospace; margin-top: 4px; }
.stat-value .accent { color: var(--accent); }
.stat-value .muted { color: var(--muted); opacity: 0.5; }
.stat-value.secondary { color: var(--secondary); }

/* --- Results List --- */
.results-header { font-size: 0.85rem; font-weight: 600; color: var(--muted); margin-top: 0.5rem; }
.results-list { flex: 1; overflow-y: auto; max-height: 220px; margin-bottom: 1rem; }

.result-item { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; background: var(--bg); border-radius: 10px; margin-bottom: 6px; transition: all 0.2s; }
.result-item:hover { background: var(--accent-light); }
.result-info h4 { font-size: 0.9rem; margin-bottom: 2px; }
.result-info p { font-size: 0.75rem; color: var(--muted); }

.result-meta { display: flex; align-items: center; gap: 8px; }
.status-indicator { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; transition: all 0.2s; }
.status-indicator svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; }
.status-indicator.empty { background: var(--border); color: var(--muted); }
.status-indicator.filled { background: rgba(16, 185, 129, 0.2); color: var(--success); }
.status-indicator.warning { background: rgba(245, 158, 11, 0.2); color: var(--warning); }

.badge { font-size: 0.65rem; padding: 3px 8px; border-radius: 20px; font-weight: 600; text-transform: uppercase; }
.badge-ideal { background: rgba(16, 185, 129, 0.2); color: var(--success); }
.badge-warning { background: rgba(245, 158, 11, 0.2); color: var(--warning); }

/* --- Code Output --- */
.code-output { 
    background: var(--code-bg); 
    border-radius: 12px; 
    padding: 1rem; 
    min-height: 120px; 
    max-height: 250px; 
    overflow-y: auto; 
    border: 1px solid var(--border);
}
.code-output pre { 
    font-family: 'JetBrains Mono', monospace; 
    font-size: 0.85rem; 
    line-height: 1.8; 
    color: var(--code-text); 
    white-space: pre-wrap; 
    word-break: break-word; 
    margin: 0; 
}
.code-output .tag-line {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    line-height: 1.8;
    color: var(--code-text);
}
.code-output .tag-name { color: #f472b6; }
.code-output .attr-name { color: #7dd3fc; }
.code-output .attr-value { color: #34d399; }
.placeholder-text { 
    color: var(--muted); 
    text-align: center; 
    margin-top: 2rem; 
    font-family: 'Space Grotesk', sans-serif; 
    font-size: 0.9rem;
}

/* --- Buttons --- */
.actions-row { display: flex; gap: 1rem; margin-top: 1.5rem; }
.btn-action { flex: 1; padding: 14px; background: var(--accent); color: white; border: none; border-radius: 12px; font-weight: 600; font-size: 1rem; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; transition: all 0.2s; }
.btn-action svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; }
.btn-action:hover { transform: translateY(-2px); box-shadow: 0 8px 20px var(--accent-glow); filter: brightness(1.05); }
.btn-secondary { flex: 1; padding: 14px; background: var(--bg); color: var(--fg); border: 2px solid var(--border); border-radius: 12px; font-weight: 600; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; transition: all 0.2s; }
.btn-secondary svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

.btn-copy { width: 100%; padding: 12px; background: var(--accent); color: white; border: none; border-radius: 12px; font-weight: 600; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; transition: all 0.2s; margin-top: 0.5rem; }
.btn-copy svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; }
.btn-copy:hover { filter: brightness(1.1); }
.btn-copy.copied { background: var(--success); }

/* --- Toast --- */
.toast { position: fixed; bottom: 2rem; right: 2rem; background: var(--card); border: 1px solid var(--accent); padding: 1rem 1.5rem; border-radius: 12px; display: flex; align-items: center; gap: 10px; box-shadow: 0 10px 30px rgba(0,0,0,0.1); transform: translateY(100px); opacity: 0; transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55); z-index: 1000; }
.toast.show { transform: translateY(0); opacity: 1; }
.toast svg { width: 20px; height: 20px; stroke: var(--accent); fill: none; }

/* Utility */
.hidden { display: none !important; }
.fade-in { animation: fadeIn 0.6s ease forwards; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 768px) {
    .stats-row { grid-template-columns: 1fr; }
    .actions-row { flex-direction: column; }
    h1 { font-size: 2rem; }
}
