/* ===================================================
   LACTALIS DO BRASIL — SISTEMA DE GESTÃO DOCUMENTAL
   Identidade Visual Corporativa
   =================================================== */

/* --- Google Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* --- Variáveis de Marca Lactalis --- */
:root {
  /* Paleta Lactalis */
  --lac-red:          #E30613;
  --lac-red-dark:     #B5000F;
  --lac-red-light:    #FF2533;
  --lac-red-pale:     #FFF0F0;
  --lac-white:        #FFFFFF;
  --lac-black:        #1A1A1A;
  --lac-gray-900:     #212529;
  --lac-gray-800:     #343A40;
  --lac-gray-700:     #495057;
  --lac-gray-600:     #6C757D;
  --lac-gray-500:     #ADB5BD;
  --lac-gray-400:     #CED4DA;
  --lac-gray-300:     #DEE2E6;
  --lac-gray-200:     #E9ECEF;
  --lac-gray-100:     #F8F9FA;

  /* Status de Documentos */
  --status-vigente:      #198754;
  --status-vigente-bg:   #D1E7DD;
  --status-avencer:      #FD7E14;
  --status-avencer-bg:   #FFE8D6;
  --status-vencido:      #DC3545;
  --status-vencido-bg:   #F8D7DA;
  --status-renovacao:    #0D6EFD;
  --status-renovacao-bg: #CFE2FF;

  /* Layout */
  --sidebar-width:    260px;
  --sidebar-collapsed: 72px;
  --header-height:    64px;
  --border-radius:    8px;
  --border-radius-lg: 12px;
  --border-radius-xl: 16px;
  --shadow-sm:        0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow:           0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --shadow-md:        0 10px 15px rgba(0,0,0,.07), 0 4px 6px rgba(0,0,0,.05);
  --shadow-lg:        0 20px 25px rgba(0,0,0,.10), 0 10px 10px rgba(0,0,0,.04);
  --transition:       all 0.25s cubic-bezier(.4,0,.2,1);
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 14px; scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--lac-gray-100);
  color: var(--lac-gray-900);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ===================================================
   TELAS DE AUTENTICAÇÃO
   =================================================== */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  background: linear-gradient(135deg, #1a1a1a 0%, #2d0508 40%, #E30613 100%);
  position: relative;
  overflow: hidden;
}

.auth-wrapper::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(ellipse at center, rgba(227,6,19,0.15) 0%, transparent 60%);
  animation: pulseGlow 6s ease-in-out infinite;
}

@keyframes pulseGlow {
  0%, 100% { transform: scale(1); opacity: 0.5; }
  50% { transform: scale(1.1); opacity: 1; }
}

.auth-left {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 3rem;
  position: relative;
  z-index: 1;
}

.auth-brand {
  text-align: center;
  margin-bottom: 3rem;
}

.auth-logo-container {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.1);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 20px;
  padding: 1.5rem 2.5rem;
  margin-bottom: 1.5rem;
}

.auth-logo-svg {
  width: 180px;
  height: auto;
}

.auth-tagline {
  color: rgba(255,255,255,0.9);
  font-size: 1rem;
  font-weight: 400;
  letter-spacing: 0.5px;
  margin-top: 0.5rem;
}

.auth-system-name {
  color: #fff;
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 0.3rem;
  text-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

.auth-illustration {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
  max-width: 360px;
}

.auth-feature-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: rgba(255,255,255,0.08);
  backdrop-filter: blur(5px);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  color: #fff;
  transition: var(--transition);
}

.auth-feature-item:hover {
  background: rgba(255,255,255,0.14);
  transform: translateX(4px);
}

.auth-feature-icon {
  width: 40px;
  height: 40px;
  background: rgba(255,255,255,0.15);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.auth-feature-text strong {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
}

.auth-feature-text span {
  font-size: 0.75rem;
  opacity: 0.75;
}

.auth-right {
  width: 480px;
  background: var(--lac-white);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 3rem 3.5rem;
  position: relative;
  z-index: 1;
  box-shadow: -20px 0 60px rgba(0,0,0,0.3);
}

.auth-right::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 4px;
  height: 100%;
  background: linear-gradient(to bottom, var(--lac-red), var(--lac-red-dark));
}

