/* Product Book - Minimalist
   Light/Dark theme, RTL support, portal-shaped shell.
   Based on the Retail Training Portal design system. */

:root{
  --bg: #f5f6f9;
  --surface: #ffffff;
  --surface-2: #f1f3f7;
  --text: #0f172a;
  --muted: #64748b;
  --border: rgba(15, 23, 42, 0.10);
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);

  --navy:  #0a1326;
  --navy-2:#0e1b36;
  --gold:  #caa24a;
  --gold-2:#e4c675;

  --success:#16a34a;
  --danger: #dc2626;
  --warn:   #d97706;

  --radius-xl: 22px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 10px;

  --sidebar-w: 260px;
  --header-h:  68px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
          Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  --serif: "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --mono:  ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

body.theme-dark{
  --bg:        #050b16;
  --surface:   #0b142a;
  --surface-2: #0e1b36;
  --text:      #e6edf7;
  --muted:     rgba(230,237,247,0.70);
  --border:    rgba(230,237,247,0.10);
  --shadow:    0 14px 45px rgba(0,0,0,0.35);
}

*{ box-sizing:border-box; }
html, body{ height:100%; }
body{
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}
a{ color: inherit; text-decoration: none; }
a:hover{ text-decoration: none; }
button, input, select, textarea{ font-family: var(--font); }

/* Shell -------------------------------------------------------------- */
.app{ height:100%; display:flex; }

.sidebar{
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sidebar .brand{
  display:flex;
  align-items:center;
  gap:10px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  cursor: pointer;
}
.sidebar .brand:hover{ background: var(--surface-2); }
.sidebar .brand img{
  width: 40px; height: 40px; object-fit: contain; flex-shrink: 0;
}
.sidebar .brand-text{ display:flex; flex-direction:column; line-height:1.05; }
.sidebar .brand-title{ font-weight: 800; letter-spacing: 0.4px; }
.sidebar .brand-sub{ font-size: 12px; color: var(--muted); }

.nav{
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px;
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(202,162,74,0.06), transparent);
}
.nav a{
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  border-radius: 12px;
  color: var(--text);
  border: 1px solid transparent;
  font-size: 14px;
}
.nav a:hover{ background: var(--surface-2); }
.nav a.active{
  border-color: rgba(202,162,74,0.35);
  background: linear-gradient(90deg, rgba(202,162,74,0.18), transparent);
}
.nav .nav-icon{
  width: 22px; height: 22px;
  display:inline-grid; place-items:center;
  opacity: 0.9;
  color: var(--gold);
  font-size: 16px;
}

.sidebar-foot{
  margin-top: auto;
  padding: 10px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
}

.main{ flex:1; display:flex; flex-direction:column; height:100%; }

.header{
  height: var(--header-h);
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.65);
  backdrop-filter: blur(10px);
}
body.theme-dark .header{ background: rgba(11,20,42,0.75); }
.header .left, .header .right{ display:flex; align-items:center; gap: 10px; }
.header .crumb{ color: var(--muted); font-size: 13px; }
.header .search-form input{
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  width: 240px;
  outline: none;
}

.icon-btn{
  width: 40px; height: 40px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  display: grid; place-items: center;
  cursor: pointer;
  font-size: 16px;
}
.icon-btn:hover{ background: var(--surface-2); }

.toggle{ display: flex; align-items: center; gap: 6px; }
.lang-toggle{
  gap: 6px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}
.lang-toggle a{
  border: 0;
  background: transparent;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}
.lang-toggle a.active{ background: rgba(202,162,74,0.18); }
.lang-toggle .slash{ color: var(--muted); font-weight: 900; }

.content{
  flex: 1;
  overflow: auto;
  padding: 24px 28px;
  scrollbar-gutter: stable;
}

/* Typography --------------------------------------------------------- */
h1, h2, h3, h4{ margin: 0 0 10px 0; color: var(--text); }
h1{ font-family: var(--serif); letter-spacing: -0.01em; font-weight: 600; }
p{ margin: 0 0 10px 0; color: var(--muted); line-height: 1.6; }
ul, ol{ margin: 8px 0 10px 18px; color: var(--muted); line-height: 1.6; }

/* Cards + components ------------------------------------------------- */
.card{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  padding: 18px;
}
.pill{
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(202,162,74,0.10);
  font-size: 12px;
  color: var(--text);
}
.pill strong{ color: var(--gold); }

.chip{
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  white-space: nowrap;
}
.chip.active,
.chip:hover{
  border-color: rgba(202,162,74,0.55);
  background: rgba(202,162,74,0.14);
}

