/* ═══════════════════════════════════════════════════════════════
   AURION — Panel Web | Design System
   ═══════════════════════════════════════════════════════════════ */

:root {
  --primary: #6C5CE7;
  --primary-dark: #5A4BD1;
  --primary-light: #A29BFE;
  --accent: #00CEC9;
  --accent-dark: #00B5B0;
  --bg: #0F0F1A;
  --bg-card: #1A1A2E;
  --bg-card-hover: #222240;
  --bg-input: #16162B;
  --text: #E8E8F0;
  --text-muted: #8888A0;
  --text-dim: #555570;
  --border: #2A2A45;
  --success: #00D68F;
  --warning: #FFAA00;
  --danger: #FF6B6B;
  --info: #0ABDE3;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.3);
  --transition: 0.2s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--primary-light); text-decoration: none; }
a:hover { color: var(--accent); }

/* ── Login ──────────────────────────────────────────────────── */
.login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  background: radial-gradient(ellipse at 50% 0%, rgba(108,92,231,0.15) 0%, transparent 60%);
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
}

.login-card .logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-card .logo h1 {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 4px;
  background: linear-gradient(135deg, var(--primary-light), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.login-card .logo p {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 4px;
}

/* ── Forms ──────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.95rem;
  transition: border-color var(--transition);
  outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary);
}

.form-group textarea {
  resize: vertical;
  min-height: 80px;
}

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-dark); }

.btn-accent {
  background: var(--accent);
  color: #0F0F1A;
}
.btn-accent:hover { background: var(--accent-dark); }

.btn-success {
  background: var(--success);
  color: #0F0F1A;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary-light);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.8rem;
}

.btn-block {
  width: 100%;
  justify-content: center;
  padding: 14px;
  font-size: 1rem;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Layout ─────────────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 260px;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
}

.sidebar-header {
  padding: 24px 20px;
  border-bottom: 1px solid var(--border);
}

.sidebar-header h2 {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: 3px;
  background: linear-gradient(135deg, var(--primary-light), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar-header .role-badge {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.role-admin { background: rgba(108,92,231,0.2); color: var(--primary-light); }
.role-supervisor { background: rgba(0,206,201,0.2); color: var(--accent); }
.role-client { background: rgba(0,214,143,0.2); color: var(--success); }

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}

.nav-section {
  padding: 8px 20px 4px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-dim);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  border-left: 3px solid transparent;
}

.nav-item:hover {
  background: rgba(108,92,231,0.08);
  color: var(--text);
}

.nav-item.active {
  background: rgba(108,92,231,0.12);
  color: var(--primary-light);
  border-left-color: var(--primary);
}

.nav-item .icon {
  font-size: 1.1rem;
  width: 22px;
  text-align: center;
}

.nav-item .badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: #fff;
}

.user-details {
  flex: 1;
  min-width: 0;
}

.user-details .name {
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-details .role {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.btn-logout {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 4px;
  transition: color var(--transition);
}
.btn-logout:hover { color: var(--danger); }

/* ── Main content ───────────────────────────────────────────── */
.main-content {
  flex: 1;
  margin-left: 260px;
  padding: 32px;
  min-height: 100vh;
}

.page-header {
  margin-bottom: 28px;
}

.page-header h1 {
  font-size: 1.6rem;
  font-weight: 700;
}

.page-header p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 4px;
}

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

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: border-color var(--transition);
}

.stat-card:hover {
  border-color: var(--primary);
}

.stat-card .stat-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.stat-card .stat-value {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
}

.stat-card .stat-change {
  font-size: 0.8rem;
  margin-top: 6px;
}

.stat-card .stat-change.up { color: var(--success); }
.stat-card .stat-change.down { color: var(--danger); }

/* ── Cards & Panels ─────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.card-header h3 {
  font-size: 1rem;
  font-weight: 600;
}

.card-body {
  padding: 20px;
}

.card-body.no-padding {
  padding: 0;
}

/* ── Tables ─────────────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

table th {
  text-align: left;
  padding: 12px 16px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
}

table td {
  padding: 12px 16px;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border);
}

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

table tr:hover td {
  background: rgba(108,92,231,0.04);
}

/* ── Status badges ──────────────────────────────────────────── */
.status {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.status-pending { background: rgba(255,170,0,0.15); color: var(--warning); }
.status-approved, .status-completed, .status-done { background: rgba(0,214,143,0.15); color: var(--success); }
.status-rejected { background: rgba(255,107,107,0.15); color: var(--danger); }
.status-in_progress, .status-in_production, .status-development { background: rgba(10,189,227,0.15); color: var(--info); }
.status-queued { background: rgba(108,92,231,0.15); color: var(--primary-light); }

.priority-high { color: var(--danger); font-weight: 600; }
.priority-medium { color: var(--warning); }
.priority-low { color: var(--text-muted); }

/* ── Section grid ───────────────────────────────────────────── */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 20px;
}

/* ── Tabs ────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.tab {
  padding: 10px 20px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition);
}

.tab:hover { color: var(--text); }
.tab.active {
  color: var(--primary-light);
  border-bottom-color: var(--primary);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Modal ───────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  width: 90%;
  max-width: 500px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  transform: translateY(20px);
  transition: transform var(--transition);
}

.modal-overlay.active .modal {
  transform: translateY(0);
}

.modal h3 {
  margin-bottom: 20px;
  font-size: 1.1rem;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 24px;
}

/* ── Toast ───────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: var(--shadow);
  animation: slideIn 0.3s ease;
  max-width: 360px;
}

.toast-success { background: var(--success); color: #0F0F1A; }
.toast-error { background: var(--danger); color: #fff; }
.toast-info { background: var(--info); color: #0F0F1A; }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ── Empty state ─────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}

.empty-state .icon {
  font-size: 3rem;
  margin-bottom: 12px;
  opacity: 0.4;
}

.empty-state p {
  font-size: 0.9rem;
}

/* ── Loading ─────────────────────────────────────────────────── */
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 20px auto;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
}

