/* ============================================================
   SALDOAMIGO ADMIN — Estilos do Painel de Administração
   Reaproveita os mesmos tokens de assets/css/global.css e o
   mesmo "esqueleto" visual do dashboard (sidebar, topbar, cards,
   tabelas, paginação) para manter consistência entre as telas.
   ============================================================ */

body.admin-body {
  background: var(--bg);
  overflow-x: hidden;
}

/* ── Loading Screen ── */
#loading-screen {
  position: fixed; inset: 0;
  background: var(--sidebar-bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; z-index: 9999;
  transition: opacity .4s ease;
}
#loading-screen.hidden { opacity: 0; pointer-events: none; }
.loading-logo { color: #fff; font-size: 1.4rem; font-weight: 800; letter-spacing: -.3px; display: flex; align-items: center; gap: 12px; }
.loading-logo-verde { color: var(--green); }
.loading-logo-img { width: 60px; height: 60px; border-radius: 9px; object-fit: cover; }
.loading-ring { width: 44px; height: 44px; border: 3px solid rgba(255,255,255,.1); border-top-color: var(--cyan); border-radius: 50%; animation: spin .8s linear infinite; }

/* ── Layout Shell ── */
#app { display: flex; min-height: 100vh; }

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w); min-height: 100vh;
  background: var(--sidebar-bg);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 100;
  transition: transform .25s ease;
  border-right: 1px solid rgba(255,255,255,.05);
}
.sidebar-header { padding: 22px 18px; border-bottom: 1px solid rgba(255,255,255,.06); }
.sidebar-logo { display: flex; align-items: center; gap: 11px; }
.sidebar-logo-img { width: 34px; height: 34px; border-radius: 9px; object-fit: cover; }
.sidebar-logo-text { color: #fff; font-weight: 800; font-size: 0.95rem; }
.sidebar-logo-text span { color: var(--green); }
.admin-tag {
  display: inline-block; margin-top: 4px;
  font-size: 0.62rem; font-weight: 700; letter-spacing: 1px; text-transform: uppercase;
  color: var(--sidebar-bg); background: var(--cyan);
  padding: 2px 8px; border-radius: var(--radius-full);
}

.sidebar-nav { flex: 1; padding: 14px 10px; overflow-y: auto; }
.nav-section-label { color: #fff; font-size: 0.68rem; font-weight: 700; letter-spacing: 1.3px; text-transform: uppercase; padding: 8px 10px 5px; margin-top: 4px; opacity: .55; }
.nav-link {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  cursor: pointer; color: #fff; font-size: 0.875rem; font-weight: 500;
  transition: var(--ease); margin-bottom: 2px; position: relative;
  text-decoration: none; border: none; background: none; width: 100%; text-align: left;
  font-family: 'DM Sans', sans-serif;
}
.nav-link:hover { background: rgba(255,255,255,.06); color: rgba(255,255,255,.85); }
.nav-link.active { background: rgba(0,229,255,.1); color: var(--green); }
.nav-link.active::before {
  content: ''; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 20px; background: var(--green); border-radius: 0 99px 99px 0;
}
.nav-icon { width: 17px; text-align: center; font-size: 0.875rem; }

.sidebar-footer { padding: 14px; border-top: 1px solid rgba(255,255,255,.06); }
.user-card { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: var(--radius); cursor: pointer; transition: var(--ease); }
.user-card:hover { background: rgba(255,255,255,.06); }
.user-avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--grad-brand); display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 800; font-size: 0.9rem; flex-shrink: 0; }
.user-info { flex: 1; min-width: 0; }
.user-name { color: #fff; font-size: 0.85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-email { color: rgba(255,255,255,.38); font-size: 0.73rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logout-btn { color: rgba(255,255,255,.3); background: none; border: none; cursor: pointer; padding: 4px; border-radius: 6px; transition: var(--ease); font-size: 0.875rem; }
.logout-btn:hover { color: #fc8181; background: rgba(255,100,100,.1); }

/* ── Main / Topbar ── */
.main { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
  background: #fff; border-bottom: 1px solid var(--border);
  padding: 14px 28px; display: flex; align-items: center; justify-content: space-between;
  gap: 16px; position: sticky; top: 0; z-index: 50;
}
.topbar-left { display: flex; align-items: center; gap: 14px; }
.hamburger { display: none; background: none; border: none; cursor: pointer; color: var(--text); font-size: 1.15rem; padding: 4px; border-radius: var(--radius-sm); transition: var(--ease); }
.hamburger:hover { background: var(--bg); }
.page-title { font-family: 'DM Serif Display', serif; font-size: 1.3rem; color: var(--text); }
.page-subtitle { color: var(--muted); font-size: 0.78rem; margin-top: 1px; }
.topbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.period-select, .search-input, .filter-select {
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px 12px; font-family: 'DM Sans', sans-serif; font-size: 0.83rem;
  color: var(--text); background: #fff; cursor: pointer; transition: var(--ease); outline: none;
}
.period-select:focus, .search-input:focus, .filter-select:focus { border-color: var(--primary); }
.search-input { cursor: text; min-width: 220px; }

.btn-refresh {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border); background: var(--surface);
  cursor: pointer; font-size: 0.8rem; font-weight: 600; color: var(--text-secondary);
  transition: var(--ease); font-family: 'DM Sans', sans-serif;
}
.btn-refresh:hover { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }

/* ── Content ── */
.content { padding: 24px 28px; flex: 1; }
.page { display: none; }
.page.active { display: block; animation: fadeIn .2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ── Mock/Demo banner ── */
#admin-demo-banner {
  background: var(--amber-light); border: 1px solid var(--amber);
  color: #8a5a00; border-radius: var(--radius); padding: 10px 16px;
  font-size: 0.82rem; margin-bottom: 18px; display: flex; align-items: center; gap: 8px;
}

/* ── Stats Grid (reaproveitado do dashboard) ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 10px; transition: var(--ease-slow); }
.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.stat-row { display: flex; align-items: center; justify-content: space-between; }
.stat-label { color: var(--muted); font-size: 0.78rem; font-weight: 500; }
.stat-icon { width: 34px; height: 34px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; font-size: 0.85rem; }
.stat-value { font-size: 1.5rem; font-weight: 800; line-height: 1; letter-spacing: -.5px; }
.stat-sub { font-size: 0.75rem; color: var(--muted); }
.stat-sub.up { color: var(--green); }
.stat-sub.down { color: var(--red); }

/* ── Card ── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; margin-bottom: 20px; }
.card-header { padding: 20px 22px 0; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.card-title { font-family: 'DM Serif Display', serif; font-size: 1rem; color: var(--text); }
.card-desc { color: var(--muted); font-size: 0.77rem; margin-top: 2px; }
.card-body { padding: 16px 22px 22px; }

/* ── Charts ── */
.charts-row { display: grid; grid-template-columns: 3fr 2fr; gap: 16px; margin-bottom: 20px; }
.chart-container { position: relative; }
.donut-legend { display: flex; flex-direction: column; gap: 7px; margin-top: 12px; }
.legend-row { display: flex; align-items: center; gap: 8px; font-size: 0.78rem; }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.legend-name { flex: 1; color: var(--text); font-weight: 500; }
.legend-val { color: var(--muted); font-weight: 600; font-size: 0.77rem; }

/* ── Table ── */
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.855rem; }
thead tr { border-bottom: 1.5px solid var(--border); }
th { padding: 10px 16px; text-align: left; color: var(--muted); font-weight: 700; font-size: 0.72rem; text-transform: uppercase; letter-spacing: .7px; white-space: nowrap; background: var(--bg); }
td { padding: 11px 16px; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(240,244,248,.6); }
.tx-date { color: var(--muted); font-size: 0.8rem; white-space: nowrap; }

