/* CSS Variables */
:root {
    /* Light Mode */
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --accent: #0ea5e9;
    --accent-hover: #0284c7;
    --accent-glow: rgba(14, 165, 233, 0.3);
    --border: rgba(0, 0, 0, 0.08);
    --card-bg: rgba(255, 255, 255, 0.8);
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.08);
    --gradient-start: #e0f2fe;
    --gradient-end: #f0fdf4;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
}

[data-theme="dark"] {
    --bg-primary: #0a0f1a;
    --bg-secondary: #111827;
    --bg-tertiary: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;
    --accent: #38bdf8;
    --accent-hover: #7dd3fc;
    --accent-glow: rgba(56, 189, 248, 0.3);
    --border: rgba(255, 255, 255, 0.08);
    --card-bg: rgba(17, 24, 39, 0.8);
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.4);
    --gradient-start: #0c1929;
    --gradient-end: #0f1f1a;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    transition: background 0.3s ease, color 0.3s ease;
}

/* Background Effects */
.bg-gradient {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-end) 100%);
    z-index: -2;
    transition: background 0.3s ease;
}

.bg-grid {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        linear-gradient(var(--border) 1px, transparent 1px),
        linear-gradient(90deg, var(--border) 1px, transparent 1px);
    background-size: 60px 60px;
    z-index: -1;
    opacity: 0.5;
}

/* Theme Toggle */
.theme-toggle {
    position: fixed;
    top: 24px;
    right: 24px;
    width: 48px;
    height: 48px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    transition: all 0.3s ease;
    z-index: 100;
    box-shadow: var(--shadow);
}

.theme-toggle:hover {
    transform: scale(1.05);
    border-color: var(--accent);
}

.sun-icon, .moon-icon {
    position: absolute;
    transition: all 0.3s ease;
}

.sun-icon {
    opacity: 1;
    transform: rotate(0);
}

.moon-icon {
    opacity: 0;
    transform: rotate(-90deg);
}

[data-theme="dark"] .sun-icon {
    opacity: 0;
    transform: rotate(90deg);
}

[data-theme="dark"] .moon-icon {
    opacity: 1;
    transform: rotate(0);
}

/* Container */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 40px 24px;
    min-height: 100vh;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 48px;
    animation: fadeInDown 0.6s ease;
}

.logo-combined {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0;
}

.logo-image {
    width: 180px;
    height: 180px;
    object-fit: contain;
    margin-bottom: -65px;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.15));
}

[data-theme="dark"] .logo-image {
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.4)) brightness(1.15) invert(0.85);
}

.logo-text-inline {
    display: flex;
    align-items: baseline;
    justify-content: center;
}

.logo-name {
    font-size: 3.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--text-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo-tld {
    font-size: 3.5rem;
    font-weight: 800;
    color: var(--accent);
}

.tagline {
    font-size: 1.3rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-top: 8px;
}

/* Search Section */
.search-section {
    margin-bottom: 40px;
    animation: fadeInUp 0.6s ease 0.1s both;
}

.search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 20px;
    color: var(--text-muted);
    pointer-events: none;
    transition: color 0.3s ease;
}

.search-input {
    width: 100%;
    padding: 20px 140px 20px 56px;
    font-size: 1.1rem;
    font-family: inherit;
    font-weight: 500;
    border: 2px solid var(--border);
    border-radius: 20px;
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    color: var(--text-primary);
    transition: all 0.3s ease;
    box-shadow: var(--shadow);
}

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

.search-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: var(--shadow-lg), 0 0 0 4px var(--accent-glow);
}

.search-input:focus + .search-icon,
.search-wrapper:focus-within .search-icon {
    color: var(--accent);
}

.search-shortcut {
    position: absolute;
    right: 16px;
    display: flex;
    gap: 4px;
}

.search-shortcut kbd {
    padding: 6px 10px;
    font-size: 0.75rem;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 500;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-muted);
}

/* Suggestions Dropdown */
.suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 8px;
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    max-height: 400px;
    overflow-y: auto;
    z-index: 50;
    display: none;
}

.suggestions.active {
    display: block;
    animation: fadeInUp 0.2s ease;
}

.suggestion-item {
    padding: 16px 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 16px;
    border-bottom: 1px solid var(--border);
    transition: background 0.2s ease;
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item:hover {
    background: var(--bg-tertiary);
}

.suggestion-item.active {
    background: var(--bg-tertiary);
}

.suggestion-code {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 500;
    font-size: 0.95rem;
    color: var(--accent);
    background: var(--accent-glow);
    padding: 6px 12px;
    border-radius: 8px;
    min-width: 120px;
    text-align: center;
}

.suggestion-desc {
    flex: 1;
    color: var(--text-secondary);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Results Section */
.results-section {
    margin-bottom: 48px;
}

.result-card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 32px;
    box-shadow: var(--shadow-lg);
    animation: fadeInUp 0.4s ease;
}

.result-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

.result-title {
    flex: 1;
}

.result-code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 8px;
}

.result-desc {
    font-size: 1.1rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.result-policy {
    padding: 8px 16px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.policy-restricted {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.policy-free {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

/* Duty Grid */
.duty-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 16px;
}

.duty-item {
    background: var(--bg-tertiary);
    border-radius: 16px;
    padding: 20px;
    text-align: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.duty-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.duty-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 8px;
}

.duty-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
}

.duty-value.highlight {
    color: var(--accent);
}

/* Stats Section */
.stats-section {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 48px;
    animation: fadeInUp 0.6s ease 0.2s both;
}

.stat-card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 24px;
    text-align: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.stat-number {
    display: block;
    font-size: 2rem;
    font-weight: 800;
    color: var(--accent);
    margin-bottom: 4px;
}

.stat-label {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Features Section */
.features-section {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 48px;
    animation: fadeInUp 0.6s ease 0.3s both;
}

.feature {
    text-align: center;
    padding: 24px;
}

.feature-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
}

.feature h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.feature p {
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* Footer */
.footer {
    text-align: center;
    padding-top: 32px;
    border-top: 1px solid var(--border);
    animation: fadeInUp 0.6s ease 0.4s both;
}

.footer p {
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 8px;
}

.footer .disclaimer {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Animations */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 24px 16px;
    }

    .logo-image {
        width: 140px;
        height: 140px;
        margin-bottom: -55px;
    }

    .logo-name, .logo-tld {
        font-size: 2.5rem;
    }

    .tagline {
        font-size: 1.1rem;
    }

    .search-input {
        padding: 18px 20px 18px 52px;
        font-size: 1rem;
    }

    .search-shortcut {
        display: none;
    }

    .stats-section {
        grid-template-columns: repeat(3, 1fr);
        gap: 12px;
    }

    .stat-card {
        padding: 16px 12px;
    }

    .stat-number {
        font-size: 1.4rem;
    }

    .features-section {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .feature {
        padding: 16px;
    }

    .result-card {
        padding: 20px;
    }

    .result-header {
        flex-direction: column;
        gap: 16px;
    }

    .duty-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .theme-toggle {
        top: 16px;
        right: 16px;
        width: 42px;
        height: 42px;
    }
}

/* No Results */
.no-results {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}

.no-results-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

.no-results h3 {
    font-size: 1.2rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

/* Loading State */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
}

.loading::after {
    content: '';
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}
