/* ═══════════════════════════════════════
   KORISHA — layout.css
   Core shell: header, nav, mega menu, footer
   ═══════════════════════════════════════ */

/* ─── Variables ─── */
:root {
  --k-primary: #E8485C;
  --k-primary-dark: #C73A4C;
  --k-primary-light: #FFE0E5;
  --k-secondary: #3D3D5C;
  --k-accent: #5BBFBA;
  --k-accent-light: #E0F5F4;
  --k-dark: #1E1E2E;
  --k-text: #333347;
  --k-text-light: #7A7A8E;
  --k-bg: #FAFAFA;
  --k-white: #FFFFFF;
  --k-border: #EBEBEF;
  --k-shadow-sm: 0 1px 3px rgba(30,30,46,0.06);
  --k-shadow: 0 4px 16px rgba(30,30,46,0.08);
  --k-shadow-lg: 0 8px 32px rgba(30,30,46,0.12);
  --k-radius: 10px;
  --k-radius-sm: 6px;
  --k-transition: 0.22s ease;

  --font-main: 'Montserrat', 'Noto Sans KR', sans-serif;
  --font-kr: 'Noto Sans KR', sans-serif;

  /* Sticky offsets — JS overwrites these with actual measured values */
  --header-h: 62px;
  --topbar-h: 30px;
  --nav-h: 52px;
}

/* ─── Reset / Base ─── */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: var(--font-main);
  color: var(--k-text);
  background: var(--k-bg);
  margin: 0;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { text-decoration: none; color: inherit; }
img { max-width: 100%; display: block; }
button { font-family: var(--font-main); }

.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 20px;
}


/* ═══════════════════════════════════════
   TOP BAR
   ═══════════════════════════════════════ */

.top-bar {
  background: var(--k-secondary);
  color: rgba(255,255,255,0.75);
  font-size: 12px;
  padding: 6px 0;
  letter-spacing: 0.01em;
  height: var(--topbar-h);
}
.top-links a {
  color: rgba(255,255,255,0.75);
  margin-right: 18px;
  transition: color var(--k-transition);
}
.top-links a:hover { color: #fff; }
.top-right {
  display: flex;
  align-items: center;
}
.top-right span { margin-left: 12px; }
.top-right i { margin-right: 4px; }
.top-right a { color: rgba(255,255,255,0.75); transition: color var(--k-transition); }
.top-right a:hover { color: #fff; }
.top-sep { opacity: 0.3; margin: 0 4px; }


/* ═══════════════════════════════════════
   HEADER
   ═══════════════════════════════════════ */

.main-header {
  background: var(--k-white);
  padding: 14px 0;
  /* Border via shadow so it doesn't add 1px to height — keeps total even */
  box-shadow: inset 0 -1px 0 var(--k-border);
  position: sticky;
  top: 0;
  z-index: 100;
}

/* Logo */
.logo {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.logo-img {
  height: 30px;
  width: auto;
}

/* Search */
.header-search {
  flex: 1;
  max-width: 520px;
  margin: 0 40px;
  position: relative;
}
.header-search input {
  width: 100%;
  padding: 11px 50px 11px 18px;
  border: 2px solid var(--k-border);
  border-radius: 50px;
  font-size: 14px;
  font-family: var(--font-main);
  background: var(--k-bg);
  outline: none;
  transition: border-color var(--k-transition), box-shadow var(--k-transition);
}
.header-search input:focus {
  border-color: var(--k-primary);
  box-shadow: 0 0 0 3px var(--k-primary-light);
}
.header-search input::placeholder { color: var(--k-text-light); }

/* Search autocomplete dropdown */
.search-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--k-white);
  border: 1px solid var(--k-border);
  border-radius: var(--k-radius);
  box-shadow: var(--k-shadow-lg);
  z-index: 110;
  max-height: 400px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--k-border) transparent;
}
.search-dropdown::-webkit-scrollbar { width: 4px; }
.search-dropdown::-webkit-scrollbar-track { background: transparent; }
.search-dropdown::-webkit-scrollbar-thumb { background: var(--k-border); border-radius: 4px; }
.search-dropdown.show { display: block; }

