:root {
    --color-bg: #F8FAFC;
    --color-surface: #FFFFFF;
    --color-surface-2: #F1F5F9;
    --color-primary: #10B981;
    --color-primary-text: #059669;
    --color-primary-hover: #047857;
    --color-border: #E2E8F0;
    --color-text-main: #0F172A;
    --color-text-muted: #64748B;
    --color-shadow: rgba(148, 163, 184, 0.15);
    --color-success: #10B981;
    --color-error: #EF4444;
    --color-warning: #F59E0B;

    --font-en: 'Inter', sans-serif;
    --font-km: 'Battambang', sans-serif;
    --font-current: var(--font-en);

    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --radius-card: 16px;
    --radius-input: 12px;
}

[lang="km"] { --font-current: var(--font-km); }

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

html { scroll-behavior: smooth; }

body {
    background-color: var(--color-bg);
    color: var(--color-text-main);
    font-family: var(--font-current);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow-x: hidden;
}

/* ── Ambient blobs ───────────────────────────────── */
.bg-blobs { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.25;
    animation: drift 14s ease-in-out infinite alternate;
}
.blob-1 {
    width: 520px; height: 520px;
    background: radial-gradient(circle, #A7F3D0, #34D399);
    top: -180px; left: -160px;
    animation-duration: 18s;
}
.blob-2 {
    width: 400px; height: 400px;
    background: radial-gradient(circle, #6EE7B7, #10B981);
    bottom: -120px; right: -100px;
    animation-duration: 14s;
    animation-delay: -6s;
}
@keyframes drift {
    from { transform: translate(0, 0) scale(1); }
    to   { transform: translate(30px, 20px) scale(1.06); }
}

/* ── Navbar ──────────────────────────────────────── */
.navbar {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--color-border);
    padding: 1rem 5%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 4px 24px -4px var(--color-shadow);
}

.logo { display: flex; align-items: center; gap: 0.85rem; }
.logo-icon { flex-shrink: 0; }
.logo-text { display: flex; flex-direction: column; line-height: 1.2; }
.logo-title { font-size: 1.05rem; font-weight: 700; color: var(--color-text-main); }
.logo-sub { font-size: 0.75rem; color: var(--color-primary-text); font-weight: 600; letter-spacing: 0.3px; }

.lang-switcher { display: flex; background: var(--color-surface-2); border: 1px solid var(--color-border); border-radius: 8px; padding: 2px; gap: 2px; }
.lang-btn {
    background: transparent; border: none;
    padding: 0.35rem 0.9rem;
    border-radius: 6px;
    font-weight: 500; cursor: pointer;
    font-size: 0.82rem;
    color: var(--color-text-muted);
    transition: var(--transition);
    font-family: var(--font-en);
}
.lang-btn.active { background: var(--color-primary); color: #FFFFFF; box-shadow: 0 1px 3px var(--color-shadow); }
.lang-btn:not(.active):hover { color: var(--color-text-main); }

/* ── Main Layout ─────────────────────────────────── */
.main-content {
    position: relative;
    z-index: 1;
    max-width: 780px;
    margin: 0 auto;
    padding: 4rem 1.5rem 3rem;
    flex: 1;
    width: 100%;
}

/* ── Hero ────────────────────────────────────────── */
.hero-section { text-align: center; margin-bottom: 2.5rem; }

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: rgba(16, 185, 129, 0.1);
    color: var(--color-primary-text);
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: 100px;
    padding: 0.4rem 1.2rem;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    margin-bottom: 1.25rem;
    animation: fadeDown 0.5s ease both;
}

.hero-title {
    font-size: clamp(1.9rem, 5vw, 2.8rem);
    font-weight: 800;
    color: var(--color-text-main);
    line-height: 1.2;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, #0F172A 30%, #059669 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: fadeDown 0.5s 0.08s ease both;
}

.hero-subtitle {
    font-size: 1.05rem;
    color: var(--color-text-muted);
    max-width: 560px;
    margin: 0 auto;
    animation: fadeDown 0.5s 0.16s ease both;
}

/* ── Search Card ─────────────────────────────────── */
.search-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-card);
    padding: 2rem;
    box-shadow: 0 10px 40px -10px var(--color-shadow);
    margin-bottom: 1.25rem;
    animation: fadeUp 0.5s 0.22s ease both;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.search-card:focus-within {
    border-color: rgba(16, 185, 129, 0.4);
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.1), 0 10px 40px -10px var(--color-shadow);
}

.search-card-inner {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.input-group { width: 100%; display: flex; flex-direction: column; gap: 0.5rem; }

.input-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--color-primary-text);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.input-wrapper { position: relative; width: 100%; }

.input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #94A3B8;
    pointer-events: none;
    transition: color var(--transition);
}
.input-wrapper:focus-within .input-icon { color: var(--color-primary-text); }

.cert-input {
    width: 100%;
    background: var(--color-bg);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-input);
    padding: 0.85rem 2.8rem 0.85rem 2.75rem;
    color: var(--color-text-main);
    font-size: 1.1rem;
    font-family: 'Inter', monospace;
    font-weight: 500;
    letter-spacing: 0.5px;
    transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
    outline: none;
}
.cert-input::placeholder { color: #94A3B8; font-weight: 400; }
.cert-input:focus {
    background: var(--color-surface);
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.12);
}