.auth-form-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--lac-gray-900);
  margin-bottom: 0.25rem;
}

.auth-form-subtitle {
  color: var(--lac-gray-600);
  font-size: 0.875rem;
  margin-bottom: 2rem;
}

/* --- Form Elements --- */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--lac-gray-700);
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-control {
  width: 100%;
  padding: 0.65rem 1rem;
  font-family: inherit;
  font-size: 0.875rem;
  border: 1.5px solid var(--lac-gray-300);
  border-radius: var(--border-radius);
  background: var(--lac-white);
  color: var(--lac-gray-900);
  transition: var(--transition);
  outline: none;
}

.form-control:focus {
  border-color: var(--lac-red);
  box-shadow: 0 0 0 3px rgba(227,6,19,0.1);
}

.form-control.is-invalid {
  border-color: var(--lac-red);
  background: var(--lac-red-pale);
}

.form-control::placeholder { color: var(--lac-gray-500); }

.input-icon-wrap {
  position: relative;
}

.input-icon-wrap .form-control {
  padding-left: 2.75rem;
}

.input-icon-wrap .input-icon {
  position: absolute;
  left: 0.875rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--lac-gray-500);
  font-size: 0.9rem;
  pointer-events: none;
}

.input-icon-wrap .input-toggle {
  position: absolute;
  right: 0.875rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--lac-gray-500);
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  font-size: 0.9rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* Indicador de força da senha */
.password-strength {
  margin-top: 0.5rem;
}

.strength-bar {
  height: 4px;
  background: var(--lac-gray-200);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 0.4rem;
}

.strength-fill {
  height: 100%;
  border-radius: 2px;
  transition: var(--transition);
  width: 0%;
}

.strength-fill.weak    { width: 33%; background: var(--lac-red); }
.strength-fill.medium  { width: 66%; background: var(--status-avencer); }
.strength-fill.strong  { width: 100%; background: var(--status-vigente); }

.strength-label {
  font-size: 0.75rem;
  color: var(--lac-gray-600);
}

.password-rules {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.3rem;
  margin-top: 0.5rem;
}

.password-rule {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.72rem;
  color: var(--lac-gray-500);
  transition: var(--transition);
}

.password-rule.valid { color: var(--status-vigente); }
.password-rule.valid .rule-icon::before { content: '✓'; }
.password-rule .rule-icon::before { content: '○'; }

/* Botões */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  border: none;
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--lac-red);
  color: #fff;
}

.btn-primary:hover {
  background: var(--lac-red-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 15px rgba(227,6,19,0.35);
}

.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: var(--lac-gray-200);
  color: var(--lac-gray-800);
}

.btn-secondary:hover {
  background: var(--lac-gray-300);
}

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--lac-gray-300);
  color: var(--lac-gray-700);
}

.btn-outline:hover {
  border-color: var(--lac-red);
  color: var(--lac-red);
}

.btn-outline-danger {
  background: transparent;
  border: 1.5px solid var(--lac-red);
  color: var(--lac-red);
}

.btn-outline-danger:hover {
  background: var(--lac-red);
  color: #fff;
}

.btn-ghost {
  background: transparent;
  color: var(--lac-gray-600);
  padding: 0.5rem;
}

.btn-ghost:hover {
  background: var(--lac-gray-100);
  color: var(--lac-red);
}

.btn-sm { padding: 0.4rem 0.85rem; font-size: 0.8rem; }
.btn-lg { padding: 0.85rem 1.75rem; font-size: 1rem; }
.btn-block { width: 100%; }
.btn-icon { gap: 0; }

