/* ============================================================
   FLOWCARE - ULTRA PREMIUM CSS (Glassmorphism & Dark Mode)
   Layout Corrigido (Sem sobreposição, sem espaços em branco)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Space+Grotesk:wght@500;600;700&display=swap');

:root {
  --bg-deep: #020617;
  --bg-panel: rgba(15, 23, 42, 0.6);
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --accent: #00f0ff;
  --accent-glow: rgba(0, 240, 255, 0.4);
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --glass-border: rgba(255, 255, 255, 0.08);
  --radius: 12px;
  --radius-lg: 16px;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================================
   RESET & GLOBAIS
   ============================================================ */
* { 
  margin: 0; 
  padding: 0; 
  box-sizing: border-box; 
  -webkit-tap-highlight-color: transparent; 
}

html {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-deep);
  color: var(--text-main);
  overflow-x: hidden;
  scroll-behavior: smooth;
  height: 100%; /* Base sólida para o flexbox */
}

body {
  background-color: var(--bg-deep);
  color: var(--text-main);
  min-height: 100vh;
  min-height: 100dvh;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
}

/* ============================================================
   PÁGINAS DE AUTH (Login / Landing) - Sobrescreve o layout padrão
   ============================================================ */
body.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

body.auth-page::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background-image: 
    radial-gradient(circle at 15% 50%, rgba(59, 130, 246, 0.15) 0%, transparent 50%),
    radial-gradient(circle at 85% 30%, rgba(0, 240, 255, 0.1) 0%, transparent 50%);
  z-index: -1;
  animation: bgPulse 8s ease-in-out infinite alternate;
}

@keyframes bgPulse {
  0% { opacity: 0.6; transform: scale(1); }
  100% { opacity: 1; transform: scale(1.05); }
}

