/* CSS Variables */
:root {
    --primary-color: #2563EB;
    /* Royal Blue */
    --primary-dark: #1E40AF;
    --secondary-color: #06B6D4;
    /* Cyan */
    --accent-color: #F59E0B;
    /* Amber/Orange */
    --text-color: #1F2937;
    --text-light: #6B7280;
    --bg-color: #F3F4F6;
    --card-bg: rgba(255, 255, 255, 0.95);
    --glass-border: rgba(255, 255, 255, 0.3);
    --font-heading: 'IBM Plex Sans Thai', sans-serif;
    --font-body: 'IBM Plex Sans Thai', sans-serif;
    --shadow-sm: 0 1px 2px 0 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 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --border-radius: 12px;
    --transition: all 0.3s ease;
}

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

html {
    scroll-behavior: smooth;
    height: 100%;
}

/* เพิ่มส่วนนี้เพื่อให้ Input และ Button ทุกตัวใช้ฟอนต์หลัก */
button,
input,
textarea,
select {
    font-family: var(--font-body);
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    background-image:
        radial-gradient(at 100% 0%, hsla(189, 100%, 56%, 0.2) 0px, transparent 50%),
        radial-gradient(at 0% 100%, hsla(217, 100%, 58%, 0.2) 0px, transparent 50%);
    background-attachment: fixed;
    background-size: cover;
}

a {
    text-decoration: none;
    color: inherit;
}

ul {
    list-style: none;
}

img {
    max-width: 100%;
    display: block;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
}

/* Typography */
h1,
h2,
h3,
h4 {
    font-family: var(--font-heading);
    line-height: 1.2;
    margin-bottom: 1rem;
}

h1 {
    font-size: 3.5rem;
    font-weight: 700;
}

h2 {
    font-size: 2.5rem;
    color: var(--text-color);
    text-align: center;
    margin-bottom: 0.5rem;
}

p {
    margin-bottom: 1.5rem;
    color: var(--text-light);
}

.highlight {
    color: var(--primary-color);
}

.gradient-text {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.section-header {
    text-align: center;
    margin-bottom: 3rem;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

/* Buttons */
.btn-primary,
.btn-secondary,
.btn-outline {
    display: inline-block;
    padding: 0.8rem 1.8rem;
    border-radius: 50px;
    font-weight: 500;
    transition: var(--transition);
    cursor: pointer;
    font-size: 1rem;
    border: none;
    text-align: center;
    font-family: var(--font-body);
    /* ย้ำฟอนต์ตรงนี้อีกครั้ง */
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    box-shadow: 0 4px 15px rgba(37, 99, 235, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.6);
}

.btn-secondary {
    background: white;
    color: var(--primary-color);
    box-shadow: var(--shadow-sm);
    margin-left: 1rem;
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-outline {
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
    background: transparent;
}

.btn-outline:hover {
    background: var(--primary-color);
    color: white;
}

/* Navbar */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    padding: 1rem 0;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--glass-border);
    transition: var(--transition);
}

.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-color);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.nav-links a {
    font-weight: 500;
    color: var(--text-color);
    transition: var(--transition);
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--primary-color);
}

.nav-links .btn-primary {
    padding: 0.6rem 1.5rem;
    color: white;
    /* fix for link color override */
}

.menu-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
}

.menu-toggle span {
    width: 25px;
    height: 3px;
    background-color: var(--text-color);
    border-radius: 2px;
    transition: var(--transition);
}

/* Hero Section */
.hero {
    padding: 8rem 0 4rem;
    min-height: 100vh;
    display: flex;
    align-items: center;
}

.hero-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4rem;
    align-items: center;
}

.badge {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary-color);
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
}

.hero p {
    font-size: 1.2rem;
    max-width: 90%;
}

.stats {
    display: flex;
    gap: 3rem;
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.stat-item {
    display: flex;
    flex-direction: column;
}

.stat-number {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-color);
}

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

.image-wrapper {
    position: relative;
    z-index: 1;
}

.image-wrapper::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 120%;
    height: 120%;
    background: radial-gradient(circle, rgba(6, 182, 212, 0.2) 0%, rgba(255, 255, 255, 0) 70%);
    z-index: -1;
}

.floating-img {
    animation: float 6s ease-in-out infinite;
}

@keyframes float {
    0% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-20px);
    }

    100% {
        transform: translateY(0px);
    }
}

/* Features Section */
.features {
    padding: 6rem 0;
}

.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
}

.feature-card {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 20px;
    border: 1px solid white;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
    text-align: center;
}

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

.icon-box {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: white;
    margin: 0 auto 1.5rem;
}

.feature-card h3 {
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
}

/* Resources Section - UI Updated */
.resources {
    padding: 6rem 0;
    background: rgba(255, 255, 255, 0.5);
}

.categories {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 3rem;
    flex-wrap: wrap;
}

.cat-btn {
    padding: 0.6rem 1.5rem;
    border: 1px solid rgba(0, 0, 0, 0.1);
    background: white;
    border-radius: 30px;
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 1rem;
    transition: var(--transition);
}