.sd-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  text-decoration: none;
  color: var(--k-text);
  transition: background var(--k-transition);
}
.sd-item:hover { background: var(--k-bg); }
.sd-thumb {
  width: 36px;
  height: 36px;
  border-radius: var(--k-radius-sm);
  background: var(--k-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}
.sd-thumb img { width: 100%; height: 100%; object-fit: contain; }
.sd-thumb i { font-size: 16px; color: var(--k-border); }
.sd-brand { font-size: 11px; color: var(--k-text-light); font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px; }
.sd-name { font-size: 13px; color: var(--k-dark); }
.sd-info { display: flex; flex-direction: column; gap: 1px; min-width: 0; }

.sd-total {
  display: block;
  padding: 10px 14px;
  text-align: center;
  font-size: 13px;
  color: var(--k-primary);
  font-weight: 500;
  border-top: 1px solid var(--k-border);
  transition: background var(--k-transition);
}
.sd-total:hover { background: var(--k-primary-light); }

/* Folder results in search */
.sd-section { padding: 6px 14px 4px; font-size: 11px; font-weight: 600; color: var(--k-text-light); text-transform: uppercase; letter-spacing: 0.5px; }
.sd-brand-card { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--k-white); text-decoration: none; color: var(--k-text); font-size: 13px; border-bottom: 1px solid var(--k-border); transition: background var(--k-transition); }
.sd-brand-card:hover { background: var(--k-bg); }
.sd-brand-card img { flex-shrink: 0; }
.sd-brand-card strong { color: var(--k-dark); }
.sd-brand-card i { margin-left: auto; color: var(--k-primary); font-size: 12px; }
.sd-folder { display: flex; align-items: center; gap: 10px; padding: 8px 14px; color: var(--k-text); transition: background var(--k-transition); }
.sd-folder:hover { background: var(--k-bg); }
.sd-folder i { font-size: 18px; color: var(--k-text-light); flex-shrink: 0; }
.sd-folder-name { font-size: 13px; font-weight: 500; color: var(--k-dark); }
.sd-folder-path { font-size: 11px; color: var(--k-text-light); }

/* Mobile: dropdown full width */
@media (max-width: 768px) {
  #mobileSearchDropdown {
    position: fixed !important;
    left: 12px !important;
    right: 12px !important;
    top: calc(var(--header-h) + 50px) !important;
    max-height: 60vh;
    width: auto !important;
  }
}

.search-btn {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--k-primary);
  border: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--k-transition);
}
.search-btn:hover { background: var(--k-primary-dark); }

/* ─── Mobile search toggle — hidden on desktop ─── */
.search-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  background: var(--k-bg);
  border: 2px solid var(--k-border);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  color: var(--k-text-light);
  font-size: 17px;
  cursor: pointer;
  transition: border-color var(--k-transition), color var(--k-transition);
  flex-shrink: 0;
}
.search-toggle:hover { border-color: var(--k-primary); color: var(--k-primary); }
.search-toggle span { display: none; }

/* ─── Expanded mobile search (full-width below header row) ─── */
.header-search-expanded {
  display: none;
  padding: 8px 20px 10px;
  align-items: center;
  gap: 8px;
  position: relative;
  z-index: 101;
}
.header-search-expanded.show {
  display: flex;
}
/* Force-hide on desktop — CSS overrides stale JS .show class */
@media (min-width: 577px) {
  .header-search-expanded.show { display: none; }
}
.header-search-expanded .header-search {
  margin: 0;
  max-width: none;
  position: relative;
}
.header-search-expanded .search-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 200;
}
.search-expanded-close {
  background: none;
  border: none;
  font-size: 18px;
  color: var(--k-text-light);
  cursor: pointer;
  padding: 6px;
  flex-shrink: 0;
}
.search-expanded-close:hover { color: var(--k-dark); }

/* ─── Header Actions — FIXED WIDTH ─── */
.header-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.action-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  /* Fixed width so all three buttons are identical */
  width: 72px;
  padding: 6px 0;
  border-radius: var(--k-radius-sm);
  font-size: 11px;
  color: var(--k-text);
  position: relative;
  transition: background var(--k-transition), color var(--k-transition);
  text-align: center;
}
.action-item i {
  font-size: 22px;
  margin-bottom: 2px;
}
.action-item:hover {
  background: var(--k-bg);
  color: var(--k-primary);
}

.badge-count {
  position: absolute;
  top: 0;
  /* Anchor badge relative to the icon, always same position */
  right: 10px;
  background: var(--k-primary);
  color: #fff;
  font-size: 10px;
  font-style: normal;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}
