body {
    margin: 0;
    font-family: Arial, sans-serif;
}

/* ---------------- HEADER BLUE BAR ---------------- */
.top-bar {
    background: #1C4D8D;
    color: #C2E4F2;
    display: flex;
    align-items: center;
    padding: 20px 40px;
    gap: 20px;
    padding-bottom: 40px;  
}


.logo {
    height: 65px;
}

.title-box {
    flex-grow: 1;
}

.title { font-size: 20px; font-weight: bold; line-height: 1.3; }
.subtitle { font-size: 13px; color: #FF8246; }

/* ---------- Language Switch ---------- */
.right-tools {
    display: flex;
    align-items: center;
    gap: 5px;
}



.search-icon {
    font-size: 22px;
    cursor: pointer;
}

.search-box input {
    width: 170px;              
    padding: 8px 12px;
    border-radius: 6px;        
    border: 2px solid #FFFEEB; 
    background: #FFFEEB;       
    outline: none;
    font-size: 14px;
}

/* ---------- HAMBURGER (Mobile Only) ---------- */
.hamburger {
    font-size: 26px;
    cursor: pointer;
    display: none;
    color: white;
}

header{
    position: sticky;
    top: 0;
    z-index: 9999;
    
}
/* ---------------- MENU BAR ---------------- */
.menu {
    background: #C2E4F2;        
    display: flex;
    justify-content: center;
    align-items: flex-start;    
    gap: 40px;
    font-size: 16px;
    font-weight: 550;

    width: 85%;
    margin: 0 auto;
    padding: 20px 20px;
    border-radius: 25px;

    margin-top: -30px;
    position: relative;
    z-index: 10;
}

.menu a,
.menu .dropdown {
    text-decoration: none;
    color: #1C4D8D;             
    cursor: pointer;
}

.menu a:hover,
.menu .dropdown:hover {
    background-color: rgba(28, 77, 141, 0.1);
}


.menu .active {
    border-bottom: 3px solid #1C4D8D;  
    padding-bottom: 0px;
    line-height: 1;
    display: inline-block;
}
/* ---------------- SIDE MENU ---------------- */

.side-menu {
    position: fixed;
    top: 0;
    right: -100%;
    width: 80%;
    height: 100vh;
    background: linear-gradient(180deg, #1C4D8D, #081F3F);
    color: white;
    padding: 40px 25px;
    transition: 0.4s ease;
    z-index: 10000;

    display: flex;
    flex-direction: column;
}

.side-menu.show {
    right: 0;
}

.menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.menu-header input {
    width: 80%;
    padding: 10px 15px;
    border-radius: 25px;
    border: none;
    outline: none;
}

.close-btn {
    font-size: 22px;
    cursor: pointer;
}

.menu-links {
    margin-top: 40px;
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.menu-links a {
    text-decoration: none;
    color: white;
    font-size: 18px;
    border-bottom: 1px solid rgba(255,255,255,0.3);
    padding-bottom: 10px;
}

.menu-footer {
    margin-top: auto;
    color: #FF8246;
    font-size: 14px;
    margin-bottom: 90px; 
}

/* Active สำหรับ mobile menu */
.menu-links a {
    text-decoration: none;
    color: white;
    font-size: 18px;
    border-bottom: 1px solid rgba(255,255,255,0.3);
    padding-bottom: 10px;
    display: block;
}

/* เส้นใต้ตอนกด */
.menu-links a:focus,
.menu-links a:active {
    border-bottom: 3px solid #FF8246;
}
/* ---------------- RESPONSIVE ---------------- */

/* ---------------- RESPONSIVE ---------------- */

@media(max-width: 650px) {

    /* แสดง hamburger */
    .hamburger {
        display: block;
    }

    /* ซ่อน navbar */
    .menu {
        display: none;
    }

    /*  ซ่อน search box ตอนจอเล็ก */
    .search-box {
        display: none;
    }

    /* ปรับ padding */
    .top-bar {
        padding: 15px 20px;
    }

}
@media(min-width: 650px) {

    /* ซ่อน hamburger */
    .hamburger {
        display: none;
    }

/* -------- SEARCH BOX -------- */

.search-box {
    display: flex;
    align-items: center;
    background: #FFFEEB;
    border-radius: 25px;
    padding: 5px 12px;
    gap: 8px;
}

.search-box input {
    border: none;
    outline: none;
    background: transparent;
    font-size: 14px;
    width: 140px;
}

.search-box input::placeholder {
    color: #555;
}

/* ── DROPDOWN ── */
.dropdown-wrap {
    position: relative;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: white;
    border-radius: 10px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
    min-width: 160px;
    z-index: 999;
    overflow: hidden;
}

.dropdown-menu a {
    display: block;
    padding: 12px 20px;
    color: #1C4D8D;
    font-size: 14px;
    border-bottom: 1px solid #eee;
    text-decoration: none;
}

.dropdown-menu a:last-child {
    border-bottom: none;
}

.dropdown-menu a:hover {
    background: #f0f6ff;
}

.dropdown-wrap:hover .dropdown-menu {
    display: block;
}
.sub-menu {
    display: none;
    flex-direction: column;
    padding-left: 20px;
}

.sub-menu.open { display: flex; }

.sub-menu a {
    font-size: 15px !important;
    color: rgba(255,255,255,0.7) !important;
    border-bottom: 1px solid rgba(255,255,255,0.1) !important;
    padding: 10px 0 10px 10px !important;
}

/* --- CSS สำหรับ Side Menu เท่านั้น --- */

.side-menu .sub-menu {
    display: none;              /* 1. ซ่อนไว้ก่อนเป็นค่าเริ่มต้น */
    flex-direction: column;
    padding-left: 20px;
    background: rgba(0, 0, 0, 0.2);
    overflow: hidden;           /* ป้องกันเนื้อหาแลบ */
}

/* 2. เมื่อมีการเติม class 'open' ให้แสดงผล */
.side-menu .sub-menu.open {
    display: flex !important;   /* ใช้ !important เพื่อทับคำสั่งเก่า */
}


}



/* ================= GPA SECTION ================= */

.gpa-section {
    padding: 80px 20px;
    background: linear-gradient(180deg, #f4f6f9, #e9f1ff);
}

.gpa-container {
    max-width: 1200px;
    margin: auto;
}

.gpa-title {
    text-align: center;
    font-size: 32px;
    color: #1C4D8D;
    margin-bottom: 10px;
}

.gpa-subtitle {
    text-align: center;
    margin-bottom: 50px;
    color: #555;
}


.gpa-card {
    background: white;
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.08);
}

/* ตาราง */
#gradeTable {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 30px;
     table-layout: fixed; /* บังคับให้ตารางคำนวณขนาดตาม % ไม่ใช่ตามความยาวตัวอักษร */
    word-wrap: break-word; 
}

#gradeTable th {
    background: #1C4D8D;
    color: white;
    padding: 14px;
    
}

#gradeTable td {
    padding: 12px;
    text-align: center;
    border-bottom: 1px solid #eee;
     word-break: break-word; /* ถ้าเจอคำยาวๆ ให้ตัดขึ้นบรรทัดใหม่ทันที */
    font-size: 14px; /* ลดขนาดฟอนต์ลงหน่อยเมื่อดูในมือถือ */
}

