/* ============================================================
   MODARAFTA — Design System v4
   Warm Brown Palette — Top Header Layout
   ============================================================ */

/* ---- CSS Custom Properties ---- */
:root {
  --bg:           #f0ebe5;
  --surface:      #ffffff;
  --surface-2:    #f5f0eb;
  --surface-h:    #efe9e1;
  --text:         #1a1412;
  --text-2:       #6b5e54;
  --text-3:       #a39585;
  --border:       #e8e0d8;
  --border-2:     #d9cfc4;
  --brand:        #8B4513;
  --brand-h:      #723a10;
  --brand-light:  #a0522d;
  --brand-rgb:    139, 69, 19;
  --brand-alpha:  rgba(139, 69, 19, 0.10);
  --brand-alpha2: rgba(139, 69, 19, 0.18);
  --accent:       #d4a574;
  --accent-rgb:   212, 165, 116;
  --header-bg:    rgba(250, 248, 245, 0.92);
  --slide-bg:     #ffffff;
  --input-bg:     #f0ebe5;
  --badge-bg:     #f0ebe5;
  --shadow-xs:    0 1px 3px rgba(44, 24, 16, 0.04);
  --shadow-sm:    0 2px 8px rgba(44, 24, 16, 0.06), 0 1px 3px rgba(44, 24, 16, 0.04);
  --shadow-md:    0 8px 24px rgba(44, 24, 16, 0.08), 0 2px 8px rgba(44, 24, 16, 0.05);
  --shadow-lg:    0 20px 60px rgba(44, 24, 16, 0.12), 0 6px 20px rgba(44, 24, 16, 0.08);
  --shadow-float: 0 8px 32px rgba(44, 24, 16, 0.18);
  --radius-s:     10px;
  --radius-m:     14px;
  --radius-l:     20px;
  --radius-xl:    28px;
  --radius-pill:  100px;
  --ease:         cubic-bezier(0.4, 0, 0.2, 1);
  --ease-spring:  cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-out:     cubic-bezier(0, 0, 0.2, 1);
  --header-h:     48px;
  --safe-bottom:  env(safe-area-inset-bottom, 0px);
}

[data-theme="dark"] {
  --bg:           #0e0c0a;
  --surface:      #1a1714;
  --surface-2:    #231f1b;
  --surface-h:    #2c2622;
  --text:         #f2ede8;
  --text-2:       #a89e94;
  --text-3:       #5c534a;
  --border:       #2c2622;
  --border-2:     #382f28;
  --brand:        #c4763a;
  --brand-h:      #d4864a;
  --brand-light:  #d4a574;
  --brand-rgb:    196, 118, 58;
  --brand-alpha:  rgba(196, 118, 58, 0.12);
  --brand-alpha2: rgba(196, 118, 58, 0.22);
  --accent:       #d4a574;
  --accent-rgb:   212, 165, 116;
  --header-bg:    rgba(14, 12, 10, 0.92);
  --slide-bg:     #1a1714;
  --input-bg:     #231f1b;
  --badge-bg:     #231f1b;
  --shadow-xs:    0 1px 3px rgba(0,0,0,0.3);
  --shadow-sm:    0 2px 8px rgba(0,0,0,0.4);
  --shadow-md:    0 8px 24px rgba(0,0,0,0.5);
  --shadow-lg:    0 20px 60px rgba(0,0,0,0.7);
  --shadow-float: 0 8px 32px rgba(0,0,0,0.5);
}

/* ---- Base ---- */
*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }

html {
  scroll-behavior: smooth;
  touch-action: manipulation;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding-top: calc(var(--header-h) + env(safe-area-inset-top, 0px));
  transition: background 0.3s var(--ease), color 0.3s var(--ease);
  min-height: 100dvh;
  overflow-x: hidden;
}

/* =============================================
   HEADER
   ============================================= */
.mobile-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: calc(var(--header-h) + env(safe-area-inset-top, 0px));
  padding-top: env(safe-area-inset-top, 0px);
  background: #ffffff;
  border-bottom: 1.5px solid #d9cfc4;
  box-shadow: 0 2px 8px rgba(44, 24, 16, 0.08);
  z-index: 900;
  transition: box-shadow 0.3s var(--ease);
}

[data-theme="dark"] .mobile-header {
  background: #1a1714;
  border-bottom-color: #382f28;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.mobile-header.scrolled {
  box-shadow: 0 4px 16px rgba(44, 24, 16, 0.12);
}

[data-theme="dark"] .mobile-header.scrolled {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-h);
  padding: 0 8px;
  max-width: 1200px;
  margin: 0 auto;
}

.header-left,
.header-right {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 76px;
}

.header-right {
  justify-content: flex-end;
}

.header-center {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
}

.logo-link {
  display: flex;
  align-items: center;
  text-decoration: none;
}

.logo-text {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 2.5px;
  color: var(--brand);
  text-transform: uppercase;
  line-height: 1;
}

/* Icon button base */
.header-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: transparent;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text);
  font-size: 18px;
  text-decoration: none;
  position: relative;
  flex-shrink: 0;
  transition: background 0.18s var(--ease), color 0.18s var(--ease), transform 0.15s;
  -webkit-tap-highlight-color: transparent;
  line-height: 1;
}

.header-btn:hover  { background: var(--surface-2); }
.header-btn:active { transform: scale(0.88); }

/* =============================================
   SEARCH PANEL (fullscreen)
   ============================================= */
.search-panel {
  position: fixed;
  top: 0;
  left: 0; right: 0;
  bottom: 0;
  background: var(--bg);
  z-index: 960;
  transform: translateY(-100%);
  transition: transform 0.35s var(--ease);
  padding-top: env(safe-area-inset-top, 0px);
}

