/* Professional ecommerce-like UI skin (full-width + top nav)
   Keeps existing class names so the app logic stays intact.
*/

:root{
  --page-bg:#f5f5f5;
  --surface:#ffffff;
  --surface-2:#fafafa;
  --text:#111827;
  --text-muted:#6b7280;
  --border:#e5e7eb;
  --border-2:#d1d5db;
  --accent:#2563eb;
  --accent-2:#0ea5e9;
  --accent-soft:rgba(37,99,235,.12);
  --success:#16a34a;
  --warning:#d97706;
  --danger:#dc2626;
  --radius:14px;
  --radius-lg:18px;
  --shadow:0 8px 24px rgba(0,0,0,.08);
  --shadow-soft:0 2px 10px rgba(0,0,0,.06);
  --transition:160ms ease;
}

[data-theme="dark"]{
  --accent:#60a5fa;
  --accent-2:#38bdf8;
  --accent-soft:rgba(96,165,250,.18);

  --page-bg:#0b1220;
  --surface:#0f172a;
  --surface-2:#111c33;
  --text:#e5e7eb;
  --text-muted:#9ca3af;
  --border:rgba(148,163,184,.18);
  --border-2:rgba(148,163,184,.28);
  --shadow:0 10px 30px rgba(0,0,0,.35);
  --shadow-soft:0 4px 14px rgba(0,0,0,.28);
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family:"Vazirmatn",system-ui,-apple-system,"Segoe UI",Roboto,Arial,sans-serif;
  background:var(--page-bg);
  color:var(--text);
}

.shell{width:100%;min-height:100vh;background:var(--page-bg)}
.shell-inner{min-height:100vh;display:flex;flex-direction:column}

header{
  position:sticky;
  top:0;
  z-index:50;
  background:var(--surface);
  border-bottom:1px solid var(--border);
  padding:12px 16px;
  display:flex;
  align-items:center;
  gap:14px;
}

