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

/* ===========================
   Body & Theme
=========================== */
body {
    font-family: 'Poppins', sans-serif;
    line-height: 1.6;
    color: var(--dark);
    overflow-x: hidden;
    background-color: var(--light);
    transition: background 0.3s, color 0.3s;
}

.dark-mode {
    background-color: #181818;
    color: #f1f1f1;
}

/* ===========================
   Container
=========================== */
.container {
    max-width: 1200px;
    margin: 40px auto;
    padding: 0 20px;
}

/* ===========================
   Navigation Bar
=========================== */
.navbar {
    position: fixed;
    top: 0;
    width: 100%;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    z-index: 1000;
    padding: 1rem 0;
    transition: all 0.3s ease;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-logo a {
    font-size: 1.5rem;
    font-weight: 700;
    color: #2c3e50;
    text-decoration: none;
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 2rem;
}

.nav-link {
    color: #333;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s ease;
}

.nav-link:hover {
    color: #3498db;
}

.nav-toggle {
    display: none;
    flex-direction: column;
    cursor: pointer;
}

.bar {
    width: 25px;
    height: 3px;
    background: #333;
    margin: 3px 0;
    transition: 0.3s;
}

/* ===========================
   Hero Section
=========================== */
.hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    padding: 100px 20px 50px;
    background: linear-gradient(135deg, #7226FF 0%, #160078 50%, #010030 100%);
    color: white;
}

.hero-content {
    flex: 1;
    max-width: 600px;
}

.hero h1 {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.highlight {
    color: #f39c12;
}

.hero-subtitle {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    opacity: 0.9;
}

.hero-description {
    font-size: 1.1rem;
    margin-bottom: 2rem;
    opacity: 0.8;
}

.hero-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.btn {
    padding: 12px 30px;
    text-decoration: none;
    border-radius: 5px;
    font-weight: 500;
    transition: all 0.3s ease;
    display: inline-block;
    text-align: center;
}

.btn-primary {
    background: #3498db;
    color: white;
}

.btn-primary:hover {
    background: #2980b9;
    transform: translateY(-2px);
}

.btn-secondary {
    background: transparent;
    color: white;
    border: 2px solid white;
}

.btn-secondary:hover {
    background: white;
    color: #333;
}

.hero-image {
    flex: 1;
    text-align: center;
}

.hero-image img {
    width: 300px;
    height: 300px;
    border-radius: 50%;
    object-fit: cover;
    border: 5px solid rgba(255, 255, 255, 0.2);
}

/* ===========================
   Section Title
=========================== */
.section-title {
    font-size: 2.5rem;
    text-align: center;
    margin-bottom: 3rem;
    color: #2c3e50;
}

/* ===========================
   About Section
=========================== */
.about {
    padding: 100px 0;
    background: #f8f9fa;
}

.about-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
    align-items: center;
}

.about-text p {
    font-size: 1.1rem;
    margin-bottom: 2rem;
    color: #666;
}

.about-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.stat-item {
    text-align: center;
}

.stat-item h3 {
    font-size: 2rem;
    color: #3498db;
    margin-bottom: 0.5rem;
}

.about-image img {
    width: 280px;
    /* ขนาดปกติสำหรับ PC */
    max-width: 100%;
    /* ไม่เกิน container */
    border-radius: 10px;
    display: block;
    margin: 0 auto;
}

/* ===========================
   Skills Section
=========================== */
.skills {
    padding: 100px 0;
}

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

.skill-item {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
}

.skill-item:hover {
    transform: translateY(-5px);
}

.skill-item i {
    font-size: 3rem;
    color: #3498db;
    margin-bottom: 1rem;
}

.skill-item h3 {
    margin-bottom: 1rem;
    color: #2c3e50;
}

/* ===========================
   Projects Section
=========================== */
.projects {
    padding: 100px 0;
    background: #f8f9fa;
}

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

.project-card {
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
}

.project-card:hover {
    transform: translateY(-5px);
}

.project-card img {
    width: 100%;
    height: 200px;
    object-fit: cover;
}

.project-info {
    padding: 1.5rem;
}

.project-info h3 {
    margin-bottom: 1rem;
    color: #2c3e50;
}

.project-info p {
    color: #666;
    margin-bottom: 1.5rem;
}

.project-links {
    display: flex;
    gap: 1rem;
}

.btn-small {
    padding: 8px 20px;
    font-size: 0.9rem;
}

/* ===========================
   Contact Section
=========================== */
.contact {
    padding: 100px 0;
}

.contact-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
}