#gradeTable select {
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid #ccc;
}

/* ปุ่ม */
.calculate-btn {
    display: block;
    margin: auto;
    padding: 18px 40px;
    font-size: 16px;
    background: linear-gradient(90deg, #75c9cc, #8182db);
    color: white;
    border: none;
    border-radius: 30px;
    cursor: pointer;
    transition: 0.3s ease;
}
.calculate-btn + .calculate-btn {
    margin-top: 12px;
}

.calculate-btn:hover {
    transform: scale(1.05);
}

/* ผลลัพธ์ */
.result-wrapper {
    margin-top: 50px;
    display: flex;
    justify-content: center;
    gap: 30px;
    flex-wrap: wrap;
}

.result-card {
    background: white;
    padding: 30px 40px;
    border-radius: 20px;
    box-shadow: 0 15px 30px rgba(0,0,0,0.07);
    text-align: center;
    min-width: 220px;
}

.result-card h3 {
    color: #1C4D8D;
    margin-bottom: 15px;
}

.result-value {
    font-size: 32px;
    font-weight: bold;
    color: #FF8246;
}

.result-card.highlight {
    background: #FF8246;
    color: white;
}

.result-card.highlight .result-value {
    color: #FFD3B6;
}

/* ================= SEARCH BOX ================= */

.subject-search-wrapper{
    width: 100%;
    max-width: 500px;
    margin: 0 auto 30px auto;
    position: relative;
}

.subject-search-box{
    display: flex;
    align-items: center;
    background: #f5f7fb;
    border-radius: 40px;
    padding: 12px 20px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    transition: 0.3s;
    border: 2px solid transparent;
}

.subject-search-box:hover{
    box-shadow: 0 12px 30px rgba(0,0,0,0.15);
}

.subject-search-box:focus-within{
    border: 2px solid #1C4D8D;
    background: white;
}

.search-icon-gpa{
    font-size: 18px;
    margin-right: 10px;
    color: #1C4D8D;
}

.subject-search-box input{
    border: none;
    outline: none;
    background: transparent;
    font-size: 15px;
    width: 100%;
}

/* ═══════════════════════════════════════════════════
   MOBILE RESPONSIVE FIXES — เพิ่มต่อท้าย main.css
   ═══════════════════════════════════════════════════ */

/* ── 1. TOP BAR ── */
@media (max-width: 650px) {
    .top-bar { padding: 12px 16px 35px; gap: 12px; }
    .logo { height: 42px; }
    .title { font-size: 13px; }
    .subtitle { font-size: 11px; }
}

/* ================= DROPDOWN ================= */

.search-dropdown{
    position: absolute;
    top: 60px;
    width: 100%;
    background: white;
    border-radius: 15px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.2);
    overflow: hidden;
    z-index: 99;
}

