/**
 * Resonance Threads — Role-Based Dashboard Layout
 * Covers: my-dashboard.php, creator-dashboard.php, admin/dashboard.php
 * Responsive: desktop sidebar + main, tablet collapsible, mobile bottom nav
 */

/* ═══════════════════════════════════════════════════════════════
   DASHBOARD ROOT
═══════════════════════════════════════════════════════════════ */
.rs-dashboard {
  display: flex;
  min-height: calc(100vh - var(--rt-nav-h));
  background: transparent;
  position: relative;
  z-index: 1;
}

/* ═══════════════════════════════════════════════════════════════
   SIDEBAR
═══════════════════════════════════════════════════════════════ */
.rs-dash-sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--rt-glass, rgba(22,22,34,0.72));
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-right: 1px solid var(--rt-glass-border, rgba(255,255,255,0.10));
  display: flex;
  flex-direction: column;
  position: sticky;
  top: var(--rt-nav-h);
  height: calc(100vh - var(--rt-nav-h));
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,78,205,0.3) transparent;
  transition: width 0.25s ease, transform 0.25s ease;
  z-index: 50;
}
.rs-dash-sidebar::-webkit-scrollbar { width: 3px; }
.rs-dash-sidebar::-webkit-scrollbar-thumb { background: rgba(255,78,205,0.3); border-radius: 3px; }

[data-theme="light"] .rs-dash-sidebar {
  background: rgba(255,255,255,0.85);
  border-right-color: rgba(0,0,0,0.08);
  box-shadow: 2px 0 12px rgba(0,0,0,0.04);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

/* Sidebar header */
.rs-dash-sidebar-header {
  padding: 20px 16px 12px;
  border-bottom: 1px solid var(--rt-border);
  flex-shrink: 0;
}
.rs-dash-role-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 20px;
  background: rgba(255,78,205,0.12); color: #ff4ecd;
  font-size: 10px; font-weight: 800; letter-spacing: 1px;
  text-transform: uppercase; margin-bottom: 8px;
}
.rs-dash-user-name {
  font-size: 14px; font-weight: 800; color: var(--rt-text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rs-dash-user-email {
  font-size: 11px; color: var(--rt-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-top: 2px;
}

/* Sidebar nav */
.rs-dash-nav { padding: 8px 0; flex: 1; }
.rs-dash-nav-section { padding: 12px 16px 4px; font-size: 9px; font-weight: 800; letter-spacing: 1.5px; text-transform: uppercase; color: var(--rt-muted-2); }
.rs-dash-nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 16px; font-size: 13px; font-weight: 600;
  color: var(--rt-text-2); text-decoration: none;
  border-radius: 0; transition: var(--rt-trans);
  cursor: pointer; background: transparent; border: none;
  width: 100%; text-align: left; font-family: inherit;
  position: relative;
}
.rs-dash-nav-item:hover {
  background: rgba(255,78,205,0.08);
  color: var(--rt-pink);
}
.rs-dash-nav-item.active {
  background: rgba(255,78,205,0.12);
  color: var(--rt-pink);
  font-weight: 700;
}
.rs-dash-nav-item.active::before {
  content: '';
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px; background: var(--rt-pink); border-radius: 0 2px 2px 0;
}
.rs-dash-nav-icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.rs-dash-nav-badge {
  margin-left: auto; background: var(--rt-pink); color: #000;
  font-size: 9px; font-weight: 800; padding: 2px 6px;
  border-radius: 10px; min-width: 18px; text-align: center;
}

/* ═══════════════════════════════════════════════════════════════
   MAIN CONTENT AREA
═══════════════════════════════════════════════════════════════ */
.rs-dash-main {
  flex: 1;
  min-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ═══════════════════════════════════════════════════════════════
   DASHBOARD HEADER
═══════════════════════════════════════════════════════════════ */
.rs-dash-header {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px;
}
.rs-dash-title {
  font-size: clamp(20px, 3vw, 28px); font-weight: 900;
  color: var(--rt-text); letter-spacing: 1px;
}
.rs-dash-subtitle { font-size: 13px; color: var(--rt-muted); margin-top: 2px; }
.rs-dash-header-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ═══════════════════════════════════════════════════════════════
   STAT CARDS GRID
═══════════════════════════════════════════════════════════════ */
.rs-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}
.rs-stat-card {
  background: var(--rt-glass, rgba(22,22,34,0.72));
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--rt-glass-border, rgba(255,255,255,0.10));
  border-radius: var(--rt-radius-lg);
  padding: 18px 20px;
  display: flex; flex-direction: column; gap: 6px;
  transition: var(--rt-trans);
  position: relative; overflow: hidden;
}
.rs-stat-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0;
  height: 2px; background: var(--rt-grad);
}
.rs-stat-card:hover { border-color: rgba(255,78,205,0.2); transform: translateY(-2px); box-shadow: 0 8px 28px rgba(0,0,0,0.25); }
.rs-stat-icon { font-size: 22px; margin-bottom: 4px; }
.rs-stat-value { font-size: 26px; font-weight: 900; color: var(--rt-text); line-height: 1; }
.rs-stat-label { font-size: 11px; font-weight: 600; color: var(--rt-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.rs-stat-change { font-size: 11px; font-weight: 700; }
.rs-stat-change.up   { color: #4ade80; }
.rs-stat-change.down { color: #ef4444; }

[data-theme="light"] .rs-stat-card { background: rgba(255,255,255,0.82); box-shadow: 0 2px 12px rgba(0,0,0,0.05); }

/* ═══════════════════════════════════════════════════════════════
   CONTENT PANELS
═══════════════════════════════════════════════════════════════ */
.rs-dash-panel {
  background: var(--rt-glass, rgba(22,22,34,0.72));
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--rt-glass-border, rgba(255,255,255,0.10));
  border-radius: var(--rt-radius-lg);
  overflow: hidden;
}
[data-theme="light"] .rs-dash-panel { background: rgba(255,255,255,0.82); box-shadow: 0 2px 12px rgba(0,0,0,0.05); }

.rs-dash-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--rt-border);
}
.rs-dash-panel-title { font-size: 13px; font-weight: 800; color: var(--rt-text); letter-spacing: 0.5px; }
.rs-dash-panel-action { font-size: 11px; color: var(--rt-pink); text-decoration: none; font-weight: 700; }
.rs-dash-panel-action:hover { text-decoration: underline; }

.rs-dash-panel-body {
  padding: 16px 18px;
  overflow-x: auto;
  overflow-y: auto;
  max-height: 400px;
  scrollbar-width: thin;
}
.rs-dash-panel-body::-webkit-scrollbar { width: 4px; height: 4px; }
.rs-dash-panel-body::-webkit-scrollbar-thumb { background: rgba(255,78,205,0.3); border-radius: 3px; }

/* ═══════════════════════════════════════════════════════════════
   NOTIFICATIONS PANEL
═══════════════════════════════════════════════════════════════ */
.rs-notif-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--rt-border);
}
.rs-notif-item:last-child { border-bottom: none; }
.rs-notif-item.unread { background: rgba(255,78,205,0.04); margin: 0 -18px; padding: 10px 18px; }
.rs-notif-icon { font-size: 18px; flex-shrink: 0; margin-top: 1px; }
.rs-notif-body { flex: 1; min-width: 0; }
.rs-notif-msg { font-size: 12px; color: var(--rt-text); line-height: 1.4; }
.rs-notif-time { font-size: 10px; color: var(--rt-muted); margin-top: 2px; }
.rs-notif-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--rt-pink); flex-shrink: 0; margin-top: 5px; }