.contact-info h3 {
    font-size: 1.8rem;
    margin-bottom: 1rem;
    color: #2c3e50;
}

.contact-info p {
    color: #666;
    margin-bottom: 2rem;
}

.contact-details {
    margin-bottom: 2rem;
}

.contact-item {
    display: flex;
    align-items: center;
    margin-bottom: 1rem;
}

.contact-item i {
    font-size: 1.2rem;
    color: #3498db;
    margin-right: 1rem;
    width: 20px;
}

.social-links {
    display: flex;
    gap: 1rem;
}

.social-links a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: #3498db;
    color: white;
    border-radius: 50%;
    text-decoration: none;
    transition: background 0.3s ease;
}

.social-links a:hover {
    background: #2980b9;
}

/* ===========================
   Contact Form
=========================== */
.contact-form {
    background: #f8f9fa;
    padding: 2rem;
    border-radius: 10px;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #3498db;
}

/* ===========================
   Footer
=========================== */
.footer {
    background: #2c3e50;
    color: white;
    text-align: center;
    padding: 2rem 0;
}

/* ===========================
   Responsive Design
=========================== */
@media (max-width: 768px) {
    .nav-menu {
        position: fixed;
        left: -100%;
        top: 70px;
        flex-direction: column;
        background-color: white;
        width: 100%;
        text-align: center;
        transition: 0.3s;
        box-shadow: 0 10px 27px rgba(0, 0, 0, 0.05);
        padding: 2rem 0;
    }

    .nav-menu.active {
        left: 0;
    }

    .nav-toggle {
        display: flex;
    }

    .nav-toggle.active .bar:nth-child(2) {
        opacity: 0;
    }

    .nav-toggle.active .bar:nth-child(1) {
        transform: translateY(8px) rotate(45deg);
    }

    .nav-toggle.active .bar:nth-child(3) {
        transform: translateY(-8px) rotate(-45deg);
    }

    .hero {
        flex-direction: column-reverse;
        text-align: center;
        padding: 120px 20px 50px;
    }

    .hero h1 {
        font-size: 2rem;
    }

    .hero-image {
        margin-bottom: 2rem;
    }

    .hero-image img {
        width: 200px;
        height: 200px;
    }

    .about-content {
        grid-template-columns: 1fr;
    }

    .about-stats {
        grid-template-columns: repeat(3, 1fr);
        gap: 1rem;
    }

    .skills-grid {
        grid-template-columns: 1fr;
    }

    .projects-grid {
        grid-template-columns: 1fr;
    }

    .contact-content {
        grid-template-columns: 1fr;
    }

    .hero-buttons {
        justify-content: center;
    }
}

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

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

    .about-stats {
        grid-template-columns: 1fr;
    }

    .project-links {
        flex-direction: column;
    }
}

/* ===========================
   Theme Toggle Button
=========================== */
.theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.3rem;
    color: var(--dark);
    margin-left: 1rem;
}

.theme-toggle i {
    transition: color 0.3s ease;
}

/* ===========================
   Loading Screen
=========================== */
#loading-screen {
    position: fixed;
    width: 100%;
    height: 100%;
    background: var(--navy);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 5px solid var(--light);
    border-top: 5px solid var(--blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ===========================
   Back to Top Button
=========================== */
#back-to-top {
    position: fixed;
    bottom: 40px;
    right: 30px;
    background: var(--blue);
    color: white;
    border: none;
    padding: 10px;
    border-radius: 50%;
    display: none;
    cursor: pointer;
    z-index: 1000;
}

