/* ============================================
   TS Error Decoder — Blue Dark Theme
   ============================================ */

:root {
    --primary: #3178C6;
    --primary-hover: #2563EB;
    --primary-glow: rgba(49, 120, 198, 0.25);
    --accent: #60A5FA;
    --accent-glow: rgba(96, 165, 250, 0.2);
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;
    --bg: #0C1222;
    --bg-card: rgba(15, 23, 42, 0.85);
    --bg-elevated: rgba(30, 41, 59, 0.9);
    --bg-hover: rgba(49, 120, 198, 0.06);
    --border: rgba(49, 120, 198, 0.12);
    --border-hover: rgba(49, 120, 198, 0.25);
    --text: #E2E8F0;
    --text-muted: #94A3B8;
    --text-dim: #475569;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    --glass: blur(20px);
    --mono: 'JetBrains Mono', 'Fira Code', monospace;
    --sans: 'Inter', system-ui, -apple-system, sans-serif;
    --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

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

body {
    font-family: var(--sans);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
    background-image:
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(49, 120, 198, 0.1), transparent),
        radial-gradient(ellipse 60% 40% at 80% 100%, rgba(96, 165, 250, 0.06), transparent);
}

/* --- Header --- */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: var(--glass);
    -webkit-backdrop-filter: var(--glass);
    background: rgba(12, 18, 34, 0.85);
    border-bottom: 1px solid var(--border);
}

.header-inner {
    max-width: 900px;
    margin: 0 auto;
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
}

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

.logo-icon {
    display: flex;
}

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

.logo-sub {
    font-size: 0.7rem;
    color: var(--text-muted);
    display: block;
}

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

.section-title {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.75rem;
}

/* --- Search --- */
.search-box {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0 1rem;
    backdrop-filter: var(--glass);
}

.search-icon {
    color: var(--text-dim);
    flex-shrink: 0;
}

.search-input {
    flex: 1;
    padding: 0.75rem 0.75rem;
    background: transparent;
    border: none;
    color: var(--text);
    font-family: var(--sans);
    font-size: 0.92rem;
    outline: none;
}

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

.search-kbd {
    font-family: var(--mono);
    font-size: 0.68rem;
    color: var(--text-dim);
    background: rgba(0, 0, 0, 0.3);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    border: 1px solid var(--border);
}

/* --- Paste --- */
.paste-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.error-textarea {
    width: 100%;
    padding: 0.75rem;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--danger);
    font-family: var(--mono);
    font-size: 0.82rem;
    resize: vertical;
    outline: none;
    transition: all var(--transition);
}

.error-textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
    color: var(--text);
}

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

.mono {
    font-family: var(--mono);
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--sans);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    line-height: 1;
    align-self: flex-start;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
    box-shadow: 0 0 20px var(--primary-glow);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 0 30px var(--primary-glow);
}

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

.btn-ghost:hover {
    color: var(--text);
    border-color: var(--border-hover);
    background: var(--bg-hover);
}

.btn-sm {
    padding: 0.35rem 0.65rem;
    font-size: 0.75rem;
}

/* --- Result Card --- */
.result-section.hidden {
    display: none;
}

.result-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    backdrop-filter: var(--glass);
    animation: fadeIn 300ms ease-out;
}

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

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

.result-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.error-code {
    font-family: var(--mono);
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary);
    background: var(--primary-glow);
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-xs);
}

.category-badge {
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
}

.cat-type {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

.cat-syntax {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

.cat-import {
    background: rgba(49, 120, 198, 0.15);
    color: var(--primary);
}

.cat-config {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
}

.cat-other {
    background: rgba(148, 163, 184, 0.15);
    color: var(--text-muted);
}

.result-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.result-explanation {
    font-size: 0.88rem;
    color: var(--text-muted);
    line-height: 1.7;
    margin-bottom: 0.75rem;
}

.fix-section {
    margin-top: 0.75rem;
}

.fix-title {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--success);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.4rem;
}

.fix-code {
    background: rgba(0, 0, 0, 0.35);
    border-radius: var(--radius-xs);
    padding: 0.6rem 0.85rem;
    font-family: var(--mono);
    font-size: 0.78rem;
    color: var(--accent);
    overflow-x: auto;
    white-space: pre;
}

.result-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
    flex-wrap: wrap;
}

.result-link {
    font-size: 0.78rem;
    color: var(--primary);
    text-decoration: none;
}

.result-link:hover {
    text-decoration: underline;
}

/* --- Errors Grid --- */
.errors-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 0.5rem;
}

.error-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: all var(--transition);
}

.error-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-1px);
    background: var(--bg-elevated);
}

.error-card-code {
    font-family: var(--mono);
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--primary);
}

.error-card-title {
    font-size: 0.82rem;
    color: var(--text);
    margin-top: 0.15rem;
}

.error-card-cat {
    font-size: 0.68rem;
    color: var(--text-dim);
    margin-top: 0.1rem;
}

/* --- Category Grid --- */
.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.5rem;
}

.category-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.85rem 1rem;
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.category-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-1px);
}

.category-emoji {
    font-size: 1.3rem;
}

.category-name {
    font-size: 0.88rem;
    font-weight: 500;
}

.category-count {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-left: auto;
}

/* --- Toast --- */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.6rem 1rem;
    font-size: 0.82rem;
    color: var(--text);
    box-shadow: var(--shadow);
    animation: toastIn 300ms ease-out;
}

.toast.success {
    border-left: 3px solid var(--success);
}

.toast.info {
    border-left: 3px solid var(--primary);
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

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

/* --- Responsive --- */
@media (max-width: 640px) {
    .main {
        padding: 1rem;
        gap: 1.5rem;
    }

    .errors-grid {
        grid-template-columns: 1fr;
    }

    .category-grid {
        grid-template-columns: 1fr;
    }
}