.search-item{
    padding: 12px 20px;
    cursor: pointer;
    transition: 0.2s;
    font-size: 14px;
    border-bottom: 1px solid #eee;
}

.search-item:hover{
    background: #1C4D8D;
    color: white;
}

/* ====== INPUT พิมพ์รหัสวิชา ====== */

/* ===== ช่องพิมพ์รหัสวิชา (Dual + Single เหมือนกัน) ===== */

#subjectInput,
#singleSubjectInput {
    width: 320px;
    padding: 14px 18px;
    font-size: 15px;
    border-radius: 30px;
    border: 2px solid #e0e0e0;
    outline: none;
    background: #ffffff;
    transition: all 0.3s ease;
    box-shadow: 0 8px 20px rgba(0,0,0,0.08);
}

/* hover */
#subjectInput:hover,
#singleSubjectInput:hover {
    box-shadow: 0 10px 25px rgba(0,0,0,0.12);
}

/* focus */
#subjectInput:focus,
#singleSubjectInput:focus {
    border: 2px solid #1C4D8D;
    box-shadow: 0 0 0 4px rgba(28,77,141,0.15);
}

/* ตอน hover */
#subjectInput:hover {
    box-shadow: 0 10px 25px rgba(0,0,0,0.12);
}

/* ตอนกดพิมพ์ */
#subjectInput:focus {
    border: 2px solid #1C4D8D;
    box-shadow: 0 0 0 4px rgba(28,77,141,0.15);
}

/* placeholder ให้ดูละมุน */
#subjectInput::placeholder {
    color: #999;
    font-weight: 400;
}

