:root {
  --primary: #0B9A5A;
  --primary-dark: #067647;
  --primary-light: #E3F6EC;
  --primary-glow: rgba(11, 154, 90, 0.15);
  --dark-bg: #0D1512;
  --dark-card: #131E1A;
  --dark-border: #1E2E28;
  --text-main: #FFFFFF;
  --text-muted: #95A5A0;
  --text-sub: #5E716B;
  --accent-amber: #FDB022;
  --accent-danger: #F04438;
  --accent-blue: #0BA5EC;
  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 20px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  background: var(--dark-bg);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
}

/* ==================== LOGIN SCREEN ==================== */
.auth-wrapper {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 50% 20%, #152720 0%, var(--dark-bg) 70%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--dark-card);
  border: 1px solid var(--dark-border);
  border-radius: var(--r-lg);
  padding: 36px 28px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.auth-header {
  text-align: center;
  margin-bottom: 28px;
}

.auth-logo {
  height: 38px;
  margin-bottom: 12px;
}

.auth-header h1 {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

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

.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.form-input {
  width: 100%;
  height: 48px;
  background: #0B120F;
  border: 1px solid var(--dark-border);
  border-radius: var(--r-sm);
  padding: 0 14px;
  color: #fff;
  font-size: 14.5px;
  font-weight: 600;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.btn-primary {
  width: 100%;
  height: 48px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--r-sm);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.1s, background 0.2s, box-shadow 0.2s;
  box-shadow: 0 4px 14px rgba(11, 154, 90, 0.35);
}

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

.btn-primary:active {
  transform: scale(0.98);
}

.auth-alert {
  padding: 10px 12px;
  border-radius: var(--r-sm);
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}

.auth-alert.error {
  display: block;
  background: rgba(240, 68, 56, 0.15);
  border: 1px solid var(--accent-danger);
  color: #FDA29B;
}

/* ==================== DASHBOARD LAYOUT ==================== */
.dashboard-layout {
  display: flex;
  width: 100%;
  min-height: 100vh;
}

/* Sidebar */
aside.sidebar {
  width: 260px;
  background: var(--dark-card);
  border-right: 1px solid var(--dark-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform 0.3s ease;
}

.sidebar-brand {
  padding: 24px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--dark-border);
}

.sidebar-brand h2 {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.sidebar-brand .badge-admin {
  background: var(--primary-glow);
  color: var(--primary);
  font-size: 10px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  border: 1px solid rgba(11, 154, 90, 0.3);
}

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

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--r-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-link svg {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
}

.nav-link.active {
  background: var(--primary-glow);
  color: var(--primary);
  border: 1px solid rgba(11, 154, 90, 0.25);
}

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

.user-badge {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.user-info {
  min-width: 0;
}

.user-name {
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 11px;
  color: var(--text-muted);
}

.btn-logout {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}

.btn-logout:hover {
  color: var(--accent-danger);
  background: rgba(240, 68, 56, 0.1);
}

/* Main Content */
main.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow-y: auto;
}

header.topbar {
  height: 70px;
  border-bottom: 1px solid var(--dark-border);
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(13, 21, 18, 0.8);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title h1 {
  font-size: 19px;
  font-weight: 800;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(11, 154, 90, 0.12);
  border: 1px solid rgba(11, 154, 90, 0.3);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 8px var(--primary);
  animation: pulse 1.8s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.6; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.6; }
}

.content-body {
  padding: 28px;
  flex: 1;
}

/* Tab Panels */
.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* ==================== CARDS & METRICS ==================== */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}

.card {
  background: var(--dark-card);
  border: 1px solid var(--dark-border);
  border-radius: var(--r-md);
  padding: 20px;
}

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

.metric-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.metric-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.05);
}

