/* ==========================================================================
   RESET & SYSTEM VARIABLES (Stripe/GitHub Light Mode Theme)
   ========================================================================== */
:root {
  --font-main: 'DM Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  
  /* Color Palette */
  --bg-app: #f8fafc;
  --bg-surface: #ffffff;
  --bg-subtle: #f1f5f9;
  
  --border-color: #e2e8f0;
  --border-hover: #cbd5e1;
  
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #eeef2;
  
  --danger: #ef4444;
  --danger-bg: #fef2f2;
  --success: #10b981;
  --success-bg: #ecfdf5;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-card: 0 4px 6px -1px rgb(0 0 0 / 0.03), 0 2px 4px -2px rgb(0 0 0 / 0.03);
  --shadow-popover: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;
  
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a {
  text-decoration: none;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
}

/* ==========================================================================
   LAYOUT STRUCTURE
   ========================================================================== */
.app-container {
  display: flex;
  min-height: 100vh;
  position: relative;
}

/* Sidebar Overlay (Mobile) */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
  z-index: 40;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
}

.sidebar-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background-color: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 50;
  transition: var(--transition);
}

.sidebar-header {
  height: 70px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid transparent;
}

.brand-logo {
  height: 34px;
  object-fit: contain;
}

.close-sidebar-btn {
  display: none;
  font-size: 20px;
  color: var(--text-muted);
}

.sidebar-nav {
  padding: 20px 16px;
  flex: 1;
  overflow-y: auto;
}

.nav-section {
  margin-bottom: 24px;
}

.nav-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-light);
  margin-bottom: 10px;
  padding-left: 12px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition);
  margin-bottom: 4px;
}

.nav-item i {
  font-size: 16px;
  display: flex;
}

.nav-item:hover {
  background-color: var(--bg-subtle);
  color: var(--text-main);
}

.nav-item.active {
  background-color: #f1f5f9;
  color: var(--primary);
  font-weight: 600;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border-color);
}

.ia-status-card {
  background: var(--bg-app);
  padding: 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.status-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 8px;
}

.progress-bar {
  height: 6px;
  background: #e2e8f0;
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: var(--radius-full);
}

.status-text {
  font-size: 11px;
  color: var(--text-muted);
}

/* Main Content Wrapper */
.main-content {
  flex: 1;
  margin-left: 260px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Navbar */
.top-navbar {
  height: 60px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 30;
}

.navbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
  max-width: 480px;
}

.menu-toggle-btn {
  display: none;
  font-size: 20px;
  color: var(--text-main);
}

.search-box {
  width: 100%;
  position: relative;
  display: flex;
  align-items: center;
}

.search-box i {
  position: absolute;
  left: 14px;
  color: var(--text-light);
  font-size: 15px;
}

.search-box input {
  width: 100%;
  padding: 9px 16px 9px 40px;
  background: var(--bg-app);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  color: var(--text-main);
  outline: none;
  transition: var(--transition);
}

.search-box input:focus {
  border-color: var(--primary);
  background: var(--bg-surface);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.navbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-icon-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 16px;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  transition: var(--transition);
  position: relative;
}

.nav-icon-btn:hover {
  background: var(--bg-subtle);
  color: var(--text-main);
}

.nav-icon-btn .badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  width: 18px;
  height: 18px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg-surface);
}

/* Profile Avatar & Popover (Visual idêntico ao screenshot) */
.profile-dropdown-wrapper {
  position: relative;
}

.profile-avatar-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: #64748b;
  color: #ffffff;
  font-weight: 700;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.profile-avatar-btn:hover {
  opacity: 0.9;
}

.profile-popover {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 240px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-popover);
  padding: 12px 0;
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: var(--transition);
}

.profile-popover.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.popover-header {
  padding: 4px 16px 12px 16px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
}

.popover-header strong {
  font-size: 14px;
  color: var(--text-main);
}

.popover-header .user-email {
  font-size: 12px;
  color: var(--text-muted);
}

.popover-menu {
  padding-top: 8px;
}

.popover-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  font-size: 13.5px;
  color: var(--text-main);
  transition: var(--transition);
}

.popover-item i {
  font-size: 15px;
  color: var(--text-muted);
}