/* ── Status Pills (clientes) ── */
.status-pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 11px; border-radius: var(--radius-full); font-size: 0.72rem; font-weight: 700; white-space: nowrap; }
.status-pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; }
.status-ativo { background: var(--green-light); color: var(--green-dark); }
.status-ativo::before { background: var(--green); }
.status-trial { background: var(--cyan-dim); color: #007a94; }
.status-trial::before { background: var(--cyan); }
.status-inativo { background: var(--amber-light); color: #8a5a00; }
.status-inativo::before { background: var(--amber); }
.status-cancelado { background: var(--red-light); color: var(--red); }
.status-cancelado::before { background: var(--red); }

.btn-icon-sm {
  background: none; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-secondary); transition: var(--ease); font-size: 0.8rem;
}
.btn-icon-sm:hover { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }

/* ── Pagination (reaproveitado) ── */
.pagination { display: flex; align-items: center; justify-content: space-between; padding: 12px 22px; border-top: 1px solid var(--border); gap: 10px; flex-wrap: wrap; }
.pg-info { color: var(--muted); font-size: 0.78rem; }
.pg-btns { display: flex; gap: 4px; align-items: center; }
.pg-btn { min-width: 30px; height: 30px; border-radius: var(--radius-sm); border: 1.5px solid var(--border); background: var(--surface); cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 0.8rem; font-weight: 600; color: var(--text); transition: var(--ease); padding: 0 6px; }
.pg-btn:hover:not(:disabled) { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }
.pg-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pg-btn:disabled { opacity: .35; cursor: not-allowed; }

/* ── Filtros ── */
.filters-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }

/* ── Empty State ── */
.empty-state { text-align: center; padding: 56px 20px; color: var(--muted); }
.empty-state i { font-size: 2.2rem; opacity: .25; display: block; margin-bottom: 12px; }
.empty-state p { font-size: 0.875rem; }

/* ── Links de Infraestrutura (não recriamos monitoramento, só linkamos) ── */
.links-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.infra-link-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; text-decoration: none; transition: var(--ease-slow);
}
.infra-link-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); border-color: var(--primary); }
.infra-link-icon { width: 40px; height: 40px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; font-size: 1rem; flex-shrink: 0; }
.infra-link-name { font-weight: 700; font-size: 0.9rem; color: var(--text); }
.infra-link-desc { font-size: 0.75rem; color: var(--muted); margin-top: 2px; }
.infra-link-arrow { margin-left: auto; color: var(--muted-light); }

.health-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.health-ok { background: var(--green); box-shadow: 0 0 0 3px var(--green-light); }
.health-fail { background: var(--red); box-shadow: 0 0 0 3px var(--red-light); }
.health-checking { background: var(--muted-light); }
.health-row { display: flex; align-items: center; gap: 6px; font-size: 0.8rem; color: var(--text-secondary); margin-top: 10px; }

/* ── Overlay (mobile) ── */
.overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 90; }
.overlay.visible { display: block; }

