:root {
    /* Light Mode */
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary: #f1f5f9;
    --danger: #ef4444;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --bg-main: #f8fafc;
    --card-bg: rgba(255, 255, 255, 0.8);
    --border: rgba(0, 0, 0, 0.08);
    --ring: rgba(37, 99, 235, 0.2);
    --blob-1-gradient: radial-gradient(circle, rgba(37, 99, 235, 0.15) 0%, rgba(248, 250, 252, 0) 70%);
    --blob-2-gradient: radial-gradient(circle, rgba(139, 92, 246, 0.1) 0%, rgba(248, 250, 252, 0) 70%);
    --title-gradient: linear-gradient(to right, #1e40af, #3b82f6);
    --select-bg: rgba(255, 255, 255, 0.9);
    --input-text: #1e293b;
    --shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.05), 0 10px 10px -5px rgba(0, 0, 0, 0.02);
    --header-logo-filter: drop-shadow(0 0 8px rgba(37, 99, 235, 0.3));
    --icon-stroke: #1e293b;

    --radius-lg: 16px;
    --radius-md: 12px;
}

[data-theme="dark"] {
    /* Dark Mode */
    --primary: #3b82f6;
    --primary-hover: #60a5fa;
    --secondary: #0f172a;
    --danger: #ef4444;
    --text-main: #f8fafc;
    --text-muted: #cbd5e1;
    --bg-main: #020617;
    --card-bg: rgba(30, 41, 59, 0.7);
    --border: rgba(255, 255, 255, 0.1);
    --ring: rgba(59, 130, 246, 0.5);
    --blob-1-gradient: radial-gradient(circle, rgba(37, 99, 235, 0.4) 0%, rgba(2, 6, 23, 0) 70%);
    --blob-2-gradient: radial-gradient(circle, rgba(139, 92, 246, 0.25) 0%, rgba(2, 6, 23, 0) 70%);
    --title-gradient: linear-gradient(to right, #ffffff, #93c5fd);
    --select-bg: rgba(15, 23, 42, 0.6);
    --input-text: white;
    --shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    --header-logo-filter: drop-shadow(0 0 10px rgba(37, 99, 235, 0.8));
    --icon-stroke: white;
}

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

body {
    font-family: 'Outfit', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    overflow-x: hidden;
    position: relative;
    line-height: 1.5;
}

/* Background Blobs for Glassmorphism effect */
.background-blobs {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.blob {
    position: absolute;
    filter: blur(100px);
    border-radius: 50%;
    opacity: 0.5;
    animation: float 20s infinite ease-in-out alternate;
}

.blob-1 {
    top: -10%;
    right: -5%;
    width: 50vw;
    height: 50vw;
    background: var(--blob-1-gradient);
}

.blob-2 {
    bottom: -10%;
    left: -10%;
    width: 60vw;
    height: 60vw;
    background: var(--blob-2-gradient);
    animation-delay: -10s;
}

@keyframes float {
    0% {
        transform: translate(0, 0) scale(1);
    }

    100% {
        transform: translate(-50px, 50px) scale(1.1);
    }
}

/* Layout */
.container {
    width: 100%;
    max-width: 600px;
    padding: 20px; /* Reduced top padding */
    display: flex;
    flex-direction: column;
    gap: 16px; /* Halved container gap */
}

header {
    text-align: center;
    animation: slideDown 0.6s ease-out;
}

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

.logo-img {
    height: 240px;
    width: auto;
    max-width: 100%;
    object-fit: contain;
    margin-bottom: -95px; /* Slightly reduced to fix overlap */
    transition: filter 0.3s ease;
}

[data-theme="dark"] .logo-img {
    filter: brightness(1.2) contrast(1.1);
}

h1 {
    font-size: 2.25rem;
    font-weight: 700;
    margin: 0;
    line-height: 1.2; /* Increased for descenders like 'g' */
    padding-bottom: 4px; /* Extra safety for 'g' */
    background: var(--title-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: var(--text-muted);
    font-size: 1rem;
    margin-top: 0; /* Adjusted since h1 has more space now */
}

/* Cards & Glassmorphism */
.glass {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.card {
    padding: 32px;
}

.search-card {
    display: flex;
    flex-direction: column;
    gap: 20px;
    animation: fadeIn 0.8s ease-out;
}

/* Forms */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

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

.custom-select-wrapper {
    position: relative;
}

select {
    width: 100%;
    appearance: none;
    background-color: var(--select-bg);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 14px 16px;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-family: inherit;
    outline: none;
    transition: all 0.2s ease;
    cursor: pointer;
}

select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--ring);
}

select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.custom-select-wrapper::after {
    content: "▼";
    font-size: 0.8rem;
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

/* Inputs */
.custom-input {
    width: 100%;
    background-color: var(--select-bg);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 14px 16px;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-family: inherit;
    outline: none;
    transition: all 0.2s ease;
}

.custom-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--ring);
}

.custom-input::placeholder {
    color: rgba(203, 213, 225, 0.4);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.primary-btn {
    background-color: var(--primary);
    color: white;
    margin-top: 8px;
}

.primary-btn:hover:not(:disabled) {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(37, 99, 235, 0.4);
}

.primary-btn:active:not(:disabled) {
    transform: translateY(0);
}

.primary-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: #334155;
    color: #94a3b8;
}

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

.secondary-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
}

.icon {
    transition: transform 0.2s;
}

.primary-btn:hover:not(:disabled) .icon {
    transform: translateX(4px);
}

/* Results Card */
.result-card {
    transform-origin: top;
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.result-card.hidden {
    display: none;
    opacity: 0;
    transform: scaleY(0.95);
}

.result-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
}

.status-badge {
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary);
    border: 1px solid var(--ring);
    padding: 6px 16px;
    border-radius: 9999px;
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.result-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-main);
}

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

.res-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.res-value {
    font-weight: 600;
    color: var(--text-main);
}

.res-divider {
    height: 1px;
    background: var(--border);
    margin: 8px 0;
}

.res-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.res-text {
    font-size: 1rem;
    color: var(--text-main);
    line-height: 1.6;
}

.res-explanation-box {
    background: var(--secondary);
    border-radius: var(--radius-md);
    padding: 20px;
    border: 1px solid var(--border);
    font-size: 0.95rem;
    color: var(--text-main);
    line-height: 1.6;
}

/* HTML Content from JSON (Explicacion) */
.res-explanation-box a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.2s;
}

.res-explanation-box a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

.res-explanation-box br {
    display: block;
    margin-bottom: 12px;
}

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

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

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

.slide-up {
    animation: slideInUp 0.5s forwards;
}

/* Theme Toggle styles */
.theme-toggle-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
}

.theme-switch {
    display: flex;
    align-items: center;
    background: var(--card-bg);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border);
    padding: 4px;
    border-radius: 999px;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
}

.theme-switch:hover {
    transform: scale(1.05);
}

.toggle-option {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--text-muted);
}

.toggle-option.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.toggle-option svg {
    width: 18px;
    height: 18px;
}

@media (min-width: 640px) {
    .theme-toggle-container {
        top: 30px;
        right: 30px;
        left: auto;
        transform: none;
    }
}