/* ===========================
   Project Filters
=========================== */
.project-filters {
    text-align: center;
    margin-bottom: 2rem;
}

.filter-btn {
    padding: 10px 20px;
    margin: 5px;
    background: var(--sky);
    border: none;
    color: var(--dark);
    cursor: pointer;
    border-radius: 20px;
}

.filter-btn.active {
    background: var(--blue);
    color: white;
}

/* ===========================
   Dark Mode Features
=========================== */
.dark-mode .navbar {
    background-color: #23243a;
    color: #f1f1f1;
}

.dark-mode .nav-logo a,
.dark-mode .nav-link {
    color: #181818 !important;
}

.dark-mode .nav-link:hover {
    color: #7DA0CA !important;
}

.dark-mode .bar {
    background: #f1f1f1;
}

.dark-mode .hero {
    background: #181818;
    color: #f1f1f1;
}

.dark-mode .highlight {
    color: #7DA0CA;
}

.dark-mode .about {
    background: #23243a;
    color: #f1f1f1;
}

.dark-mode .about-text p {
    color: #ccc;
}

.dark-mode .stat-item h3 {
    color: #7DA0CA;
}

.dark-mode .skills {
    background: #1a1b2e;
    color: #f1f1f1;
}

.dark-mode .skill-item {
    background: #222;
    color: #f1f1f1;
}

.dark-mode .skill-item i {
    color: #7DA0CA;
}

.dark-mode .projects {
    background: #23243a;
    color: #f1f1f1;
}

.dark-mode .project-card {
    background: #222;
    color: #f1f1f1;
}

.dark-mode .project-info h3 {
    color: #f1f1f1;
}

.dark-mode .project-info p {
    color: #ccc;
}

.dark-mode .contact {
    background: #181818;
    color: #f1f1f1;
}

.dark-mode .contact-info h3 {
    color: #f1f1f1;
}

.dark-mode .contact-info p {
    color: #ccc;
}

.dark-mode .contact-item i {
    color: #7DA0CA;
}

.dark-mode .social-links a {
    background: #7DA0CA;
    color: #181818;
}

.dark-mode .social-links a:hover {
    background: #f1f1f1;
    color: #181818;
}

.dark-mode .contact-form {
    background: #222;
    color: #f1f1f1;
}

.dark-mode .form-group input,
.dark-mode .form-group textarea {
    background: #222;
    color: #f1f1f1;
    border-color: #7DA0CA;
}

.dark-mode .form-group input:focus,
.dark-mode .form-group textarea:focus {
    border-color: #7DA0CA;
}

.dark-mode .footer {
    background: #23243a;
    color: #f1f1f1;
}

.dark-mode .nav-toggle {
    background: transparent;
}

.dark-mode .bar {
    background: #0e0e0e;
}

/* เพิ่ม border หรือ box-shadow เพื่อแยกแต่ละบล็อก */
.dark-mode section,
.dark-mode .project-card,
.dark-mode .skill-item,
.dark-mode .contact-form {
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    border: 1px solid #2c2c3e;
}

/* ===========================
   Dark Mode Toggle Button
=========================== */
.checkbox {
    opacity: 0;
    position: absolute;
}

.checkbox-label {
    background-color: #111;
    width: 50px;
    height: 26px;
    border-radius: 50px;
    position: relative;
    padding: 5px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.fa-moon {
    color: #f1c40f;
}

.fa-sun {
    color: #f39c12;
}

.checkbox-label .ball {
    background-color: #fff;
    width: 22px;
    height: 22px;
    position: absolute;
    left: 2px;
    top: 2px;
    border-radius: 50%;
    transition: transform 0.2s linear;
}

.checkbox:checked+.checkbox-label .ball {
    transform: translateX(24px);
}

@media (max-width: 768px) {
    .checkbox-label {
        position: relative;
        margin: 0 auto;
        display: flex;
        justify-content: center;
        align-items: center;
        width: 50px;
    }
}