/* ============================================
   SISTEMA DE SORTEIO BRASMÁQUINAS — GLOBAL CSS
   ============================================ */

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

:root {
  --bg: #071712;
  --surface: #0a2119;
  --surface2: #0f2e24;
  --border: #194032;
  --accent: #0bb544;
  --accent2: #fbc02d;
  --accent-glow: rgba(11,181,68,0.25);
  --text: #e8f5e9;
  --text-dim: #a5d6a7;
  --muted: #629471;
  --danger: #ef4444;
  --danger-dim: rgba(239,68,68,0.12);
  --success: #22c55e;
  --success-dim: rgba(34,197,94,0.12);
  --warning: #fbc02d;
  --warning-dim: rgba(251,192,45,0.12);
  --sidebar-w: 240px;
}

html, body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100%;
  font-size: 14px;
  line-height: 1.6;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ===== LAYOUT ===== */
#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  z-index: 100;
  transition: transform 0.3s;
}

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

.sidebar-logo .logo-icon {
  width: 48px; height: 48px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  margin-bottom: 12px;
  box-shadow: 0 4px 16px rgba(11,181,68,0.4);
}

.sidebar-logo h2 {
  font-size: 15px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}

.sidebar-logo p {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

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

.nav-section-title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  padding: 12px 20px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  color: var(--text-dim);
  cursor: pointer;
  border-radius: 0;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  border-left: 3px solid transparent;
  margin: 1px 0;
}

.nav-item:hover { background: rgba(11,181,68,0.08); color: var(--text); }
.nav-item.active { background: rgba(11,181,68,0.12); color: var(--accent2); border-left-color: var(--accent); }

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

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

.btn-logout {
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: var(--danger-dim);
  border: 1px solid rgba(239,68,68,0.2);
  border-radius: 10px;
  color: #fca5a5;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s;
}
.btn-logout:hover { background: rgba(239,68,68,0.2); }

/* ===== MAIN CONTENT ===== */
.main-content {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.page-header {
  padding: 28px 32px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.page-header h1 {
  font-size: 24px;
  font-weight: 700;
}

.page-header p {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}

.page-body {
  padding: 24px 32px 40px;
}

/* ===== CARDS ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 20px;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.stat-icon.purple { background: rgba(11,181,68,0.15); }
.stat-icon.green { background: rgba(34,197,94,0.15); }
.stat-icon.amber { background: rgba(245,158,11,0.15); }
.stat-icon.blue { background: rgba(59,130,246,0.15); }

.stat-value { font-size: 28px; font-weight: 700; }
.stat-label { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: 8px;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
}

.btn-primary {
  background: linear-gradient(135deg, #09a63c, #13cc51);
  color: #fff;
  box-shadow: 0 2px 12px rgba(11,181,68,0.35);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 20px rgba(11,181,68,0.5); }

.btn-secondary {
  background: var(--surface2);
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: #252535; color: var(--text); }

.btn-danger {
  background: var(--danger-dim);
  color: #fca5a5;
  border: 1px solid rgba(239,68,68,0.2);
}
.btn-danger:hover { background: rgba(239,68,68,0.2); }

.btn-success {
  background: var(--success-dim);
  color: #86efac;
  border: 1px solid rgba(34,197,94,0.2);
}
.btn-success:hover { background: rgba(34,197,94,0.2); }

.btn-warning {
  background: var(--warning-dim);
  color: #fcd34d;
  border: 1px solid rgba(245,158,11,0.2);
}
.btn-warning:hover { background: rgba(245,158,11,0.2); }

.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 14px 28px; font-size: 16px; font-weight: 600; }
.btn-xl { padding: 18px 40px; font-size: 18px; font-weight: 700; }

/* ===== TABLE ===== */
.table-wrap {
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid var(--border);
}

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

thead th {
  background: var(--surface2);
  padding: 12px 16px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  text-align: left;
  border-bottom: 1px solid var(--border);
}

tbody tr {
  border-bottom: 1px solid rgba(42,42,61,0.5);
  transition: background 0.1s;
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(11,181,68,0.04); }

tbody td {
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text-dim);
}

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

.form-group { margin-bottom: 16px; }
.form-group:last-child { margin-bottom: 0; }

label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 7px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

input, select, textarea {
  width: 100%;
  background: #1a1a28;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--text);
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(11,181,68,0.15);
}
select option { background: #1a1a28; }

/* ===== BADGE ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}
.badge-success { background: var(--success-dim); color: #86efac; }
.badge-danger { background: var(--danger-dim); color: #fca5a5; }
.badge-accent { background: rgba(11,181,68,0.15); color: var(--accent2); }
.badge-warning { background: var(--warning-dim); color: #fcd34d; }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.show { display: flex; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  animation: modalIn 0.2s ease-out;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 20px;
}

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

/* ===== TOAST ===== */
#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 18px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 280px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  animation: toastIn 0.3s ease-out;
}
@keyframes toastIn { from { opacity:0; transform:translateX(20px); } to { opacity:1; transform:translateX(0); } }
@keyframes toastOut { to { opacity:0; transform:translateX(20px); } }
.toast.toast-success { border-color: rgba(34,197,94,0.3); }
.toast.toast-error { border-color: rgba(239,68,68,0.3); }
.toast.toast-info { border-color: rgba(11,181,68,0.3); }

/* ===== LOADING ===== */
.loading-spinner {
  display: inline-block;
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state h3 { font-size: 16px; color: var(--text-dim); margin-bottom: 8px; }
.empty-state p { font-size: 13px; }

/* ===== TOGGLE SWITCH ===== */
.toggle-wrap { display: flex; align-items: center; gap: 10px; }
.toggle {
  position: relative;
  width: 40px; height: 22px;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0;
  background: var(--border);
  border-radius: 22px;
  cursor: pointer;
  transition: background 0.2s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  left: 3px; top: 3px;
  background: var(--muted);
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}
.toggle input:checked + .toggle-slider { background: rgba(34,197,94,0.25); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); background: var(--success); }

/* ===== HAMBURGER (MOBILE) ===== */
.hamburger {
  display: none;
  position: fixed;
  top: 16px; left: 16px;
  z-index: 200;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  cursor: pointer;
  font-size: 18px;
  color: var(--text);
}

/* ===== SORTEIO LIVE ===== */
.sorteio-stage {
  background: linear-gradient(135deg, #071712, #0d2a21);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 48px;
  text-align: center;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
}

.sorteio-stage::before {
  content: '';
  position: absolute;
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(11,181,68,0.1) 0%, transparent 70%);
  top: -200px; left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
}

.premio-label {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--muted);
  margin-bottom: 8px;
}

