 :root {
  --footer-red: #333131;
}

/* ===== Main Footer ===== */
.main-footer {
  background-color: var(--footer-red);
  color: #393636;
  font-family: "Prompt", sans-serif;
  padding-top: 40px;
  width: 100%;
  box-sizing: border-box;
}

/* ===== Top Section ===== */
.footer-top {
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 0 40px 30px;
  box-sizing: border-box;
}

/* 2 Columns Layout (Grid) */
.footer-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
  align-items: start;
}

/* Footer Column Styling */
.footer-col h3 {
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 12px;
  margin-top: 0;
}

/* จัดการ Grid สำหรับหมวดหมู่หนังสือ */

.book-category-grid {
    display: grid;
    grid-template-columns: max-content max-content;
    column-gap: 40px;
    row-gap: 15px;
    margin-top: 15px;
    justify-content: start; /* เปลี่ยนจาก center เป็น start */
}


/* Tablet */
@media (max-width: 991px) {
    .book-category-grid {
        justify-content: center;
    }
}

/* Mobile */
@media (max-width: 768px) {
    .book-category-grid {
        grid-template-columns: 1fr;
        text-align: center;
    }
}



/* เพิ่มเติม: ปรับหัวข้อให้อยู่กึ่งกลางเสมอ */
.footer-contact h3 {
    text-align: left;
    margin-bottom: 5px;
    display: inline-block; /* ให้หัวข้อกว้างเท่าเนื้อหา */
    width: 100%;          /* หรือกำหนดความกว้างให้สัมพันธ์กับ grid */
}

@media (max-width: 991px) {
    .footer-contact h3 {
        text-align: center;
    }
}

.footer-col p {
  font-size: 15px;
  opacity: 0.9;
  line-height: 1.6;
  margin: 0 0 8px 0;
}

/* Specific Column Alignment */

.footer-contact {
    text-align: left; /* เปลี่ยนจาก right เป็น center */
}
.footer-contact .back-to-top {
  margin-left: auto;
}

/* Social Icons */
.footer-social a {
  font-size: 20px;
  display: inline-block;
  margin-top: 10px;
  text-decoration: none;
}

.back-to-top {
    position: fixed;
    bottom: 25px;
    right: 25px;
    z-index: 999;

    background: #ffffff;
    color: #333;

    border: 1px solid rgba(0,0,0,0.25);
    border-radius: 6px;

    padding: 8px 14px;
    font-size: 14px;
    font-family: "Prompt", sans-serif;

    display: flex;
    align-items: center;
    gap: 6px;

    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    transition: background 0.2s ease, box-shadow 0.2s ease;
}

.back-to-top i {
    font-size: 12px;
}

.back-to-top:hover {
    background: #f5f5f5;
    box-shadow: 0 3px 8px rgba(0,0,0,0.2);
}




/* ลบ CSS เก่าใน Media Query ที่สั่งให้ margin: auto ออกด้วย */
@media (max-width: 991px) {
    /* ลบส่วนนี้ออกเพื่อให้มันยังลอยอยู่ที่เดิมแม้ในมือถือ */
    /* .footer-contact .back-to-top { margin: 20px auto 0; } */
}

/* ===== Bottom Bar ===== */
.footer-bottom {
  background-color: rgba(0, 0, 0, 0.12);
  padding: 15px 0; 
  font-size: 13px;
  border-top: 1px solid rgba(255,255,255,0.15);
}

.footer-bottom-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 40px;
  flex-wrap: wrap; 
  gap: 15px;
}

.footer-bottom a {
  color: inherit;
  text-decoration: none;
  opacity: 0.85;
  transition: opacity 0.2s;
}

.footer-bottom a:hover {
  opacity: 1;
  text-decoration: underline;
}

/* ===== Responsive Design ===== */
/* Tablet & Mobile (ต่ำกว่า 991px) */
@media (max-width: 991px) {
  .footer-grid-2 {
    grid-template-columns: 1fr; 
    gap: 30px; 
    text-align: center;
  }

  .footer-contact {
    text-align: center; 
  }

  .footer-contact .back-to-top {
    margin: 20px auto 0; 
  }

  .footer-bottom-content {
    flex-direction: column;
    text-align: center;
    gap: 10px;
  }
  
  .bottom-center {
    order: -1; 
  }
}

/* Mobile Small (ต่ำกว่า 576px) */
@media (max-width: 576px) {
  .footer-top {
    padding: 0 20px 30px;
  }
  
  .footer-bottom-content {
    padding: 0 20px;
  }

  .footer-col h3 {
    font-size: 20px;
  }

  .footer-col p {
    font-size: 14px;
  }
  
  .bottom-center .divider {
    display: none;
  }
  .bottom-center a {
    display: block;
    margin: 5px 0;
  }
}