/* =====================================================================
   Hadex — Design System
   Paleta azul/branco premium com suporte a tema claro e escuro
   ===================================================================== */

/* ── Tema Claro (padrão) ────────────────────────────────────────────── */
:root {
  /* Cores primárias */
  --primary: #1B4DDB;
  --primary-hover: #1540B8;
  --primary-light: #EBF0FF;
  --primary-subtle: rgba(27, 77, 219, 0.08);
  --accent: #38BDF8;
  --accent-hover: #0EA5E9;

  /* Sidebar */
  --sidebar-bg: #0B1628;
  --sidebar-text: #8B9DC3;
  --sidebar-text-hover: #E2E8F0;
  --sidebar-active-bg: rgba(56, 189, 248, 0.10);
  --sidebar-active-text: #38BDF8;
  --sidebar-section-label: #4A6085;
  --sidebar-width: 252px;
  --sidebar-border: rgba(255, 255, 255, 0.06);

  /* Layout */
  --header-height: 56px;
  --bg-main: #F4F7FB;
  --bg-card: #FFFFFF;
  --border-subtle: #E2E8F0;

  /* Semânticas */
  --success: #10B981;
  --warning: #F59E0B;
  --danger: #EF4444;
  --purple: #8B5CF6;
  --info: #06B6D4;

  /* Sombras */
  --card-shadow: 0 1px 3px rgba(15, 23, 42, 0.04), 0 1px 2px rgba(15, 23, 42, 0.06);
  --card-shadow-hover: 0 4px 12px rgba(15, 23, 42, 0.08), 0 2px 4px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 10px 40px rgba(15, 23, 42, 0.12);

  /* Transições */
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.35s cubic-bezier(0.4, 0, 0.2, 1);

  /* Tipografia */
  --font-display: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
}

/* ── Tema Escuro ────────────────────────────────────────────────────── */
[data-bs-theme="dark"] {
  --primary-light: rgba(27, 77, 219, 0.15);
  --primary-subtle: rgba(56, 189, 248, 0.08);
  --sidebar-bg: #060D1B;
  --sidebar-text: #6B82A8;
  --sidebar-text-hover: #CBD5E1;
  --sidebar-active-bg: rgba(56, 189, 248, 0.08);
  --sidebar-section-label: #3D5575;
  --sidebar-border: rgba(255, 255, 255, 0.04);
  --bg-main: #0F172A;
  --bg-card: #1E293B;
  --border-subtle: #334155;
  --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
  --card-shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.5);
}

/* ── Reset e base ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  background-color: var(--bg-main);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.01em;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  letter-spacing: -0.02em;
}

/* =====================================================================
   SIDEBAR
   ===================================================================== */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: linear-gradient(180deg, var(--sidebar-bg) 0%, #0A1120 100%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform var(--transition);
  border-right: 1px solid var(--sidebar-border);
}

.sidebar-logo {
  padding: 0 20px;
  height: var(--header-height);
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.sidebar-logo a {
  display: flex;
  align-items: center;
  gap: 11px;
  color: #F1F5F9;
  text-decoration: none;
}

.sidebar-logo-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, #1B4DDB 0%, #38BDF8 100%);
  color: #fff;
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(27, 77, 219, 0.3);
  flex-shrink: 0;
}

.sidebar-logo-text {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: #F8FAFC;
}

.sidebar-menu {
  padding: 8px 0 20px;
  overflow-y: auto;
  flex: 1;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.08) transparent;
}

.sidebar-menu::-webkit-scrollbar { width: 3px; }
.sidebar-menu::-webkit-scrollbar-track { background: transparent; }
.sidebar-menu::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 3px; }

.sidebar-section-label {
  padding: 18px 20px 6px;
  font-family: var(--font-display);
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--sidebar-section-label);
  text-transform: uppercase;
}

.sidebar-nav {
  list-style: none;
  margin: 0;
  padding: 0 8px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  margin: 1px 0;
  color: var(--sidebar-text);
  text-decoration: none;
  font-family: var(--font-body);
  font-size: 0.825rem;
  font-weight: 500;
  border-radius: 8px;
  transition: all var(--transition);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-link i {
  font-size: 0.95rem;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
  opacity: 0.7;
  transition: opacity var(--transition);
}

.sidebar-link:hover {
  color: var(--sidebar-text-hover);
  background-color: rgba(255, 255, 255, 0.05);
}

.sidebar-link:hover i { opacity: 1; }

.sidebar-link.active {
  color: var(--sidebar-active-text);
  background-color: var(--sidebar-active-bg);
  font-weight: 600;
}

.sidebar-link.active i {
  opacity: 1;
  color: var(--sidebar-active-text);
}

/* Sidebar footer */
.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.sidebar-footer-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-footer-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: #CBD5E1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-footer-role {
  font-size: 0.7rem;
  color: var(--sidebar-section-label);
}

/* =====================================================================
   MAIN WRAPPER + HEADER
   ===================================================================== */
.main-wrapper {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--transition);
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border-subtle);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
  backdrop-filter: blur(8px);
}

.page-content { flex: 1; padding: 0; }

/* =====================================================================
   HEADER — Componentes
   ===================================================================== */
.notification-badge {
  position: absolute;
  top: -4px;
  right: -6px;
  background: var(--danger);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
}

.avatar-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.notif-dropdown { max-height: 380px; overflow-y: auto; }

/* =====================================================================
   PÁGINA — Componentes gerais
   ===================================================================== */
