/* QNSQY Dashboard Styles */

.dashboard {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.dash-sidebar {
  width: 240px;
  background: var(--color-bg-elevated);
  border-right: 1px solid var(--color-border);
  padding: var(--space-lg) 0;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
}

.dash-sidebar-logo {
  font-family: var(--font-mono);
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--color-accent);
  padding: 0 var(--space-lg);
  margin-bottom: var(--space-2xl);
  text-decoration: none;
  display: block;
}

.dash-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 var(--space-sm);
}

.dash-nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  color: var(--color-text-secondary);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 500;
  text-decoration: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  transition: all var(--duration-fast);
}

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

.dash-nav-item.active {
  background: rgba(255, 107, 0, 0.1);
  color: var(--color-accent);
}

.dash-nav-item svg {
  width: 16px;
  height: 16px;
  opacity: 0.7;
  flex-shrink: 0;
}

.dash-nav-item.active svg {
  opacity: 1;
}

.dash-sidebar-footer {
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--color-border);
}

.dash-logout {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  color: var(--color-text-secondary);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  cursor: pointer;
  background: none;
  border: none;
  padding: var(--space-xs) 0;
  transition: color var(--duration-fast);
}

.dash-logout:hover {
  color: #ff3b30;
}

/* Burger Menu (mobile) */
.dash-burger {
  display: none;
  background: none;
  border: none;
  color: var(--color-text);
  cursor: pointer;
  padding: var(--space-sm);
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
  z-index: 110;
}
.dash-burger:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* Main Content */
.dash-main {
  flex: 1;
  margin-left: 240px;
  padding: var(--space-2xl) var(--space-3xl);
  max-width: 1000px;
  overflow-x: hidden;
  box-sizing: border-box;
}

.dash-header {
  margin-bottom: var(--space-2xl);
}

.dash-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--space-xs);
}

.dash-subtitle {
  color: var(--color-text-secondary);
  font-size: 0.9rem;
}

.dash-section.active {
  display: block;
}

/* Cards */
.dash-card {
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  margin-bottom: var(--space-lg);
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  box-sizing: border-box;
  width: 100%;
}

.dash-card-title {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-lg);
}

/* Info Row */
.dash-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--color-border);
  gap: var(--space-sm);
  flex-wrap: wrap;
  overflow: hidden;
  word-break: break-word;
}

.dash-info-row:last-child {
  border-bottom: none;
}

.dash-info-label {
  color: var(--color-text-secondary);
  font-size: 0.85rem;
  flex-shrink: 0;
  min-width: 100px;
}

