@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

/* ── Reset & Base ────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #F8FAFC;
  --surface:     #FFFFFF;
  --surface2:    #F1F5F9;
  --surface3:    #E2E8F0;
  --border:      #E2E8F0;
  --border2:     #CBD5E1;
  --text:        #020617; /* Slate 950 */
  --text2:       #1E293B; /* Slate 800 */
  --text3:       #475569; /* Slate 600 */
  --accent:      #F97316;
  --accent-dim:  rgba(249,115,22,0.12);
  --green:       #10B981;
  --green-dim:   rgba(16,185,129,0.1);
  --amber:       #F59E0B;
  --amber-dim:   rgba(245,158,11,0.1);
  --red:         #EF4444;
  --red-dim:     rgba(239,68,68,0.1);
  --blue:        #3B82F6;
  --blue-dim:    rgba(59,130,246,0.1);
  --sidebar-w-expanded: 240px;
  --sidebar-w-collapsed: 72px;
  --sidebar-w:   var(--sidebar-w-expanded);
  --radius:      12px;
  --radius-sm:   8px;
  --shadow:      0 8px 32px rgba(15,23,42,0.06);
  --transition:  0.2s cubic-bezier(0.4,0,0.2,1);
}

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

a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; border: none; background: none; }
input, select, textarea { font-family: inherit; }

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

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

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: width var(--transition), transform var(--transition);
}

.sidebar-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-shrink: 0;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  min-width: 0;
  flex: 1;
}
.sidebar-brand img {
  height: 28px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  object-position: left center;
}
.sidebar-toggle {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text3);
  transition: background var(--transition), color var(--transition);
}
.sidebar-toggle:hover {
  background: var(--surface2);
  color: var(--text2);
}
.sidebar-toggle ion-icon { font-size: 20px; transition: transform var(--transition); }
.sidebar-logo-text { display: none; }

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