/* Buttons ------------------------------------------------------------ */
.btn{
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn:hover{ background: var(--surface-2); }
.btn.primary{
  background: linear-gradient(180deg, var(--gold-2), var(--gold));
  border-color: rgba(202,162,74,0.55);
  color: var(--navy);
  font-weight: 800;
}
.btn-primary{
  background: linear-gradient(180deg, var(--gold-2), var(--gold));
  border: 1px solid rgba(202,162,74,0.55);
  color: var(--navy);
  font-weight: 800;
  padding: 10px 18px;
  border-radius: 999px;
  cursor: pointer;
}
.btn-primary:hover{ filter: brightness(1.05); }

/* Hero + stats (index page) ----------------------------------------- */
.hero h1{ font-size: 32px; margin: 0 0 8px; }
.hero .sub{ color: var(--muted); max-width: 720px; }

.stats-grid{
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 24px 0 28px;
}
.stat{
  padding: 16px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(202,162,74,0.08), transparent);
  text-align: left;
}
.stat strong{
  display: block;
  font-size: 26px;
  font-weight: 900;
  margin-bottom: 4px;
}
.stat span{
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 800;
}

/* Brand picker (index) ---------------------------------------------- */
.brand-picker{
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}
.brand-tile{
  display: block;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  color: var(--text);
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: transform 120ms ease, border-color 120ms ease;
}
.brand-tile:hover{
  transform: translateY(-2px);
  border-color: rgba(202,162,74,0.45);
}
.brand-tile h2{ margin: 0 0 6px; font-family: var(--serif); }
.brand-tile p{ margin: 0; color: var(--muted); font-size: 13px; }

/* Brand page / collection grid -------------------------------------- */
.brand-head{ margin-bottom: 20px; }
.brand-head h1{ margin: 0; }
.brand-head .sub{ color: var(--muted); }

.category-block{ margin: 24px 0 32px; }
.category-block h2{
  font-size: 13px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 900;
  margin: 0 0 12px;
}
.collection-list{
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
}
.collection-list li a{
  display: block;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  transition: transform 120ms ease, border-color 120ms ease;
}
.collection-list li a:hover{
  transform: translateY(-2px);
  border-color: rgba(202,162,74,0.45);
}
.collection-list strong{ display: block; font-weight: 700; }
.collection-list .meta{ color: var(--muted); font-size: 12px; margin-top: 4px; }

