:root {
    --primary: #2563eb;
    --primary-light: #60a5fa;
    --primary-dark: #1e40af;
    --secondary: #0d9488;
    --accent: #f59e0b;
    --bg-light: #f1f5f9;
    --bg-white: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --glass: rgba(255, 255, 255, 0.7);
    --border: rgba(226, 232, 240, 0.8);
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --shadow-lg: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
    --transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    --radius: 1rem;
}

[data-theme="dark"] {
    --bg-light: #0f172a;
    --bg-white: #1e293b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --glass: rgba(30, 41, 59, 0.7);
    --border: rgba(51, 65, 85, 0.8);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Sarabun', sans-serif;
    background-color: var(--bg-light);
    color: var(--text-main);
    line-height: 1.8;
    font-size: 1.1rem; /* Slightly reduced base font for better fit */
    transition: var(--transition);
}

h1, h2, h3, h4 {
    font-family: 'Kanit', sans-serif;
    font-weight: 600;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
}

/* --- Header & Nav --- */
header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    background: var(--glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    transition: var(--transition);
}

header.scrolled {
    padding: 0.2rem 0;
    box-shadow: var(--shadow-md);
}

.nav-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    text-decoration: none;
    color: var(--primary);
    font-family: 'Kanit', sans-serif;
    font-size: 1.4rem;
}

.nav-links {
    display: flex;
    list-style: none;
    gap: 0.5rem;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-muted);
    padding: 0.6rem 1rem;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 500;
    transition: var(--transition);
}

.nav-links a:hover, .nav-links a.active {
    color: var(--primary);
    background: rgba(37, 99, 235, 0.08);
}

.nav-tools {
    display: flex;
    align-items: center;
    gap: 1.2rem;
}

.theme-toggle, .lang-toggle {
    cursor: pointer;
    font-size: 1.1rem;
    color: var(--text-muted);
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.theme-toggle:hover, .lang-toggle:hover {
    color: var(--primary);
    transform: scale(1.1);
}

/* --- Hero --- */
.hero {
    padding: 12rem 0 8rem;
    background: radial-gradient(circle at top right, rgba(37,99,235,0.08), transparent),
                radial-gradient(circle at bottom left, rgba(13,148,136,0.08), transparent);
    text-align: center;
}

.hero h1 {
    font-size: clamp(2.5rem, 6vw, 4rem);
    margin-bottom: 1.5rem;
    line-height: 1.2;
    background: linear-gradient(135deg, var(--primary-dark), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero p {
    font-size: 1.2rem;
    max-width: 700px;
    margin: 0 auto 2.5rem;
    color: var(--text-muted);
}

/* --- Sections & Cards --- */
section {
    padding: 8rem 0;
}

.section-header {
    text-align: center;
    margin-bottom: 4rem;
}

.section-header h2 {
    font-size: 2.4rem;
    margin-bottom: 1rem;
    position: relative;
    display: inline-block;
}

.section-header h2::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 50px;
    height: 4px;
    background: var(--primary);
    border-radius: 2px;
}

.card {
    background: var(--bg-white);
    border-radius: 1.5rem;
    padding: 2.5rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
    transition: var(--transition);
    height: 100%;
}

.card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-light);
}

/* --- BEFAST Modern Cards --- */
.befast-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); /* Reduced min-width to prevent overlap */
    gap: 2rem; /* Adjusted gap */
}