/* ===============================
   SINGLE DEGREE (Same Theme)
================================= */

.single-section .gpa-container {
    max-width: 1200px;
    margin: auto;
}

.single-section {
    padding: 80px 20px;
    background: linear-gradient(180deg, #f4f6f9, #e9f1ff);
    margin-top: 0;
}

/* Title */
.single-section .gpa-title {
    text-align: center;
    font-size: 24px;
    font-weight: bold;
    color: #1C4D8D;
    margin-bottom: 25px;
}

/* Card */
.single-section .gpa-card {
    background: white;          
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.08);
    max-width: 1200px;           /* จำกัดความกว้างเหมือน dual */
    margin: 0 auto;              /* จัดกึ่งกลาง */
    
}



/* ตาราง */
#singleGradeTable {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 30px;
        table-layout: fixed; /* บังคับให้ตารางคำนวณขนาดตาม % ไม่ใช่ตามความยาวตัวอักษร */
    word-wrap: break-word; 
}

#singleGradeTable th {
    background: #1C4D8D;
    color: white;
    padding: 14px;
}

#singleGradeTable td {
    padding: 12px;
    text-align: center;
    border-bottom: 1px solid #eee;
     word-break: break-word; /* ถ้าเจอคำยาวๆ ให้ตัดขึ้นบรรทัดใหม่ทันที */
    font-size: 14px; /* ลดขนาดฟอนต์ลงหน่อยเมื่อดูในมือถือ */
}

#singleGradeTable select {
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid #ccc;
}





/* Search Box */
.search-box-gpa {
    position: relative;
    max-width: 350px;
    margin: 0 auto;
}

.search-box-gpa input {
    width: 100%;
    padding: 12px 15px;
    border-radius: 20px;
    border: 2px solid #1C4D8D;
    outline: none;
    font-size: 14px;
}

/* Search dropdown */
.search-result {
    position: absolute;
    width: 100%;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
    margin-top: 5px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
}

.search-item {
    padding: 10px 15px;
    cursor: pointer;
    transition: 0.2s;
}

.search-item:hover {
    background: #C2E4F2;
}

/* RESULT CARD */

.result-wrapper {
    margin-top: 50px;
    display: flex;
    justify-content: center;
    gap: 30px;
    flex-wrap: wrap;
}

.result-card {
    background: white;
    padding: 30px 40px;
    border-radius: 20px;
    box-shadow: 0 15px 30px rgba(0,0,0,0.07);
    text-align: center;
    min-width: 220px;
}

.result-card h3 {
    color: #1C4D8D;
    margin-bottom: 15px;
}

.result-value {
    font-size: 32px;
    font-weight: bold;
    color: #FF8246;
}

.result-card.highlight {
    background: #bde6f7;
    color: rgb(43, 116, 199);
}

.result-card.highlight .result-value {
    color: #605fa0;
}


.single-section .result-card {
    background: #bde6f7;
    color: #935fa0;
    padding: 30px;
    border-radius: 25px;
    text-align: center;
    box-shadow: 0 15px 35px rgba(0,0,0,0.15);
    max-width: 220px;
    margin: 40px auto 0;
}

.single-section .result-card h3 {
    margin-bottom: 15px;
    font-size: 20px;
}

.single-section .result-card p {
    font-size: 16px;
    margin: 8px 0;
}

#singleGPA {
    font-size: 32px;
    font-weight: bold;
}

/* ================= DELETE BUTTON UNIVERSAL ================= */

.delete-btn {
    background: linear-gradient(135deg, #FF8246, #ff9b6b);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: auto;
}

.delete-btn:hover {
    transform: scale(1.15);
    box-shadow: 0 8px 18px rgba(255,130,70,0.4);
}

.delete-btn:active {
    transform: scale(0.9);
}

/* ===== Manual Row Design ===== */

/* ===== Manual Row (Dual + Single เหมือนกัน) ===== */

#gradeTable input,
#gradeTable select,
#singleGradeTable input,
#singleGradeTable select {
    width: 100%;
    padding: 8px 10px;
    border-radius: 12px;
    border: 2px solid #e3e8f0;
    font-size: 14px;
    outline: none;
    background: #f9fbff;
    transition: all 0.25s ease;
}