/* ── Mobile top bar ─────────────────────────────────────────── */
.mobile-topbar {
  display: none;
}

.sidebar-overlay {
  display: none;
}

/* ── Mobile bottom nav ─────────────────────────────────────── */
.mobile-bottomnav {
  display: none;
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  /* Hide sidebar by default, slide in as overlay */
  .sidebar {
    z-index: 300;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }
  .sidebar.mobile-open {
    transform: translateX(0);
  }

  /* Dark overlay behind sidebar */
  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 299;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
  }
  .sidebar-overlay.active {
    opacity: 1;
    pointer-events: all;
  }

  /* Mobile top bar */
  .mobile-topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    padding: 0 16px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    z-index: 200;
  }

  .mobile-hamburger {
    background: rgba(108,92,231,0.12);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 1.6rem;
    cursor: pointer;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: background var(--transition);
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
  }
  .mobile-hamburger:active {
    background: rgba(108,92,231,0.3);
  }

  .mobile-topbar-title {
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: 3px;
    background: linear-gradient(135deg, var(--primary-light), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    flex: 1;
  }

  .mobile-topbar .role-badge {
    display: inline-block;
    font-size: 0.65rem;
    padding: 3px 10px;
    border-radius: 20px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
  }

  /* Main content adjustments */
  .main-content {
    margin-left: 0;
    padding: 72px 16px 90px;
  }

  /* Mobile bottom nav */
  .mobile-bottomnav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    min-height: 70px;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    z-index: 200;
    padding: 0;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }

  .bottomnav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    min-height: 70px;
    min-width: 44px;
    padding: 8px 4px;
    transition: color var(--transition);
    position: relative;
    -webkit-tap-highlight-color: transparent;
  }

  .bottomnav-item:active {
    background: rgba(108,92,231,0.1);
  }

  .bottomnav-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 16%;
    right: 16%;
    height: 3px;
    background: var(--primary);
    border-radius: 0 0 3px 3px;
    opacity: 0;
    transition: opacity var(--transition);
  }

  .bottomnav-item.active {
    color: var(--primary-light);
  }
  .bottomnav-item.active::before {
    opacity: 1;
  }

  .bottomnav-icon {
    font-size: 1.5rem;
    line-height: 1;
  }

  .bottomnav-label {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.3px;
  }

  /* ── Global mobile typography & touch ────────────────────────── */
  .page-header {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 8px;
    margin-bottom: 20px;
  }
  .page-header h1 {
    font-size: 1.25rem;
  }
  .page-header p {
    font-size: 0.875rem;
  }

  /* ── Tables: scrollable, legible ────────────────────────────── */
  .table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  table th {
    padding: 10px 12px;
    font-size: 0.7rem;
    white-space: nowrap;
  }

  table td {
    padding: 10px 12px;
    font-size: 0.875rem;
  }

  .status {
    font-size: 0.7rem;
    padding: 3px 8px;
    white-space: nowrap;
  }

  /* ── Stats grid: 2 columns, compact ─────────────────────────── */
  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
  }

  .stat-card {
    padding: 14px;
  }
  .stat-card .stat-label {
    font-size: 0.7rem;
    margin-bottom: 6px;
  }
  .stat-card .stat-value {
    font-size: 1.5rem;
  }

  /* ── Cards ───────────────────────────────────────────────────── */
  .card {
    border-radius: var(--radius-sm);
  }
  .card-header {
    padding: 12px 14px;
  }
  .card-header h3 {
    font-size: 0.9rem;
  }
  .card-body {
    padding: 14px;
  }

  /* ── Grids: single column ────────────────────────────────────── */
  .grid-2, .grid-3 {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  /* ── Buttons: 44px min touch target ──────────────────────────── */
  .btn {
    min-height: 44px;
    padding: 10px 18px;
    font-size: 0.875rem;
  }
  .btn-sm {
    min-height: 40px;
    padding: 8px 14px;
    font-size: 0.8rem;
  }
  .btn-primary,
  .btn-accent,
  .btn-success,
  .btn-danger,
  .btn-outline {
    -webkit-tap-highlight-color: transparent;
  }

  /* ── Modals: full width on mobile ────────────────────────────── */
  .modal {
    width: 95%;
    padding: 20px;
  }
  .modal h3 {
    font-size: 1.05rem;
  }
  .form-group label {
    font-size: 0.75rem;
  }
  .form-group input,
  .form-group select,
  .form-group textarea {
    font-size: 1rem;
    padding: 12px 14px;
  }
  .modal-actions {
    flex-direction: column-reverse;
    gap: 8px;
  }
  .modal-actions .btn {
    width: 100%;
    justify-content: center;
  }

  /* ── Tabs: scrollable on mobile ──────────────────────────────── */
  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab {
    padding: 10px 16px;
    font-size: 0.8rem;
    white-space: nowrap;
  }

  /* ── Empty states ────────────────────────────────────────────── */
  .empty-state {
    padding: 32px 16px;
  }
  .empty-state p {
    font-size: 0.875rem;
  }

  /* ── Toast: wider on mobile ──────────────────────────────────── */
  .toast-container {
    left: 16px;
    right: 16px;
    top: 64px;
  }
  .toast {
    max-width: none;
  }
}
