/* --- CSS Reset --- */
@import url('https://fonts.googleapis.com/css2?family=Afacad:wght@400;600;700&display=swap');

a, button, input, select, h1, h2, h3, h4, h5, * {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  border: none;
  text-decoration: none;
  background: none;
  -webkit-font-smoothing: antialiased;
}
    
menu, ol, ul {
  list-style-type: none;
  margin: 0;
  padding: 0;
}

@font-face {
  font-family: "Afacad";
  src: url("../assets/Afacad[wght].ttf") format("truetype");
  font-weight: 400 700; 
  font-style: normal;
  font-display: swap; 
}

@font-face {
  font-family: "Bauhaus 93";
  src: url("../assets/Bauhaus 93 Regular.ttf") format("truetype"); /* កែតម្រូវ Space ក្នុងឈ្មោះ File */
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

/* --- CSS Variables (រក្សាពណ៌ដើម) --- */
:root {
  --color-primary: #002d6d;
  --color-secondary: #e5f5ff;
  --color-accent: #0282fe;
  --color-accent-dark: #0057d3;
  --color-white: #ffffff;
  --color-black: #000000;
  --color-border: #b4dafc;

  /* ពណ៌ Theme សម្រាប់ Light Mode */
  --color-bg: var(--color-white);
  --color-text: var(--color-primary);
  --color-header-bg: var(--color-secondary);
  --color-header-border: var(--color-border);
  --color-search-bg: var(--color-white);
  --color-body-bg: #ffffff;

  /* Fonts (រក្សាទុកដដែល) */
  --font-body: "Afacad", sans-serif;
  --font-bold: "Afacad", sans-serif;
  --font-semibold: "Afacad", sans-serif;
  --font-logo: "Bauhaus 93", sans-serif; 

  --header-control-height: 40px; 
}

html[data-theme="dark"] {
  --color-primary: #e5f5ff;       /* ពណ៌អក្សរគោល (ខៀវស្រាល) */
  --color-secondary: #0c1a2e;     /* ផ្ទៃខាងក្រោយ Header/Footer (ខៀវចាស់) */
  --color-accent: #0282fe;       /* ពណ៌ Accent (ខៀវភ្លឺ) */
  --color-accent-dark: #0057d3; /* ពណ៌ Accent ពេលចុច */
  --color-white: #ffffff;
  --color-black: #000000;
  --color-border: #0057d3;       /* ពណ៌ Border (ខៀវមធ្យម) */
  
  /* ពណ៌ Theme សម្រាប់ Dark Mode */
  --color-bg: #08121f;             /* ផ្ទៃខាងក្រោយ Body (ខៀវខ្មៅ) */
  --color-text: var(--color-primary);
  --color-header-bg: var(--color-secondary);
  --color-header-border: var(--color-border);
  --color-search-bg: #08121f;
  --color-body-bg: #03142D;
}

/*======================================================================================================================================*/


/* --- Base Styles (Desktop-First) --- */

body {
  min-height: 100vh;
  background: var(--color-body-bg);
  border-bottom: 3px solid var(--color-header-border);
  color: var(--color-text);
  overflow-x: hidden;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.page-container {
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

/* --- Header (PC) --- */
.header {
  background: var(--color-header-bg);
  border-bottom: 3px solid var(--color-border);
  padding: 0 150px;
  width: 100%;
  position: relative;
  position: fixed; 
  top: 0;          
  left: 0;         
  z-index: 1000;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.header-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 10px 0;
}

.logo-container img {
  width: auto;
  height: 25px;
  display: block;
}
    
.header-right {
  display: flex;
  align-items: center;
  gap: 15px;
  height: var(--header-control-height);
}


/* --- ▼▼▼ ចាប់ផ្តើម៖ បន្ថែមកូដ Theme Switcher ថ្មីនៅទីនេះ ▼▼▼ --- */
.theme-switcher-container {
  position: relative;
  display: flex;
  align-items: center;
}

.theme-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--header-control-height);
  height: var(--header-control-height);
  border-radius: 12px;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.3s ease; /* បន្ថែម border-color transition */
  color: var(--color-primary);
  background-color: var(--color-search-bg);
  border: 2px solid var(--color-primary);
}

.theme-toggle-btn .theme-icon {
  stroke: currentColor;
  width: 22px;
  height: 22px;
}

.theme-toggle-btn:hover {
  background-color: var(--color-border);
}

/* ពេល Dark Mode ឲ្យវាភ្លឺជាងមុនពេល Hover */
html[data-theme="dark"] .theme-toggle-btn:hover {
  background-color: var(--color-accent-dark);
}

.theme-dropdown {
  display: none; /* លាក់ជា Default */
  position: absolute;
  top: calc(100% + 15px); /* ឲ្យវាធ្លាក់មកក្រោមប៊ូតុងបន្តិច */
  right: 0;
  width: 150px;
  background-color: var(--color-bg); /* ប្រើផ្ទៃខាងក្រោយរបស់ Theme */
  border: 2px solid var(--color-header-border);
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  z-index: 1001;
  overflow: hidden;
  padding: 5px;
}

html[data-theme="dark"] .theme-dropdown {
  background-color: var(--color-header-bg); /* ផ្ទៃខាងក្រោយ Dropdown ពេល Dark */
}

.theme-dropdown.is-open {
  display: block; /* បង្ហាញពេលចុច */
}

.theme-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text);
  cursor: pointer;
  border-radius: 8px;
  border: none;
  background-color: transparent;
  text-align: left;
}