.brand{display:flex;align-items:center;gap:10px;min-width:190px}
.brand-logo{
  width:40px;height:40px;border-radius:12px;
  background:linear-gradient(135deg,var(--accent),var(--accent-2));
  display:flex;align-items:center;justify-content:center;
  box-shadow:var(--shadow-soft);
}
.brand-logo span{color:#fff;font-weight:800;letter-spacing:.03em}
.brand-text{display:flex;flex-direction:column;gap:2px}
.brand-title{font-weight:800;font-size:15px;line-height:1.2}
.brand-sub{font-size:11px;color:var(--text-muted)}

.header-search{flex:1;display:flex;align-items:center}
.header-search input{
  width:100%;
  height:42px;
  border:1px solid var(--border);
  background:var(--surface-2);
  border-radius:999px;
  padding:0 14px;
  font-size:13px;
  outline:none;
  transition:border-color var(--transition), box-shadow var(--transition), background var(--transition);
}
.header-search input:focus{
  border-color:rgba(239,68,68,.55);
  box-shadow:0 0 0 4px rgba(239,68,68,.14);
  background:var(--surface);
}

.top-controls{display:flex;align-items:center;gap:10px}
.pill-toggle{
  display:inline-flex;
  background:var(--surface-2);
  border:1px solid var(--border);
  border-radius:999px;
  padding:3px;
  gap:4px;
}
.pill-toggle button{
  border:0;
  background:transparent;
  color:var(--text-muted);
  font-size:11px;
  padding:6px 10px;
  border-radius:999px;
  cursor:pointer;
  transition:background var(--transition), color var(--transition), transform 120ms ease;
  display:inline-flex;
  align-items:center;
  gap:6px;
  white-space:nowrap;
}
.pill-toggle button.active{
  background:var(--surface);
  color:var(--text);
  box-shadow:var(--shadow-soft);
  transform:translateY(-1px);
}

.user-chip{
  display:flex;
  align-items:center;
  gap:10px;
  padding:6px 10px;
  border-radius:999px;
  border:1px solid var(--border);
  background:var(--surface-2);
  cursor:pointer;
}
.user-avatar{
  width:28px;height:28px;border-radius:999px;
  background:linear-gradient(135deg,var(--accent-2),#8b5cf6);
  color:#fff;font-weight:700;font-size:12px;
  display:flex;align-items:center;justify-content:center;
}
.user-name{font-weight:700;font-size:12px;line-height:1.1}
.user-role{font-size:11px;color:var(--text-muted);line-height:1.1}

main{display:flex;flex-direction:column;min-height:0}

nav{
  position:sticky;
  top:66px;
  z-index:40;
  background:var(--surface);
  border-bottom:1px solid var(--border);
  padding:8px 12px;
  display:flex;
  align-items:center;
  gap:10px;
  overflow-x:auto;
  -webkit-overflow-scrolling:touch;
}
nav::-webkit-scrollbar{height:6px}
nav::-webkit-scrollbar-thumb{background:rgba(0,0,0,.18);border-radius:999px}
[data-theme="dark"] nav::-webkit-scrollbar-thumb{background:rgba(255,255,255,.16)}

.nav-title,.nav-separator,.nav-footer{display:none}
.nav-group{display:flex;align-items:center;gap:8px;flex:0 0 auto}
#accountNavGroup{margin-left:auto}
.nav-item{
  border:1px solid transparent;
  background:var(--surface-2);
  color:var(--text);
  padding:8px 12px;
  border-radius:999px;
  cursor:pointer;
  font-size:12px;
  display:inline-flex;
  align-items:center;
  gap:8px;
  white-space:nowrap;
  transition:background var(--transition), border-color var(--transition), transform 120ms ease;
}
.nav-item:hover{border-color:var(--border-2);transform:translateY(-1px)}
.nav-item.active{
  background:var(--accent-soft);
  border-color:rgba(239,68,68,.35);
}

.content{
  flex:1;
  min-height:0;
  overflow:auto;
  padding:16px;
}
.content > .view{max-width:1280px;margin:0 auto}

.view{display:none;animation:fadeIn 180ms ease-out}
.view.active{display:block}
@keyframes fadeIn{from{opacity:0;transform:translateY(4px)}to{opacity:1;transform:translateY(0)}}

.card{
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:var(--radius-lg);
  box-shadow:var(--shadow-soft);
  padding:16px;
}
.card.hidden{display:none}

.card-header{display:flex;justify-content:space-between;align-items:flex-start;gap:12px;margin-bottom:12px}
.card-title{font-size:16px;font-weight:800}
.card-subtitle{font-size:12px;color:var(--text-muted);margin-top:2px}

.grid{display:grid;grid-template-columns:1fr;gap:14px;width:100%}

.btn{
  border:0;
  background:var(--accent);
  color:#fff;
  border-radius:12px;
  padding:10px 12px;
  cursor:pointer;
  font-weight:700;
  font-size:12px;
  display:inline-flex;
  align-items:center;
  gap:8px;
  box-shadow:var(--shadow-soft);
  transition:transform 120ms ease, box-shadow var(--transition), opacity var(--transition);
}
.btn:hover{transform:translateY(-1px)}
.btn:active{transform:translateY(0)}
.btn-ghost{background:transparent;color:var(--text);border:1px solid var(--border);box-shadow:none}
.btn-ghost:hover{border-color:var(--border-2);box-shadow:var(--shadow-soft)}
.actions{display:flex;gap:10px;flex-wrap:wrap}

.pill,.chip{
  display:inline-flex;
  align-items:center;
  gap:6px;
  border:1px solid var(--border);
  background:var(--surface-2);
  color:var(--text);
  border-radius:999px;
  padding:6px 10px;
  font-size:11px;
}
.muted{color:var(--text-muted);font-size:12px}

.stack{display:flex;flex-direction:column;gap:10px}
.stack-row{display:flex;flex-wrap:wrap;gap:10px}
.code{border:1px dashed var(--border-2);background:var(--surface-2);padding:10px 12px;border-radius:12px;font-size:12px}

form{display:flex;flex-direction:column;gap:10px}
.form-row{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}
@media (max-width:720px){.form-row{grid-template-columns:1fr}}
label{font-size:12px;color:var(--text-muted)}
input,textarea,select{
  width:100%;
  border:1px solid var(--border);
  background:var(--surface);
  border-radius:12px;
  padding:10px 12px;
  font-size:13px;
  color:var(--text);
  outline:none;
  transition:border-color var(--transition), box-shadow var(--transition), background var(--transition);
}
textarea{min-height:110px;resize:vertical}
input:focus,textarea:focus,select:focus{
  border-color:rgba(37,99,235,.55);
  box-shadow:0 0 0 4px rgba(37,99,235,.14);
}

.alert{border-radius:12px;padding:10px 12px;border:1px solid var(--border);background:var(--surface-2);font-size:12px}
.alert-success{border-color:rgba(22,163,74,.35);background:rgba(22,163,74,.08)}
.alert-error{border-color:rgba(220,38,38,.35);background:rgba(220,38,38,.08)}
.alert-warning{border-color:rgba(217,119,6,.35);background:rgba(217,119,6,.08)}

.badge{display:inline-flex;align-items:center;gap:8px;border-radius:999px;padding:6px 10px;font-size:11px;font-weight:700;border:1px solid var(--border);background:var(--surface-2)}
.status-indicator{width:8px;height:8px;border-radius:999px}
.status-green{background:var(--success);box-shadow:0 0 0 4px rgba(22,163,74,.18)}
.status-yellow{background:var(--warning);box-shadow:0 0 0 4px rgba(217,119,6,.18)}
.status-red{background:var(--danger);box-shadow:0 0 0 4px rgba(220,38,38,.18)}
.badge-success{border-color:rgba(22,163,74,.30)}
.badge-warning{border-color:rgba(217,119,6,.30)}
.badge-danger{border-color:rgba(220,38,38,.30)}

.list{
  display:grid;
  grid-template-columns:repeat(auto-fill,minmax(240px,1fr));
  gap:12px;
  margin-top:10px;
}
.list-item{
  border:1px solid var(--border);
  background:var(--surface);
  border-radius:var(--radius);
  padding:12px;
  box-shadow:var(--shadow-soft);
  cursor:pointer;
  transition:transform 120ms ease, box-shadow var(--transition), border-color var(--transition);
  display:flex;
  flex-direction:column;
  gap:10px;
  min-height:140px;
}
.list-item:hover{transform:translateY(-2px);box-shadow:var(--shadow)}
.list-main{display:flex;flex-direction:column;gap:6px}
.list-title{font-weight:900;font-size:14px}
.list-meta{font-size:12px;color:var(--text-muted);line-height:1.5}
.list-right{margin-top:auto;display:flex;justify-content:flex-end}

.download-grid{display:grid;grid-template-columns:minmax(0,1.2fr) minmax(0,0.8fr);gap:14px}
@media (max-width:900px){.download-grid{grid-template-columns:1fr}}
.download-meta{border:1px solid var(--border);border-radius:12px;padding:10px 12px;background:var(--surface-2)}
.download-meta-row{display:flex;justify-content:space-between;gap:10px;padding:6px 0;border-bottom:1px dashed var(--border)}
.download-meta-row:last-child{border-bottom:0}
.download-note{display:flex;align-items:center;gap:10px;padding:10px 12px;border-radius:12px;background:rgba(37,99,235,.08);border:1px solid rgba(37,99,235,.22)}

@media (max-width:920px){
  header{flex-wrap:wrap}
  .brand{min-width:auto}
  .header-search{order:3;flex:1 1 100%}
  nav{top:104px}
}


/* --- Thumbnails in lists (posts/products) --- */
.list-item{align-items:center}
.list-thumb {
    width: 270px;
    height: 56px;
    flex: 0 0 106px;
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid var(--border);
    background: var(--surface-2);
    display: flex;
    align-items: center;
    justify-content: center;
}
.list-thumb img{width:100%;height:100%;object-fit:cover;display:block}

@media (max-width:720px){
  .list-thumb{width:120px;flex:0 0 90px}
}

/* --- Auth (login/register) polish --- */
.auth-card{
  max-width:520px;
  margin:0 auto;
}
.auth-card .form-row{
  grid-template-columns:1fr;
}
@media (min-width:760px){
  .auth-card .form-row{grid-template-columns:1fr 1fr}
}
.auth-switch{
  margin-top:12px;
  text-align:center;
}

/* --- Admin polish --- */
#adminOverview.stack{
  display:grid;
  grid-template-columns:repeat(12,minmax(0,1fr));
  gap:12px;
}
#adminOverview .metric-card{
  grid-column:span 6;
}
@media (min-width:900px){
  #adminOverview .metric-card{grid-column:span 3}
}

