/* ==========================================================================
   Dashboard layout — sidebar, topbar, stat cards, tables, modal, charts
   Extends the design tokens defined in /style.css
   ========================================================================== */

.dash-body {
  background: var(--color-bg-alt);
}

.dash-layout {
  display: flex;
  min-height: 100vh;
  align-items: stretch;
}

/* Sidebar
   ========================================================================== */
.dash-sidebar {
  width: 240px;
  flex-shrink: 0;
  background: #ffffff;
  border-right: 1px solid var(--color-border);
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.dash-logo {
  font-size: 16px;
}

.dash-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.dash-nav-link {
  display: block;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
  color: var(--color-text-muted);
  transition: background var(--transition), color var(--transition);
}

.dash-nav-link:hover {
  background: var(--color-bg-alt);
  color: var(--color-text);
}

.dash-nav-link.active {
  background: rgba(124, 58, 237, 0.08);
  color: var(--color-accent);
}

.dash-user {
  border-top: 1px solid var(--color-border);
  padding-top: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dash-user-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 14px;
  min-width: 0;
}

.dash-user-info strong {
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dash-plan-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 999px;
  width: fit-content;
  background: var(--color-bg-alt);
  color: var(--color-text-muted);
}

.dash-plan-pro,
.dash-plan-business {
  background: rgba(124, 58, 237, 0.1);
  color: var(--color-accent);
}

/* Main area
   ========================================================================== */
.dash-main {
  flex: 1;
  min-width: 0;
}

.dash-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 24px 32px;
  background: #ffffff;
  border-bottom: 1px solid var(--color-border);
}

.dash-topbar h1 {
  font-size: 22px;
  margin: 0;
}

.dash-content {
  padding: 32px;
  max-width: 1100px;
}

/* Stat cards
   ========================================================================== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: #ffffff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stat-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
}

.stat-value {
  font-size: 28px;
  font-weight: 800;
}

/* Sections
   ========================================================================== */
.dash-section {
  background: #ffffff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  padding: 24px;
  margin-bottom: 24px;
}

.dash-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.dash-section-head h2 {
  font-size: 16px;
  margin: 0;
}

/* Table
   ========================================================================== */
.table-wrap {
  overflow-x: auto;
}

.dash-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.dash-table th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

.dash-table td {
  padding: 12px;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}

.dash-table tr:last-child td {
  border-bottom: none;
}

.dash-table .qr-name {
  font-weight: 600;
}

.dash-table .qr-meta {
  color: var(--color-text-muted);
  font-size: 12px;
  margin-top: 2px;
}

.dash-table .qr-meta a {
  color: var(--color-text-muted);
}

.dash-empty {
  text-align: center;
  color: var(--color-text-muted);
  padding: 32px 0;
}

/* Status badges
   ========================================================================== */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  text-transform: capitalize;
  white-space: nowrap;
}

.status-active {
  background: rgba(34, 197, 94, 0.12);
  color: #15803d;
}

.status-paused {
  background: rgba(234, 179, 8, 0.14);
  color: #92660b;
}

.status-expired {
  background: rgba(220, 38, 38, 0.1);
  color: #dc2626;
}

/* Row actions
   ========================================================================== */
.row-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  flex-wrap: wrap;
  white-space: nowrap;
}

.row-actions .link-btn,
.row-actions a.link-btn {
  font-size: 13px;
}

.link-btn {
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
  font-weight: 600;
  font-size: 14px;
  color: var(--color-accent);
  cursor: pointer;
  text-decoration: none;
}

.link-btn:hover {
  text-decoration: underline;
}

.link-btn.danger {
  color: #dc2626;
}

/* Filters
   ========================================================================== */
.dash-filters {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.dash-filters input,
.dash-filters select {
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  background: #ffffff;
  color: var(--color-text);
}

.dash-filters input {
  flex: 1;
  min-width: 180px;
}

/* Modal
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 10, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 1000;
}

.modal-overlay.hidden {
  display: none;
}

.modal-content {
  background: #ffffff;
  border-radius: var(--radius-card);
  padding: 28px;
  max-width: 480px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-content h2 {
  margin: 0 0 16px;
  font-size: 18px;
}

.modal-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

.modal-actions .btn {
  flex: 1;
}

/* Charts / top lists
   ========================================================================== */
.chart-card {
  background: #ffffff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  padding: 24px;
  margin-bottom: 24px;
}

.chart-card h2 {
  font-size: 16px;
  margin: 0 0 16px;
}

.chart-card canvas {
  max-height: 280px;
}

.top-list-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.top-list h3 {
  font-size: 14px;
  margin: 0 0 10px;
}

.top-list ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
}

.top-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  padding: 8px 10px;
  background: var(--color-bg-alt);
  border-radius: var(--radius-sm);
}

.top-list .top-list-empty {
  color: var(--color-text-muted);
  padding: 8px 10px;
}

/* Billing
   ========================================================================== */
.plan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.plan-card {
  background: #ffffff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  padding: 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
}

.plan-card.current {
  border-color: var(--color-accent);
  box-shadow: var(--shadow-hover);
}

.plan-card h3 {
  margin: 0 0 8px;
}

.plan-card .price {
  font-size: 32px;
  font-weight: 800;
  margin-bottom: 12px;
}

.plan-card .price span {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-muted);
}

.plan-card ul {
  list-style: none;
  padding: 0;
  margin: 0 0 20px;
  text-align: left;
  display: grid;
  gap: 8px;
  font-size: 13px;
  flex: 1;
}

.plan-card ul li::before {
  content: '✓ ';
  color: var(--color-accent);
  font-weight: 700;
}

.current-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(124, 58, 237, 0.1);
  color: var(--color-accent);
  margin-bottom: 12px;
  align-self: center;
}

/* Responsive
   ========================================================================== */
@media (max-width: 860px) {
  .dash-layout {
    flex-direction: column;
  }

  .dash-sidebar {
    width: 100%;
    height: auto;
    position: static;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
  }

  .dash-nav {
    flex-direction: row;
    flex-wrap: wrap;
    flex: 1;
  }

  .dash-user {
    border-top: none;
    width: auto;
  }

  .dash-content {
    padding: 20px;
  }

  .dash-topbar {
    padding: 16px 20px;
  }
}