/* focus effect */
#gradeTable input:focus,
#gradeTable select:focus,
#singleGradeTable input:focus,
#singleGradeTable select:focus {
    border-color: #1C4D8D;
    box-shadow: 0 0 0 3px rgba(28,77,141,0.15);
    background: white;
}

/* ===== SAVE BUTTON UNIVERSAL (Dual + Single) ===== */

.save-btn {
    background: linear-gradient(135deg, #3bf676, #a9f6ad);
    border: none;
    color: white;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: auto;
}

.save-btn:hover {
    transform: scale(1.12);
    box-shadow: 0 8px 18px rgba(255,165,30,0.4);
}

.save-btn:active {
    transform: scale(0.9);
}

/*--------------------- RESPONSIVE TABLE (Mobile) ---------------- */

@media screen and (max-width: 600px) {
    /* ปิดการแสดงผลแบบตารางปกติ */
    #gradeTable, #gradeTable thead, #gradeTable tbody, #gradeTable th, #gradeTable td, #gradeTable tr {
        display: block;
    }

    /* ซ่อนหัวตารางสีน้ำเงินไปเลย */
    #gradeTable thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    #gradeTable tr {
        border: 1px solid #eee;
        margin-bottom: 15px;
        border-radius: 15px;
        padding: 10px;
        background: #fff;
    }

    #gradeTable td {
        border: none;
        position: relative;
        padding-left: 45%; /* เว้นที่ว่างด้านซ้ายไว้ใส่หัวข้อ */
        text-align: left;
        min-height: 40px;
    }

    /* เอาชื่อหัวข้อมาใส่ข้างหน้าแทน */
    #gradeTable td:before {
        position: absolute;
        left: 15px;
        width: 40%;
        white-space: nowrap;
        font-weight: bold;
        color: #1C4D8D;
    }

    /* ใส่ชื่อหัวข้อตามลำดับคอลัมน์ของคุณ */
    #gradeTable td:nth-of-type(1):before { content: "รหัสวิชา:"; }
    #gradeTable td:nth-of-type(2):before { content: "ชื่อวิชา:"; }
    #gradeTable td:nth-of-type(3):before { content: "หน่วยกิต:"; }
    #gradeTable td:nth-of-type(4):before { content: "ประเภท:"; }
    #gradeTable td:nth-of-type(5):before { content: "เกรด:"; }
    #gradeTable td:nth-of-type(6):before { content: "ลบ:"; }

    /* ปรับให้ช่องชื่อวิชาและ select เต็มความกว้างที่เหลือ */
    #gradeTable select {
        width: 100%;
        max-width: 120px;
    }
}