.clear-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--color-surface-2);
    border: none;
    border-radius: 6px;
    width: 26px; height: 26px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    color: var(--color-text-muted);
    opacity: 0;
    transition: opacity var(--transition), background var(--transition), color var(--transition);
    pointer-events: none;
}
.clear-btn.visible { opacity: 1; pointer-events: auto; }
.clear-btn:hover { background: rgba(239, 68, 68, 0.1); color: var(--color-error); }

.verify-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    gap: 0.5rem;
    background: linear-gradient(135deg, #10B981, #059669);
    color: #fff;
    border: none;
    border-radius: var(--radius-input);
    padding: 0.95rem 1.6rem;
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.25);
    font-family: var(--font-current);
}
.verify-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(16, 185, 129, 0.35);
    background: linear-gradient(135deg, #059669, #047857);
}
.verify-btn:active { transform: translateY(0); }
.verify-btn.loading { pointer-events: none; opacity: 0.7; }
.verify-btn-icon { transition: transform var(--transition); }
.verify-btn:hover .verify-btn-icon { transform: translateX(3px); }

.search-hint {
    margin-top: 0.9rem;
    font-size: 0.8rem;
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

/* ── Result Area ─────────────────────────────────── */
.result-area {
    margin-bottom: 2.5rem;
    animation: none;
}

/* States */
.result-searching {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-card);
    padding: 1.5rem 2rem;
    box-shadow: 0 4px 12px var(--color-shadow);
}
.spinner {
    width: 28px; height: 28px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Valid Certificate Card ──────────────────────── */
.result-found {
    background: var(--color-surface);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: var(--radius-card);
    overflow: hidden;
    box-shadow: 0 12px 36px -12px rgba(16, 185, 129, 0.2);
    animation: fadeUp 0.4s ease;
}

.result-header {
    background: linear-gradient(135deg, #059669, #10B981);
    padding: 1.5rem 2rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}
.result-status-icon {
    width: 44px; height: 44px;
    background: rgba(255,255,255,0.25);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}
.result-header-text h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: #fff;
}
.result-header-text p {
    font-size: 0.88rem;
    color: rgba(255,255,255,0.9);
    margin-top: 0.1rem;
}

.result-body { padding: 1.75rem 2rem; }

.result-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.25rem;
}
@media (max-width: 520px) { .result-grid { grid-template-columns: 1fr; } }

.result-field {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 1rem 1.25rem;
}
.result-field.wide { grid-column: 1 / -1; }
.result-field-label {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--color-primary-text);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.3rem;
}
.result-field-value {
    font-size: 1.05rem;
    color: var(--color-text-main);
    font-weight: 600;
}

.result-stamp {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: rgba(16, 185, 129, 0.05);
    border: 1px dashed rgba(16, 185, 129, 0.3);
    border-radius: 10px;
    padding: 0.85rem 1.25rem;
    font-size: 0.85rem;
    color: var(--color-primary-text);
    font-weight: 600;
}

/* ── Not Found Card ──────────────────────────────── */
.result-not-found {
    background: var(--color-surface);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-card);
    padding: 2rem;
    display: flex;
    gap: 1.25rem;
    align-items: flex-start;
    animation: fadeUp 0.4s ease;
    box-shadow: 0 8px 32px -8px rgba(239, 68, 68, 0.15);
}
.not-found-icon {
    width: 44px; height: 44px;
    background: rgba(239, 68, 68, 0.1);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}
.not-found-text h2 { font-size: 1.15rem; font-weight: 700; color: var(--color-error); margin-bottom: 0.3rem; }
.not-found-text p { font-size: 0.95rem; color: var(--color-text-main); line-height: 1.5; }

/* ── Empty / Error states ────────────────────────── */
.result-empty {
    background: var(--color-surface);
    border: 1px solid rgba(245, 158, 11, 0.4);
    border-radius: var(--radius-card);
    padding: 1.5rem 2rem;
    display: flex;
    gap: 1rem;
    align-items: center;
    font-size: 0.95rem;
    font-weight: 500;
    color: #B45309;
    animation: fadeUp 0.4s ease;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.1);
}

/* ── Footer ──────────────────────────────────────── */
.site-footer {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 2rem 2rem;
    color: var(--color-text-muted);
    border-top: 1px solid var(--color-border);
    font-size: 0.85rem;
}

/* ── Animations ──────────────────────────────────── */
@keyframes fadeDown {
    from { opacity: 0; transform: translateY(-12px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Enter key press animation */
@keyframes pulse-ring {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}
.verify-btn.pulse { animation: pulse-ring 0.4s ease; }

/* ── Mobile Optimizations ────────────────────────── */
.proficiency-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

@media (max-width: 600px) {
    .navbar {
        flex-direction: row;
        align-items: flex-start;
        padding: 1rem;
    }
    .logo {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.4rem;
        max-width: 70%;
    }
    #site-logo {
        height: 60px !important;
    }
    .logo-title {
        font-size: 0.7rem;
        line-height: 1.3;
        white-space: normal;
    }
    .logo-sub {
        font-size: 0.6rem;
    }
    .lang-switcher {
        transform: scale(0.85);
        transform-origin: top right;
    }
    
    .main-content {
        padding: 2.5rem 1rem 2rem;
    }
    
    .proficiency-grid {
        grid-template-columns: 1fr;
    }
    
    .hero-title {
        font-size: 1.6rem !important;
    }
    
    .hero-subtitle {
        font-size: 0.95rem;
    }

    .cert-input {
        padding: 0.8rem 1.2rem 0.8rem 2.4rem;
        font-size: 0.95rem;
    }
    
    .result-field {
        padding: 0.85rem 1rem;
    }
}
