/* ========================================
   COMISIOTRACK — GLOBAL STYLES
   ======================================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0d0f1a;
  --bg-2: #131629;
  --bg-3: #1a1e35;
  --surface: rgba(255,255,255,0.045);
  --surface-hover: rgba(255,255,255,0.07);
  --border: rgba(255,255,255,0.08);
  --border-light: rgba(255,255,255,0.13);

  --purple: #8b5cf6;
  --purple-light: #a78bfa;
  --purple-dim: rgba(139,92,246,0.15);
  --blue: #3b82f6;
  --blue-light: #60a5fa;
  --blue-dim: rgba(59,130,246,0.15);
  --green: #10b981;
  --green-light: #34d399;
  --green-dim: rgba(16,185,129,0.15);
  --orange: #f59e0b;
  --orange-light: #fbbf24;
  --orange-dim: rgba(245,158,11,0.15);
  --red: #ef4444;
  --red-dim: rgba(239,68,68,0.15);

  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --gradient-main: linear-gradient(135deg, #8b5cf6 0%, #3b82f6 100%);
  --gradient-green: linear-gradient(135deg, #10b981 0%, #3b82f6 100%);

  --sidebar-w: 240px;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 8px 32px rgba(0,0,0,0.4);
  --shadow-sm: 0 2px 12px rgba(0,0,0,0.3);

  --transition: 0.2s ease;
  --transition-slow: 0.35s ease;

  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

html, body { height: 100%; overflow: hidden; }
body { background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.6; }

/* ========================================
   SCROLLBAR
   ======================================== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 10px; }

/* ========================================
   SCREENS
   ======================================== */
.screen { display: none; position: fixed; inset: 0; overflow: auto; }
.screen.active { display: flex; }

/* ========================================
   LOGIN
   ======================================== */
#screen-login {
  align-items: center;
  justify-content: center;
  background: var(--bg);
  overflow: hidden;
}

.login-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.login-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.25;
  animation: orb-float 8s ease-in-out infinite;
}
.orb-1 { width: 600px; height: 600px; background: var(--purple); top: -200px; left: -200px; animation-delay: 0s; }
.orb-2 { width: 500px; height: 500px; background: var(--blue); bottom: -200px; right: -100px; animation-delay: -3s; }
.orb-3 { width: 300px; height: 300px; background: var(--green); top: 50%; left: 50%; transform: translate(-50%,-50%); animation-delay: -6s; }

@keyframes orb-float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(20px, -20px) scale(1.05); }
  66% { transform: translate(-10px, 15px) scale(0.97); }
}

.login-card {
  position: relative;
  width: 420px;
  max-width: calc(100vw - 32px);
  padding: 40px;
  z-index: 1;
  animation: slide-up 0.5s ease;
}

.glass-card {
  background: rgba(19, 22, 41, 0.75);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.brand.compact { margin-bottom: 0; }
.brand-icon {
  width: 44px; height: 44px;
  background: var(--gradient-main);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 15px rgba(139,92,246,0.4);
}
.brand-icon.sm { width: 32px; height: 32px; border-radius: 8px; }
.brand-name { font-size: 22px; font-weight: 800; background: var(--gradient-main); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.brand-name.sm { font-size: 16px; font-weight: 700; }

.login-subtitle { color: var(--text-muted); font-size: 13px; margin-bottom: 28px; }

.login-form { display: flex; flex-direction: column; gap: 16px; }
.login-hint { margin-top: 16px; color: var(--text-dim); font-size: 12px; text-align: center; }
.login-hint strong { color: var(--text-muted); }

/* ========================================
   FORMS & INPUTS
   ======================================== */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }

.input-wrap { position: relative; }
.input-icon {
  position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  color: var(--text-dim); pointer-events: none;
}
.input-wrap input, .input-wrap textarea {
  width: 100%;
  padding: 11px 14px 11px 40px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  transition: border-color var(--transition), background var(--transition);
  outline: none;
}
input, select, textarea {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition), background var(--transition);
}
.input-wrap input:focus, input:focus, select:focus, textarea:focus {
  border-color: var(--purple);
  background: rgba(139,92,246,0.07);
  box-shadow: 0 0 0 3px rgba(139,92,246,0.15);
}

select { padding: 10px 14px; cursor: pointer; }
select option { background: var(--bg-3); }