@media screen and (max-width: 600px) {
    /* ปิดการแสดงผลแบบตารางปกติ */
    #gradeTable, #gradeTable thead, #gradeTable tbody, #gradeTable th, #gradeTable td, #gradeTable tr {
        display: block;
    }

    /* ซ่อนหัวตารางสีน้ำเงินไปเลย */
    #gradeTable thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    #gradeTable tr {
        border: 1px solid #eee;
        margin-bottom: 15px;
        border-radius: 15px;
        padding: 10px;
        background: #fff;
    }

    #gradeTable td {
        border: none;
        position: relative;
        padding-left: 45%; /* เว้นที่ว่างด้านซ้ายไว้ใส่หัวข้อ */
        text-align: left;
        min-height: 40px;
    }

    /* เอาชื่อหัวข้อมาใส่ข้างหน้าแทน */
    #gradeTable td:before {
        position: absolute;
        left: 15px;
        width: 40%;
        white-space: nowrap;
        font-weight: bold;
        color: #1C4D8D;
    }

    /* ใส่ชื่อหัวข้อตามลำดับคอลัมน์ของคุณ */
    #gradeTable td:nth-of-type(1):before { content: "รหัสวิชา:"; }
    #gradeTable td:nth-of-type(2):before { content: "ชื่อวิชา:"; }
    #gradeTable td:nth-of-type(3):before { content: "หน่วยกิต:"; }
    #gradeTable td:nth-of-type(4):before { content: "ประเภท:"; }
    #gradeTable td:nth-of-type(5):before { content: "เกรด:"; }
    #gradeTable td:nth-of-type(6):before { content: "ลบ:"; }

    /* ปรับให้ช่องชื่อวิชาและ select เต็มความกว้างที่เหลือ */
    #gradeTable select {
        width: 100%;
        max-width: 120px;
    }
}


/* ===============================
   SINGLE SECTION RESPONSIVE (Card View)
================================= */
@media screen and (max-width: 600px) {
    /* 1. ปรับกล่องขาว (gpa-card) ให้พอดีมือถือ */
    .single-section .gpa-card {
        padding: 15px;
        width: 95%;
        margin: 10px auto;
    }

    /* 2. เปลี่ยนการแสดงผลตารางเป็น Block */
    #singleGradeTable, 
    #singleGradeTable thead, 
    #singleGradeTable tbody, 
    #singleGradeTable th, 
    #singleGradeTable td, 
    #singleGradeTable tr {
        display: block;
    }

    /* 3. ซ่อนหัวตารางสีน้ำเงินเดิมในมือถือ */
    #singleGradeTable thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    /* 4. แต่งแต่ละแถว (TR) ให้ดูเหมือนการ์ดแยกชิ้น */
    #singleGradeTable tr {
        border: 1px solid #e1e8f0;
        margin-bottom: 20px;
        border-radius: 15px;
        padding: 10px;
        background: #fff;
        box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    }

    /* 5. จัดช่องข้อมูล (TD) ให้มี Label ด้านซ้าย */
    #singleGradeTable td {
        border: none;
        border-bottom: 1px solid #f0f0f0;
        position: relative;
        padding: 12px 10px 12px 45%; /* เว้นที่ว่างด้านซ้าย 45% */
        text-align: left;
        min-height: 45px;
        display: flex;
        align-items: center;
    }

    #singleGradeTable td:last-child {
        border-bottom: none;
    }

    /* 6. ใส่ชื่อหัวข้อด้วย :before (ดึงค่ามาใส่ข้างหน้า) */
    #singleGradeTable td:before {
        position: absolute;
        left: 15px;
        width: 40%;
        white-space: nowrap;
        font-weight: bold;
        color: #1C4D8D;
    }

    /* กำหนดข้อความหัวข้อตามลำดับคอลัมน์ */
    #singleGradeTable td:nth-of-type(1):before { content: "รหัสวิชา:"; }
    #singleGradeTable td:nth-of-type(2):before { content: "ชื่อวิชา:"; }
    #singleGradeTable td:nth-of-type(3):before { content: "หน่วยกิต:"; }
    #singleGradeTable td:nth-of-type(4):before { content: "ประเภท:"; }
    #singleGradeTable td:nth-of-type(5):before { content: "เกรด:"; }
    #singleGradeTable td:nth-of-type(6):before { content: "ลบ:"; }

    /* 7. ปรับช่อง Select ให้กดง่ายขึ้น */
    #singleGradeTable select {
        width: 100%;
        max-width: 150px;
        padding: 8px;
        font-size: 14px;
    }

    /* จัดปุ่มลบให้อยู่ตรงกลางหรือขวาในบรรทัดตัวเอง */
    #singleGradeTable td:nth-of-type(6) {
        justify-content: flex-start;
    }
}