.popover-item:hover {
  background: var(--bg-subtle);
}

.popover-divider {
  height: 1px;
  background: var(--border-color);
  margin: 6px 0;
}

.popover-item.text-danger {
  color: var(--danger);
}

.popover-item.text-danger i {
  color: var(--danger);
}

/* ==========================================================================
   DASHBOARD BODY
   ========================================================================== */
.dashboard-body {
  padding: 32px;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
}

.welcome-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 32px;
  gap: 16px;
}

.welcome-header h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.welcome-header p {
  color: var(--text-muted);
  font-size: 14px;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  background: var(--primary-hover);
}

/* Stats Grid (Baseado na imagem enviada) */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 36px;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.stat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.stat-title {
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 500;
}

.badge-tag {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 4px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 700;
}

.tag-danger {
  background: var(--danger);
  color: #ffffff;
}

.stat-value-container {
  margin-bottom: 16px;
}

.stat-value {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-main);
}

.stat-footer {
  border-top: 1px solid var(--bg-subtle);
  padding-top: 12px;
}

.stat-trend {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 2px;
}

.stat-subtext {
  font-size: 12px;
  color: var(--text-light);
}

/* Seção de IAs */
.content-section {
  margin-top: 20px;
}

.section-title-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.section-title-bar h2 {
  font-size: 18px;
  font-weight: 700;
}

.link-btn {
  font-size: 13px;
  color: var(--primary);
  font-weight: 600;
}

.ai-cards-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.ai-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-card);
  transition: var(--transition);
}

.ai-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
}

.ai-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.ai-icon-box {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: #e0e7ff;
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.ai-icon-box.accent-purple {
  background: #f3e8ff;
  color: #9333ea;
}

.status-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--radius-full);
}

.status-online {
  background: var(--success-bg);
  color: var(--success);
}

.ai-card h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 6px;
}

.ai-card p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 16px;
  flex: 1;
}

.ai-card-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--text-light);
  margin-bottom: 18px;
  padding-top: 12px;
  border-top: 1px solid var(--bg-subtle);
}

.ai-card-meta span {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ai-card-actions {
  display: flex;
  gap: 8px;
}

.btn-secondary {
  flex: 1;
  background: var(--bg-subtle);
  color: var(--text-main);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  transition: var(--transition);
}

.btn-secondary:hover {
  background: var(--border-color);
}

.btn-outline {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: var(--transition);
}

.btn-outline:hover {
  background: var(--bg-subtle);
  color: var(--text-main);
}

.new-ai-card {
  border: 2px dashed var(--border-color);
  background: transparent;
  justify-content: center;
  align-items: center;
  text-align: center;
  cursor: pointer;
  box-shadow: none;
}

.new-ai-card:hover {
  border-color: var(--primary);
  background: rgba(79, 70, 229, 0.02);
}

.new-ai-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px;
}

.add-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  background: var(--bg-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.new-ai-card:hover .add-icon {
  background: var(--primary);
  color: #fff;
}

/* ==========================================================================
   RESPONSIVIDADE (MOBILE & DESKTOP)
   ========================================================================== */

/* Tablets / Telas Médias */
@media (max-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .ai-cards-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Mobile Devices */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.active {
    transform: translateX(0);
  }

  .close-sidebar-btn {
    display: block;
  }

  .main-content {
    margin-left: 0;
  }

  .top-navbar {
    padding: 0 16px;
  }

  .menu-toggle-btn {
    display: block;
  }

  .search-box {
    display: none; /* Esconde campo de busca no mobile para otimizar espaço */
  }

  .dashboard-body {
    padding: 20px 16px;
  }

  .welcome-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .welcome-header button {
    width: 100%;
    justify-content: center;
  }

  .stats-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .ai-cards-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
}

/* ==========================================================================
   NAVBAR & BUTTONS UPDATES
   ========================================================================== */

/* Botão de Upgrade Violeta */
.btn-pontos {
  background: transparent; /* Cor Violeta */
  color: #000000;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  border: 2px solid var(--border-color);
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
}

/* Remoção de borda do botão de Notificações */
.nav-icon-btn.notif-btn {
  border: none;
  background: transparent;
}

.nav-icon-btn.notif-btn:hover {
  background: var(--bg-subtle);
}