.theme-option .theme-icon {
  stroke: currentColor;
  width: 20px;
  height: 20px;
  flex-shrink: 0; /* កុំឲ្យ Icon គៀប */
}

.theme-option span {
  flex-grow: 1;
}

.theme-option:hover {
  background-color: var(--color-secondary); /* ពណ៌ពេល Hover */
}

.theme-option.is-active {
  background-color: var(--color-secondary);
  color: var(--color-accent);
}

html[data-theme="dark"] .theme-option {
    color: var(--color-primary);
}

html[data-theme="dark"] .theme-option:hover {
  background-color: #08121f; /* ពណ៌ Hover ពេល Dark */
}

html[data-theme="dark"] .theme-option.is-active {
  background-color: #08121f;
  color: var(--color-accent);
}
/* --- ▲▲▲ បញ្ចប់៖ កូដ Theme Switcher ថ្មី ▲▲▲ --- */

/* ----------------------------------- */
/* --------Search Popup (Mobile)------- */
/* ----------------------------------- */

.search-popup-overlay {
  /* 1. Layout & Position */
  position: fixed; /* នៅលើគេបង្អស់ */
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2000;
  background: var(--color-bg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

/* Class សម្រាប់បង្ហាញ Popup ពេលចុច */
.search-popup-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

/* 3. Header ពណ៌សនៅខាងលើ */
.popup-search-header {
  display: flex;
  align-items: center;
  padding: 15px 20px;
  background: var(--color-header-bg);
  border-bottom: 2px solid var(--color-header-border);
}

/* 4. ប៊ូតុងបិទ (X) */
.popup-close-btn {
  font-size: 24px;
  color: var(--color-primary);
  cursor: pointer;
  margin-right: 15px;
}

/* 5. វាលវាយអក្សរស្វែងរក (Input) */
.popup-search-input {
  flex-grow: 1; /* ពង្រីកពេញទំហំដែលនៅសល់ */
  font-size: 16px;
  font-family: var(--font-body);
  color: var(--color-primary);
  border: none;
  outline: none;
}
.popup-search-input::placeholder {
  color: var(--color-primary);
  opacity: 0.7;
}

/* 6. រូបសញ្ញាស្វែងរក (Magnifier) */
.popup-search-icon {
  font-size: 20px;
  color: var(--color-primary);
  margin-left: 15px;
}

/* 7. តំបន់ Tags ខាងក្រោម */
.popup-content-area {
  padding: 20px;
  overflow-y: auto; 
  height: calc(100% - 70px);
}

.popup-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

/* 8. រចនាប័ទ្ម Tags ពណ៌ខៀវ */
.tag {
  background: linear-gradient(136deg,rgb(1, 71, 171) 0%,rgba(0, 87, 211, 1) 100%);
  color: var(--color-white);
  padding: 8px 14px;
  border-radius: 8px;
  font-family: sans-serif;
  font-size: 14px;
  flex-shrink: 0;
  transition: background 0.2s;
}

.tag:hover {
  background: linear-gradient(136deg,rgb(3, 85, 201) 0%,rgb(1, 91, 218) 100%);
}

/* ----------------------------------- */
/* ------ចប់ Search Popup (Mobile)----- */
/* ----------------------------------- */

.nav-menu-icon {
  display: none; 
  width: var(--header-control-height);
  height: var(--header-control-height);
  cursor: pointer;
  color: var(--color-primary); /* <-- បន្ថែមនេះ ដើម្បីឲ្យវាប្រើสี Theme */
  transition: color 0.3s ease;  /* <-- បន្ថែមនេះ សម្រាប់ប្តូរពណ៌រលូន */
}

.nav-menu-icon path {
  fill: currentColor;
}

.nav-menu-desktop {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-body);
  font-weight: 600;
  width: 100%;
  padding-top: 10px;
}
    
.nav-menu-mobile {
  display: none; 
  position: absolute; 
  top: 100%; 
  right: 0;
  width: 350px;
  height: auto; 
  background: var(--color-header-bg);
  border-left: 3px solid var(--color-header-border);
  border-bottom: 3px solid var(--color-header-border);
  padding: 20px 36px;
  flex-direction: column;
  gap: 23px;
  z-index: 1000;
  transition: transform 0.3s ease-in-out;
  transform: translateX(100%); 
}
    
.nav-menu-mobile.is-open {
  display: flex;
  transform: translateX(0); 
}

.nav-item {
  padding-bottom: 10px;
  border-bottom: 3px solid transparent;
  font-size: 24px;
  font-family: var(--font-semibold);
  color: var(--color-primary);
  cursor: pointer;
  transition: all 0.2s ease;
}
    
.nav-item:hover {
  color: var(--color-accent);
}

.nav-item.active {
  border-bottom-color: var(--color-accent);
  color: var(--color-accent);
}

/* --------------------------------------------------------------------------------------------------*/   
/* --- Footer (PC) --- */
.footer {
  background: var(--color-header-bg);
  padding: 20px 150px;
  width: 100%;
}

.footer-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.footer-copyright {
  font-size: 24px;
}
    
.footer-social .social-links img {
  width: 40px;
  height: 40px;
}

.social-links {
  display: flex;
  gap: 10px;
  align-items: center;
}

.social-links img {
  width: 33px;
  height: 33px;
}

@media (max-width: 1400px) {

  .header { padding: 0 100px; }
  .footer { padding: 20px 100px; }
}

/* ===== Tablet Styles (max-width: 1199px) ===== */
@media (max-width: 1199px) {
  :root {
    --header-control-height: 35px;
  }

  .header { padding: 0 50px; }
  .header-right{ gap: 10px;}
  .logo-container img {
    width: 100%;
    height: auto;
    display: block;
  }

  /* ▼▼▼ ពេល Dark Mode ពេល Hover លើ Search Icon Mobile ▼▼▼ */
  html[data-theme="dark"] .search-icon-mobile:hover {
    background-color: var(--color-primary); /* ពណ៌អក្សរ (ខៀវស្រាល) */
  }
  html[data-theme="dark"] .search-icon-mobile:hover svg {
    color: var(--color-bg); /* ពណ៌ផ្ទៃខាងក្រោយ (ខៀវខ្មៅ) */
    stroke: var(--color-bg);
  }


  .social-links-header { display: none; } 
  .nav-menu-desktop { display: none; } 
  .nav-menu-icon { display: block; } 

  .nav-menu-mobile {
    width: 350px;
    padding: 20px 36px;
  }
  .nav-menu-mobile .social-links { margin-top: 20px; }
  .nav-menu-mobile .social-links img { width: 24px; height: 24px; }
  .footer { padding: 20px 50px; }
  .footer-copyright { font-size: 24px; }
  .footer-social .social-links img { width: 40px; height: 40px; }
}
    
/* ===== Mobile Styles (max-width: 767px) ===== */
@media (max-width: 767px) {
  :root {
    --header-control-height: 30px;
  }

  .header { padding: 0 20px; }
  .header-main{ padding: 10px 0}

  .theme-toggle-btn {
    border-radius: 10px;
  }

  .theme-toggle-btn .theme-icon {
    width: 18px;
    height: 18px;
  }
  
  .nav-menu-mobile { width: 250px; padding: 20px; }
      
  .footer { padding: 20px; }
  .footer-content { flex-direction: column; gap: 15px; text-align: center;}
  .footer-copyright { font-size: 16px; }
  .footer-social .social-links img { width: 16px; height: 16px; }
}