/* Modern SaaS Design System for Email Marketing */
:root {
  --app-font: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --sidebar-width: 260px;
  --sidebar-bg: #0f172a;
  --sidebar-color: #94a3b8;
  --sidebar-active-bg: #1e293b;
  --sidebar-active-color: #38bdf8;
  --sidebar-border: rgba(255, 255, 255, 0.08);
  
  --primary-color: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-subtle: #dbeafe;
  --primary-gradient: linear-gradient(135deg, #2563eb 0%, #4f46e5 100%);
  
  --success-color: #10b981;
  --warning-color: #f59e0b;
  --danger-color: #ef4444;
  --info-color: #06b6d4;
  
  --body-bg: #f8fafc;
  --card-bg: #ffffff;
  --card-border: rgba(226, 232, 240, 0.8);
  --card-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05), 0 1px 2px -1px rgba(0, 0, 0, 0.05);
  --card-hover-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.07), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
  
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
}

[data-bs-theme="dark"] {
  --body-bg: #090d16;
  --card-bg: #111827;
  --card-border: rgba(255, 255, 255, 0.08);
  --card-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.4);
  --card-hover-shadow: 0 10px 20px -3px rgba(0, 0, 0, 0.5);
  --sidebar-bg: #0b101c;
  --sidebar-active-bg: #1f2937;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-light: #64748b;
}

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

/* App Wrapper Layout */
.app-layout {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

/* Sidebar */
.app-sidebar {
  width: var(--sidebar-width);
  background-color: var(--sidebar-bg);
  color: var(--sidebar-color);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 1040;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border-right: 1px solid var(--sidebar-border);
}

.sidebar-brand {
  padding: 1.5rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid var(--sidebar-border);
  text-decoration: none;
  color: #fff;
}

.sidebar-brand:hover {
  color: #fff;
}

.brand-icon-wrapper {
  width: 36px;
  height: 36px;
  background: var(--primary-gradient);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
  color: #ffffff;
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0.75rem;
}

.nav-section-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
  padding: 0.75rem 0.75rem 0.25rem 0.75rem;
  margin-top: 0.5rem;
}

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

.sidebar-nav .nav-item {
  margin-bottom: 0.25rem;
}

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.65rem 0.85rem;
  color: var(--sidebar-color);
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.15s ease-in-out;
}

.sidebar-nav .nav-link i {
  font-size: 1.15rem;
  transition: transform 0.15s ease;
}

.sidebar-nav .nav-link:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.05);
}

.sidebar-nav .nav-link:hover i {
  transform: translateX(2px);
}

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

.sidebar-nav .nav-link.active i {
  color: var(--sidebar-active-color);
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

/* Topbar */
.app-topbar {
  height: 64px;
  background-color: var(--card-bg);
  border-bottom: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.75rem;
  position: sticky;
  top: 0;
  z-index: 1020;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.page-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

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

.theme-toggle-btn {
  background: none;
  border: 1px solid var(--card-border);
  color: var(--text-muted);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.theme-toggle-btn:hover {
  color: var(--text-main);
  border-color: var(--primary-color);
}

/* User dropdown button */
.user-dropdown-btn {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.35rem 0.65rem;
  border-radius: 8px;
  background: transparent;
  border: 1px solid var(--card-border);
  cursor: pointer;
  text-decoration: none;
  color: var(--text-main);
}

.user-avatar-badge {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  background: var(--primary-gradient);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Content Container */
.app-content {
  padding: 1.75rem;
  flex: 1;
}

/* SaaS Cards */
.saas-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  box-shadow: var(--card-shadow);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
  margin-bottom: 1.5rem;
}

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

.saas-card .card-header {
  background: transparent;
  border-bottom: 1px solid var(--card-border);
  padding: 1.25rem 1.5rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.saas-card .card-body {
  padding: 1.5rem;
}

/* Stat KPI Cards */
.stat-kpi-card {
  position: relative;
  overflow: hidden;
  padding: 1.5rem;
  border-radius: 14px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  box-shadow: var(--card-shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

.stat-kpi-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.stat-kpi-title {
  font-size: 0.825rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 0;
}

.stat-kpi-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

.stat-kpi-value {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-main);
  line-height: 1.1;
  margin-bottom: 0.35rem;
}

.stat-kpi-footer {
  font-size: 0.825rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Custom Table */
.saas-table {
  width: 100%;
  margin-bottom: 0;
  vertical-align: middle;
}

.saas-table th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.02);
  border-bottom: 1px solid var(--card-border);
  padding: 0.85rem 1rem;
}

[data-bs-theme="dark"] .saas-table th {
  background: rgba(255, 255, 255, 0.02);
}

.saas-table td {
  padding: 0.95rem 1rem;
  border-bottom: 1px solid var(--card-border);
  color: var(--text-main);
  font-size: 0.875rem;
}

.saas-table tbody tr:hover {
  background-color: rgba(37, 99, 235, 0.03);
}

/* Badges */
.badge-saas {
  font-weight: 600;
  font-size: 0.75rem;
  padding: 0.35em 0.75em;
  border-radius: 9999px;
  letter-spacing: 0.02em;
}

/* Mobile responsive */
@media (max-width: 991.98px) {
  .app-sidebar {
    transform: translateX(-100%);
  }
  .app-sidebar.show {
    transform: translateX(0);
  }
  .app-main {
    margin-left: 0;
  }
  .sidebar-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1030;
    display: none;
  }
  .sidebar-backdrop.show {
    display: block;
  }
}
