/* ==========================================================
   APAudit — estilo SaaS
   Mesma linguagem visual do manual interativo do AP5030DN
   (IBM Plex, acento teal, callouts coloridos) para manter
   consistência entre os artefatos do projeto.
   ========================================================== */

:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-alt: #eef2f5;
  --border: #dde3e8;
  --text: #1a222b;
  --text-muted: #5b6b79;
  --accent: #0f8a7e;
  --accent-strong: #0b6b62;
  --accent-soft: #e3f4f1;
  --success: #1d9e75;
  --success-bg: #e1f5ee;
  --danger: #d1453d;
  --danger-bg: #fdf0ee;
  --warning: #b8860b;
  --warning-bg: #fff8ec;
  --sidebar-bg: #10161c;
  --sidebar-text: #9aabb8;
  --sidebar-text-active: #ffffff;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow-card: 0 1px 3px rgba(20, 30, 40, .06), 0 1px 2px rgba(20, 30, 40, .04);
  --shadow-hover: 0 8px 20px rgba(20, 30, 40, .10);
  --transition: .18s ease;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  font-size: 14.5px;
  line-height: 1.5;
}

code, .mono { font-family: 'IBM Plex Mono', monospace; }

a { color: var(--accent-strong); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------------- Layout shell ---------------- */
.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  padding: 20px 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar .brand {
  display: flex; align-items: center; gap: 10px;
  padding: 0 20px 4px; font-weight: 600; color: #fff; font-size: 15px;
}
.sidebar .sidebar-tagline {
  padding: 0 20px 18px; font-size: 11px; color: #6b7c88;
  border-bottom: 1px solid rgba(255,255,255,.08); margin-bottom: 14px;
}

.nav-badge {
  margin-left: auto; background: var(--accent); color: #fff;
  font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px;
  font-family: 'IBM Plex Mono', monospace;
}
.sidebar nav a { justify-content: flex-start; }

.live-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--success); position: relative; flex: none;
}
.live-dot::after {
  content: ""; position: absolute; inset: -4px; border-radius: 50%;
  border: 2px solid var(--success); opacity: .6;
  animation: livePulse 1.8s ease-out infinite;
}
@keyframes livePulse {
  0% { transform: scale(.6); opacity: .7; }
  100% { transform: scale(1.9); opacity: 0; }
}

.status-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 8px;
  border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--success-bg); color: var(--success);
}
.status-pill.offline { background: var(--surface-alt); color: var(--text-muted); }
.status-pill.offline .live-dot { background: var(--text-muted); }
.status-pill.offline .live-dot::after { display: none; }

.refresh-note {
  display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-muted);
}
.refresh-note .live-dot { margin-right: 2px; }

.row-enter { animation: rowFade .4s ease; }
@keyframes rowFade { from { background: var(--accent-soft); opacity: 0; } to { background: transparent; opacity: 1; } }

.callout-box {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--accent-soft); color: var(--accent-strong);
  border: 1px solid rgba(15,138,126,.25); border-radius: var(--radius);
  padding: 14px 18px; margin-bottom: 22px; font-size: 13.5px;
}
.callout-box i { font-size: 18px; margin-top: 2px; flex: none; }
.callout-box strong { display: block; color: var(--text); margin-bottom: 3px; font-size: 13.5px; }
.callout-box p { margin: 0; color: var(--text-muted); line-height: 1.5; }

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

.sidebar nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--sidebar-text); font-size: 13.5px; font-weight: 500;
  text-decoration: none; border-left: 3px solid transparent;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.sidebar nav a i { font-size: 17px; flex: none; }

.sidebar nav a:hover { background: rgba(255,255,255,.05); color: #fff; }

.sidebar nav a.active {
  background: rgba(15,138,126,.16); color: var(--sidebar-text-active);
  border-left-color: var(--accent);
}

.sidebar .sidebar-footer {
  padding: 14px 20px 4px; border-top: 1px solid rgba(255,255,255,.08);
  font-size: 12px; color: #6b7c88;
}

.main { min-width: 0; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 14px 26px; background: var(--surface);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10;
}

.topbar .search {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-alt); border: 1px solid var(--border);
  border-radius: 999px; padding: 8px 14px; width: 320px; max-width: 40vw;
}
.topbar .search input { border: none; background: transparent; outline: none; width: 100%; font-size: 13.5px; color: var(--text); }
.topbar .search svg { opacity: .5; flex: none; }

.topbar .user-menu { display: flex; align-items: center; gap: 10px; }
.topbar .avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--accent-soft);
  color: var(--accent-strong); display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 13px;
}