.action-cart .badge-count { background: var(--k-accent); }


/* ═══════════════════════════════════════
   NAVIGATION BAR
   ═══════════════════════════════════════ */

.main-nav {
  background: var(--k-white);
  border-bottom: 1px solid var(--k-border);
  position: sticky;
  /* Pull 1px up to seal subpixel gap with header */
  top: calc(var(--header-h) - 1px);
  z-index: 99;
  padding: 6px 0;
}

.catalog-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--k-primary);
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: var(--k-radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--k-transition);
  flex-shrink: 0;
}
.catalog-btn:hover { background: var(--k-primary-dark); }
.catalog-btn .chevron {
  font-size: 11px;
  transition: transform var(--k-transition);
}
.catalog-btn.open .chevron { transform: rotate(180deg); }

.nav-links {
  display: flex;
  list-style: none;
  margin: 0;
  padding: 0;
  margin-left: 24px;
  gap: 4px;
}
.nav-links a {
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--k-text);
  border-radius: var(--k-radius-sm);
  transition: background var(--k-transition), color var(--k-transition);
  white-space: nowrap;
}
.nav-links a:hover {
  background: var(--k-bg);
  color: var(--k-primary);
}
.nav-hot {
  color: var(--k-primary) !important;
  font-weight: 600 !important;
}
.nav-hot i { margin-right: 4px; }

/* Burger — hidden on desktop */
.burger {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  margin-left: auto;
}
.burger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--k-dark);
  border-radius: 2px;
  transition: all 0.3s;
}


/* ═══════════════════════════════════════
   MEGA MENU
   ═══════════════════════════════════════ */

.mega-overlay {
  display: none;
  position: fixed;
  inset: 0;
  /* Transparent — only catches clicks to close menu */
  background: transparent;
  z-index: 97;
}
.mega-overlay.show { display: block; }

.mega-menu {
  /* Absolute to document flow, positioned via JS right below the nav */
  position: fixed;
  left: 0;
  right: 0;
  top: var(--mega-top, 120px); /* JS sets --mega-top precisely */
  z-index: 98;
  background: var(--k-white);
  border-bottom: 2px solid var(--k-primary);
  box-shadow: var(--k-shadow-lg);
  display: none;
  max-height: calc(100vh - var(--mega-top, 120px));
  overflow-y: auto;
}
.mega-menu.show { display: block; }

.mega-inner {
  display: flex;
}

/* ─── Left column: root categories ─── */
.mega-cats {
  list-style: none;
  margin: 0;
  padding: 12px 0;
  width: 280px;
  flex-shrink: 0;
  border-right: 1px solid var(--k-border);
}

.mega-cat {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  font-size: 14px;
  cursor: pointer;
  transition: background var(--k-transition), color var(--k-transition);
  color: var(--k-text);
}

/* ─── Universal icon wrapper ─── */
.mega-cat-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  color: var(--k-text-light);
  transition: color var(--k-transition);
}

/* Bootstrap icons inside wrapper */
.mega-cat-icon i {
  font-size: 16px;
}

/* Inline SVG inside wrapper — inherits currentColor */
.mega-cat-icon svg {
  width: 18px;
  height: 18px;
  /* stroke/fill inherit from parent color via currentColor */
}

.mega-cat .arr {
  margin-left: auto;
  font-size: 11px;
  opacity: 0;
  transition: opacity var(--k-transition);
}

/* Hover / Active states */
.mega-cat:hover, .mega-cat.active {
  background: var(--k-primary-light);
  color: var(--k-primary);
}
.mega-cat:hover .mega-cat-icon,
.mega-cat.active .mega-cat-icon {
  color: var(--k-primary);
}
.mega-cat:hover .arr,
.mega-cat.active .arr { opacity: 1; }


/* ─── Right column: subcategories ─── */
.mega-sub {
  flex: 1;
  padding: 20px 24px;
  position: relative;
}

.mega-panel {
  display: none;
}
.mega-panel.active {
  display: block;
  column-count: 3;
  column-gap: 32px;
}

.mega-col {
  break-inside: avoid;
  -webkit-column-break-inside: avoid;
  margin-bottom: 20px;
}

.mega-col h6 {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--k-dark);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--k-primary-light);
}
.mega-col a {
  display: block;
  font-size: 13px;
  color: var(--k-text-light);
  padding: 4px 0;
  transition: color var(--k-transition), transform var(--k-transition);
}
.mega-col a:hover {
  color: var(--k-primary);
  transform: translateX(6px);
}


