/* Dark Mode Styles */
[data-theme="dark"] {
    --bg-color: #1a1a1a;
    --text-color: #ffffff;
    --card-bg: #2d2d2d;
    --section-bg: #262626;
}

[data-theme="light"] {
    --bg-color: #ffffff;
    --text-color: #333333;
    --card-bg: #ffffff;
    --section-bg: #f8f9fa;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: background-color 0.3s ease, color 0.3s ease;
}

.theme-toggle {
    cursor: pointer;
    font-size: 1.2rem;
    color: #333;
    transition: color 0.3s ease;
}

.theme-toggle:hover {
    color: #3498db;
}

/* Update other elements to use CSS variables */
.skill-item,
.project-card,
.contact-form {
    background: var(--card-bg);
}

.about,
.projects {
    background: var(--section-bg);
}

/* Loading Animation */
.loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.5s ease;
}

.loader-content {
    text-align: center;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.loader.fade-out {
    opacity: 0;
    pointer-events: none;
}

/* Scroll Progress Indicator */
.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    z-index: 1001;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #3498db, #f39c12);
    width: 0%;
    transition: width 0.1s ease;
}

/* Project Filter */
.filter-buttons {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 3rem;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 10px 20px;
    border: none;
    background: transparent;
    color: #666;
    cursor: pointer;
    border-radius: 25px;
    transition: all 0.3s ease;
    font-weight: 500;
}

.filter-btn.active,
.filter-btn:hover {
    background: #3498db;
    color: white;
}

.project-card.hide {
    display: none;
}

/* Typing Animation */
.cursor {
    animation: blink 1s infinite;
}

@keyframes blink {

    0%,
    50% {
        opacity: 1;
    }

    51%,
    100% {
        opacity: 0;
    }
}

/* Back to Top Button */
.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1000;
}

.back-to-top.show {
    opacity: 1;
    visibility: visible;
}

.back-to-top:hover {
    background: #2980b9;
    transform: translateY(-2px);
}

/* Global Styles & Variables */
:root {
    --primary-color: #3498db;
    --secondary-color: #f39c12;
    --text-color-light: #333333;
    --text-color-dark: #ffffff;
    --bg-color-light: #ffffff;
    --bg-color-dark: #1a1a1a;
    --card-bg-light: #ffffff;
    --card-bg-dark: #2d2d2d;
    --section-bg-light: #f8f9fa;
    --section-bg-dark: #262626;
    --border-color-light: #e0e0e0;
    --border-color-dark: #444444;
    --shadow-light: rgba(0, 0, 0, 0.1);
    --shadow-dark: rgba(0, 0, 0, 0.3);
}

/* Dark Mode Variables */
[data-theme="dark"] {
    --bg-color: var(--bg-color-dark);
    --text-color: var(--text-color-dark);
    --card-bg: var(--card-bg-dark);
    --section-bg: var(--section-bg-dark);
    --border-color: var(--border-color-dark);
    --shadow: var(--shadow-dark);
}

/* Light Mode Variables (Default) */
[data-theme="light"] {
    --bg-color: var(--bg-color-light);
    --text-color: var(--text-color-light);
    --card-bg: var(--card-bg-light);
    --section-bg: var(--section-bg-light);
    --border-color: var(--border-color-light);
    --shadow: var(--shadow-light);
}

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

body {
    font-family: 'Roboto', sans-serif;
    /* ใช้ Roboto เป็นฟอนต์หลัก */
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
    -webkit-font-smoothing: antialiased;
    /* ทำให้ฟอนต์ดูคมชัดขึ้น */
    overflow-x: hidden;
    /* ป้องกัน scrollbar แนวนอน */
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.3s ease;
}

a:hover {
    color: var(--secondary-color);
}

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

h1,
h2,
h3 {
    font-family: 'Poppins', sans-serif;
    /* ใช้ Poppins สำหรับหัวข้อ */
    color: var(--text-color);
    margin-bottom: 1rem;
    font-weight: 600;
}

h1 {
    font-size: 3.5rem;
    line-height: 1.2;
}

h2 {
    font-size: 2.5rem;
}

h3 {
    font-size: 1.8rem;
}

p {
    margin-bottom: 1rem;
}

/* Theme Toggle */
.theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    cursor: pointer;
    font-size: 1.8rem;
    color: var(--text-color);
    background: var(--card-bg);
    border-radius: 50%;
    width: 45px;
    height: 45px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 10px var(--shadow);
    transition: all 0.3s ease;
    z-index: 1002;
}

.theme-toggle:hover {
    color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 6px 15px var(--shadow);
}

/* Loader Animation */
.loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-color);
    /* ใช้สีตามธีม */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.5s ease;
}