.content { padding: 26px; animation: fadeUp .35s ease; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.page-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; flex-wrap: wrap; gap: 12px; }
.page-title h1 { font-size: 21px; font-weight: 600; margin: 0; }
.page-title p { margin: 4px 0 0; color: var(--text-muted); font-size: 13.5px; }

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 16px; border-radius: var(--radius-sm); font-size: 13.5px; font-weight: 500;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  cursor: pointer; transition: all var(--transition);
}
.btn:hover { border-color: var(--accent); color: var(--accent-strong); transform: translateY(-1px); box-shadow: var(--shadow-hover); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
.btn i { font-size: 15px; }

/* ---------------- KPI cards ---------------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 24px; }

.kpi-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow-card);
  transition: transform var(--transition), box-shadow var(--transition);
  position: relative; overflow: hidden;
}
.kpi-card::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--kpi-accent, var(--accent));
}
.kpi-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); }
.kpi-card .kpi-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.kpi-card .kpi-icon {
  width: 34px; height: 34px; border-radius: 9px; display: flex; align-items: center; justify-content: center;
  background: var(--kpi-bg, var(--accent-soft)); color: var(--kpi-accent, var(--accent-strong)); font-size: 17px;
}
.kpi-card .kpi-label { font-size: 12.5px; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: .03em; }
.kpi-card .kpi-value { font-size: 28px; font-weight: 600; font-variant-numeric: tabular-nums; }
.kpi-card .kpi-delta { font-size: 12px; margin-top: 4px; color: var(--text-muted); }
.kpi-card.success { --kpi-accent: var(--success); --kpi-bg: var(--success-bg); }
.kpi-card.danger  { --kpi-accent: var(--danger);  --kpi-bg: var(--danger-bg); }

/* ---------------- Cards / panels ---------------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-card); padding: 20px 22px; margin-bottom: 22px;
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 10px; }
.card-header h2 { font-size: 15.5px; font-weight: 600; margin: 0; }

.charts-row { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; margin-bottom: 22px; }
@media (max-width: 900px) { .charts-row { grid-template-columns: 1fr; } }

/* ---------------- Filters ---------------- */
.filters { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
.filters select, .filters input[type="date"], .filters input[type="text"] {
  padding: 9px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); font-size: 13.5px; color: var(--text); font-family: inherit;
  transition: border-color var(--transition);
}
.filters select:focus, .filters input:focus { outline: none; border-color: var(--accent); }
.filters .search-field { flex: 1; min-width: 220px; }

/* ---------------- Badges ---------------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px;
  border-radius: 999px; font-size: 12px; font-weight: 600;
}
.badge i { font-size: 13px; }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger); }

/* ---------------- Table ---------------- */
table.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data-table th {
  text-align: left; padding: 11px 14px; background: var(--surface-alt);
  font-weight: 600; font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .02em;
  border-bottom: 1px solid var(--border);
}
table.data-table td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data-table tbody tr { transition: background var(--transition); }
table.data-table tbody tr:hover { background: var(--surface-alt); }

/* DataTables layout tweaks to match the SaaS look */
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_length { display: none; }
.dataTables_wrapper .dataTables_info { color: var(--text-muted); font-size: 13px; padding-top: 12px; }
.dataTables_wrapper .dataTables_paginate { padding-top: 10px; }
.dataTables_wrapper .dataTables_paginate .paginate_button {
  padding: 6px 11px !important; margin-left: 4px; border-radius: var(--radius-sm) !important;
  border: 1px solid var(--border) !important; background: var(--surface) !important; color: var(--text) !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.current {
  background: var(--accent) !important; border-color: var(--accent) !important; color: #fff !important;
}
.dt-buttons { display: flex; gap: 8px; }
.dt-buttons .dt-button {
  padding: 9px 14px !important; border-radius: var(--radius-sm) !important; border: 1px solid var(--border) !important;
  background: var(--surface) !important; color: var(--text) !important; font-size: 13.5px !important; font-weight: 500 !important;
  font-family: inherit !important; transition: all var(--transition);
}
.dt-buttons .dt-button:hover { border-color: var(--accent) !important; color: var(--accent-strong) !important; }

/* ---------------- Login page ---------------- */
.login-shell {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #10161c 0%, #17222b 100%);
}
.login-card {
  background: var(--surface); border-radius: 16px; padding: 40px 36px;
  width: 100%; max-width: 380px; box-shadow: 0 20px 60px rgba(0,0,0,.35);
  animation: fadeUp .4s ease;
}
.login-card .brand { display: flex; align-items: center; gap: 10px; margin-bottom: 26px; font-weight: 600; font-size: 16px; }
.login-card .brand .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.login-card label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; color: var(--text-muted); }
.login-card input {
  width: 100%; padding: 11px 13px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  font-size: 14px; margin-bottom: 16px; font-family: inherit; transition: border-color var(--transition);
}
.login-card input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.login-card button { width: 100%; justify-content: center; padding: 11px; font-size: 14px; }
.login-error {
  background: var(--danger-bg); color: var(--danger); padding: 10px 13px; border-radius: var(--radius-sm);
  font-size: 13px; margin-bottom: 16px; display: flex; align-items: center; gap: 8px;
  animation: shake .3s ease;
}
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

/* ---------------- Toast ---------------- */
.toast {
  position: fixed; top: 18px; right: 18px; z-index: 999;
  background: var(--text); color: #fff; padding: 12px 18px; border-radius: var(--radius-sm);
  font-size: 13.5px; box-shadow: var(--shadow-hover);
  display: flex; align-items: center; gap: 8px;
  animation: slideIn .25s ease, fadeOutToast .25s ease 2.6s forwards;
}
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeOutToast { to { opacity: 0; transform: translateY(-6px); } }

/* ---------------- Skeleton loading ---------------- */
.skeleton {
  background: linear-gradient(90deg, var(--surface-alt) 25%, #e4e9ec 37%, var(--surface-alt) 63%);
  background-size: 400% 100%; animation: skeleton-loading 1.4s ease infinite; border-radius: var(--radius-sm);
}
@keyframes skeleton-loading { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ---------------- Count-up number animation hook ---------------- */
.count-up { display: inline-block; }

@media (max-width: 780px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: -240px; z-index: 50; transition: left var(--transition); }
  .sidebar.open { left: 0; }
}