.dash-info-value {
  color: var(--color-text);
  font-size: 0.9rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* Plan Badge */
.plan-badge {
  display: inline-block;
  padding: 2px 12px;
  border-radius: 12px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.plan-badge.free { background: var(--color-border); color: var(--color-text-secondary); border: 1px dashed var(--color-text-secondary); }
.plan-badge.pro { background: rgba(255, 107, 0, 0.2); color: var(--color-accent); border: 1px solid var(--color-accent); }
.plan-badge.business { background: rgba(147, 51, 234, 0.2); color: #a855f7; border: 2px double #a855f7; }

/* Progress Bar */
.dash-progress {
  height: 8px;
  background: var(--color-border);
  border-radius: 4px;
  overflow: hidden;
  margin-top: var(--space-sm);
}

.dash-progress-fill {
  height: 100%;
  background: var(--color-accent);
  border-radius: 4px;
  transition: width 0.5s ease;
}

.dash-progress-fill.warning { background: var(--color-warning); }
.dash-progress-fill.danger { background: #ff3b30; }

/* Tables */
.dash-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
}
/* Make cards scrollable when tables overflow */
.dash-card--scrollable {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.dash-table th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: var(--space-sm) var(--space-sm);
  border-bottom: 1px solid var(--color-border);
}

.dash-table td {
  padding: var(--space-sm) var(--space-sm);
  font-size: 0.85rem;
  word-break: break-word;
  max-width: 250px;
  color: var(--color-text);
  border-bottom: 1px solid var(--color-border);
}

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

.dash-table .mono {
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

/* Buttons */
.dash-btn {
  padding: 6px 16px;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: opacity var(--duration-fast);
}

.dash-btn:hover { opacity: 0.8; }
.dash-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.dash-btn-primary { background: var(--color-accent); color: #fff; }
.dash-btn-ghost { background: none; border: 1px solid var(--color-border); color: var(--color-text); }
.dash-btn-danger { background: rgba(255, 59, 48, 0.1); border: 1px solid rgba(255, 59, 48, 0.3); color: #ff3b30; }
.dash-btn-sm { padding: 4px 10px; font-size: 0.75rem; }

/* Sections container */
.dash-section {
  display: none;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  box-sizing: border-box;
}

/* Inputs */
.dash-input {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 0.9rem;
  width: 100%;
  box-sizing: border-box;
  transition: border-color var(--duration-fast);
}
.dash-input:focus {
  outline: none;
  border-color: var(--color-accent);
}
.dash-input:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* Key Display */
.key-display {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  padding: var(--space-sm) var(--space-md);
  margin-top: var(--space-md);
}

.key-display code {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--color-accent);
  word-break: break-all;
  flex: 1;
}

/* Status Indicators */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}

.status-dot.active { background: var(--color-success); }
.status-dot.revoked { background: #ff3b30; }
.status-dot.expired { background: var(--color-text-muted); }

/* Loading */
.dash-loading {
  text-align: center;
  color: var(--color-text-secondary);
  padding: var(--space-2xl);
}

/* Empty State */
.dash-empty {
  text-align: center;
  color: var(--color-text-muted);
  padding: var(--space-2xl);
  font-size: 0.9rem;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 12px 20px;
  font-size: 0.85rem;
  color: var(--color-text);
  box-shadow: 0 4px 24px rgba(0,0,0,0.4);
  animation: toast-in 0.3s ease;
  border-left: 3px solid var(--color-success);
  max-width: 360px;
}
.toast--error { border-left-color: #ff3b30; }
.toast--removing { animation: toast-out 0.3s ease forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toast-out { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(16px); } }

/* Loading Skeletons */
.dash-skeleton {
  background: linear-gradient(90deg, var(--color-bg-elevated) 25%, var(--color-border) 50%, var(--color-bg-elevated) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
}
.dash-skeleton-row {
  height: 16px;
  margin-bottom: 12px;
  width: 100%;
}
.dash-skeleton-row--short { width: 60%; }
.dash-skeleton-row--med { width: 80%; }
.dash-skeleton-input {
  height: 42px;
  margin-bottom: 12px;
  width: 100%;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* Error States */
.dash-error {
  text-align: center;
  padding: var(--space-2xl);
  color: var(--color-text-secondary);
}
.dash-error-icon {
  font-size: 2rem;
  margin-bottom: var(--space-sm);
  opacity: 0.5;
}
.dash-error-msg {
  font-size: 0.9rem;
  margin-bottom: var(--space-md);
}
.dash-retry-btn {
  background: none;
  border: 1px solid var(--color-border);
  color: var(--color-text);
  padding: 8px 20px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color var(--duration-fast);
}
.dash-retry-btn:hover { border-color: var(--color-accent); color: var(--color-accent); }

/* Focus Styles (Accessibility) */
.dash-btn:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
.dash-nav-item:focus-visible { outline: 2px solid var(--color-accent); outline-offset: -2px; }
.dash-logout:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }

/* Toggle Switch */
.dash-toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.dash-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}
.dash-toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--color-border);
  border-radius: 24px;
  transition: background var(--duration-fast);
}
.dash-toggle-slider::before {
  content: '';
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: var(--color-text);
  border-radius: 50%;
  transition: transform var(--duration-fast);
}
.dash-toggle input:checked + .dash-toggle-slider {
  background: var(--color-accent);
}
.dash-toggle input:checked + .dash-toggle-slider::before {
  transform: translateX(20px);
}
.dash-toggle input:focus-visible + .dash-toggle-slider {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* Mobile Nav Logout (hidden on desktop, shown inline on mobile) */
.dash-nav-logout { display: none; }

/* Mobile */
@media (max-width: 768px) {
  .dash-burger {
    display: block;
  }
  .dash-sidebar {
    width: 260px;
    position: fixed;
    top: 0;
    left: -260px;
    bottom: 0;
    border-right: 1px solid var(--color-border);
    border-bottom: none;
    padding: var(--space-lg) 0;
    transition: left 0.25s ease;
    z-index: 200;
    background: var(--color-bg-elevated);
  }
  .dash-sidebar.open {
    left: 0;
  }
  .dash-sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 199;
  }
  .dash-sidebar.open ~ .dash-sidebar-overlay {
    display: block;
  }
  .dashboard { flex-direction: column; }
  .dash-main { margin-left: 0; padding: var(--space-lg); padding-top: calc(var(--space-lg) + 48px); }
  .dash-sidebar-logo {
    font-size: 1rem;
    margin-bottom: var(--space-lg);
    padding: 0 var(--space-md);
  }
  .dash-nav {
    flex-direction: column;
    overflow-x: visible;
    gap: 2px;
    padding: 0 var(--space-sm);
    scrollbar-width: none;
  }
  .dash-nav::-webkit-scrollbar { display: none; }
  .dash-nav-item {
    white-space: nowrap;
    font-size: 0.8rem;
    padding: 12px 14px;
    min-height: 44px;
    justify-content: flex-start;
    width: 100%;
  }
  .dash-nav-item svg { width: 16px; height: 16px; }
  .dash-sidebar-footer { display: none; }
  .dash-nav-logout {
    display: flex !important;
    color: #ff3b30;
    border-top: 1px solid var(--color-border);
    margin-top: auto;
    border-left: none;
  }
  .dash-table { font-size: 0.8rem; }
  .dash-table th:nth-child(n+4), .dash-table td:nth-child(n+4) { display: none; }
  .toast-container { bottom: 12px; right: 12px; left: 12px; }
  .toast { max-width: none; }
}