.btn-success { background: var(--status-vigente); color: #fff; }
.btn-success:hover { background: #157347; }

.btn-warning { background: var(--status-avencer); color: #fff; }
.btn-warning:hover { background: #e07010; }

.btn-danger { background: var(--lac-red); color: #fff; }
.btn-danger:hover { background: var(--lac-red-dark); }

.btn-info { background: var(--status-renovacao); color: #fff; }
.btn-info:hover { background: #0b5ed7; }

.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none !important; }

/* Divider */
.auth-divider {
  text-align: center;
  margin: 1.25rem 0;
  position: relative;
}

.auth-divider::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--lac-gray-200);
}

.auth-divider span {
  background: #fff;
  padding: 0 0.75rem;
  color: var(--lac-gray-500);
  font-size: 0.8rem;
  position: relative;
}

.auth-switch-link {
  text-align: center;
  color: var(--lac-gray-600);
  font-size: 0.85rem;
  margin-top: 1.5rem;
}

.auth-switch-link a {
  color: var(--lac-red);
  font-weight: 600;
  text-decoration: none;
}

.auth-switch-link a:hover { text-decoration: underline; }

/* ===================================================
   LAYOUT PRINCIPAL (APP)
   =================================================== */
#app-wrapper {
  display: none;
  min-height: 100vh;
}

#app-wrapper.visible { display: flex; }

/* --- Sidebar --- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--lac-gray-900);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  z-index: 1000;
  transition: var(--transition);
  box-shadow: 4px 0 20px rgba(0,0,0,0.15);
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed);
}

.sidebar-header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  gap: 0.75rem;
  overflow: hidden;
}

.sidebar-logo-mark {
  width: 36px;
  height: 36px;
  background: var(--lac-red);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: 900;
  color: #fff;
  flex-shrink: 0;
  letter-spacing: -1px;
}

.sidebar-brand-text {
  overflow: hidden;
  transition: var(--transition);
}

.sidebar.collapsed .sidebar-brand-text { width: 0; opacity: 0; }

.sidebar-brand-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
}

.sidebar-brand-sub {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.4);
  white-space: nowrap;
}

.sidebar-toggle {
  margin-left: auto;
  background: none;
  border: none;
  color: rgba(255,255,255,0.5);
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 6px;
  flex-shrink: 0;
  transition: var(--transition);
}

.sidebar-toggle:hover { color: #fff; background: rgba(255,255,255,0.05); }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1rem 0;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

.nav-section-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255,255,255,0.3);
  padding: 0.75rem 1.25rem 0.4rem;
  white-space: nowrap;
  overflow: hidden;
  transition: var(--transition);
}

.sidebar.collapsed .nav-section-label { opacity: 0; height: 0; padding: 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.7rem 1.25rem;
  color: rgba(255,255,255,0.65);
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  white-space: nowrap;
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  border-left: 3px solid transparent;
  margin: 1px 0;
}

.nav-item:hover {
  color: #fff;
  background: rgba(255,255,255,0.05);
}

.nav-item.active {
  color: #fff;
  background: rgba(227,6,19,0.15);
  border-left-color: var(--lac-red);
}

.nav-item-icon {
  width: 20px;
  text-align: center;
  flex-shrink: 0;
  font-size: 1rem;
}

.nav-item-text {
  transition: var(--transition);
  overflow: hidden;
}

.sidebar.collapsed .nav-item-text { width: 0; opacity: 0; }

.nav-badge {
  margin-left: auto;
  background: var(--lac-red);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
  flex-shrink: 0;
  animation: badgePulse 2s ease-in-out infinite;
}

@keyframes badgePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(227,6,19,0.4); }
  50% { box-shadow: 0 0 0 5px rgba(227,6,19,0); }
}

.sidebar.collapsed .nav-badge { display: none; }

.sidebar-footer {
  border-top: 1px solid rgba(255,255,255,0.06);
  padding: 1rem;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem;
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition);
  overflow: hidden;
}

.sidebar-user:hover { background: rgba(255,255,255,0.05); }

.user-avatar {
  width: 36px;
  height: 36px;
  background: var(--lac-red);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: #fff;
  flex-shrink: 0;
}

.user-info { overflow: hidden; flex: 1; }
.user-name { font-size: 0.8rem; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 0.7rem; color: rgba(255,255,255,0.45); white-space: nowrap; }

.sidebar.collapsed .user-info { width: 0; opacity: 0; }

/* --- Main Content --- */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  transition: var(--transition);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.main-content.expanded {
  margin-left: var(--sidebar-collapsed);
}

/* --- Top Bar --- */
.topbar {
  height: var(--header-height);
  background: var(--lac-white);
  border-bottom: 1px solid var(--lac-gray-200);
  display: flex;
  align-items: center;
  padding: 0 2rem;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.topbar-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--lac-gray-900);
}

.topbar-breadcrumb {
  font-size: 0.75rem;
  color: var(--lac-gray-500);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.topbar-spacer { flex: 1; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.topbar-search {
  position: relative;
}

.topbar-search input {
  background: var(--lac-gray-100);
  border: 1.5px solid var(--lac-gray-200);
  border-radius: 8px;
  padding: 0.5rem 1rem 0.5rem 2.5rem;
  font-size: 0.85rem;
  width: 250px;
  transition: var(--transition);
  outline: none;
  font-family: inherit;
}

.topbar-search input:focus {
  border-color: var(--lac-red);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(227,6,19,0.1);
  width: 300px;
}

.topbar-search-icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--lac-gray-500);
  font-size: 0.85rem;
  pointer-events: none;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  border: 1.5px solid var(--lac-gray-200);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--lac-gray-600);
  transition: var(--transition);
  position: relative;
  font-size: 1rem;
}

.icon-btn:hover {
  border-color: var(--lac-red);
  color: var(--lac-red);
}

.icon-btn .notification-dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 8px; height: 8px;
  background: var(--lac-red);
  border-radius: 50%;
  border: 2px solid #fff;
}

