/* --- Global Color Palette (Professional Update) --- */
/* Primary Dark: #1e293b (Slate 900) */
/* Primary Light: #f8fafc (Slate 50) */
/* Accent: #3b82f6 (Bright Blue) */
/* Text Color: #334155 (Slate 700) */
/* Border Color: #e2e8f0 (Light Grey) */

/* --- Day Theme (Default) --- */
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: #f1f5f9; 
  min-height: 100vh;
  color: #334155; 
  line-height: 1.6;
  transition: background-color 0.3s, color 0.3s;
}

header {
  background: #1e293b; 
  color: white;
  text-align: center;
  padding: 8px 20px; 
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  border-bottom: none; 
  position: relative;
  transition: background-color 0.3s, border-color 0.3s;
  display: flex; 
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

h1 {
  font-size: 1.5em;
  margin: 0; 
  font-weight: 600;
  letter-spacing: 0.5px;
  color: #f8fafc;
}

.subtitle {
  font-size: 0.9em;
  font-weight: 300;
  color: #cbd5e1; 
  opacity: 1;
  margin-top: 2px;
  transition: color 0.3s;
}

.card {
  /* *** แก้ไขจุดที่ 1: ปรับความกว้างให้ "พอดี" (Compact Standard) *** */
  max-width: 1150px; /* ลดจาก 1400px เหลือ 1150px (ระยะสายตากำลังสวย) */
  width: 90%;        /* ลดจาก 95% เหลือ 90% ให้มีขอบเหลือด้านข้างมากขึ้น */
  /* ************************************************************* */
  margin: 25px auto; 
  background: #ffffff; 
  border-radius: 8px; 
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  padding: 25px;
  text-align: left;
  color: #334155; 
  transition: background-color 0.3s, color 0.3s;
  border: 1px solid #e2e8f0;
}

h2 {
  color: #1e293b; 
  font-size: 1.4em;
  margin-top: 0;
  margin-bottom: 15px;
  font-weight: 700;
  border-bottom: 2px solid #e2e8f0; 
  padding-bottom: 10px;
  transition: color 0.3s, border-color 0.3s;
}

ul {
  list-style: none;
  padding: 0;
  margin: 0 0 30px 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 10px; 
}

li {
  margin-bottom: 0;
  font-size: 0.95em; 
}

/* ส่วนนี้เป็นตัวกำหนดสไตล์ลิงก์ (File List Item) */
.card ul li a {
  display: block;
  color: #334155; 
  background: #f8fafc; 
  text-decoration: none;
  padding: 10px 15px; 
  border-radius: 6px;
  transition: all 0.2s ease;
  font-weight: 500;
  border: 1px solid #e2e8f0;
  height: 100%;
  box-sizing: border-box;
}

.card ul li a:hover {
  color: #2563eb; 
  background: #ffffff;
  border-color: #2563eb;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.15);
}

.loading-link {
    text-align: center;
    opacity: 0.7;
    pointer-events: none;
}

.description {
  font-size: 0.9em;
  color: #64748b; 
  margin-top: 20px;
  padding-top: 15px;
  border-top: 1px solid #e2e8f0;
  transition: color 0.3s, border-color 0.3s;
}

.footer {
  text-align: center;
  margin: 30px auto;
  font-size: 0.85em;
  color: #64748b; 
  transition: color 0.3s;
}

/* --- 1. สไตล์สำหรับปุ่มสลับธีม --- */
#theme-toggle {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  right: 20px;
  background: transparent; 
  color: #f8fafc; 
  border: 1px solid rgba(255,255,255,0.3);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  font-size: 0.85em;
  transition: all 0.3s;
}
#theme-toggle:hover {
  background: rgba(255,255,255,0.1);
  border-color: #fff;
}