/* Collection article ------------------------------------------------- */
.collection-actions{
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.collection-actions .spacer{ flex: 1; }

.collection-body{ max-width: 880px; }
.collection-body h1{ font-size: 30px; }
.collection-body h2{ margin-top: 32px; padding-top: 12px; border-top: 1px solid var(--border); font-size: 22px; }
.collection-body h3{ margin-top: 22px; font-size: 16px; font-weight: 800; }
.collection-body h4{ margin-top: 16px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; font-size: 11px; }
.collection-body img{ max-width: 100%; border-radius: var(--radius-lg); margin: 12px 0; }
.collection-body table{ width: 100%; border-collapse: collapse; margin: 14px 0; font-size: 13px; }
.collection-body th, .collection-body td{ border: 1px solid var(--border); padding: 8px 10px; text-align: left; }
.collection-body th{ background: var(--surface-2); color: var(--muted); font-weight: 900; }
.collection-body pre{ background: var(--surface-2); padding: 12px; overflow: auto; border-radius: var(--radius-md); font-family: var(--mono); font-size: 12px; }
.collection-body code{ background: var(--surface-2); padding: 1px 6px; border-radius: 4px; font-family: var(--mono); font-size: 12px; }

/* Admin grid + forms ------------------------------------------------ */
.admin-grid{
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
  margin: 20px 0 28px;
}
.admin-grid .card h2{ font-size: 16px; margin-bottom: 8px; }
.admin-grid .card button{
  display: inline-block;
  margin: 4px 4px 4px 0;
  padding: 8px 14px;
  border: 1px solid rgba(202,162,74,0.45);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  cursor: pointer;
  font-size: 12px;
}
.admin-grid .card button:hover{ background: rgba(202,162,74,0.14); }

.form-grid{ display: flex; flex-direction: column; gap: 16px; margin: 16px 0; }
.form-row{ display: flex; flex-direction: column; gap: 6px; }
.form-row label{ font-weight: 700; font-size: 13px; }
.form-row .muted{ font-weight: 400; color: var(--muted); font-size: 12px; }
.form-row textarea,
.form-row input[type="text"]{
  font: 13px/1.45 var(--mono);
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  resize: vertical;
  width: 100%;
}
.form-row textarea:focus,
.form-row input:focus{
  outline: 0;
  box-shadow: 0 0 0 3px rgba(202,162,74,0.18);
  border-color: rgba(202,162,74,0.55);
}
.form-actions{ display: flex; gap: 12px; align-items: center; margin: 20px 0 40px; }
pre.muted{
  white-space: pre-wrap; word-break: break-word; font-size: 11px;
  background: var(--surface-2); padding: 8px; border-radius: 6px;
  max-height: 140px; overflow: auto; margin: 0;
}

table{ border-collapse: collapse; width: 100%; font-size: 13px; }
table th, table td{ border: 1px solid var(--border); padding: 8px 10px; text-align: left; }
table th{ background: var(--surface-2); color: var(--muted); font-weight: 900; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }

.pager{ margin: 18px 0; display: flex; gap: 12px; align-items: center; }
.pager span{ color: var(--muted); font-size: 13px; }

/* RTL ---------------------------------------------------------------- */
body.rtl .app{ flex-direction: row-reverse; }
body.rtl .sidebar{
  border-right: 0;
  border-left: 1px solid var(--border);
}
body.rtl .nav a{ flex-direction: row-reverse; justify-content: flex-end; }
body.rtl .header,
body.rtl .header .left,
body.rtl .header .right{ flex-direction: row-reverse; }
body.rtl .collection-body th,
body.rtl .collection-body td,
body.rtl table th,
body.rtl table td{ text-align: right; }
body.rtl .content,
body.rtl .brand-head,
body.rtl .category-block,
body.rtl .card{ text-align: right; }

body.theme-dark img[src$="logo.svg"]{ filter: invert(1); }

/* Responsive --------------------------------------------------------- */
@media (max-width: 960px){
  .sidebar{ display: none; }
  .header{ position: sticky; top: 0; z-index: 10; }
  .content{ padding: 18px; }
  .stats-grid{ grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px){
  .stats-grid{ grid-template-columns: 1fr; }
  .header{ flex-direction: column; align-items: flex-start; height: auto; gap: 8px; padding: 10px; }
  .header .right{ width: 100%; flex-wrap: wrap; }
  .header .search-form input{ width: 100%; }
}

/* Library / Product detail ------------------------------------------ */
.library-topbar { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.brand-toggle { padding: 4px 10px; border: 1px solid var(--border); border-radius: 999px;
                background: var(--surface); }
.brand-toggle a { padding: 6px 12px; font-weight: 700; font-size: 13px; border-radius: 999px; }
.brand-toggle a.active { background: rgba(202,162,74,0.2); }
.brand-toggle .slash { color: var(--muted); margin: 0 4px; }
.library-search { display: flex; gap: 8px; flex: 1; min-width: 260px; }
.library-search input { flex: 1; padding: 9px 14px; border-radius: 999px;
                        border: 1px solid var(--border); background: var(--surface);
                        color: var(--text); font-size: 14px; }

.category-chips, .subcategory-pills {
  display: flex; gap: 8px; overflow-x: auto; padding: 4px 0; margin: 16px 0;
}
.chip-count { background: rgba(202,162,74,0.2); color: var(--gold);
              padding: 1px 8px; border-radius: 999px; font-size: 11px;
              margin-left: 6px; font-weight: 700; }
.pill { padding: 6px 14px; border: 1px solid var(--border); border-radius: 999px;
        background: var(--surface); font-size: 13px; color: var(--text); white-space: nowrap; }
.pill.active { border-color: var(--gold); background: rgba(202,162,74,0.14); }
.pill strong { color: var(--gold); margin-left: 4px; }

.product-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px; margin: 16px 0 40px;
}
.product-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden;
  transition: transform 0.08s ease, box-shadow 0.12s ease;
  display: flex; flex-direction: column;
}
.product-card:hover { transform: translateY(-3px); box-shadow: var(--shadow);
                      border-color: rgba(202,162,74,0.35); }
.product-card img { width: 100%; aspect-ratio: 1/1; object-fit: cover; background: var(--surface-2); }
.product-card-body { padding: 12px 14px; }
.product-title { font-weight: 700; font-size: 14px; margin-bottom: 2px;
                 white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.product-title-ar { font-size: 12px; color: var(--muted); direction: rtl;
                    text-align: right; margin-bottom: 4px; }
.product-meta { color: var(--muted); font-size: 11px; margin-bottom: 6px;
                white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.product-price { font-weight: 800; color: var(--gold); font-size: 14px; }
.product-rating { color: var(--muted); font-size: 12px; margin-top: 2px; }

.product-hero { display: grid; grid-template-columns: 1.2fr 1fr; gap: 32px; margin: 0 0 40px; }
.product-hero-gallery .primary { width: 100%; aspect-ratio: 1/1; object-fit: cover;
  border-radius: var(--radius-xl); border: 1px solid var(--border); background: var(--surface-2); }
.thumbs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 12px; }
.thumbs img { width: 100%; aspect-ratio: 1/1; object-fit: cover;
              border-radius: var(--radius-md); border: 1px solid var(--border); }
.product-hero-body h1 { font-size: 32px; margin: 6px 0 4px; }
.title-ar { direction: rtl; text-align: right; color: var(--muted);
            font-size: 16px; margin: 0 0 12px; }
.price-line { font-size: 22px; font-weight: 800; color: var(--gold); margin: 12px 0 6px; }
.rating-line { color: var(--muted); font-size: 14px; margin-bottom: 16px; }
.product-desc { line-height: 1.65; margin-bottom: 16px; }
.product-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }

.spec-table { width: 100%; border-collapse: collapse; }
.spec-table th, .spec-table td { padding: 8px 12px; text-align: left;
                                 border-bottom: 1px solid var(--border); font-size: 13px; }
.spec-table th { color: var(--muted); font-weight: 500; width: 35%; }
.stock-line { display: flex; justify-content: space-between; gap: 10px;
              font-size: 12px; padding: 2px 0; }
.stock-line strong { color: var(--gold); }

@media (max-width: 800px) {
  .product-hero { grid-template-columns: 1fr; }
}