/* --- Tickets redesign --- */
#ticketsMainGrid{
  grid-template-columns: minmax(0,1fr);
}
@media (min-width:980px){
  #ticketsMainGrid{
    grid-template-columns: minmax(0,420px) minmax(0,1fr);
    align-items:start;
  }
}
#ticketsList .list-item{
  padding:14px;
}
#ticketDetailMessages .list-item{
  padding:14px;
}
.ticket-bubble{
  background:var(--surface-2);
  border:1px solid var(--border);
  border-radius:16px;
  padding:12px 14px;
}
.ticket-bubble.me{
  background:var(--accent-soft);
  border-color:rgba(239,68,68,.18);
}
.ticket-meta{
  display:flex;
  gap:10px;
  align-items:center;
  color:var(--text-muted);
  font-size:12px;
  margin-top:6px;
}

/* --- Better Persian typography + consistent header --- */
html[dir="rtl"] body{
  font-family: "Vazirmatn", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  letter-spacing:0;
}
html[dir="rtl"] .brand-text{align-items:flex-start}
html[dir="rtl"] .header-search input{text-align:right}
html[dir="rtl"] .pill-toggle{direction:ltr} /* keep pills consistent */
html[dir="rtl"] header{gap:12px}
html[dir="rtl"] .nav-bar{direction:rtl}