/* --- 2. CSS สำหรับ Night Mode --- */
body.night {
  background: #0f172a; 
  color: #e2e8f0; 
}
body.night header {
  background: #1e293b; 
  border-bottom: 1px solid #334155;
}
body.night .subtitle {
  color: #94a3b8; 
}
body.night .card {
  background: #1e293b; 
  color: #e2e8f0; 
  border-color: #334155;
}
body.night .card h2 {
  color: #f1f5f9; 
  border-bottom-color: #334155;
}
body.night .card ul li a {
  background: #334155; 
  color: #e2e8f0;
  border-color: #475569;
}
body.night .card ul li a:hover {
  background: #475569; 
  color: #60a5fa; 
  border-color: #60a5fa;
}
body.night .description {
  color: #94a3b8; 
  border-top-color: #334155;
}
body.night .footer {
  color: #64748b; 
}
body.night #theme-toggle {
  background: rgba(255,255,255,0.05); 
  color: #e2e8f0; 
  border-color: rgba(255,255,255,0.2);
}
body.night #theme-toggle:hover {
  background: rgba(255,255,255,0.15);
}


/* --- 3. New 2-Column Layout Styles --- */
#two-column-layout {
    display: grid;
    /* คงสัดส่วนเดิมไว้ แต่เนื่องจากความกว้างรวมลดลง พื้นที่ file จะกระชับขึ้นเอง */
    grid-template-columns: 260px 1fr; 
    gap: 25px;
    margin-top: 10px;
    text-align: left;
    min-height: 50vh; 
}

#folder-column {
    border-right: 1px solid #e2e8f0; 
    padding-right: 15px;
    max-height: 70vh; 
    overflow-y: auto; 
}
body.night #folder-column {
    border-right-color: #334155;
}

#folder-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: block; 
}

#folder-list li a {
    display: block;
    background: none !important; 
    border: none !important; 
    text-decoration: none;
    padding: 8px 12px; 
    border-radius: 6px;
    margin-bottom: 4px;
    color: #475569; 
    font-weight: 500;
    transition: background 0.1s, color 0.1s;
    font-size: 0.95em;
}
#folder-list li a:hover {
    background: #f1f5f9 !important;
    color: #1e293b;
}

body.night #folder-list li a {
    color: #cbd5e1; 
}
body.night #folder-list li a:hover {
    background: #334155 !important;
    color: #fff;
}

/* ACTIVE State */
#folder-list li a.active {
    background: #e0f2fe !important; 
    color: #0369a1 !important; 
    font-weight: 600;
    transform: none !important;
    box-shadow: none !important;
}
body.night #folder-list li a.active {
    background: #1d4ed8 !important; 
    color: #fff !important; 
}

/* Style สำหรับรายการในคอลัมน์ File */
#file-list {
    display: grid;
    /* *** แก้ไขจุดที่ 2: ลดขนาดขั้นต่ำของกล่องไฟล์ลงเพื่อให้เรียงตัวสวยในพื้นที่ที่แคบลง *** */
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); 
    /* ****************************************************************************** */
    gap: 12px; 
    margin-bottom: 0 !important;
}

/* Media Query (Mobile) */
@media (max-width: 768px) {
  header { 
    padding: 10px 15px; 
    flex-direction: row; 
    justify-content: space-between;
  } 
  h1 { font-size: 1.2em; text-align: left; }
  .subtitle { display: none; }
  .card {
    padding: 15px;
    margin: 10px auto;
    width: 92%; /* มือถือยังคงให้กว้างเกือบเต็มจอเพื่อให้ใช้งานง่าย */
  }
  ul { grid-template-columns: 1fr; }
  #theme-toggle {
    position: static;
    transform: none;
    margin-left: 10px;
  }

  #two-column-layout {
      grid-template-columns: 1fr;
      gap: 20px;
  }
  #folder-column {
      border-right: none;
      padding-right: 0;
      max-height: 200px; 
      border-bottom: 1px solid #e2e8f0;
      padding-bottom: 15px;
  }
  body.night #folder-column {
      border-bottom-color: #334155;
  }
  #folder-column::after { display: none; }
}