.befast-card {
    position: relative;
    padding: 2rem 1.5rem !important; /* Reduced padding to make cards smaller */
    text-align: left !important;
    background: var(--bg-white);
    border-radius: 1.5rem;
    border: 1px solid var(--border);
    transition: var(--transition);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.befast-card[data-letter]::before {
    content: attr(data-letter);
    position: absolute;
    top: -0.5rem;
    right: -0.2rem;
    font-size: 6rem; /* Reduced background letter size */
    font-weight: 800;
    color: var(--primary);
    opacity: 0.05;
    font-family: 'Kanit', sans-serif;
    transition: var(--transition);
}

.befast-card i {
    font-size: 2rem; /* Reduced icon size */
    color: var(--primary);
    margin-bottom: 0.2rem;
}

.befast-card h3 {
    font-size: 1.5rem; /* Reduced title size */
    color: var(--primary-dark);
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.befast-card p {
    font-size: 1rem !important; /* Reduced description size */
    color: var(--text-muted);
    line-height: 1.5;
}

/* --- Media & Education --- */
.media-section {
    background: linear-gradient(180deg, var(--bg-white) 0%, #0f172a 100%);
    padding-bottom: 10rem;
}

[data-theme="dark"] .media-section {
    background: #0f172a;
}

.cinema-wrapper {
    max-width: 1000px;
    margin: 0 auto;
    background: #000;
    border-radius: 2rem;
    overflow: hidden;
    box-shadow: 0 30px 60px rgba(0,0,0,0.5);
    border: 4px solid #1e293b;
    position: relative;
}

.video-wrapper {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
}

.video-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* --- Super Footer --- */
.super-footer {
    background: #0f172a;
    color: #94a3b8;
    padding: 6rem 0 3rem;
    position: relative;
    overflow: hidden;
}

.super-footer::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, var(--primary), var(--secondary), var(--accent));
}

.footer-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1.5fr;
    gap: 4rem;
}

