/* ============================================================
   DASHBOARD.CSS — Device Resale Portal
   Sidebar layout shared by partner + admin views
   ============================================================ */

html, body { height: 100%; }

body {
  display: flex;
  background: var(--cream);
  overflow: hidden;
}

/* ════════════════════════════════════════
   SIDEBAR
   ════════════════════════════════════════ */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100%;
  background: var(--ink);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow: hidden;
}

/* texture overlay */
.sidebar::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    -60deg,
    transparent,
    transparent 50px,
    rgba(255,255,255,0.012) 50px,
    rgba(255,255,255,0.012) 51px
  );
  pointer-events: none;
}

/* glow at bottom */
.sidebar::after {
  content: '';
  position: absolute;
  bottom: -60px; left: -40px;
  width: 300px; height: 300px;
  background: radial-gradient(circle, rgba(184,151,74,0.1) 0%, transparent 65%);
  pointer-events: none;
}

/* Brand */
.sidebar-brand {
  padding: 28px 24px 24px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  position: relative;
  z-index: 1;
}
.sidebar-brand-mark {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.sidebar-brand-icon {
  width: 32px; height: 32px;
  border: 1.5px solid var(--gold);
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sidebar-brand-icon svg {
  width: 16px; height: 16px;
  stroke: var(--gold);
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sidebar-brand-name {
  font-family: 'Playfair Display', serif;
  font-size: 1rem;
  font-weight: 500;
  color: #fff;
  white-space: nowrap;
}
.sidebar-brand-sub {
  font-size: 0.62rem;
  font-weight: 300;
  color: rgba(255,255,255,0.28);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding-left: 42px;
}

/* Nav */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px;
  position: relative;
  z-index: 1;
  scrollbar-width: none;
}
.sidebar-nav::-webkit-scrollbar { display: none; }

.nav-section-label {
  font-size: 0.6rem;
  font-weight: 500;
  color: rgba(255,255,255,0.22);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  padding: 16px 12px 8px;
}
.nav-section-label:first-child { padding-top: 8px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  color: rgba(255,255,255,0.5);
  font-size: 0.82rem;
  font-weight: 400;
  transition: background 0.15s, color 0.15s;
  position: relative;
  cursor: pointer;
}
.nav-item:hover {
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.85);
}
.nav-item.active {
  background: rgba(184,151,74,0.15);
  color: var(--gold-lt);
}
.nav-item.active .nav-icon { stroke: var(--gold-lt); }

.nav-icon {
  width: 16px; height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
  transition: stroke 0.15s;
}

.nav-badge {
  margin-left: auto;
  background: var(--gold);
  color: var(--ink);
  font-size: 0.6rem;
  font-weight: 600;
  min-width: 18px;
  height: 18px;
  border-radius: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

/* Sidebar footer */
.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid rgba(255,255,255,0.06);
  position: relative;
  z-index: 1;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background 0.15s;
}
.sidebar-user:hover { background: rgba(255,255,255,0.05); }

.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name {
  font-size: 0.8rem;
  font-weight: 500;
  color: rgba(255,255,255,0.85);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-role {
  font-size: 0.65rem;
  color: rgba(255,255,255,0.3);
}

.sidebar-signout {
  background: none;
  border: none;
  padding: 6px;
  border-radius: 6px;
  transition: background 0.15s;
}
.sidebar-signout:hover { background: rgba(255,255,255,0.07); }
.sidebar-signout svg {
  width: 14px; height: 14px;
  stroke: rgba(255,255,255,0.35);
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ════════════════════════════════════════
   MAIN LAYOUT
   ════════════════════════════════════════ */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* Topbar */
.topbar {
  height: 64px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 32px;
  gap: 16px;
  flex-shrink: 0;
}

.topbar-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.15rem;
  font-weight: 400;
  color: var(--ink);
}

.topbar-search {
  margin-left: auto;
  position: relative;
  width: 240px;
}
.topbar-search input {
  width: 100%;
  height: 36px;
  padding: 0 12px 0 36px;
  background: var(--cream);
  border: 1px solid var(--border-med);
  border-radius: var(--r-sm);
  font-size: 0.8rem;
  color: var(--ink);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.topbar-search input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(184,151,74,0.1);
}
.topbar-search svg {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  width: 14px; height: 14px;
  stroke: var(--ink-muted);
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-icon-btn {
  position: relative;
  width: 36px; height: 36px;
  border-radius: var(--r-sm);
  background: none;
  border: 1px solid var(--border-med);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.topbar-icon-btn:hover { background: var(--cream); }
.topbar-icon-btn svg {
  width: 16px; height: 16px;
  stroke: var(--ink-soft);
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.topbar-notif-dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 7px; height: 7px;
  background: var(--gold);
  border-radius: 50%;
  border: 2px solid var(--white);
}

/* Content Area */
.content {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-med) transparent;
}
.content::-webkit-scrollbar { width: 5px; }
.content::-webkit-scrollbar-thumb { background: var(--border-med); border-radius: 4px; }

/* Page header */
.page-header {
  margin-bottom: 28px;
}
.page-header h1 {
  font-size: 1.75rem;
  color: var(--ink);
  margin-bottom: 4px;
}
.page-header p {
  font-size: 0.83rem;
  color: var(--ink-muted);
}

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

/* Two-col layout */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

.three-col {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 20px;
}

/* Full-width row */
.full-row { margin-bottom: 20px; }

/* ── Device / Inventory Card ── */
.device-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 14px;
}
.device-card {
  padding: 18px 16px;
  border-radius: var(--r-md);
  background: var(--white);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: box-shadow 0.2s, transform 0.15s;
}
.device-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.device-card-icon {
  width: 40px; height: 40px;
  background: var(--cream);
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}
.device-card-icon svg {
  width: 20px; height: 20px;
  stroke: var(--ink-soft);
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.device-card-name {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 3px;
}
.device-card-sub {
  font-size: 0.72rem;
  color: var(--ink-muted);
  margin-bottom: 10px;
}
.device-card-price {
  font-family: 'DM Mono', monospace;
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--ink);
}
.device-card-price .per { font-size: 0.65rem; color: var(--ink-muted); }

/* ── Order activity ── */
.activity-list { display: flex; flex-direction: column; gap: 0; }
.activity-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}
.activity-item:last-child { border-bottom: none; }
.activity-item:hover { background: var(--cream); }
.activity-icon {
  width: 34px; height: 34px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.activity-icon svg {
  width: 16px; height: 16px;
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.activity-info { flex: 1; min-width: 0; }
.activity-title {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.activity-sub {
  font-size: 0.72rem;
  color: var(--ink-muted);
  margin-top: 1px;
}
.activity-meta { text-align: right; flex-shrink: 0; }
.activity-amount {
  font-family: 'DM Mono', monospace;
  font-size: 0.82rem;
  font-weight: 400;
  color: var(--ink);
}
.activity-time {
  font-size: 0.7rem;
  color: var(--ink-muted);
  margin-top: 2px;
}

/* ── Progress bar ── */
.progress-bar-wrap { margin-top: 6px; }
.progress-bar-track {
  height: 4px;
  background: var(--cream-dark);
  border-radius: 99px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--gold);
  transition: width 0.6s var(--ease);
}
.progress-bar-fill.green  { background: var(--green); }
.progress-bar-fill.blue   { background: var(--blue); }
.progress-bar-fill.red    { background: var(--red); }

/* ── Admin specific ── */
.admin-accent { --gold: #6366f1; --gold-lt: #818cf8; --gold-bg: rgba(99,102,241,0.08); --gold-border: rgba(99,102,241,0.25); }

.partner-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}
.partner-row:last-child { border-bottom: none; }
.partner-row:hover { background: var(--cream); }
.partner-info { flex: 1; }
.partner-name { font-size: 0.83rem; font-weight: 500; color: var(--ink); }
.partner-email { font-size: 0.72rem; color: var(--ink-muted); }
.partner-stats { display: flex; gap: 20px; text-align: right; }
.partner-stat-val { font-size: 0.83rem; font-weight: 500; color: var(--ink); font-family: 'DM Mono', monospace; }
.partner-stat-lbl { font-size: 0.65rem; color: var(--ink-muted); text-transform: uppercase; letter-spacing: 0.08em; }

/* ── Responsive ── */
@media (max-width: 1200px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
  .two-col, .three-col { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(-240px); width: 240px; }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .topbar-search { display: none; }
  .content { padding: 20px 16px; }
  .mobile-menu-btn { display: flex !important; }
}

.mobile-menu-btn {
  display: none;
  width: 36px; height: 36px;
  border-radius: var(--r-sm);
  background: none;
  border: 1px solid var(--border-med);
  align-items: center;
  justify-content: center;
}
.mobile-menu-btn svg {
  width: 16px; height: 16px;
  stroke: var(--ink-soft);
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Mobile overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 99;
}
.sidebar-overlay.active { display: block; }