.page-header-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: var(--primary-subtle);
  color: var(--primary);
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.card {
  border: 1px solid var(--border-subtle);
  box-shadow: var(--card-shadow);
  border-radius: 12px;
  background: var(--bg-card);
  transition: box-shadow var(--transition);
  animation: hadex-fade-up 0.3s ease-out both;
}

.card:hover {
  box-shadow: var(--card-shadow-hover);
}

.flash-container { max-width: 900px; }

/* =====================================================================
   LOGIN
   ===================================================================== */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: stretch;
}

.login-split {
  display: flex;
  width: 100%;
  min-height: 100vh;
}

.login-panel-left {
  flex: 0 0 420px;
  background: linear-gradient(160deg, #0B1628 0%, #0F2044 60%, #1B4DDB 100%);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 48px 48px;
  position: relative;
  overflow: hidden;
}

.login-panel-left::before {
  content: '';
  position: absolute;
  top: -120px;
  right: -80px;
  width: 360px;
  height: 360px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(56,189,248,0.12) 0%, transparent 70%);
  pointer-events: none;
}

.login-panel-right {
  flex: 1;
  background: var(--bg-main);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
}

.login-card {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 40px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-subtle);
  width: 100%;
  max-width: 400px;
}

.login-logo-icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: linear-gradient(135deg, #1B4DDB 0%, #38BDF8 100%);
  color: #fff;
  font-size: 1.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(27, 77, 219, 0.35);
}

.login-bullet {
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(240, 237, 232, 0.75);
  font-size: 0.875rem;
}

.login-bullet i {
  color: var(--accent);
  font-size: 1rem;
  flex-shrink: 0;
}

/* =====================================================================
   RESPONSIVIDADE — Mobile
   ===================================================================== */
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.sidebar-open { transform: translateX(0); }
  .main-wrapper { margin-left: 0; }
  .login-panel-left { display: none; }
  .login-panel-right { background: linear-gradient(160deg, #0B1628 0%, #0F2044 60%, #1B4DDB 100%); }
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
  backdrop-filter: blur(2px);
}

.sidebar-overlay.active { display: block; }

/* =====================================================================
   UTILITÁRIOS
   ===================================================================== */
.text-primary { color: var(--primary) !important; }
.bg-primary { background-color: var(--primary) !important; }

.btn-primary {
  background-color: var(--primary);
  border-color: var(--primary);
  font-weight: 500;
  letter-spacing: -0.01em;
  border-radius: 8px;
}
.btn-primary:hover {
  background-color: var(--primary-hover);
  border-color: var(--primary-hover);
}

/* Badges de status */
.badge-backlog    { background-color: #64748b; }
.badge-andamento  { background-color: var(--info); }
.badge-revisao    { background-color: var(--warning); }
.badge-aprovacao  { background-color: var(--purple); }
.badge-concluida  { background-color: var(--success); }

.badge-baixa    { background-color: #94a3b8; }
.badge-normal   { background-color: var(--info); }
.badge-alta     { background-color: var(--warning); }
.badge-urgente  { background-color: var(--danger); }

/* =====================================================================
   REFINAMENTOS GLOBAIS HADEX
   ===================================================================== */

/* Forms */
.form-control, .form-select {
  border-radius: 8px;
  border-color: var(--border-subtle);
  font-size: 0.875rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-subtle);
}

/* Buttons */
.btn {
  border-radius: 8px;
  font-weight: 500;
  font-size: 0.875rem;
  transition: all var(--transition);
}

/* Badges */
.badge {
  font-weight: 600;
  letter-spacing: 0.01em;
}

/* Table headers */
.table th {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--sidebar-section-label);
}

/* Code */
code, .font-monospace {
  font-family: var(--font-mono);
}

/* Links */
a { transition: color var(--transition); }

/* Card entrance animation */
@keyframes hadex-fade-up {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Scrollbar global */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(15, 23, 42, 0.12);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(15, 23, 42, 0.2);
}

/* =====================================================================
   DARK MODE — Overrides de componentes
   ===================================================================== */
[data-bs-theme="dark"] .app-header {
  background-color: var(--bg-card);
  border-color: var(--border-subtle);
}

[data-bs-theme="dark"] .card {
  background: var(--bg-card);
  border-color: var(--border-subtle);
}

[data-bs-theme="dark"] .page-header-icon {
  background: rgba(56, 189, 248, 0.08);
}

[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
  background-color: #0F172A;
  border-color: #334155;
  color: #E2E8F0;
}

[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.12);
}

[data-bs-theme="dark"] .login-card {
  background: #1E293B;
  border-color: rgba(255, 255, 255, 0.06);
}

[data-bs-theme="dark"] .avatar-circle {
  box-shadow: 0 0 0 2px var(--bg-card);
}

[data-bs-theme="dark"] .sidebar {
  background: linear-gradient(180deg, var(--sidebar-bg) 0%, #050A15 100%);
}

[data-bs-theme="dark"] ::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
}
[data-bs-theme="dark"] ::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.18);
}

[data-bs-theme="dark"] .table th {
  color: #6B82A8;
}

[data-bs-theme="dark"] .btn-outline-secondary {
  border-color: #334155;
  color: #94A3B8;
}

[data-bs-theme="dark"] .btn-outline-secondary:hover {
  background-color: rgba(255, 255, 255, 0.05);
  border-color: #475569;
  color: #E2E8F0;
}