.ticket-msg{justify-content:flex-start;background:transparent;border:0;padding:0}
.ticket-msg .ticket-bubble{width:100%}
.ticket-row{
  display:flex;
  justify-content:space-between;
  gap:12px;
  align-items:baseline;
  margin-bottom:6px;
}
.ticket-who{font-weight:700}
.ticket-time{font-size:12px;color:var(--text-muted)}
.ticket-text{white-space:pre-wrap;line-height:1.7}

/* --- Admin panel --- */
.admin-wrap{display:flex;flex-direction:column;gap:14px}
.admin-topbar{
  display:flex;flex-wrap:wrap;
  align-items:flex-end;justify-content:space-between;
  gap:12px;
  padding:10px 0;
  border-bottom:1px solid var(--border);
}
.admin-title{font-size:18px;font-weight:900}
.admin-subtitle{color:var(--text-muted);font-size:12px;margin-top:4px}
.admin-actions{display:flex;flex-wrap:wrap;gap:8px}
.admin-actions .btn{padding:8px 12px;border-radius:12px}
.admin-stats{
  display:grid;
  grid-template-columns:repeat(12,minmax(0,1fr));
  gap:12px;
}
.admin-stat{
  grid-column:span 6;
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:18px;
  padding:14px;
  text-align:left;
  box-shadow:var(--shadow-soft);
  cursor:pointer;
  transition:transform .08s ease, box-shadow .08s ease;
}
.admin-stat:hover{transform:translateY(-1px);box-shadow:var(--shadow)}
.admin-stat .k{color:var(--text-muted);font-size:12px}
.admin-stat .v{font-size:22px;font-weight:900;margin-top:6px}
.admin-stat .hint{font-size:12px;color:var(--text-muted);margin-top:6px}
@media (min-width:900px){
  .admin-stat{grid-column:span 3}
}
.admin-section{
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:18px;
  padding:14px;
  box-shadow:var(--shadow-soft);
}
.admin-table{
  width:100%;
  border-collapse:separate;
  border-spacing:0;
  overflow:hidden;
  border:1px solid var(--border);
  border-radius:14px;
}
.admin-table th, .admin-table td{
  padding:10px 12px;
  border-bottom:1px solid var(--border);
  font-size:13px;
}
.admin-table th{background:var(--surface-2);text-align:left}
.admin-table tr:last-child td{border-bottom:0}
html[dir="rtl"] .admin-table th, html[dir="rtl"] .admin-table td{text-align:right}

/* Detail hero image (post/product) */
.detail-hero{
  width:100%;
  max-height:320px;
  object-fit:cover;
  border-radius:18px;
  border:1px solid var(--border);
  box-shadow:var(--shadow-soft);
  margin-bottom:12px;
}

html[dir="rtl"] header{flex-direction:row-reverse}
html[dir="rtl"] .top-controls{flex-direction:row-reverse}
html[dir="rtl"] .nav-links{flex-direction:row-reverse}

/* Admin internal panel */
.admin-panel{display:flex;flex-direction:column;gap:12px}
.admin-panel-head{padding:10px 0;border-bottom:1px solid var(--border)}
.admin-panel-head-row{display:flex;align-items:center;justify-content:space-between;gap:10px;flex-wrap:wrap}
.admin-panel-head .t{font-weight:900;font-size:16px}
.admin-panel-head .s{color:var(--text-muted);font-size:12px;margin-top:4px}
.admin-panel-actions{display:flex;gap:8px;flex-wrap:wrap}
.admin-panel-body{padding-top:12px}

/* Tables used by admin (legacy .table) */
.table-wrap{overflow:auto;border:1px solid var(--border);border-radius:14px;background:var(--surface);box-shadow:var(--shadow-soft)}
.table{width:100%;border-collapse:separate;border-spacing:0;min-width:780px}
.table th,.table td{padding:10px 12px;border-bottom:1px solid var(--border);font-size:13px;vertical-align:middle}
.table th{background:var(--surface-2);text-align:left;font-weight:800}
.table tr:last-child td{border-bottom:0}
html[dir="rtl"] .table th, html[dir="rtl"] .table td{text-align:right}

/* Price + status layout on list items */
.list-right{display:flex;gap:10px;align-items:center;justify-content:flex-end;direction:ltr}
.price-pill{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:6px 10px;
  border-radius:999px;
  border:1px solid var(--border);
  background:var(--surface-2);
  font-size:12px;
  font-weight:800;
  min-width:64px;
}

/* Auth checkboxes */
.auth-checks{display:flex;flex-direction:column;gap:10px;margin:12px 0}
.auth-check{display:flex;align-items:center;gap:10px;font-size:13px;color:var(--text)}
.auth-check input{width:16px;height:16px;accent-color:var(--accent)}