.cat-btn:hover,
.cat-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.resource-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
    margin-bottom: 3rem;
}

/* Updated Resource Card Styles */
.resource-card {
    background: white;
    border-radius: 20px;
    overflow: hidden;
    /* จำเป็นสำหรับ Effect ภาพขยาย */
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    /* เงาเริ่มต้นแบบนุ่มนวล */
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    /* Effect เด้งดึ๋งเล็กน้อยตอน Hover */
    border: 1px solid rgba(0, 0, 0, 0.05);
    /* เส้นขอบจางๆ เพิ่มความคมชัด */
    display: flex;
    flex-direction: column;
    height: 100%;
    /* ให้การ์ดสูงเท่ากันในแถว */
}

.resource-card:hover {
    transform: translateY(-8px);
    /* ลอยขึ้นเมื่อเอาเมาส์ชี้ */
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    /* เงาใหญ่ขึ้น */
}

/* Image Zoom Effect */
.card-image {
    height: 200px;
    /* ปรับความสูงเพิ่มเล็กน้อย */
    width: 100%;
    background-size: cover;
    background-position: center;
    transition: transform 0.8s ease;
    /* ระยะเวลาการขยายภาพ */
}

.resource-card:hover .card-image {
    transform: scale(1.1);
    /* ขยายภาพพื้นหลังเมื่อ Hover การ์ด */
}