.footer-logo {
    color: #fff;
    font-size: 1.8rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.footer-title {
    color: #fff;
    font-size: 1.2rem;
    margin-bottom: 1.5rem;
    font-weight: 600;
    font-family: 'Kanit', sans-serif;
}

.footer-links {
    list-style: none;
    padding-left: 0 !important;
}

.footer-links li {
    margin-bottom: 0.8rem;
    padding-left: 0 !important;
}

.footer-links li::before {
    content: none !important;
}

.footer-links a {
    color: inherit;
    text-decoration: none;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.footer-links a:hover {
    color: var(--primary-light);
    transform: translateX(5px);
}

.emergency-card {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    padding: 2rem;
    border-radius: 1.5rem;
    text-align: center;
}

.emergency-number {
    font-size: 3.5rem;
    color: #ef4444;
    font-weight: 800;
    margin: 0.5rem 0;
    display: block;
    text-decoration: none;
    font-family: 'Kanit', sans-serif;
}

.emergency-btn {
    background: #ef4444;
    color: #fff;
    padding: 0.8rem 1.5rem;
    border-radius: 1rem;
    text-decoration: none;
    font-weight: 600;
    display: inline-block;
    margin-top: 1rem;
    transition: var(--transition);
}

.emergency-btn:hover {
    background: #dc2626;
    transform: scale(1.05);
}

.footer-bottom {
    margin-top: 5rem;
    padding-top: 2rem;
    border-top: 1px solid rgba(255,255,255,0.05);
    text-align: center;
    font-size: 0.9rem;
}

@media (max-width: 992px) {
    .footer-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 768px) {
    .footer-grid {
        grid-template-columns: 1fr;
        gap: 3rem;
    }
}

/* --- Modal / Popup Styles --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

.modal-content {
    background: var(--bg-white);
    width: 90%;
    max-width: 500px;
    padding: 3rem;
    border-radius: 2rem;
    position: relative;
    box-shadow: var(--shadow-lg);
    transform: scale(0.8);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    text-align: center;
    border: 1px solid var(--border);
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

.close-modal {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
}

.close-modal:hover {
    color: #ef4444;
    transform: rotate(90deg);
}

.modal-icon {
    font-size: 4rem;
    margin-bottom: 1.5rem;
}

.modal-bmi-value {
    font-size: 3.5rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    font-family: 'Kanit', sans-serif;
}

/* --- BMI Calculator --- */
.bmi-container {
    max-width: 650px;
    margin: 0 auto;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.6rem;
    font-weight: 500;
    color: var(--text-main);
}

.form-control {
    width: 100%;
    padding: 1rem;
    border-radius: 1rem;
    border: 1px solid var(--border);
    background: var(--bg-light);
    color: var(--text-main);
    font-size: 1rem;
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

.btn {
    padding: 1rem 2rem;
    background: var(--primary);
    color: white;
    border-radius: 3rem;
    font-family: 'Kanit', sans-serif;
    font-weight: 600;
    text-decoration: none;
    display: inline-block;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 8px 15px rgba(37, 99, 235, 0.2);
}

.btn:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(37, 99, 235, 0.3);
}

/* --- Accessibility --- */
.accessibility-fab {
    position: fixed;
    bottom: 2.5rem;
    right: 2.5rem;
    z-index: 1001;
}

.fab-main {
    width: 3.5rem;
    height: 3.5rem;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
}

/* --- Desktop Grid Layout --- */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 3rem;
}

/* --- Risk Factors Badges & Detailed Lists --- */
.risk-badge {
    padding: 0.8rem 1.5rem;
    background: rgba(239, 68, 68, 0.05);
    border: 1px solid rgba(239, 68, 68, 0.15);
    border-radius: 2rem;
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: 500;
    font-size: 1rem;
    color: var(--text-main);
    transition: var(--transition);
}
.risk-badge:hover {
    transform: translateY(-2px);
    background: rgba(239, 68, 68, 0.1);
    box-shadow: var(--shadow-sm);
}
.risk-detailed-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.risk-detailed-list li {
    padding: 1rem 0;
    border-bottom: 1px solid var(--border);
    transition: var(--transition);
}
.risk-detailed-list li:last-child {
    border-bottom: none;
}
.risk-detailed-list li strong {
    color: var(--text-main);
    display: block;
    font-size: 1.1rem;
    margin-bottom: 0.2rem;
}
.risk-detailed-list li span {
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.6;
    display: block;
}
.risk-detailed-list li:hover {
    padding-left: 0.5rem;
}

/* --- Treatment Cards --- */
.treatment-card {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 1.5rem !important;
    transition: var(--transition);
    height: auto !important;
}
.treatment-card:hover {
    transform: translateX(5px);
}
.treatment-icon {
    font-size: 2rem;
    color: var(--primary);
    background: rgba(37, 99, 235, 0.08);
    width: 4rem;
    height: 4rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: var(--transition);
}
.treatment-card:hover .treatment-icon {
    background: var(--primary);
    color: white;
}
.treatment-body p {
    margin: 0;
    font-size: 1.05rem;
    line-height: 1.6;
    color: var(--text-main);
}

/* --- Complication Lists --- */
.comp-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.comp-list li {
    padding: 0.8rem 0;
    border-bottom: 1px solid var(--border);
    transition: var(--transition);
}
.comp-list li:last-child {
    border-bottom: none;
}
.comp-list li strong {
    color: var(--text-main);
    display: block;
    font-size: 1.05rem;
}
.comp-list li span {
    color: var(--text-muted);
    font-size: 0.95rem;
    display: block;
    margin-top: 0.2rem;
    line-height: 1.6;
}
.comp-list li:hover {
    padding-left: 0.5rem;
}

/* --- Responsive --- */
@media (max-width: 1024px) {
    .container { padding: 0 1.5rem; }
}

@media (max-width: 768px) {
    .nav-links {
        display: none; /* Hide for mobile toggle if needed */
    }
    .hero { padding: 10rem 0 6rem; }
    .hero h1 { font-size: 2.8rem; }
    .section-header h2 { font-size: 2rem; }
    .grid-2 { grid-template-columns: 1fr; gap: 2rem; }
    section { padding: 5rem 0; }
}

/* Animation classes */
.reveal {
    opacity: 0;
    transform: translateY(40px);
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.reveal.active {
    opacity: 1;
    transform: translateY(0);
}