/* ===================================================
   PÁGINA DE CONTEÚDO
   =================================================== */
.page-content {
  padding: 2rem;
  flex: 1;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

/* --- Cards de Estatísticas --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--lac-white);
  border-radius: var(--border-radius-lg);
  padding: 1.5rem;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--lac-gray-200);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 4px;
  height: 100%;
  border-radius: 4px 0 0 4px;
}

.stat-card.red::before    { background: var(--lac-red); }
.stat-card.orange::before { background: var(--status-avencer); }
.stat-card.green::before  { background: var(--status-vigente); }
.stat-card.blue::before   { background: var(--status-renovacao); }

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--border-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.stat-icon.red    { background: rgba(227,6,19,0.1); color: var(--lac-red); }
.stat-icon.orange { background: rgba(253,126,20,0.1); color: var(--status-avencer); }
.stat-icon.green  { background: rgba(25,135,84,0.1); color: var(--status-vigente); }
.stat-icon.blue   { background: rgba(13,110,253,0.1); color: var(--status-renovacao); }

.stat-info { flex: 1; }
.stat-value {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 0.25rem;
  color: var(--lac-gray-900);
}

.stat-label {
  font-size: 0.8rem;
  color: var(--lac-gray-600);
  font-weight: 500;
}

.stat-trend {
  font-size: 0.72rem;
  margin-top: 0.4rem;
  display: flex;
  align-items: center;
  gap: 0.2rem;
}

.stat-trend.up   { color: var(--status-vigente); }
.stat-trend.down { color: var(--lac-red); }

/* --- Section Headers --- */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--lac-gray-900);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.section-title-icon {
  width: 28px;
  height: 28px;
  background: rgba(227,6,19,0.1);
  color: var(--lac-red);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
}

/* --- Tabelas --- */
.table-card {
  background: var(--lac-white);
  border-radius: var(--border-radius-lg);
  border: 1px solid var(--lac-gray-200);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.table-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--lac-gray-200);
}

.table-responsive { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

thead {
  background: var(--lac-gray-100);
}

thead th {
  padding: 0.85rem 1rem;
  text-align: left;
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--lac-gray-600);
  border-bottom: 1px solid var(--lac-gray-200);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--lac-gray-100);
  transition: var(--transition);
}

tbody tr:last-child { border-bottom: none; }

tbody tr:hover { background: var(--lac-gray-100); }

tbody td {
  padding: 0.85rem 1rem;
  color: var(--lac-gray-800);
  vertical-align: middle;
}