/* ═══════════════════════════════════════
   MOBILE MENU (sidebar)
   ═══════════════════════════════════════ */

.mobile-menu {
  position: fixed;
  top: 0;
  right: -300px;
  width: 300px;
  height: 100%;
  background: var(--k-white);
  z-index: 200;
  box-shadow: var(--k-shadow-lg);
  transition: right 0.3s ease;
  display: flex;
  flex-direction: column;
}
.mobile-menu.open { right: 0; }

.mobile-menu-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--k-border);
  font-size: 16px;
  font-weight: 600;
  color: var(--k-dark);
}
.mobile-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--k-text-light);
  padding: 4px;
}

.mobile-menu-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0;
}
.mm-link {
  display: block;
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 500;
  color: var(--k-text);
  transition: background var(--k-transition);
}
.mm-link:hover { background: var(--k-bg); }
.mm-link i { margin-right: 8px; }
.mm-divider {
  height: 1px;
  background: var(--k-border);
  margin: 8px 20px;
}


/* ═══════════════════════════════════════
   PAGE CONTENT AREA
   ═══════════════════════════════════════ */

.page-content {
  min-height: 50vh;
  padding: 32px 0 48px;
}

/* Placeholder for demo */
.content-placeholder {
  text-align: center;
  padding: 80px 40px;
  background: var(--k-white);
  border: 2px dashed var(--k-border);
  border-radius: var(--k-radius);
  color: var(--k-text-light);
}
.content-placeholder i {
  font-size: 48px;
  opacity: 0.3;
  margin-bottom: 16px;
  display: block;
}
.content-placeholder h2 {
  font-size: 20px;
  font-weight: 600;
  color: var(--k-dark);
  margin: 0 0 8px;
}
.content-placeholder p {
  font-size: 14px;
  margin: 0;
  line-height: 1.7;
}
.content-placeholder code {
  background: var(--k-primary-light);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  color: var(--k-primary-dark);
}


/* ═══════════════════════════════════════
   FOOTER
   ═══════════════════════════════════════ */

.main-footer {
  background: var(--k-dark);
  color: rgba(255,255,255,0.65);
  padding: 48px 0 0;
}

.footer-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 1fr 1.2fr;
  gap: 32px;
  padding-bottom: 36px;
}

.fc-brand .footer-logo { margin-bottom: 14px; }
.footer-logo-img {
  height: 30px;
  width: auto;
}
.fc-brand p {
  font-size: 13px;
  line-height: 1.6;
  margin: 0 0 16px;
}

.footer-col h6 {
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 16px;
}
.footer-col a {
  display: block;
  font-size: 13px;
  padding: 3px 0;
  color: rgba(255,255,255,0.55);
  transition: color var(--k-transition);
}
.footer-col a:hover { color: #fff; }

/* Social links — after footer-col a to override display:block */
.social-links {
  display: flex;
  gap: 8px;
}
.footer-col .social-links a,
.social-links a {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: rgba(255,255,255,0.6);
  transition: all var(--k-transition);
  padding: 0;
}
.footer-col .social-links a:hover,
.social-links a:hover {
  background: var(--k-primary);
  color: #fff;
}

.fc-contact p {
  font-size: 13px;
  margin: 0 0 6px;
}
.fc-contact i { margin-right: 6px; opacity: 0.5; }

.payment-icons {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}
.payment-icons span {
  background: rgba(255,255,255,0.08);
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  color: rgba(255,255,255,0.5);
}

.footer-bottom {
  border-top: 1px solid rgba(255,255,255,0.08);
  padding: 18px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
}
.footer-legal {
  display: flex;
  gap: 20px;
}
.footer-legal a {
  color: rgba(255,255,255,0.4);
  transition: color var(--k-transition);
}
.footer-legal a:hover { color: rgba(255,255,255,0.8); }


/* ═══════════════════════════════════════
   SCROLL TOP
   ═══════════════════════════════════════ */

.scroll-top {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--k-primary);
  color: #fff;
  border: none;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--k-shadow);
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: all 0.3s ease;
  z-index: 50;
}
.scroll-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.scroll-top:hover {
  background: var(--k-primary-dark);
  transform: translateY(-2px);
}