.auth-card {
  background: var(--bg-panel);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 40px 32px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
  animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

.auth-header { text-align: center; margin-bottom: 32px; }
.auth-header h1 { 
  font-family: 'Space Grotesk', sans-serif;
  font-size: 32px; 
  font-weight: 700; 
  background: linear-gradient(90deg, #fff, var(--accent)); 
  -webkit-background-clip: text; 
  -webkit-text-fill-color: transparent; 
  margin-bottom: 8px; 
  letter-spacing: -1px;
}
.auth-header p { color: var(--text-muted); font-size: 14px; line-height: 1.5; }

.auth-footer { 
  text-align: center; 
  margin-top: 24px; 
  font-size: 13px; 
  color: var(--text-muted); 
}
.auth-footer a { 
  color: var(--accent); 
  text-decoration: none; 
  font-weight: 600; 
  transition: var(--transition);
}
.auth-footer a:hover { color: #fff; text-decoration: underline; }

/* ============================================================
   COMPONENTES: FORMULÁRIOS E BOTÕES
   ============================================================ */
.form-group { margin-bottom: 20px; }
.form-group label { 
  display: block; 
  font-size: 13px; 
  color: var(--text-muted); 
  margin-bottom: 8px; 
  font-weight: 500; 
  letter-spacing: 0.5px;
}

.form-control {
  width: 100%; 
  padding: 14px 16px; 
  background: rgba(0, 0, 0, 0.3); 
  border: 1px solid var(--glass-border);
  border-radius: var(--radius); 
  color: var(--text-main); 
  font-size: 15px; 
  transition: var(--transition);
  font-family: 'Inter', sans-serif;
}

.form-control::placeholder { color: rgba(148, 163, 184, 0.5); }

.form-control:focus { 
  outline: none; 
  border-color: var(--accent); 
  box-shadow: 0 0 0 4px rgba(0, 240, 255, 0.1); 
  background: rgba(0, 0, 0, 0.5);
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 40px;
}

.btn-primary {
  width: 100%; 
  padding: 14px 24px; 
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: white; 
  border: none; 
  border-radius: var(--radius); 
  font-size: 15px; 
  font-weight: 600; 
  cursor: pointer; 
  transition: var(--transition);
  font-family: 'Inter', sans-serif;
  letter-spacing: 0.5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
}

.btn-primary:hover { 
  transform: translateY(-2px); 
  box-shadow: 0 10px 25px rgba(59, 130, 246, 0.4); 
}

.btn-primary:active { transform: translateY(0) scale(0.98); }

/* ============================================================
   DASHBOARD LAYOUT (Motor Corrigido)
   ============================================================ */
.app-container {
    display: flex;
    min-height: 100vh; /* Garante altura mínima da tela */
    width: 100%;
    position: relative;
}

/* --- SIDEBAR --- */
.sidebar {
    width: 260px;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh; /* Altura exata da viewport */
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0; /* Impede que o header encolha */
}

.sidebar-header h2 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 20px;
    background: linear-gradient(90deg, #fff, var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-menu {
    flex: 1; /* Ocupa o espaço restante entre header e footer */
    padding: 12px 0;
    overflow-y: auto;
}

/* Títulos de Grupos no Sidebar */
.menu-group-title {
    padding: 20px 24px 8px 24px;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    opacity: 0.5;
    pointer-events: none;
}
.sidebar-menu .menu-group-title:first-child { padding-top: 12px; }

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
    border-left: 3px solid transparent;
}

.menu-item:hover, .menu-item.active {
    background: rgba(59, 130, 246, 0.1);
    color: #fff;
    border-left-color: var(--accent);
}

.menu-item i { font-size: 18px; width: 24px; text-align: center; }

.sidebar-footer {
    padding: 20px 24px;
    border-top: 1px solid var(--glass-border);
    flex-shrink: 0; /* Impede que o footer encolha */
}

/* --- MAIN WRAPPER & TOPBAR --- */
.main-wrapper {
    flex: 1;
    margin-left: 260px; /* Compensa EXATAMENTE a largura da sidebar */
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    width: calc(100% - 260px);
}

.topbar {
    height: 70px;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px; /* Padding lateral padrão */
    position: sticky;
    top: 0;
    z-index: 90;
    flex-shrink: 0;
}

.topbar-left { 
    display: flex; 
    align-items: center; 
    gap: 15px; 
    /* Garante que o título/topbar comece alinhado com o conteúdo */
    min-width: 0; 
}

.menu-toggle { 
    display: none; 
    background: none; 
    border: none; 
    color: #fff; 
    font-size: 20px; 
    cursor: pointer; 
    padding: 8px;
    border-radius: 8px;
    transition: var(--transition);
    flex-shrink: 0;
}
.menu-toggle:hover { background: rgba(255,255,255,0.1); }

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    flex-shrink: 0; /* Impede que o perfil encolha e empurre o título */
}

.user-avatar {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 14px; color: #fff;
    border: 2px solid rgba(255,255,255,0.1);
}

.user-info { text-align: right; }
.user-name { font-size: 13px; font-weight: 600; color: #fff; display: block; line-height: 1.2; white-space: nowrap; }
.user-role { font-size: 11px; color: var(--text-muted); }

/* --- CONTENT AREA (ALINHAMENTO PERFEITO) --- */
.content {
    padding: 30px; /* Mesmo padding lateral do topbar para alinhar títulos */
    flex: 1;
    width: 100%;
    /* Removemos qualquer margem extra que cause o "gap" lateral */
}

.page-header { 
    margin-bottom: 30px; 
    /* Garante que o título não seja cortado se a tela for estreita */
    overflow: hidden; 
}
.page-title { 
    font-family: 'Space Grotesk', sans-serif; 
    font-size: 24px; 
    font-weight: 700; 
    color: #fff; 
    margin-bottom: 5px; 
    word-wrap: break-word;
}
.page-subtitle { font-size: 13px; color: var(--text-muted); }

/* ============================================================
   COMPONENTES: CARDS E STATS GRID
   ============================================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
    width: 100%;
}

.stat-card {
    background: var(--bg-panel);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 24px;
    position: relative;
    overflow: hidden;
    transition: var(--transition);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.stat-card:hover { 
    transform: translateY(-5px); 
    border-color: var(--accent); 
    box-shadow: 0 10px 30px rgba(0, 240, 255, 0.1);
}

.stat-icon {
    position: absolute; top: 20px; right: 20px;
    font-size: 24px; opacity: 0.15;
}

.stat-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 10px; font-weight: 600; }
.stat-value { font-family: 'Space Grotesk', sans-serif; font-size: 28px; font-weight: 700; color: #fff; }
.stat-trend { font-size: 12px; margin-top: 12px; display: flex; align-items: center; gap: 5px; font-weight: 500; }
.stat-trend.up { color: var(--success); }
.stat-trend.down { color: var(--danger); }

/* ============================================================
   DATA TABLE ULTRA TOP
   ============================================================ */
.data-table-wrapper {
    background: var(--bg-panel);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    overflow: hidden;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table thead {
    background: rgba(0, 0, 0, 0.3);
}

.data-table th {
    text-align: left;
    padding: 16px 20px;
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 1px;
    border-bottom: 1px solid var(--glass-border);
    white-space: nowrap;
}

.data-table td {
    padding: 16px 20px;
    border-bottom: 1px solid var(--glass-border);
    color: var(--text-main);
    vertical-align: middle;
    transition: background 0.2s ease;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.data-table tbody tr:hover td {
    background: rgba(59, 130, 246, 0.08);
}

/* Botões de ação na tabela */
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(59, 130, 246, 0.1);
    color: var(--primary);
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    margin-right: 6px;
}
.btn-icon:hover { background: var(--primary); color: #fff; transform: translateY(-2px); }
.btn-icon.danger { background: rgba(239, 68, 68, 0.1); color: var(--danger); }
.btn-icon.danger:hover { background: var(--danger); color: #fff; }
.btn-icon.warning { background: rgba(245, 158, 11, 0.1); color: var(--warning); }
.btn-icon.warning:hover { background: var(--warning); color: #fff; }
.btn-icon.success { background: rgba(16, 185, 129, 0.1); color: var(--success); }
.btn-icon.success:hover { background: var(--success); color: #fff; }

/* Badges de Status */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.badge-primary { background: rgba(59, 130, 246, 0.15); color: var(--primary); }
.badge-success { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.badge-danger { background: rgba(239, 68, 68, 0.15); color: var(--danger); }
.badge-warning { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.badge-accent { background: rgba(0, 240, 255, 0.15); color: var(--accent); }

/* ============================================================
   SWEETALERT2 CUSTOMIZAÇÃO (Dark Mode)
   ============================================================ */
div:where(.swal2-container) div:where(.swal2-popup) {
  background: #0f172a !important;
  border: 1px solid var(--glass-border) !important;
  color: #f8fafc !important;
  border-radius: var(--radius-lg) !important;
  box-shadow: var(--shadow) !important;
}
div:where(.swal2-container) h2:where(.swal2-title) {
  color: #fff !important;
  font-family: 'Space Grotesk', sans-serif !important;
}
div:where(.swal2-container) div:where(.swal2-html-container) {
  color: var(--text-muted) !important;
}
div:where(.swal2-container) button:where(.swal2-confirm) {
  background: linear-gradient(135deg, var(--primary), var(--primary-hover)) !important;
  border-radius: var(--radius) !important;
  font-weight: 600 !important;
  font-family: 'Inter', sans-serif !important;
}
div:where(.swal2-container) button:where(.swal2-cancel) {
  background: rgba(255,255,255,0.1) !important;
  color: #fff !important;
  border-radius: var(--radius) !important;
  font-family: 'Inter', sans-serif !important;
}

/* ============================================================
   RESPONSIVIDADE (Mobile First approach)
   ============================================================ */

/* Tablet e telas médias */
@media (max-width: 992px) {
    .sidebar { 
        transform: translateX(-100%); 
        box-shadow: 5px 0 30px rgba(0,0,0,0.5);
    }
    .sidebar.active { 
        transform: translateX(0); 
    }
    .main-wrapper { 
        margin-left: 0; 
        width: 100%;
    }
    .menu-toggle { 
        display: block; 
    }
    
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0; left: 0; right: 0; bottom: 0;
        background: rgba(0,0,0,0.6);
        backdrop-filter: blur(4px);
        z-index: 99;
        opacity: 0;
        transition: opacity 0.3s ease;
    }
    .sidebar-overlay.active {
        display: block;
        opacity: 1;
    }
}

/* Mobile */
@media (max-width: 768px) {
    .content { padding: 20px 15px; }
    .topbar { padding: 0 15px; }
    .user-info { display: none; }
    .stats-grid { grid-template-columns: 1fr; }
    .page-title { font-size: 20px; }
    
    .data-table th, .data-table td {
        padding: 12px 15px;
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    body.auth-page { padding: 16px; align-items: flex-start; padding-top: 10vh; }
    .auth-card { padding: 32px 24px; max-width: 100%; }
    .auth-header h1 { font-size: 28px; }
    .form-control { padding: 12px 14px; font-size: 16px; }
    .btn-primary { padding: 14px; }
    
    .content { padding: 15px 12px; }
    .stat-card { padding: 18px; }
    .stat-value { font-size: 24px; }
}

@media (max-width: 360px) {
  .auth-card { padding: 24px 20px; }
  .auth-header h1 { font-size: 24px; }
}