/* --- Status Badges --- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.65rem;
  border-radius: 100px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-vigente    { background: var(--status-vigente-bg); color: var(--status-vigente); }
.badge-avencer    { background: var(--status-avencer-bg); color: var(--status-avencer); }
.badge-vencido    { background: var(--status-vencido-bg); color: var(--status-vencido); }
.badge-renovacao  { background: var(--status-renovacao-bg); color: var(--status-renovacao); }
.badge-red        { background: rgba(227,6,19,0.1); color: var(--lac-red); }
.badge-gray       { background: var(--lac-gray-200); color: var(--lac-gray-600); }
.badge-admin      { background: rgba(227,6,19,0.1); color: var(--lac-red); }
.badge-ativo      { background: var(--status-vigente-bg); color: var(--status-vigente); }
.badge-inativo    { background: var(--lac-gray-200); color: var(--lac-gray-500); }

/* --- Cards Genéricos --- */
.card {
  background: var(--lac-white);
  border-radius: var(--border-radius-lg);
  border: 1px solid var(--lac-gray-200);
  box-shadow: var(--shadow-sm);
}

.card-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--lac-gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-body { padding: 1.5rem; }
.card-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--lac-gray-200); }

/* --- Grid de CDs --- */
.cd-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.25rem;
}

.cd-card {
  background: var(--lac-white);
  border-radius: var(--border-radius-lg);
  border: 1px solid var(--lac-gray-200);
  overflow: hidden;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}

.cd-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: rgba(227,6,19,0.3);
}