.search-panel.open { transform: translateY(0); }

.search-panel-inner {
  max-width: 600px;
  margin: 0 auto;
  padding: 16px 16px 16px;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.search-top-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.search-input-row {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border-radius: var(--radius-pill);
  padding: 0 16px;
  border: 1.5px solid var(--border);
  transition: border-color 0.2s, box-shadow 0.2s;
  height: 48px;
}

.search-input-row:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-alpha);
}

.search-input-row .si-icon {
  color: var(--text-3);
  font-size: 15px;
  flex-shrink: 0;
}

#searchInput {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  padding: 12px 0;
}

#searchInput::placeholder { color: var(--text-3); }

.search-cancel-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--brand);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  padding: 8px 4px;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

.search-clear-btn {
  background: var(--surface-2);
  border: none;
  cursor: pointer;
  color: var(--text-3);
  font-size: 10px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}

.search-clear-btn:hover { background: var(--border); }

.search-results-wrap {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  -webkit-overflow-scrolling: touch;
}

.search-hint {
  text-align: center;
  padding: 40px 0 6px;
  font-size: 13px;
  color: var(--text-3);
}

.search-hint i {
  display: block;
  font-size: 32px;
  margin-bottom: 12px;
  color: var(--border-2);
}

.search-loader {
  display: none;
  text-align: center;
  padding: 24px;
}

.search-loader-dots {
  display: inline-flex;
  gap: 5px;
}

.search-loader-dots span {
  width: 8px; height: 8px;
  background: var(--brand);
  border-radius: 50%;
  animation: searchDot 1s var(--ease) infinite;
}

.search-loader-dots span:nth-child(2) { animation-delay: 0.15s; }
.search-loader-dots span:nth-child(3) { animation-delay: 0.30s; }

@keyframes searchDot {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

.search-no-result {
  text-align: center;
  padding: 40px 24px;
  font-size: 14px;
  color: var(--text-3);
}

.search-no-result i { font-size: 36px; display: block; margin-bottom: 10px; color: var(--border-2); }

.search-result-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px;
  border-radius: var(--radius-m);
  text-decoration: none;
  color: var(--text);
  transition: background 0.15s;
  cursor: pointer;
}

.search-result-item:hover { background: var(--surface); }
.search-result-item:active { background: var(--surface-h); }

.search-result-img {
  width: 50px; height: 66px;
  object-fit: cover;
  border-radius: var(--radius-s);
  flex-shrink: 0;
  background: var(--surface-2);
}

.search-result-body { flex: 1; min-width: 0; }

.search-result-name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result-meta {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 3px;
}

.search-result-meta b { color: var(--brand); }

.search-result-arrow {
  color: var(--text-3);
  font-size: 12px;
  flex-shrink: 0;
}

.search-results-divider {
  height: 1px;
  background: var(--border);
  margin: 0 12px;
}

/* =============================================
   SLIDE MENU (from right)
   ============================================= */
.slide-menu {
  position: fixed;
  top: 0; right: -100%;
  width: min(340px, 88vw);
  height: 100dvh;
  background: var(--slide-bg);
  z-index: 1001;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  transition: right 0.35s var(--ease);
  border-radius: var(--radius-l) 0 0 var(--radius-l);
}

.slide-menu.active { right: 0; }

.slide-menu-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 64px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.slide-menu-brand {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: var(--brand);
}

.menu-close {
  width: 36px; height: 36px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  border: none;
  cursor: pointer;
  color: var(--text-2);
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.menu-close:hover { background: var(--border); color: var(--text); }

.mobile-menu {
  list-style: none;
  padding: 12px;
  flex: 1;
  overflow-y: auto;
}

.mobile-menu li { margin-bottom: 2px; }

.mobile-menu a {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-m);
  transition: background 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.mobile-menu a .mi {
  width: 22px;
  text-align: center;
  color: var(--text-3);
  font-size: 15px;
  transition: color 0.15s;
}

.mobile-menu a:hover,
.mobile-menu a.active-link {
  background: var(--brand-alpha);
  color: var(--brand);
}

.mobile-menu a:hover .mi,
.mobile-menu a.active-link .mi {
  color: var(--brand);
}

.slide-menu-foot {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.slide-menu-theme {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-2);
  font-weight: 500;
}

.theme-switch {
  width: 48px; height: 26px;
  background: var(--border-2);
  border-radius: 13px;
  position: relative;
  cursor: pointer;
  border: none;
  transition: background 0.25s;
  flex-shrink: 0;
}

.theme-switch::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 20px; height: 20px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.25s var(--ease-spring), background 0.25s;
  box-shadow: var(--shadow-sm);
}

[data-theme="dark"] .theme-switch { background: var(--brand); }
[data-theme="dark"] .theme-switch::after { transform: translateX(22px); }

.slide-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 1000;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.slide-overlay.active { display: block; }

/* Theme icons in header */
.icon-sun  { display: none; }
.icon-moon { display: inline; }
[data-theme="dark"] .icon-sun  { display: inline; }
[data-theme="dark"] .icon-moon { display: none; }

/* =============================================
   TOAST NOTIFICATION
   ============================================= */
.toast-msg {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #2c1810;
  color: #fff;
  padding: 12px 24px;
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-float);
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: opacity 0.3s, transform 0.3s var(--ease-spring);
}

.toast-msg.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast-msg.removed {
  background: #c0392b;
}

/* =============================================
   RESPONSIVE
   ============================================= */
@media (min-width: 768px) {
  :root { --header-h: 52px; }
  .header-inner { padding: 0 20px; }
  .header-btn { width: 38px; height: 38px; }
  .logo-text { font-size: 19px; letter-spacing: 3px; }
}