/* ═══════════════════════════════════════════════════════════════
   ORDERS TABLE
═══════════════════════════════════════════════════════════════ */
.rs-orders-table { width: 100%; border-collapse: collapse; min-width: 500px; }
.rs-orders-table th { padding: 8px 12px; text-align: left; font-size: 10px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; color: var(--rt-muted); border-bottom: 1px solid var(--rt-border-2); white-space: nowrap; }
.rs-orders-table td { padding: 10px 12px; font-size: 12px; color: var(--rt-text); border-bottom: 1px solid var(--rt-border); vertical-align: middle; }
.rs-orders-table tr:hover td { background: rgba(255,78,205,0.04); }
.rs-orders-table tr:last-child td { border-bottom: none; }

/* Status pills */
.rs-status { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 20px; font-size: 10px; font-weight: 700; white-space: nowrap; }
.rs-status-pending    { background: rgba(245,158,11,0.15); color: #f59e0b; }
.rs-status-confirmed  { background: rgba(79,220,255,0.12); color: #4fdcff; }
.rs-status-processing { background: rgba(168,85,247,0.12); color: #a855f7; }
.rs-status-shipped    { background: rgba(59,130,246,0.12); color: #3b82f6; }
.rs-status-delivered  { background: rgba(74,222,128,0.12); color: #4ade80; }
.rs-status-cancelled  { background: rgba(239,68,68,0.12);  color: #ef4444; }
.rs-status-paid       { background: rgba(74,222,128,0.12); color: #4ade80; }
.rs-status-unpaid     { background: rgba(239,68,68,0.12);  color: #ef4444; }

/* ═══════════════════════════════════════════════════════════════
   QUICK ACTIONS GRID
═══════════════════════════════════════════════════════════════ */
.rs-quick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
}
.rs-quick-btn {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 16px 10px; border-radius: var(--rt-radius);
  background: var(--rt-surface-2); border: 1px solid var(--rt-border-2);
  color: var(--rt-text); text-decoration: none; font-size: 11px; font-weight: 700;
  text-align: center; cursor: pointer; transition: var(--rt-trans);
  font-family: inherit;
}
.rs-quick-btn:hover { border-color: var(--rt-pink); color: var(--rt-pink); background: rgba(255,78,205,0.08); transform: translateY(-2px); }
.rs-quick-btn-icon { font-size: 24px; }

/* ═══════════════════════════════════════════════════════════════
   MOBILE BOTTOM NAV (replaces sidebar on mobile)
═══════════════════════════════════════════════════════════════ */
.rs-dash-bottom-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  background: rgba(0,0,0,0.95);
  border-top: 1px solid rgba(255,78,205,0.2);
  backdrop-filter: blur(16px);
  z-index: 100;
  padding: 0 0 env(safe-area-inset-bottom);
}
[data-theme="light"] .rs-dash-bottom-nav {
  background: rgba(255,255,255,0.97);
  border-top-color: rgba(0,0,0,0.1);
}
.rs-dash-bottom-nav-inner {
  display: flex; align-items: stretch;
  height: 56px;
}
.rs-dash-bottom-item {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 3px; padding: 6px 4px;
  color: var(--rt-muted); text-decoration: none; font-size: 9px;
  font-weight: 700; cursor: pointer; background: transparent;
  border: none; font-family: inherit; transition: var(--rt-trans);
  min-width: 0;
}
.rs-dash-bottom-item:hover, .rs-dash-bottom-item.active { color: var(--rt-pink); }
.rs-dash-bottom-icon { font-size: 18px; line-height: 1; }
.rs-dash-bottom-label { font-size: 9px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE BREAKPOINTS
═══════════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
  .rs-dash-sidebar { width: 200px; }
  .rs-stat-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}

@media (max-width: 768px) {
  /* Hide sidebar, show bottom nav */
  .rs-dash-sidebar { display: none; }
  .rs-dash-bottom-nav { display: block; }
  .rs-dashboard { flex-direction: column; }
  .rs-dash-main {
    padding: 16px;
    padding-bottom: calc(56px + env(safe-area-inset-bottom) + 16px);
    gap: 16px;
  }
  .rs-stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .rs-stat-card { padding: 14px 16px; }
  .rs-stat-value { font-size: 22px; }
  .rs-dash-panel-body { max-height: 300px; }
  .rs-quick-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 480px) {
  .rs-stat-grid { grid-template-columns: repeat(2, 1fr); }
  .rs-quick-grid { grid-template-columns: repeat(2, 1fr); }
  .rs-dash-main { padding: 12px; }
  .rs-dash-title { font-size: 20px; }
}

/* ═══════════════════════════════════════════════════════════════
   SIDEBAR TOGGLE (tablet — hamburger to show/hide sidebar)
═══════════════════════════════════════════════════════════════ */
.rs-dash-sidebar-toggle {
  display: none;
  position: fixed; top: calc(var(--rt-nav-h) + 12px); left: 12px;
  width: 36px; height: 36px; border-radius: 8px;
  background: var(--rt-surface); border: 1px solid var(--rt-border-2);
  color: var(--rt-text); font-size: 16px; cursor: pointer;
  align-items: center; justify-content: center;
  z-index: 60; transition: var(--rt-trans);
}
.rs-dash-sidebar-toggle:hover { border-color: var(--rt-pink); color: var(--rt-pink); }

@media (min-width: 769px) and (max-width: 1024px) {
  .rs-dash-sidebar-toggle { display: flex; }
  .rs-dash-sidebar.collapsed { width: 0; overflow: hidden; border: none; }
  .rs-dash-main { padding-left: 60px; }
}

/* ═══════════════════════════════════════════════════════════════
   ROLE-SPECIFIC ACCENT COLORS
═══════════════════════════════════════════════════════════════ */
.rs-role-admin    .rs-dash-role-badge { background: rgba(239,68,68,0.12);  color: #ef4444; }
.rs-role-operator .rs-dash-role-badge { background: rgba(59,130,246,0.12); color: #3b82f6; }
.rs-role-designer .rs-dash-role-badge { background: rgba(168,85,247,0.12); color: #a855f7; }
.rs-role-customer .rs-dash-role-badge { background: rgba(255,78,205,0.12); color: #ff4ecd; }
.rs-role-creator  .rs-dash-role-badge { background: rgba(245,158,11,0.12); color: #f59e0b; }