.loader-content {
    text-align: center;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 6px solid var(--border-color);
    /* ใช้สีตามธีม */
    border-top: 6px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1.5rem;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.loader.fade-out {
    opacity: 0;
    pointer-events: none;
}

/* Scroll Progress Indicator */
.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 5px;
    /* เพิ่มความหนา */
    background: rgba(128, 128, 128, 0.2);
    /* สีพื้นหลังโปร่งแสง */
    z-index: 1001;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    /* ใช้สีจากตัวแปร */
    width: 0%;
    transition: width 0.1s ease;
}

/* Hero Section */
.hero-section {
    min-height: 80vh;
    /* กำหนดความสูงขั้นต่ำ */
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 80px 20px;
    /* เพิ่ม padding */
    background-color: var(--section-bg);
}

.hero-content {
    max-width: 900px;
    width: 100%;
}

.hero-content h1 {
    font-size: 4rem;
    /* เพิ่มขนาด font */
    margin-bottom: 1rem;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: inline-block;
    /* ทำให้ gradient ใช้ได้กับ span */
}

.hero-content .highlight {
    /* สไตล์สำหรับส่วนที่ถูก highlight อยู่แล้วใน h1 */
}

.hero-subtitle {
    font-size: 1.8rem;
    font-weight: 300;
    color: var(--text-color);
    margin-top: 1rem;
    min-height: 2.2rem;
    /* ป้องกันการกระโดดเมื่อพิมพ์ข้อความ */
}

/* Typing Animation */
.cursor {
    animation: blink 0.8s infinite step-end;
    /* ปรับความเร็ว */
    display: inline-block;
    /* ทำให้ cursor อยู่ในบรรทัดเดียวกัน */
    vertical-align: middle;
    /* จัดตำแหน่งกึ่งกลางแนวตั้ง */
    width: 2px;
    height: 1.5em;
    /* ขนาดให้เข้ากับ font */
    background-color: var(--primary-color);
    margin-left: 5px;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

/* Projects Section */
.projects {
    padding: 80px 0;
    background-color: var(--section-bg);
}

.section-title {
    text-align: center;
    margin-bottom: 4rem;
    font-size: 3rem;
    position: relative;
    padding-bottom: 15px;
    
}

.section-title::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: 0;
    transform: translateX(-50%);
    width: 80px;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    border-radius: 2px;
}

/* Filter Buttons */
.filter-buttons {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    /* เพิ่มระยะห่างระหว่างปุ่ม */
    margin-bottom: 3.5rem;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 12px 28px;
    /* เพิ่ม padding */
    border: 2px solid var(--primary-color);
    /* เพิ่ม border */
    background: var(--card-bg);
    /* ใช้สีพื้นหลังตามธีม */
    color: var(--text-color);
    cursor: pointer;
    border-radius: 50px;
    /* ทำให้โค้งมนมากขึ้น */
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    /* ปรับ animation */
    font-weight: 600;
    font-size: 1.1rem;
    position: relative;
    overflow: hidden;
    /* สำหรับ ripple effect */
}

.filter-btn:focus {
    outline: none;
}

.filter-btn.active,
.filter-btn:hover {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    transform: translateY(-3px);
}

.filter-btn.active {
    border-color: var(--primary-color);
}

/* Ripple effect for buttons */
.filter-btn .ripple {
    position: absolute;
    border-radius: 50%;
    transform: scale(0);
    animation: ripple 0.6s linear;
    background-color: rgba(255, 255, 255, 0.7);
    /* สีของ ripple */
}

@keyframes ripple {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

/* Project Grid */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    /* Responsive grid */
    gap: 2.5rem;
    /* เพิ่มระยะห่างระหว่าง card */
}

.project-card {
    background: var(--card-bg);
    border-radius: 12px;
    /* เพิ่มความโค้งมน */
    box-shadow: 0 8px 25px var(--shadow);
    /* เงาที่ดูนุ่มนวลขึ้น */
    overflow: hidden;
    transition: transform 0.4s ease, box-shadow 0.4s ease;
    padding: 2rem;
    /* เพิ่ม padding ภายใน card */
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    /* จัดเนื้อหาใน card ให้กระจาย */
    min-height: 250px;
    /* กำหนดความสูงขั้นต่ำ */
}

.project-card:hover {
    transform: translateY(-10px);
    /* ยกขึ้นเมื่อ hover */
    box-shadow: 0 15px 40px var(--shadow);
    /* เงาเข้มขึ้นเมื่อ hover */
}

.project-card h3 {
    font-size: 1.5rem;
    margin-bottom: 0.8rem;
    color: var(--primary-color);
    /* เปลี่ยนสีหัวข้อ */
}

.project-card p {
    font-size: 1rem;
    color: var(--text-color);
    margin-bottom: 1.2rem;
}

