/* ═══════════════════════════════════════════════
   GIL — Layout
   ═══════════════════════════════════════════════ */

/* ── Header ── */
.app-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  height: var(--header-height); padding: 0 24px;
  background: var(--bg-header); border-bottom: 1px solid var(--border);
}
.logo {
  font-weight: var(--fw-semibold, 600); font-size: var(--font-lg, 16px); color: var(--blue-light);
  letter-spacing: -0.5px;
}
.logo span {
  color: var(--text-secondary); font-weight: var(--fw-regular, 400);
  font-size: var(--font-sm, 12px); margin-left: 8px;
}
.header-right {
  display: flex; align-items: center; gap: 10px;
}
.user-chip {
  display: flex; align-items: center; gap: 8px;
  font-size: var(--font-sm, 12px); font-weight: var(--fw-medium, 500); color: var(--green-light);
}
.timestamp {
  font-size: var(--font-xs, 11px); color: var(--text-muted);
}

/* ── Header sliders (brilho texto/tela/zoom) ── */
.hdr-sliders {
  display: flex; align-items: center; gap: 4px;
  padding: 4px 8px; margin-right: 8px;
  background: rgba(56,139,253,.05);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.hdr-sliders .hdr-sl-lbl {
  font-size: 12px; color: var(--text-muted);
  padding: 0 2px 0 4px; user-select: none;
}
.hdr-sliders .hdr-sl-lbl:first-child { padding-left: 0; }
.hdr-sliders .hdr-sl {
  width: 60px; height: 4px; margin: 0;
  accent-color: var(--blue, #388bfd);
  cursor: pointer;
}
.hdr-sliders .hdr-sl-step {
  width: 18px; height: 18px; padding: 0; margin: 0;
  font-size: 11px; font-weight: 700;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-primary);
  border-radius: 4px; cursor: pointer;
  line-height: 1;
}
.hdr-sliders .hdr-sl-step:hover {
  background: var(--blue, #388bfd); color: #fff; border-color: var(--blue, #388bfd);
}
@media (max-width: 1400px) {
  .hdr-sliders .hdr-sl { width: 48px; }
}
@media (max-width: 1200px) {
  .hdr-sliders .hdr-sl-step { display: none; }
  .hdr-sliders .hdr-sl { width: 50px; }
}
@media (max-width: 980px) {
  .hdr-sliders { display: none; }
}

/* ── Sidebar ── */
.sidebar {
  position: fixed; top: var(--header-height); left: 0; bottom: 0;
  width: var(--sidebar-collapsed); background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  overflow-y: auto; overflow-x: visible; z-index: 90;
  padding: 12px 0;
}
/* Never expand — always icon-only */
.sidebar .nav-label { display:none !important; }
.sidebar .sidebar-label { display:none !important; }
.sidebar-section {
  padding: 0 6px; margin-bottom: 4px;
}
.sidebar-label {
  font-size: var(--font-xs, 11px); font-weight: var(--fw-semibold, 600); text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--text-muted);
  padding: 8px 12px 4px; margin-top: 8px;
}
.nav-item {
  display: flex; align-items: center; justify-content: center;
  padding: 9px; border-radius: 6px;
  font-size: var(--font-md, 13px); font-weight: var(--fw-medium, 500); color: rgba(255,255,255,.18);
  cursor: pointer; transition: color .2s, background .2s;
  text-decoration: none; border: none; background: none;
  width: 100%; font-family: inherit;
  position: relative;
}
.nav-item:hover {
  background: var(--bg-card-hover); color: rgba(255,255,255,.6);
  text-decoration: none;
}
.nav-item.active {
  background: rgba(74,144,210,.12); color: #4a90d2;
}
.nav-item .nav-icon { font-size: 16px; width: 20px; text-align: center; }
.nav-item .nav-label { white-space: nowrap; }

/* Tooltip on hover — shows label to the right */
.nav-item[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%) translateX(-4px);
  background: #1a2744;
  color: #e6edf3;
  border: 1px solid rgba(56,139,253,.25);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  white-space: nowrap;
  z-index: 999;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0,0,0,.35);
  letter-spacing: 0.03em;
  opacity: 0;
  transition: opacity .15s ease, transform .15s ease;
}
.nav-item[data-tooltip]:hover::after {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}

