/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  --surface2: #242424;
  --border: #2e2e2e;
  --accent: #00c37d;
  --accent-dim: rgba(0, 195, 125, 0.15);
  --text: #e8e8e8;
  --text-muted: #888;
  --danger: #f44336;
  --warning: #ff9800;
  --info: #2196f3;
  --success: #00c37d;
  --sidebar-w: 220px;
  --radius: 10px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
}

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

a { color: inherit; text-decoration: none; }

/* ===== LAYOUT ===== */
body { display: flex; }

.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0; bottom: 0;
  z-index: 100;
}

.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  padding: 28px 32px;
  overflow-y: auto;
}

/* ===== SIDEBAR ===== */
.sidebar-header {
  padding: 20px 16px;
  border-bottom: 1px solid var(--border);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.logo-icon {
  font-size: 20px;
  color: var(--accent);
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text-muted);
  transition: all 0.15s;
  cursor: pointer;
  font-size: 13.5px;
}

.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: var(--accent-dim); color: var(--accent); font-weight: 500; }
.nav-icon { font-size: 16px; }

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

.wa-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
  animation: pulse 2s infinite;
}

.status-dot.connected { background: var(--success); }
.status-dot.disconnected { background: var(--danger); animation: none; }
.status-dot.connecting { background: var(--warning); }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ===== PAGES ===== */
.page { display: none; }
.page.active { display: block; }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.page-header h1 { font-size: 22px; font-weight: 600; }

/* ===== STATS GRID ===== */
.stats-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: var(--radius);
  padding: 20px;
  transition: transform 0.15s;
}

.stat-card:hover { transform: translateY(-2px); }
.stat-card.warning { border-color: var(--warning); }
.stat-card.info { border-color: var(--info); }
.stat-card.success { border-color: var(--success); }

.stat-label { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-value { font-size: 26px; font-weight: 700; color: var(--text); }
.stat-card.warning .stat-value { color: var(--warning); }
.stat-card.info .stat-value { color: var(--info); }
.stat-card.success .stat-value { color: var(--success); }

/* ===== CARD ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

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

.card-header h2 { font-size: 15px; font-weight: 600; }
.card-body { padding: 20px; }

/* ===== TABLE ===== */
.table-container { overflow-x: auto; }

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

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

tbody tr { border-bottom: 1px solid var(--border); transition: background 0.1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface2); }

td {
  padding: 12px 16px;
  font-size: 13.5px;
  vertical-align: middle;
}

/* ===== BADGES ===== */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.badge-pendente { background: rgba(255,152,0,0.15); color: var(--warning); }
.badge-pago { background: rgba(0,195,125,0.15); color: var(--success); }
.badge-vencido { background: rgba(244,67,54,0.15); color: var(--danger); }
.badge-admin { background: rgba(33,150,243,0.15); color: var(--info); }
.badge-usuario { background: var(--surface2); color: var(--text-muted); }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn-primary { background: var(--accent); color: #000; }
.btn-primary:hover { background: #00a86b; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface2); color: var(--text); }
.btn-danger { background: rgba(244,67,54,0.15); color: var(--danger); border: 1px solid transparent; }
.btn-danger:hover { background: rgba(244,67,54,0.25); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.w-full { width: 100%; justify-content: center; }

/* ===== FILTERS ===== */
.filters {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filters select, .filters input, .input-date {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 7px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
}

.filters select:focus, .filters input:focus { outline: 1px solid var(--accent); }

.bulk-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  padding: 10px 16px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
}

.col-check { width: 36px; text-align: center; }
.col-check input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; accent-color: var(--accent); }

/* ===== FORMS ===== */
.form-group { margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 6px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.3px; }

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 7px;
  font-size: 13.5px;
  font-family: inherit;
  transition: border-color 0.15s;
}

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

.form-group small { display: block; color: var(--text-muted); font-size: 11px; margin-top: 4px; }
.form-group textarea { resize: vertical; min-height: 60px; }

/* Config form specific */
.config-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  gap: 20px;
}