/* ── Tela de Login do Admin (mesmo padrão visual do card de acesso da landing) ── */
.admin-login-wrap {
  min-height: 100vh; width: 100%;
  background: var(--grad-dark);
  display: flex; align-items: center; justify-content: center;
  padding: 24px; position: relative; overflow: hidden;
}
.admin-login-wrap::before {
  content: ''; position: absolute; top: -120px; right: -120px;
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(0,229,255,.1) 0%, transparent 65%);
  border-radius: 50%; pointer-events: none;
}
.admin-login-box {
  width: 100%; max-width: 400px;
  background: rgba(255,255,255,.06);
  backdrop-filter: blur(24px);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: var(--radius-xl);
  padding: 40px 36px;
  position: relative; z-index: 1;
}
.admin-login-tag {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--cyan-dim); color: var(--cyan);
  border: 1px solid rgba(0,229,255,.25);
  padding: 5px 14px; border-radius: var(--radius-full);
  font-size: 0.72rem; font-weight: 700; letter-spacing: .6px; text-transform: uppercase;
  margin-bottom: 22px;
}
.admin-login-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 30px; }
.admin-login-logo img { width: 40px; height: 40px; border-radius: 10px; object-fit: cover; }
.admin-login-logo span { color: #fff; font-weight: 700; font-size: 1.05rem; }
.admin-login-logo span b { color: var(--green); font-weight: 800; }
.admin-login-logo span em { color: rgba(255,255,255,.4); font-style: normal; font-weight: 500; font-size: 0.85rem; }

#admin-login-section h3, #admin-forgot-section h3 { font-size: 1.15rem; font-weight: 700; color: #fff; margin-bottom: 4px; font-family: 'DM Sans', sans-serif; }
#admin-login-section .sub, #admin-forgot-section .sub { color: rgba(255,255,255,.5); font-size: 0.82rem; margin-bottom: 26px; }

.admin-login-box .field { margin-bottom: 16px; position: relative; }
.admin-login-box .field label { display: block; font-size: 0.72rem; font-weight: 700; color: rgba(255,255,255,.5); letter-spacing: .6px; text-transform: uppercase; margin-bottom: 6px; }
.admin-login-box .field-input {
  width: 100%; background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.15); border-radius: var(--radius);
  color: #fff; padding: 13px 16px; font-size: 0.9rem;
  font-family: 'DM Sans', sans-serif; transition: var(--ease); outline: none;
}
.admin-login-box .field-input::placeholder { color: rgba(255,255,255,.35); }
.admin-login-box .field-input:focus { border-color: var(--cyan); background: rgba(255,255,255,.12); box-shadow: 0 0 0 3px rgba(0,229,255,.12); }
.admin-login-box .input-wrapper { position: relative; display: flex; align-items: center; }
.admin-login-box .input-wrapper .field-input { padding-right: 42px; }
.admin-login-box .toggle-password { position: absolute; right: 15px; cursor: pointer; color: rgba(255,255,255,.4); transition: var(--ease); }
.admin-login-box .toggle-password:hover { color: #fff; }

.admin-login-box .btn-login-primary {
  width: 100%; background: var(--grad-green); color: var(--primary-dark);
  border: none; padding: 15px; border-radius: var(--radius-full);
  font-weight: 800; font-size: 0.95rem; cursor: pointer;
  transition: var(--ease-slow); letter-spacing: .3px;
  font-family: 'DM Sans', sans-serif;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.admin-login-box .btn-login-primary:hover { opacity: .9; transform: scale(1.02); }
.admin-login-box .btn-login-primary:disabled { opacity: .6; cursor: not-allowed; transform: none; }

.admin-login-box .divider { display: flex; align-items: center; gap: 12px; margin: 20px 0 4px; color: rgba(255,255,255,.3); font-size: 0.75rem; }
.admin-login-box .divider::before, .admin-login-box .divider::after { content: ''; flex: 1; height: 1px; background: rgba(255,255,255,.1); }
.admin-login-box .auth-links { display: flex; justify-content: center; gap: 20px; margin-top: 14px; }
.admin-login-box .auth-links a { color: rgba(255,255,255,.45); font-size: 0.8rem; transition: var(--ease); text-decoration: none; }
.admin-login-box .auth-links a:hover { color: var(--cyan); }

.admin-login-box .auth-msg { display: none; border-radius: var(--radius-sm); padding: 10px 14px; font-size: 0.82rem; margin-top: 14px; }
.admin-login-box .auth-msg.error   { display: block; background: rgba(229,62,62,.12); border: 1px solid rgba(229,62,62,.25); color: #fc8181; }
.admin-login-box .auth-msg.success { display: block; background: rgba(46,204,113,.12); border: 1px solid rgba(46,204,113,.25); color: #68D391; }

@media (max-width: 480px) {
  .admin-login-box { padding: 32px 24px; }
}

/* ── Access denied ── */
.access-denied { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; text-align: center; padding: 24px; gap: 14px; }
.access-denied i { font-size: 2.6rem; color: var(--red); }

/* ── Responsive ── */
* { box-sizing: border-box; }
html, body { overflow-x: hidden; max-width: 100vw; }
#app, .main, .content { max-width: 100%; overflow-x: hidden; }
.card, .card-body, .charts-row, .charts-row > .card, .stats-grid > .stat-card, .stat-card { min-width: 0; max-width: 100%; }
.chart-container { width: 100%; max-width: 100%; overflow: hidden; }
.table-scroll { width: 100%; max-width: 100%; overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; }
.table-scroll table { width: 100%; min-width: 640px; table-layout: auto; border-collapse: collapse; }
td, th { white-space: nowrap; }

@media (max-width: 1024px) {
  .charts-row { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .hamburger { display: flex; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .content { padding: 16px; }
  .topbar { padding: 12px 16px; flex-wrap: wrap; }
  .card-header { padding: 16px 16px 0; }
  .card-body { padding: 14px 16px 16px; }
  .search-input { min-width: 0; width: 100%; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .pagination { flex-direction: column; align-items: flex-start; gap: 8px; }
}