/* ── Main Content — flex column com altura FIXA (100vh - header).
   Sem padding (modulos gerenciam seu proprio espacamento interno).
   overflow:hidden + flex column permite que modulos usem flex:1 + min-height:0
   pra suas tabelas expandirem ate o fim da viewport. ── */
.main-content {
  margin-left: var(--sidebar-collapsed);
  margin-top: var(--header-height);
  padding: 0;
  height: calc(100vh - var(--header-height));
  max-height: calc(100vh - var(--header-height));
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ── Page Header ── */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.page-header h1 { font-size: 20px; font-weight: 700; }
.page-header .sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ── Login Screen ── */
.login-screen {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-body); z-index: 200;
}
.login-box {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 48px; width: 420px;
  text-align: center;
}
.login-logo { font-size: 28px; font-weight: 800; color: var(--blue-light); margin-bottom: 4px; }
.login-sub { font-size: 13px; color: var(--text-secondary); margin-bottom: 32px; }
.login-input {
  width: 100%; padding: 12px 16px; margin-bottom: 12px;
  background: var(--bg-input); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: 6px;
  font-size: 14px; font-family: inherit;
}
.login-input:focus { border-color: var(--border-focus); outline: none; }
.login-input::placeholder { color: var(--text-muted); }
.login-btn { width: 100%; padding: 12px; font-size: 14px; justify-content: center; margin-top: 4px; }
.login-error { color: var(--red); font-size: 12px; margin-top: 12px; display: none; }

/* ── Cards Grid ── */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

/* ── Responsive ── */
@media (max-width: 1024px) {
  /* Sidebar already collapsed by default, no changes needed */
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed; left: -100%; width: 260px;
    transition: left 0.3s ease; z-index: 150;
  }
  .sidebar.open { left: 0; }
  .sidebar.open .nav-label { display: inline !important; }
  .sidebar.open .sidebar-label { display: block !important; }
  .main-content { margin-left: 0; padding: 20px 16px; }
  .cards-grid { grid-template-columns: 1fr; gap: 12px; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .app-header { padding: 0 16px; }
}

/* ── Light Theme Overrides ── */
[data-theme="light"] .app-header {
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
}
[data-theme="light"] .logo {
  color: var(--blue, #2563eb);
}
[data-theme="light"] .logo span {
  color: var(--text-support, #5c7084);
}
[data-theme="light"] .sidebar {
  background: #f0f4f9;
  border-right: 1px solid var(--border);
}
[data-theme="light"] .sidebar-label {
  color: var(--text-muted, #8295a8);
}
[data-theme="light"] .nav-item {
  color: var(--text-secondary, #3d5068);
}
[data-theme="light"] .nav-item:hover {
  background: #e5edf9;
  color: var(--text-primary, #1a2335);
}
[data-theme="light"] .nav-item.active {
  background: rgba(37,99,235,0.10);
  color: var(--blue, #2563eb);
}
[data-theme="light"] .nav-item .nav-icon {
  opacity: 0.85;
}
[data-theme="light"] .user-chip {
  color: var(--green, #1a7f3c);
}
[data-theme="light"] .timestamp {
  color: var(--text-muted, #8295a8);
}
[data-theme="light"] .header-right button,
[data-theme="light"] .header-right a {
  color: var(--text-secondary, #3d5068);
}
[data-theme="light"] ::-webkit-scrollbar-thumb {
  background: var(--border);
}
[data-theme="light"] ::-webkit-scrollbar-thumb:hover {
  background: var(--border-strong, #aab8c8);
}
[data-theme="light"] .nav-item[data-tooltip]::after {
  background: #fff;
  color: #142132;
  border-color: rgba(31,95,174,.25);
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
}