.metric-icon.green { background: var(--primary-glow); color: var(--primary); }
.metric-icon.blue { background: rgba(11, 165, 236, 0.15); color: var(--accent-blue); }
.metric-icon.amber { background: rgba(253, 176, 34, 0.15); color: var(--accent-amber); }
.metric-icon.purple { background: rgba(155, 138, 254, 0.15); color: #9B8AFE; }

.metric-value {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
}

.metric-sub {
  font-size: 12px;
  color: var(--text-sub);
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.metric-sub.up { color: var(--primary); }

/* Charts container */
.chart-card {
  margin-bottom: 24px;
}

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

.chart-header h3 {
  font-size: 16px;
  font-weight: 700;
}

.chart-wrapper {
  position: relative;
  height: 280px;
  width: 100%;
}

/* ==================== ADS CONFIGURATION ==================== */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 24px;
}

@media (max-width: 992px) {
  .settings-grid {
    grid-template-columns: 1fr;
  }
}

.switch-group {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-radius: var(--r-sm);
  background: #0B120F;
  border: 1px solid var(--dark-border);
  margin-bottom: 20px;
}

.switch-group-text b {
  font-size: 14.5px;
  display: block;
}

.switch-group-text small {
  color: var(--text-muted);
  font-size: 12.5px;
}

.toggle-switch {
  position: relative;
  width: 50px;
  height: 28px;
  flex-shrink: 0;
}

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

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: #26352F;
  transition: 0.3s;
  border-radius: 34px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--primary);
}

input:checked + .slider:before {
  transform: translateX(22px);
}

.ad-type-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--dark-border);
  padding-bottom: 12px;
}

.ad-type-btn {
  padding: 8px 16px;
  background: none;
  border: 1px solid var(--dark-border);
  border-radius: var(--r-sm);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 13.5px;
  cursor: pointer;
  transition: all 0.2s;
}

.ad-type-btn.active {
  background: var(--primary-glow);
  border-color: var(--primary);
  color: var(--primary);
}

.ad-preview-box {
  background: #0B120F;
  border: 1px dashed var(--dark-border);
  border-radius: var(--r-md);
  padding: 20px;
  text-align: center;
  min-height: 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-top: 14px;
}

.ad-preview-box img {
  max-width: 100%;
  max-height: 160px;
  border-radius: 8px;
  object-fit: cover;
}

/* ==================== CADASTROS TABLE ==================== */
.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.search-input-wrap {
  position: relative;
  flex: 1;
  max-width: 320px;
}

.search-input-wrap input {
  padding-left: 38px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

table.admin-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

table.admin-table th {
  padding: 14px 16px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--dark-border);
  font-weight: 700;
}

table.admin-table td {
  padding: 16px;
  font-size: 14px;
  border-bottom: 1px solid var(--dark-border);
}

table.admin-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.status-badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.status-badge.active { background: rgba(11, 154, 90, 0.15); color: #32D583; }
.status-badge.pending { background: rgba(253, 176, 34, 0.15); color: var(--accent-amber); }
.status-badge.blocked { background: rgba(240, 68, 56, 0.15); color: var(--accent-danger); }

/* Action buttons */
.btn-action {
  background: none;
  border: 1px solid var(--dark-border);
  color: var(--text-muted);
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  transition: all 0.15s;
}

.btn-action:hover {
  border-color: var(--primary);
  color: #fff;
}

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

.modal-backdrop.open {
  display: flex;
}

.modal-card {
  width: 100%;
  max-width: 480px;
  background: var(--dark-card);
  border: 1px solid var(--dark-border);
  border-radius: var(--r-lg);
  padding: 28px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.5);
}

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

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

/* Toast */
.admin-toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  background: var(--primary);
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--r-sm);
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 2000;
}

.admin-toast.show {
  transform: translateY(0);
  opacity: 1;
}

/* Responsive */
@media (max-width: 768px) {
  aside.sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    transform: translateX(-100%);
  }

  aside.sidebar.open {
    transform: translateX(0);
  }

  .content-body {
    padding: 16px;
  }
}