.nav-section-label {
  font-size: 9px;
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  padding: 12px 10px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--text2);
  font-size: 13px;
  font-weight: 500;
  transition: all var(--transition);
  margin-bottom: 2px;
  position: relative;
}
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active {
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 700;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 6px; bottom: 6px;
  width: 3px;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
}
.nav-item .nav-icon { font-size: 17px; width: 20px; text-align: center; flex-shrink: 0; }
.nav-badge {
  margin-left: auto;
  background: var(--red);
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 20px;
  min-width: 18px;
  text-align: center;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
}
.admin-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
}
.admin-profile:hover { background: var(--surface2); }
.admin-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #FB923C);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800; color: #fff;
  flex-shrink: 0;
}
.admin-info { flex: 1; min-width: 0; }
.admin-name { font-size: 12px; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.admin-email { font-size: 10px; color: var(--text3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Main Content ─────────────────────────────────────────── */
/* Menu fixed não ocupa fluxo: reservar espaço no body evita sobreposição (ex.: flex + filhos largos). */
body:has(> aside.sidebar) {
  padding-left: var(--sidebar-w);
  transition: padding-left var(--transition);
}
body:has(> aside.sidebar) .main-content {
  margin-left: 0;
}
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
  transition: margin-left var(--transition);
}

/* ── Top Bar ─────────────────────────────────────────────── */
.topbar {
  height: 60px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 90;
}
.topbar-title { font-size: 15px; font-weight: 800; color: var(--text); flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

/* ── Page Body ───────────────────────────────────────────── */
.page-body {
  padding: 28px 28px 60px;
  flex: 1;
}

/* ── Stat Cards ──────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.stat-card:hover { border-color: var(--border2); box-shadow: var(--shadow); }
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--accent-color, var(--accent));
}
.stat-icon {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: var(--accent-dim);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  margin-bottom: 14px;
  color: var(--accent);
}
.stat-value { font-size: 26px; font-weight: 900; color: var(--text); letter-spacing: -1px; line-height: 1; margin-bottom: 4px; }
.stat-label { font-size: 11px; color: var(--text2); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-delta {
  font-size: 10px;
  font-weight: 700;
  margin-top: 8px;
  display: flex; align-items: center; gap: 4px;
}
.stat-delta.up { color: var(--green); }
.stat-delta.down { color: var(--red); }
.stat-delta.neutral { color: var(--text3); }

/* ── Cards / Panels ──────────────────────────────────────── */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 20px;
}
.panel-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.panel-title { font-size: 13px; font-weight: 700; color: var(--text); }
.panel-body { padding: 20px; }

/* ── Tables ──────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  padding: 10px 16px;
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface2); }
tbody td {
  padding: 12px 16px;
  font-size: 12px;
  color: var(--text2);
  vertical-align: middle;
}
tbody td.bold { font-weight: 700; color: var(--text); }
tbody td.mono { font-family: 'JetBrains Mono', monospace; font-size: 11px; }

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
}
.badge-green   { background: var(--green-dim); color: var(--green); }
.badge-red     { background: var(--red-dim);   color: var(--red); }
.badge-danger  { background: var(--red-dim);   color: var(--red); }
.badge-amber   { background: var(--amber-dim); color: var(--amber); }
.badge-blue    { background: var(--blue-dim);  color: var(--blue); }
.badge-accent  { background: var(--accent-dim); color: var(--accent); }
.badge-gray    { background: var(--surface3); color: var(--text2); }
.badge-purple  { background: rgba(139,92,246,0.1); color: #8B5CF6; }
.badge-success { background: var(--green-dim); color: var(--green); }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 700;
  transition: all var(--transition);
  white-space: nowrap;
  cursor: pointer;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(249,115,22,0.2);
}
.btn-primary:hover { background: #EA580C; box-shadow: 0 4px 16px rgba(249,115,22,0.3); transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--text2); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--surface2); color: var(--text); border-color: var(--border2); }
.btn-danger { background: var(--red-dim); color: var(--red); border: 1px solid rgba(239,68,68,0.2); }
.btn-danger:hover { background: var(--red); color: #fff; }
.btn-success { background: var(--green-dim); color: var(--green); border: 1px solid rgba(16,185,129,0.2); }
.btn-success:hover { background: var(--green); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 11px; }
.btn-icon { padding: 7px; border-radius: var(--radius-sm); }

/* ── Form Controls ───────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 11px; font-weight: 700; color: var(--text2); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
.form-control {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(249,115,22,0.15); }
.form-control::placeholder { color: var(--text3); }

/* ── Toggle / Switch ─────────────────────────────────────── */
.toggle-wrap { display: flex; align-items: center; gap: 10px; }
.toggle {
  position: relative;
  width: 40px; height: 22px;
  flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: 11px;
  transition: all 0.2s;
}
.toggle-track::before {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  left: 2px; top: 2px;
  background: var(--text3);
  border-radius: 50%;
  transition: all 0.2s;
}
.toggle input:checked + .toggle-track { background: var(--accent); border-color: var(--accent); }
.toggle input:checked + .toggle-track::before { transform: translateX(18px); background: #fff; }
.toggle-label { font-size: 12px; font-weight: 600; color: var(--text); }
.toggle-desc { font-size: 11px; color: var(--text3); margin-top: 2px; }

/* ── Search ──────────────────────────────────────────────── */
.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.search-wrap .search-icon { position: absolute; left: 12px; font-size: 14px; color: var(--text3); }
.search-wrap input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px 8px 36px;
  color: var(--text);
  font-size: 12px;
  outline: none;
  width: 220px;
  transition: all var(--transition);
}
.search-wrap input:focus { border-color: var(--accent); width: 280px; }
.search-wrap input::placeholder { color: var(--text3); }

/* ── Alert Rows ──────────────────────────────────────────── */
.alert-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.alert-row:last-child { border-bottom: none; }
.alert-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
}
.alert-row-content { flex: 1; }
.alert-row-title { font-size: 12px; font-weight: 700; color: var(--text); }
.alert-row-sub { font-size: 11px; color: var(--text3); margin-top: 2px; }
.alert-row-time { font-size: 10px; color: var(--text3); white-space: nowrap; }

/* ── Activity Feed ───────────────────────────────────────── */
.activity-item {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.activity-item:last-child { border-bottom: none; }
.activity-icon {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
.activity-content { flex: 1; }
.activity-text { font-size: 12px; color: var(--text2); line-height: 1.4; }
.activity-text strong { color: var(--text); font-weight: 700; }
.activity-time { font-size: 10px; color: var(--text3); margin-top: 3px; }

/* ── Modal ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
  backdrop-filter: blur(4px);
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 16px;
  width: 480px;
  max-width: 95vw;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  transform: translateY(12px);
  transition: transform 0.2s;
}
.modal-lg { width: 840px; }
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 15px; font-weight: 800; color: var(--text); }
.modal-close { color: var(--text3); font-size: 18px; cursor: pointer; transition: color var(--transition); border: none; background: none; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ── Login Page ──────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  position: relative;
  overflow: hidden;
}
.login-bg-glow {
  position: absolute;
  width: 600px; height: 600px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(249,115,22,0.1) 0%, transparent 70%);
  top: -200px; left: -200px;
  pointer-events: none;
}
.login-bg-glow2 {
  position: absolute;
  width: 400px; height: 400px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(249,115,22,0.06) 0%, transparent 70%);
  bottom: -100px; right: -100px;
  pointer-events: none;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  width: 400px;
  padding: 40px;
  box-shadow: 0 12px 48px rgba(15,23,42,0.1);
  position: relative;
  z-index: 1;
}
.login-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
}
.login-logo img {
  height: 48px;
  width: auto;
}
.login-logo-text { margin-top: 4px; }
.login-logo-text h1 { display: none; }
.login-logo-text p { font-size: 10px; color: var(--accent); font-weight: 700; text-transform: uppercase; letter-spacing: 1.5px; opacity: 0.8; }
.login-title { font-size: 22px; font-weight: 900; color: var(--text); letter-spacing: -0.5px; margin-bottom: 6px; }
.login-subtitle { font-size: 13px; color: var(--text3); margin-bottom: 28px; }

.login-btn {
  width: 100%;
  background: linear-gradient(135deg, var(--accent), #8B5CF6);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 13px;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: 0 4px 16px rgba(249,115,22,0.3);
}
.login-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(249,115,22,0.4); }
.login-btn:active { transform: translateY(0); }
.login-error {
  background: var(--red-dim);
  border: 1px solid rgba(239,68,68,0.25);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--red);
  margin-bottom: 16px;
  display: none;
}
.login-error.show { display: block; }
.login-hint {
  text-align: center;
  font-size: 11px;
  color: var(--text3);
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.login-hint code { color: var(--accent); font-weight: 700; background: var(--accent-dim); padding: 2px 6px; border-radius: 4px; }

/* ── Feature Flag Items ──────────────────────────────────── */
.flag-item {
  display: flex;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  gap: 16px;
}
.flag-item:last-child { border-bottom: none; }
.flag-icon { font-size: 22px; width: 36px; text-align: center; flex-shrink: 0; }
.flag-info { flex: 1; }
.flag-name { font-size: 13px; font-weight: 700; color: var(--text); }
.flag-desc { font-size: 11px; color: var(--text3); margin-top: 2px; }

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

/* ── Divider ─────────────────────────────────────────────── */
.divider { height: 1px; background: var(--border); margin: 20px 0; }

/* ── Empty State ─────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text3);
}
.empty-state-icon { font-size: 40px; margin-bottom: 12px; }
.empty-state-title { font-size: 14px; font-weight: 700; color: var(--text2); margin-bottom: 6px; }
.empty-state-sub { font-size: 12px; }

/* ── Sidebar recolhível (desktop) ───────────────────────── */
@media (min-width: 769px) {
  body.sidebar-collapsed {
    --sidebar-w: var(--sidebar-w-collapsed);
  }
  body.sidebar-collapsed .sidebar-toggle ion-icon {
    transform: scaleX(-1);
  }
  body.sidebar-collapsed .sidebar-header {
    flex-direction: column;
    padding: 12px 8px;
    gap: 8px;
  }
  body.sidebar-collapsed .sidebar-brand {
    justify-content: center;
  }
  body.sidebar-collapsed .sidebar-brand img {
    height: 26px;
    max-width: 44px;
    object-position: center;
  }
  body.sidebar-collapsed .nav-section-label {
    display: none;
  }
  body.sidebar-collapsed .nav-item {
    justify-content: center;
    padding: 9px 8px;
    gap: 0;
  }
  body.sidebar-collapsed .nav-item > span:not(.nav-badge) {
    display: none;
  }
  body.sidebar-collapsed .nav-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    margin-left: 0;
    min-width: 16px;
    padding: 1px 4px;
    font-size: 8px;
  }
  body.sidebar-collapsed .admin-info,
  body.sidebar-collapsed .admin-profile > ion-icon {
    display: none;
  }
  body.sidebar-collapsed .admin-profile {
    justify-content: center;
    padding: 8px 4px;
  }
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  body:has(> aside.sidebar) {
    padding-left: 0;
  }
  .main-content { margin-left: 0; }
  body.sidebar-collapsed {
    --sidebar-w: var(--sidebar-w-expanded);
  }
  .sidebar-toggle { display: none; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── Micro animations ────────────────────────────────────── */
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.fade-in { animation: fadeIn 0.3s ease forwards; }

@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }
.pulse { animation: pulse 2s infinite; }
