/* ============================================================
   Dashboard X1 — main.css
   Reset, variáveis de tema, layout principal (shell + sidebar)
   ============================================================ */

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto,
               "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0; }

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* ============================================================
   Variáveis de tema
   ============================================================ */

:root[data-theme="dark"] {
  --bg: #0b0d12;
  --bg-elevated: #12151c;
  --bg-card: #161a23;
  --bg-card-hover: #1c2030;
  --bg-input: #161a23;
  --sidebar-bg: #0e1117;
  --topbar-bg: rgba(11, 13, 18, 0.85);

  --text: #e6e8ee;
  --text-muted: #8a93a6;
  --text-strong: #ffffff;

  --border: #1f2430;
  --border-strong: #2a3142;
  --border-focus: #4f6bff;

  --accent: #6366f1;        /* indigo */
  --accent-hover: #7c7ff5;
  --accent-soft: rgba(99, 102, 241, 0.15);

  --success: #22c55e;
  --success-soft: rgba(34, 197, 94, 0.15);
  --warning: #f59e0b;
  --warning-soft: rgba(245, 158, 11, 0.15);
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.15);
  --info: #06b6d4;
  --info-soft: rgba(6, 182, 212, 0.15);

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow: 0 4px 12px rgba(0,0,0,0.35);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.45);

  --chart-grid: #1f2430;
  --chart-line: #6366f1;
}

:root[data-theme="light"] {
  --bg: #f6f7fb;
  --bg-elevated: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #fafbfd;
  --bg-input: #ffffff;
  --sidebar-bg: #ffffff;
  --topbar-bg: rgba(255, 255, 255, 0.85);

  --text: #1c2233;
  --text-muted: #6a7388;
  --text-strong: #0a0e1a;

  --border: #e5e7ee;
  --border-strong: #d0d4de;
  --border-focus: #4f6bff;

  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: rgba(79, 70, 229, 0.10);

  --success: #16a34a;
  --success-soft: rgba(22, 163, 74, 0.10);
  --warning: #d97706;
  --warning-soft: rgba(217, 119, 6, 0.12);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.10);
  --info: #0891b2;
  --info-soft: rgba(8, 145, 178, 0.10);

  --shadow-sm: 0 1px 2px rgba(15,23,42,0.05);
  --shadow: 0 4px 12px rgba(15,23,42,0.06);
  --shadow-lg: 0 12px 32px rgba(15,23,42,0.10);

  --chart-grid: #eef0f5;
  --chart-line: #4f46e5;
}

/* ============================================================
   App shell
   ============================================================ */
.app-shell {
  display: grid;
  grid-template-columns: 250px 1fr;
  min-height: 100vh;
  transition: grid-template-columns 0.2s ease;
}
.app-shell.sidebar-collapsed {
  grid-template-columns: 72px 1fr;
}

/* ============================================================
   Sidebar
   ============================================================ */
.sidebar {
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  overflow: hidden;
}
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--border);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.brand-mark {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #a855f7);
  color: white;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}
.brand-text { line-height: 1.2; min-width: 0; }
.brand-title { font-weight: 600; color: var(--text-strong); }
.brand-sub { font-size: 11px; color: var(--text-muted); }

.sidebar-collapse {
  flex-shrink: 0;
}
.app-shell.sidebar-collapsed .sidebar-collapse svg {
  transform: rotate(180deg);
}

.nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px;
}
.nav-section { margin-bottom: 8px; }
.nav-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
  padding: 12px 12px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 13.5px;
  position: relative;
  transition: background 0.12s ease, color 0.12s ease;
}
.nav-item svg { flex-shrink: 0; }
.nav-item span:not(.badge) { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-item:hover {
  background: var(--bg-card-hover);
  color: var(--text);
}
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
}
.nav-item.active::before {
  content: "";
  position: absolute;
  left: -10px;
  top: 8px; bottom: 8px;
  width: 3px;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
}
.nav-item-soon {
  opacity: 0.55;
  pointer-events: auto;
}
.nav-item-soon:hover { opacity: 0.85; }

.badge {
  background: var(--bg-card-hover);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
  min-width: 22px;
  text-align: center;
}
.nav-item.active .badge {
  background: var(--accent);
  color: white;
}
.badge-accent {
  background: var(--accent-soft);
  color: var(--accent);
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
}
.theme-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  transition: background 0.12s, color 0.12s;
}
.theme-toggle:hover {
  background: var(--bg-card-hover);
  color: var(--text);
}
:root[data-theme="dark"] .icon-sun { display: inline; }
:root[data-theme="dark"] .icon-moon { display: none; }
:root[data-theme="light"] .icon-sun { display: none; }
:root[data-theme="light"] .icon-moon { display: inline; }

/* Sidebar collapsed mode */
.app-shell.sidebar-collapsed .brand-text,
.app-shell.sidebar-collapsed .nav-section-title,
.app-shell.sidebar-collapsed .nav-item span,
.app-shell.sidebar-collapsed .theme-label {
  display: none;
}
.app-shell.sidebar-collapsed .nav-item {
  justify-content: center;
  padding: 10px;
}
.app-shell.sidebar-collapsed .sidebar-header {
  justify-content: center;
}

/* ============================================================
   Main area
   ============================================================ */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 28px;
  background: var(--topbar-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.sidebar-toggle { display: none; }
.topbar-title { flex: 1; min-width: 0; }
.topbar-title h1 {
  font-size: 18px;
  color: var(--text-strong);
}
.topbar-title p { font-size: 12.5px; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  padding: 7px 12px;
  border-radius: 8px;
  width: 240px;
  color: var(--text-muted);
  transition: border-color 0.15s, width 0.2s;
}
.search:focus-within {
  border-color: var(--border-focus);
  color: var(--text);
}
.search input {
  border: none;
  outline: none;
  background: transparent;
  flex: 1;
  font-size: 13px;
  width: 100%;
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 4px 4px;
  border-radius: 24px;
  border: 1px solid var(--border);
  background: var(--bg-card);
}
.avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #a855f7);
  color: white;
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 12px;
}
.user-info { line-height: 1.15; }
.user-name { font-weight: 600; font-size: 12.5px; color: var(--text-strong); }
.user-role { font-size: 10.5px; }

/* Page content */
.page-content {
  flex: 1;
  padding: 28px;
}
.loading-state {
  display: grid;
  place-items: center;
  height: 200px;
  color: var(--text-muted);
}

/* Helpers */
.muted { color: var(--text-muted); }
.text-strong { color: var(--text-strong); }

/* ============================================================
   Responsivo
   ============================================================ */
@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    width: 250px;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow-lg);
  }
  .app-shell.sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-toggle { display: inline-flex; }
  .sidebar-collapse { display: none; }
  .search { width: 160px; }
  .user-info { display: none; }
}
@media (max-width: 600px) {
  .topbar { padding: 14px 16px; }
  .page-content { padding: 18px; }
  .search { display: none; }
}