.premio-atual {
  font-size: 32px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  margin-bottom: 32px;
}

.numero-display {
  position: relative;
  margin: 0 auto 24px;
}

.numero-sorteado {
  font-size: 96px;
  font-weight: 900;
  letter-spacing: -4px;
  line-height: 1;
  background: linear-gradient(135deg, #fff, var(--accent2));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  text-shadow: none;
  transition: all 0.3s;
}

.numero-sorteado.animating {
  animation: numRoll 0.08s ease-in-out infinite;
}
@keyframes numRoll {
  0% { transform: translateY(-2px); }
  50% { transform: translateY(2px); }
  100% { transform: translateY(-2px); }
}

.ganhador-nome {
  font-size: 36px;
  font-weight: 700;
  color: var(--accent2);
  letter-spacing: 1px;
  margin-top: 8px;
  min-height: 44px;
}

.confetti-container {
  position: absolute; inset: 0; pointer-events: none; overflow: hidden;
}

.confetti-piece {
  position: absolute;
  width: 8px; height: 8px;
  opacity: 0;
}

.confetti-piece.circle { border-radius: 50%; }
.confetti-piece.rect { border-radius: 2px; }

/* ===== HISTÓRICO ===== */
.historico-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  border-radius: 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  margin-bottom: 8px;
  transition: background 0.15s;
}

.historico-item:hover { background: #222235; }

.historico-ordem {
  width: 28px; height: 28px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.historico-info { flex: 1; }
.historico-info .premio-name { font-weight: 600; font-size: 14px; }
.historico-info .vendedor-name { font-size: 12px; color: var(--muted); margin-top: 2px; }
.historico-numero { font-size: 22px; font-weight: 700; color: var(--accent2); }

/* ===== PRINT STYLES ===== */
@media print {
  .sidebar, .page-header .btn, #btnGerarPDF, #btnImprimir { display: none !important; }
  .main-content { margin: 0; }
  body { background: #fff; color: #000; }
  table { border: 1px solid #ddd; }
  thead th { background: #f5f5f5; color: #333; }
  tbody td { color: #333; border-bottom: 1px solid #eee; }
  .card { border: 1px solid #ddd; }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .hamburger { display: flex; align-items: center; justify-content: center; }
  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    transform: translateX(-100%);
    z-index: 150;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 140;
    display: none;
  }
  .sidebar-overlay.show { display: block; }
  .page-header, .page-body { padding-left: 20px; padding-right: 20px; }
  .page-header { padding-top: 68px; }
  .sorteio-stage { padding: 32px 20px; }
  .numero-sorteado { font-size: 64px; }
  .ganhador-nome { font-size: 24px; }
}

/* ===== DRAG REORDER ===== */
.drag-item {
  cursor: grab;
  transition: background 0.1s, box-shadow 0.1s;
}
.drag-item:active { cursor: grabbing; }
.drag-item.dragging {
  opacity: 0.5;
  box-shadow: 0 4px 20px rgba(11,181,68,0.3);
}
.drag-item.drag-over { border-color: var(--accent) !important; }

/* ===== NUMBER GRID ===== */
.number-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
}

.number-chip {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.number-chip.sorteado {
  border-color: rgba(34,197,94,0.3);
  background: rgba(34,197,94,0.05);
}

.number-chip .num { font-size: 18px; font-weight: 700; color: var(--accent2); min-width: 48px; }
.number-chip .vend { color: var(--text-dim); font-size: 12px; }
.number-chip .tick { margin-left: auto; color: var(--success); font-size: 14px; }