.cd-card-header {
  background: linear-gradient(135deg, var(--lac-gray-900), #3d0008);
  padding: 1.25rem;
  color: #fff;
  position: relative;
  overflow: hidden;
}

.cd-card-header::before {
  content: '';
  position: absolute;
  top: -20px; right: -20px;
  width: 100px; height: 100px;
  background: rgba(227,6,19,0.15);
  border-radius: 50%;
}

.cd-name {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.2rem;
}

.cd-location {
  font-size: 0.78rem;
  opacity: 0.7;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.cd-card-body { padding: 1.25rem; }

.cd-doc-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.cd-doc-stat {
  text-align: center;
  padding: 0.6rem;
  border-radius: 8px;
  font-size: 0.7rem;
}

.cd-doc-stat .count { font-size: 1.25rem; font-weight: 800; display: block; }
.cd-doc-stat.vigente   { background: var(--status-vigente-bg); color: var(--status-vigente); }
.cd-doc-stat.avencer   { background: var(--status-avencer-bg); color: var(--status-avencer); }
.cd-doc-stat.vencido   { background: var(--status-vencido-bg); color: var(--status-vencido); }
.cd-doc-stat.renovacao { background: var(--status-renovacao-bg); color: var(--status-renovacao); }

.cd-card-actions {
  display: flex;
  gap: 0.5rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--lac-gray-100);
}

/* --- Alertas de Documentos --- */
.alert-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.alert-item {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-radius: var(--border-radius);
  border: 1px solid transparent;
  background: var(--lac-white);
  transition: var(--transition);
}

.alert-item.critical {
  border-color: rgba(220,53,69,0.3);
  background: rgba(220,53,69,0.03);
}

.alert-item.warning {
  border-color: rgba(253,126,20,0.3);
  background: rgba(253,126,20,0.03);
}

.alert-item.info {
  border-color: rgba(13,110,253,0.3);
  background: rgba(13,110,253,0.03);
}

.alert-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.alert-item.critical .alert-icon { background: rgba(220,53,69,0.1); color: #dc3545; }
.alert-item.warning .alert-icon  { background: rgba(253,126,20,0.1); color: var(--status-avencer); }
.alert-item.info .alert-icon     { background: rgba(13,110,253,0.1); color: var(--status-renovacao); }

.alert-content { flex: 1; }
.alert-title { font-size: 0.875rem; font-weight: 600; color: var(--lac-gray-900); margin-bottom: 0.2rem; }
.alert-meta { font-size: 0.78rem; color: var(--lac-gray-600); }
.alert-days {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: 100px;
  white-space: nowrap;
}

.alert-item.critical .alert-days { background: rgba(220,53,69,0.1); color: #dc3545; }
.alert-item.warning  .alert-days { background: rgba(253,126,20,0.1); color: var(--status-avencer); }
.alert-item.info     .alert-days { background: rgba(13,110,253,0.1); color: var(--status-renovacao); }

/* --- Filtros e Barra de Ações --- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
  background: var(--lac-white);
  border: 1px solid var(--lac-gray-200);
  border-radius: var(--border-radius-lg);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow-sm);
}

.toolbar-search {
  flex: 1;
  min-width: 200px;
  position: relative;
}

.toolbar-search input {
  width: 100%;
  padding: 0.55rem 1rem 0.55rem 2.25rem;
  border: 1.5px solid var(--lac-gray-200);
  border-radius: 8px;
  font-size: 0.85rem;
  font-family: inherit;
  outline: none;
  transition: var(--transition);
}

.toolbar-search input:focus {
  border-color: var(--lac-red);
  box-shadow: 0 0 0 3px rgba(227,6,19,0.1);
}

.toolbar-search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--lac-gray-500);
  font-size: 0.85rem;
  pointer-events: none;
}

.select-filter {
  padding: 0.55rem 2rem 0.55rem 0.85rem;
  border: 1.5px solid var(--lac-gray-200);
  border-radius: 8px;
  font-size: 0.85rem;
  font-family: inherit;
  background: #fff;
  color: var(--lac-gray-800);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236C757D' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  outline: none;
  transition: var(--transition);
}

.select-filter:focus {
  border-color: var(--lac-red);
  box-shadow: 0 0 0 3px rgba(227,6,19,0.1);
}

/* --- Modal --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.modal-overlay.open {
  display: flex;
}

.modal {
  background: var(--lac-white);
  border-radius: var(--border-radius-xl);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.3s cubic-bezier(.34,1.56,.64,1);
}

.modal-lg { max-width: 800px; }
.modal-sm { max-width: 420px; }

@keyframes modalIn {
  from { transform: scale(0.9) translateY(20px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem 1.75rem;
  border-bottom: 1px solid var(--lac-gray-200);
}

.modal-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--lac-gray-900);
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.modal-title-icon {
  width: 32px;
  height: 32px;
  background: rgba(227,6,19,0.1);
  color: var(--lac-red);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
}

.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--lac-gray-400);
  font-size: 1.25rem;
  padding: 0.4rem;
  border-radius: 6px;
  transition: var(--transition);
  line-height: 1;
}

.modal-close:hover { color: var(--lac-red); background: rgba(227,6,19,0.05); }

.modal-body { padding: 1.75rem; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1.25rem 1.75rem;
  border-top: 1px solid var(--lac-gray-200);
  background: var(--lac-gray-100);
  border-radius: 0 0 var(--border-radius-xl) var(--border-radius-xl);
}

/* --- Toast Notificações --- */
.toast-container {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 360px;
}

.toast {
  background: var(--lac-white);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-lg);
  padding: 1rem 1.25rem;
  border-left: 4px solid var(--lac-gray-400);
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  animation: toastIn 0.4s cubic-bezier(.34,1.56,.64,1);
  transition: var(--transition);
}

@keyframes toastIn {
  from { transform: translateX(100px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.toast.success { border-left-color: var(--status-vigente); }
.toast.error   { border-left-color: var(--lac-red); }
.toast.warning { border-left-color: var(--status-avencer); }
.toast.info    { border-left-color: var(--status-renovacao); }

.toast-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
  margin-top: 0.1rem;
}

.toast.success .toast-icon { color: var(--status-vigente); }
.toast.error   .toast-icon { color: var(--lac-red); }
.toast.warning .toast-icon { color: var(--status-avencer); }
.toast.info    .toast-icon { color: var(--status-renovacao); }

.toast-content { flex: 1; }
.toast-title   { font-size: 0.875rem; font-weight: 700; color: var(--lac-gray-900); }
.toast-message { font-size: 0.78rem; color: var(--lac-gray-600); margin-top: 0.15rem; }

/* --- Permissão Matrix --- */
.permission-table { border-collapse: collapse; width: 100%; }
.permission-table th, .permission-table td {
  padding: 0.75rem 1rem;
  border: 1px solid var(--lac-gray-200);
  font-size: 0.82rem;
}
.permission-table th { background: var(--lac-gray-100); font-weight: 700; }
.permission-table select {
  border: 1.5px solid var(--lac-gray-300);
  border-radius: 6px;
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
  font-family: inherit;
  cursor: pointer;
  outline: none;
}
.permission-table select:focus { border-color: var(--lac-red); }

/* --- Tabs --- */
.tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 2px solid var(--lac-gray-200);
  margin-bottom: 1.5rem;
}

.tab-btn {
  padding: 0.65rem 1.25rem;
  background: none;
  border: none;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--lac-gray-600);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: var(--transition);
  border-radius: 6px 6px 0 0;
}

.tab-btn:hover { color: var(--lac-gray-900); background: var(--lac-gray-100); }
.tab-btn.active { color: var(--lac-red); border-bottom-color: var(--lac-red); font-weight: 600; }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* --- Empty State --- */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--lac-gray-500);
}