.search-wrap { flex: 1; min-width: 180px; }
.search-wrap input { padding-left: 38px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ========================================
   BUTTONS
   ======================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 20px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600; font-family: inherit;
  border: none; cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn-primary {
  background: var(--gradient-main);
  color: #fff;
  box-shadow: 0 4px 15px rgba(139,92,246,0.35);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(139,92,246,0.5); }
.btn-primary:active { transform: translateY(0); }

.btn-outline {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border-light);
}
.btn-outline:hover { background: var(--surface-hover); color: var(--text); border-color: var(--border-light); }
.btn-outline.sm { padding: 7px 14px; font-size: 13px; }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface); color: var(--text); }

.btn-full { width: 100%; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-icon { width: 32px; height: 32px; padding: 0; border-radius: 6px; }

/* ========================================
   ALERTS
   ======================================== */
.alert-error {
  background: var(--red-dim);
  border: 1px solid rgba(239,68,68,0.3);
  color: #fca5a5;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.hidden { display: none !important; }

/* ========================================
   ADMIN LAYOUT
   ======================================== */
#screen-admin { flex-direction: row; background: var(--bg); overflow: hidden; }

.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform var(--transition-slow);
  z-index: 100;
}

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

.sidebar-close { display: none; background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 18px; }

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: all var(--transition);
}
.nav-item:hover { background: var(--surface-hover); color: var(--text); }
.nav-item.active {
  background: var(--purple-dim);
  color: var(--purple-light);
}
.nav-item.active svg { color: var(--purple-light); }

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-chip { display: flex; align-items: center; gap: 10px; flex: 1; overflow: hidden; }
.user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--gradient-main);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: #fff;
  flex-shrink: 0;
}
.user-chip span { font-size: 13px; font-weight: 500; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.btn-logout {
  background: none; border: 1px solid var(--border); border-radius: 8px;
  color: var(--text-dim); cursor: pointer; padding: 7px;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.btn-logout:hover { color: var(--red); border-color: rgba(239,68,68,0.4); background: var(--red-dim); }

/* ========================================
   MAIN WRAPPER
   ======================================== */
.main-wrapper { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

.topbar {
  height: 60px;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}
.topbar-title { font-size: 16px; font-weight: 700; color: var(--text); flex: 1; }
.hamburger { display: none; background: none; border: none; cursor: pointer; flex-direction: column; gap: 5px; padding: 4px; }
.hamburger span { display: block; width: 22px; height: 2px; background: var(--text-muted); border-radius: 2px; transition: var(--transition); }

.content { flex: 1; overflow-y: auto; padding: 24px; }

/* ========================================
   TABS
   ======================================== */
.tab-content { display: none; animation: fade-in 0.25s ease; }
.tab-content.active { display: block; }

@keyframes fade-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slide-up { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

/* ========================================
   PAGE HEADERS
   ======================================== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}
.page-title { font-size: 22px; font-weight: 800; color: var(--text); }
.page-sub { font-size: 13px; color: var(--text-muted); }
.header-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.section-title-row { margin: 24px 0 14px; }
.section-title { font-size: 16px; font-weight: 700; color: var(--text); }

/* ========================================
   STATS CARDS
   ======================================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.stats-grid.mini { margin-bottom: 20px; }

.stat-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: transform var(--transition), border-color var(--transition);
  animation: slide-up 0.3s ease;
}
.stat-card:hover { transform: translateY(-2px); border-color: var(--border-light); }

.stat-icon {
  width: 46px; height: 46px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon.purple { background: var(--purple-dim); color: var(--purple-light); }
.stat-icon.blue { background: var(--blue-dim); color: var(--blue-light); }
.stat-icon.green { background: var(--green-dim); color: var(--green-light); }
.stat-icon.orange { background: var(--orange-dim); color: var(--orange-light); }

.stat-value { font-size: 24px; font-weight: 800; color: var(--text); line-height: 1.1; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ========================================
   TABLE CARDS
   ======================================== */
.table-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.table-card.no-shadow { box-shadow: none; border: none; background: transparent; }

.table-toolbar {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.select-filter {
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  min-width: 150px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  padding: 12px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: rgba(255,255,255,0.02);
}
.data-table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background var(--transition); }
.data-table tbody tr:hover { background: var(--surface-hover); }
.data-table tfoot td {
  padding: 14px 16px;
  font-weight: 700;
  color: var(--text);
  background: rgba(139,92,246,0.08);
  border-top: 1px solid var(--border-light);
}
.data-table.sm th, .data-table.sm td { padding: 10px 14px; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}
.badge-active { background: var(--green-dim); color: var(--green-light); }
.badge-inactive { background: var(--red-dim); color: #fca5a5; }

.amount { font-family: 'Inter', monospace; font-weight: 600; }
.amount-positive { color: var(--green-light); }
.amount-commission { color: var(--orange-light); }

.rank-badge {
  width: 26px; height: 26px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  background: var(--purple-dim);
  color: var(--purple-light);
}
.rank-badge.gold { background: rgba(245,158,11,0.2); color: var(--orange-light); }
.rank-badge.silver { background: rgba(148,163,184,0.2); color: #cbd5e1; }
.rank-badge.bronze { background: rgba(180,100,60,0.2); color: #c4956a; }

.table-actions { display: flex; gap: 6px; }

/* ========================================
   EMPTY STATE
   ======================================== */
.empty-state {
  padding: 48px 20px;
  text-align: center;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.empty-state svg { opacity: 0.3; }
.empty-state p { font-size: 14px; }

/* ========================================
   COMISIÓN PREVIEW
   ======================================== */
.comision-preview {
  background: var(--green-dim);
  border: 1px solid rgba(16,185,129,0.2);
  color: var(--green-light);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  animation: fade-in 0.2s ease;
}
.comision-preview strong { font-size: 16px; font-weight: 800; }

/* ========================================
   MODALS
   ======================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fade-in 0.2s ease;
}

.modal {
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slide-up 0.25s ease;
}
.modal-wide { max-width: 680px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}
.modal-header h3 { font-size: 18px; font-weight: 700; }
.modal-close {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 18px; padding: 4px; line-height: 1;
  transition: color var(--transition);
}
.modal-close:hover { color: var(--text); }

.modal-form { display: flex; flex-direction: column; gap: 16px; padding: 0; }
.modal-form input, .modal-form select {
  width: 100%; padding: 10px 14px;
}
.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding-top: 6px;
}

/* Modal Padding Override */
.modal.glass-card { padding: 28px; }

/* ========================================
   TOAST
   ======================================== */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg-3);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 14px 20px;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow);
  z-index: 999;
  animation: slide-up 0.3s ease;
  max-width: 360px;
}
.toast.success { border-color: var(--green); color: var(--green-light); background: rgba(16,185,129,0.1); }
.toast.error { border-color: var(--red); color: #fca5a5; background: var(--red-dim); }

/* ========================================
   VENDOR PANEL
   ======================================== */
#screen-vendedor { flex-direction: column; background: var(--bg); }

.vendor-layout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  width: 100%;
}

.vendor-header {
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  border-radius: 0;
  border-left: none; border-right: none; border-top: none;
  background: rgba(19,22,41,0.9);
}
.vendor-header-center { flex: 1; text-align: center; }
.vendor-welcome { font-size: 14px; font-weight: 600; color: var(--text-muted); }

.vendor-content { flex: 1; overflow-y: auto; padding: 24px; max-width: 1200px; margin: 0 auto; width: 100%; }

.vendor-stats { margin-bottom: 24px; }

.vendor-two-col {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 20px;
  align-items: start;
}

.form-card { padding: 24px; }
.card-title {
  display: flex; align-items: center; gap: 10px;
  font-size: 16px; font-weight: 700;
  margin-bottom: 20px;
  color: var(--text);
}

.sale-form { display: flex; flex-direction: column; gap: 16px; }
.sale-form input { width: 100%; padding: 10px 14px 10px 40px; }

.vendor-table-card { padding: 24px; }
.vendor-table-wrap { overflow-y: auto; max-height: 400px; margin-top: 4px; }

/* ========================================
   SIDEBAR OVERLAY (Mobile)
   ======================================== */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 900px) {
  :root { --sidebar-w: 260px; }

  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: block; }
  .hamburger { display: flex; }
  .sidebar-overlay { display: block; }

  .main-wrapper { width: 100%; }
  .vendor-two-col { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .content { padding: 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .data-table th, .data-table td { padding: 10px 10px; font-size: 12px; }
  .vendor-content { padding: 16px; }
  .vendor-header { padding: 12px 16px; }
  .brand-name.sm { display: none; }
  .modal.glass-card { padding: 20px; }
}

/* ========================================
   PRINT STYLES
   ======================================== */
@media print {
  body { background: #fff; color: #000; }
  .sidebar, .topbar, .btn, .modal-overlay, .toast, #btn-imprimir { display: none !important; }
  .main-wrapper { margin: 0; }
  .tab-content { display: block !important; }
  #tab-dashboard, #tab-vendedores, #tab-ventas { display: none !important; }
  #tab-resumen { display: block !important; }
  .data-table th, .data-table td { color: #000; border-color: #ddd; }
  .table-card { border-color: #ddd; background: #fff; }
}