.project-link {
    display: inline-block;
    padding: 10px 20px;
    background: var(--primary-color);
    color: white;
    border-radius: 8px;
    text-align: center;
    font-weight: 500;
    transition: background 0.3s ease, transform 0.2s ease;
    margin-top: auto;
    /* ดัน link ลงล่างสุด */
}

.project-link:hover {
    background: var(--secondary-color);
    transform: translateY(-2px);
}

.project-card.hide {
    display: none;
    opacity: 0;
    transform: scale(0.9);
}

/* Back to Top Button */
.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    /* ขนาดใหญ่ขึ้น */
    height: 60px;
    /* ขนาดใหญ่ขึ้น */
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.5rem;
    /* ขนาด icon ใหญ่ขึ้น */
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    /* ซ่อนอยู่ข้างล่างตอนแรก */
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    z-index: 999;
}

.back-to-top.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    /* เลื่อนขึ้นมา */
}

.back-to-top:hover {
    background: var(--secondary-color);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
    transform: translateY(-5px);
}

/* Responsive Design */
@media (max-width: 768px) {
    h1 {
        font-size: 2.8rem;
    }

    h2 {
        font-size: 2rem;
    }

    .hero-subtitle {
        font-size: 1.4rem;
    }

    .theme-toggle {
        font-size: 1.5rem;
        width: 40px;
        height: 40px;
    }

    .filter-buttons {
        gap: 1rem;
    }

    .filter-btn {
        padding: 10px 20px;
        font-size: 1rem;
    }

    .projects-grid {
        grid-template-columns: 1fr;
        /* 1 column on smaller screens */
    }

    .project-card {
        padding: 1.5rem;
    }

    .back-to-top {
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
        bottom: 20px;
        right: 20px;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 2.2rem;
    }

    .hero-subtitle {
        font-size: 1.2rem;
    }

    .section-title {
        font-size: 2.2rem;
    }
}

/* Our Team / About Section */
.about-section {
    padding: 80px 0;
    background-color: var(--section-bg);
    text-align: center;
}

.team-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    /* ปรับขนาดคอลัมน์ให้ยืดหยุ่น */
    gap: 3rem;
    /* ระยะห่างระหว่าง card */
    margin-top: 4rem;
    justify-content: center;
    /* จัดกึ่งกลาง grid items */
}

.person-card {
    background: var(--card-bg);
    border-radius: 15px;
    /* โค้งมนมากขึ้น */
    box-shadow: 0 10px 30px var(--shadow);
    /* เงาที่ดูนุ่มนวลและเด่นชัด */
    padding: 2.5rem 1.5rem;
    /* เพิ่ม padding ภายใน card */
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: transform 0.4s ease, box-shadow 0.4s ease;
    text-align: center;
}

.person-card:hover {
    transform: translateY(-12px);
    /* ยกขึ้นเมื่อ hover */
    box-shadow: 0 20px 40px var(--shadow);
    /* เงาเข้มขึ้นเมื่อ hover */
}

.person-image {
    width: 150px;
    /* ขนาดรูปภาพ */
    height: 150px;
    /* ขนาดรูปภาพ */
    border-radius: 50%;
    /* ทำให้เป็นวงกลม */
    object-fit: cover;
    /* ครอบตัดรูปภาพให้พอดี */
    border: 5px solid var(--primary-color);
    /* เพิ่ม border รอบรูป */
    margin-bottom: 1.5rem;
    transition: border-color 0.3s ease, transform 0.3s ease;
}

.person-card:hover .person-image {
    border-color: var(--secondary-color);
    /* เปลี่ยนสี border เมื่อ hover */
    transform: scale(1.05);
    /* ขยายรูปเล็กน้อย */
}

.person-name {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-color);
    margin-bottom: 0.5rem;
}

.person-role {
    font-size: 1.1rem;
    color: #888;
    /* สีเทาอ่อนสำหรับตำแหน่ง */
    margin-bottom: 0;
}

/* Responsive adjustments for team section */
@media (max-width: 768px) {
    .team-grid {
        grid-template-columns: 1fr;
        /* 1 คอลัมน์บนหน้าจอขนาดเล็ก */
        gap: 2rem;
    }

    .person-image {
        width: 120px;
        height: 120px;
    }

    .person-name {
        font-size: 1.6rem;
    }

    .person-role {
        font-size: 1rem;
    }
}

.about-section {
    max-width: 100%;
    width: 100%;
}

.about-section h2 {
    font-size: 4rem;
    /* เพิ่มขนาด font */
    margin-bottom: 1rem;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: inline-block;
    /* ทำให้ gradient ใช้ได้กับ span */
}

.about-section .highlight {
    /* สไตล์สำหรับส่วนที่ถูก highlight อยู่แล้วใน h1 */
}