.empty-state-icon { font-size: 3.5rem; margin-bottom: 1rem; opacity: 0.5; }
.empty-state-title { font-size: 1.05rem; font-weight: 600; color: var(--lac-gray-700); margin-bottom: 0.5rem; }
.empty-state-text { font-size: 0.875rem; }

/* --- Countdown de Dias --- */
.days-counter {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-weight: 700;
  font-size: 0.8rem;
  padding: 0.25rem 0.65rem;
  border-radius: 100px;
}

.days-counter.critical { background: rgba(220,53,69,0.1); color: #dc3545; }
.days-counter.warning  { background: rgba(253,126,20,0.1); color: var(--status-avencer); }
.days-counter.ok       { background: rgba(25,135,84,0.1);  color: var(--status-vigente); }
.days-counter.expired  { background: rgba(220,53,69,0.15); color: #dc3545; animation: expiredBlink 1.5s ease-in-out infinite; }

@keyframes expiredBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* --- Progresso circular --- */
.progress-ring {
  transform: rotate(-90deg);
}

/* ===================================================
   DIGITALIZAÇÃO DE DOCUMENTOS
   =================================================== */

/* Container principal */
.digitalize-section {
  border: 1.5px solid var(--lac-gray-200);
  border-radius: var(--border-radius-lg);
  overflow: hidden;
  margin-top: 0.25rem;
}

/* Cabeçalho da seção */
.digitalize-header {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.9rem 1.25rem;
  background: linear-gradient(135deg, rgba(227,6,19,0.04) 0%, rgba(227,6,19,0.01) 100%);
  border-bottom: 1.5px solid var(--lac-gray-200);
}

.digitalize-header-icon {
  width: 38px;
  height: 38px;
  background: rgba(227,6,19,0.1);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--lac-red);
  font-size: 1rem;
  flex-shrink: 0;
}

.digitalize-header-title {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--lac-gray-900);
}

.digitalize-header-sub {
  font-size: 0.75rem;
  color: var(--lac-gray-500);
  margin-top: 0.1rem;
}

/* Área de ações (botões + dropzone) */
.digitalize-actions {
  padding: 1rem;
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 0.75rem;
  align-items: stretch;
}

@media (max-width: 700px) {
  .digitalize-actions {
    grid-template-columns: 1fr 1fr;
  }
  .digitalize-dropzone {
    grid-column: 1 / -1;
  }
}

/* Botões de método (upload / câmera) */
.digitalize-btn {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: var(--lac-white);
  border: 1.5px solid var(--lac-gray-200);
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
  text-align: left;
}