.config-item:last-child { border-bottom: none; }

.config-info { flex: 1; }
.config-info label { display: block; font-size: 13.5px; font-weight: 500; margin-bottom: 3px; }
.config-info small { color: var(--text-muted); font-size: 12px; }
.config-control { flex-shrink: 0; }

.config-control input[type="text"],
.config-control input[type="time"] {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 7px;
  font-size: 13px;
  font-family: inherit;
  width: 180px;
}

.config-control input:focus { outline: 1px solid var(--accent); }

/* Toggle switch */
.toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 24px;
  cursor: pointer;
  transition: background 0.2s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  left: 3px; top: 3px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
}

.toggle input:checked + .toggle-slider { background: var(--accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }

/* ===== MODAL ===== */
.modal { display: none; position: fixed; inset: 0; z-index: 1000; }
.modal.open { display: flex; align-items: center; justify-content: center; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(2px);
}

.modal-dialog {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  z-index: 1;
  box-shadow: var(--shadow);
}

.modal-sm { max-width: 380px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 0;
}

.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-close { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 18px; line-height: 1; padding: 4px; }
.modal-close:hover { color: var(--text); }

.modal form { padding: 20px 24px; }
.modal-body { padding: 20px 24px; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ===== QR ===== */
.qr-card { max-width: 420px; margin: 0 auto; }
.text-center { text-align: center; }
#qr-image { border-radius: 12px; max-width: 280px; }
.qr-status { font-size: 14px; color: var(--text-muted); margin-top: 12px; }
.qr-hint { font-size: 12px; color: var(--text-muted); margin-top: 8px; }

/* ===== LINE DIGITÁVEL ===== */
.linha-digitavel-box {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  font-family: monospace;
  font-size: 13px;
  word-break: break-all;
  color: var(--accent);
  line-height: 1.6;
}

/* ===== MISC ===== */
.loading { text-align: center; color: var(--text-muted); padding: 32px; font-size: 14px; }
.empty { text-align: center; color: var(--text-muted); padding: 48px; font-size: 14px; }
.empty-icon { font-size: 36px; margin-bottom: 12px; }
.text-muted { color: var(--text-muted); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 20px; }
.mb-2 { margin-bottom: 8px; }

/* Upload area */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 20px;
  text-align: center;
  cursor: pointer;
  margin-bottom: 16px;
  transition: all 0.2s;
  background: var(--surface2);
}

.upload-area:hover { border-color: var(--accent); background: var(--accent-dim); }
.upload-area.loading { border-color: var(--warning); opacity: 0.8; cursor: wait; }
.upload-area.sucesso { border-color: var(--success); background: rgba(0,195,125,0.08); }
.upload-area.erro { border-color: var(--danger); background: rgba(244,67,54,0.08); }

/* Action buttons in table */
.actions { display: flex; gap: 4px; }

/* Proximos boletos list */
.boleto-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

.boleto-row:last-child { border-bottom: none; }
.boleto-desc { font-weight: 500; font-size: 14px; }
.boleto-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.boleto-valor { font-weight: 600; font-size: 15px; color: var(--accent); white-space: nowrap; }

/* Toast */
#toast-container { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 8px; z-index: 9999; }

.toast {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 13.5px;
  min-width: 240px;
  box-shadow: var(--shadow);
  animation: slideIn 0.2s ease;
}

.toast.success { border-color: var(--success); color: var(--success); }
.toast.error { border-color: var(--danger); color: var(--danger); }
.toast.info { border-color: var(--info); color: var(--info); }

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

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .sidebar {
    width: 60px;
  }

  .logo-text, .nav-item span:last-child, .sidebar-footer .wa-status span:last-child { display: none; }
  .nav-item { justify-content: center; padding: 10px; }
  .nav-icon { font-size: 20px; }

  .main-content { margin-left: 60px; padding: 16px; }
  .form-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 12px; }
}