.gradient-1 {
    background: linear-gradient(135deg, #FF9A9E 0%, #FECFEF 100%);
}

.gradient-2 {
    background: linear-gradient(135deg, #a18cd1 0%, #fbc2eb 100%);
}

.gradient-3 {
    background: linear-gradient(135deg, #84fab0 0%, #8fd3f4 100%);
}

.gradient-4 {
    background: linear-gradient(135deg, #e0c3fc 0%, #8ec5fc 100%);
}

.card-content {
    padding: 1.8rem;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    /* ดันเนื้อหาให้เต็มพื้นที่ */
}

.tag {
    display: inline-block;
    padding: 0.2rem 0.8rem;
    border-radius: 15px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 0.8rem;
    align-self: flex-start;
    /* ให้ Tag ชิดซ้าย */
}

.tag.science {
    background: #e0f2fe;
    color: #0284c7;
}

.tag.math {
    background: #fce7f3;
    color: #db2777;
}

.tag.tech {
    background: #dcfce7;
    color: #16a34a;
}

.tag.lang {
    background: #ffedd5;
    color: #ea580c;
}

.resource-card h3 {
    font-size: 1.4rem;
    font-weight: 700;
    margin: 0.8rem 0;
    color: var(--text-color);
    line-height: 1.4;
}

.resource-card p {
    color: var(--text-light);
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 1.5rem;
    flex-grow: 1;
    /* ดันปุ่มลงไปด้านล่างสุดเสมอ */
}

/* Updated Button Styles */
.card-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 0.8rem 1.5rem;
    background-color: #EFF6FF;
    /* สีพื้นหลังอ่อนๆ (สีฟ้าจาง) */
    color: var(--primary-color);
    border-radius: 12px;
    font-weight: 600;
    font-size: 1rem;
    text-decoration: none;
    transition: all 0.3s ease;
    border: 1px solid transparent;
}

.card-link:hover {
    background-color: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
    /* เงาสีฟ้า */
    text-decoration: none;
}

/* Arrow Animation */
.card-link::after {
    content: "→";
    margin-left: 8px;
    transition: transform 0.3s ease;
}

.card-link:hover::after {
    transform: translateX(5px);
}

.center-btn {
    text-align: center;
}

/* CTA Section */
.cta-section {
    padding: 6rem 0;
}

.cta-box {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: 30px;
    padding: 4rem 2rem;
    text-align: center;
    color: white;
    box-shadow: var(--shadow-lg);
}

.cta-box h2 {
    color: white;
    margin-bottom: 1rem;
}

.cta-box p {
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 2rem;
    font-size: 1.2rem;
}

.newsletter-form {
    display: flex;
    justify-content: center;
    gap: 1rem;
    max-width: 500px;
    margin: 0 auto;
    flex-wrap: wrap;
}

.newsletter-form input {
    flex: 1;
    padding: 1rem 1.5rem;
    border-radius: 50px;
    border: none;
    font-size: 1rem;
    outline: none;
    min-width: 250px;
    font-family: var(--font-body);
}

.newsletter-form button {
    background: var(--accent-color);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 50px;
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
    font-family: var(--font-body);
}

.newsletter-form button:hover {
    background: #d97706;
    transform: scale(1.05);
}

/* Footer */
footer {
    background: white;
    padding: 4rem 0 0;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

.footer-container {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 4rem;
    margin-bottom: 3rem;
}

.footer-brand h3 {
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.footer-links {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 2rem;
}

.link-group h4 {
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
}

.link-group a {
    display: block;
    margin-bottom: 0.8rem;
    color: var(--text-light);
    transition: var(--transition);
}

.link-group a:hover {
    color: var(--primary-color);
}

.copyright {
    text-align: center;
    padding: 1.5rem;
    background: #f9fafb;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    color: var(--text-light);
    font-size: 0.9rem;
}

/* --- Auth Pages Styles --- */

.auth-container {
    width: 100%;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    /* align-items: center; removed to prevent cut-off on small screens/tall content */
    padding: 2rem;
}

.auth-card {
    background: var(--card-bg);
    padding: 3rem;
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 450px;
    backdrop-filter: blur(10px);
    border: 1px solid white;
    margin: auto;
    /* Safely centers vertically */
}

/* Hero Slider Styles */
.image-wrapper.slider-container {
    width: 100%;
    height: 400px;
    /* Adjust as needed */
    position: relative;
    overflow: hidden;
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
}

.image-wrapper.slider-container::before {
    display: none;
    /* Remove the radial gradient blob from original design if it interferes, or keep it */
}

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

.slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 1s ease-in-out;
}

.slide.active {
    opacity: 1;
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-header .logo {
    display: inline-block;
    margin-bottom: 1rem;
    text-decoration: none;
}

.auth-header h2 {
    font-size: 1.8rem;
    color: var(--text-color);
    margin-bottom: 0.5rem;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

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

.input-wrapper {
    position: relative;
}

.input-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
    font-size: 1.1rem;
    pointer-events: none;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.8rem 1rem 0.8rem 2.8rem;
    border: 1px solid #e5e7eb;
    border-radius: var(--border-radius);
    font-family: var(--font-body);
    /* Input มีฟอนต์อยู่แล้ว แต่ใส่ไว้เพื่อความชัวร์ */
    font-size: 1rem;
    transition: var(--transition);
    background: white;
}

.form-group select {
    padding-left: 1rem;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236B7280'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1.2rem;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
}

.checkbox-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    user-select: none;
}

.checkbox-container input {
    display: none;
}

.checkmark {
    width: 18px;
    height: 18px;
    border: 2px solid #e5e7eb;
    border-radius: 4px;
    position: relative;
    transition: var(--transition);
}

.checkbox-container input:checked~.checkmark {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
    left: 5px;
    top: 1px;
    width: 4px;
    height: 9px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.checkbox-container input:checked~.checkmark:after {
    display: block;
}

.forgot-password {
    color: var(--primary-color);
    font-weight: 500;
}

.full-width {
    width: 100%;
    margin-top: 1rem;
    font-size: 1.1rem;
}

.auth-divider {
    text-align: center;
    margin: 2rem 0;
    position: relative;
}

.auth-divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: 1px;
    background: #e5e7eb;
    z-index: 0;
}

.auth-divider span {
    background: var(--card-bg);
    padding: 0 1rem;
    color: var(--text-light);
    position: relative;
    z-index: 1;
    font-size: 0.9rem;
}

.social-login {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.social-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.8rem;
    border: 1px solid #e5e7eb;
    border-radius: var(--border-radius);
    background: white;
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
    font-family: var(--font-body);
    /* เพิ่มฟอนต์ปุ่ม Social */
}

.social-btn img {
    width: 20px;
    height: 20px;
}

.social-btn:hover {
    background: #f9fafb;
    border-color: #d1d5db;
}

.auth-footer {
    text-align: center;
    margin-top: 2rem;
    font-size: 0.95rem;
}

.auth-footer a {
    color: var(--primary-color);
    font-weight: 600;
}

/* Register Page Specifics */
.register-container {
    max-width: 1200px;
    padding-top: 8rem;
    /* ปรับตรงนี้ให้ Navbar ไม่บังฟอร์ม */
    padding-bottom: 2rem;
    margin: 0 auto;
    /* Ensure it's centered if max-width kicks in */
}

.register-card {
    max-width: 700px;
}

.form-row {
    display: flex;
    gap: 1.5rem;
}

.form-row>* {
    flex: 1;
}

.col-prefix {
    flex: 0 0 100px;
}

/* Responsive */
@media (max-width: 968px) {
    h1 {
        font-size: 2.5rem;
    }

    .hero-container {
        grid-template-columns: 1fr;
        text-align: center;
        gap: 3rem;
    }

    .hero-content {
        order: 2;
    }

    .hero-image {
        order: 1;
    }

    .hero p {
        margin: 0 auto 2rem;
    }

    .stats {
        justify-content: center;
    }

    .footer-container {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .nav-links {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        background: white;
        flex-direction: column;
        padding: 2rem;
        box-shadow: var(--shadow-md);
        text-align: center;
    }

    .nav-links.active {
        display: flex;
    }

    .menu-toggle {
        display: flex;
    }

    .newsletter-form {
        flex-direction: column;
    }

    .newsletter-form input,
    .newsletter-form button {
        width: 100%;
    }

    .form-row {
        flex-direction: column;
        gap: 1.2rem;
    }

    .col-prefix {
        flex: auto;
    }
}