.digitalize-btn:hover {
  border-color: var(--lac-red);
  background: var(--lac-red-pale);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.digitalize-btn-icon {
  width: 40px;
  height: 40px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
  transition: var(--transition);
}

.digitalize-btn-icon.blue  { background: rgba(13,110,253,0.1);  color: #0d6efd; }
.digitalize-btn-icon.green { background: rgba(25,135,84,0.1);   color: #198754; }

.digitalize-btn:hover .digitalize-btn-icon.blue  { background: #0d6efd; color: #fff; }
.digitalize-btn:hover .digitalize-btn-icon.green { background: #198754; color: #fff; }

.digitalize-btn-label {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.digitalize-btn-label strong {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--lac-gray-900);
}

.digitalize-btn-label span {
  font-size: 0.72rem;
  color: var(--lac-gray-500);
}

/* Drop zone */
.digitalize-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  border: 2px dashed var(--lac-gray-300);
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: var(--transition);
  color: var(--lac-gray-500);
  font-size: 0.75rem;
  text-align: center;
  min-width: 130px;
}

.digitalize-dropzone:hover,
.digitalize-dropzone.drag-over {
  border-color: var(--lac-red);
  background: var(--lac-red-pale);
  color: var(--lac-red);
}

.digitalize-dropzone.drag-over {
  transform: scale(1.02);
}

/* Preview do arquivo */
.digitalize-preview {
  padding: 1rem;
}

.preview-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  background: var(--lac-gray-100);
  border-radius: var(--border-radius);
  border: 1.5px solid var(--lac-gray-200);
}

.preview-file-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
  min-width: 0;
}

.preview-file-icon {
  width: 42px;
  height: 42px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.preview-file-meta { min-width: 0; flex: 1; }

.preview-file-name {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--lac-gray-900);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preview-file-size {
  font-size: 0.72rem;
  color: var(--lac-gray-500);
  margin-top: 0.1rem;
}

.preview-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* Thumbnail da imagem */
.preview-thumbnail-wrap {
  margin-top: 0.75rem;
  border-radius: var(--border-radius);
  overflow: hidden;
  max-height: 220px;
  background: #f0f0f0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--lac-gray-200);
}

.preview-thumbnail {
  width: 100%;
  max-height: 220px;
  object-fit: contain;
  display: block;
}

/* Câmera */
.camera-capture-wrap {
  margin: 0 1rem 1rem;
  border: 1.5px solid var(--lac-gray-200);
  border-radius: var(--border-radius-lg);
  overflow: hidden;
  background: #1a1a1a;
}

.camera-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--lac-gray-900);
  color: #fff;
}

.camera-video {
  width: 100%;
  max-height: 320px;
  object-fit: cover;
  display: block;
  background: #000;
}

.camera-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: var(--lac-gray-900);
}

.camera-snap-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #fff;
  border: 4px solid rgba(255,255,255,0.3);
  color: var(--lac-red);
  font-size: 1.4rem;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 6px rgba(255,255,255,0.1);
}

.camera-snap-btn:hover {
  background: var(--lac-red);
  color: #fff;
  transform: scale(1.1);
  box-shadow: 0 0 0 8px rgba(227,6,19,0.25);
}

.camera-snap-btn:active {
  transform: scale(0.95);
}

/* --- Responsive --- */
@media (max-width: 1024px) {
  .auth-left { display: none; }
  .auth-right { width: 100%; max-width: 480px; margin: 0 auto; }
  .auth-wrapper { justify-content: center; }
  .form-row { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  :root { --sidebar-width: 0; }
  .sidebar { transform: translateX(-100%); }
  .sidebar.mobile-open { transform: translateX(0); width: var(--sidebar-collapsed); }
  .main-content { margin-left: 0; }
  .page-content { padding: 1.25rem; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .cd-grid { grid-template-columns: 1fr; }
  .topbar-search { display: none; }
}

/* --- Utilitários --- */
.text-red    { color: var(--lac-red) !important; }
.text-muted  { color: var(--lac-gray-500) !important; }
.text-sm     { font-size: 0.8rem; }
.text-xs     { font-size: 0.72rem; }
.fw-bold     { font-weight: 700; }
.fw-semibold { font-weight: 600; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.flex-1 { flex: 1; }
.d-none { display: none !important; }
.w-100 { width: 100%; }
.text-center { text-align: center; }

/* Scrollbar personalizada */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--lac-gray-100); }
::-webkit-scrollbar-thumb { background: var(--lac-gray-400); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--lac-red); }

/* Loading spinner */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Tooltip simples */
[data-tooltip] { position: relative; }
[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--lac-gray-900);
  color: #fff;
  font-size: 0.72rem;
  padding: 0.35rem 0.7rem;
  border-radius: 6px;
  white-space: nowrap;
  z-index: 1000;
  pointer-events: none;
}
