/* =====================================================================
   MAILNEX OFFICIAL DESIGN SYSTEM & BRAND TOKENS
   Palette:
     - White:         #FFFFFF (Primary background, cards, tables, forms)
     - Forest Green:  #081C15 (Headings, primary body text, dark surfaces)
     - Deep Green:    #184322 (Sidebar background, primary structure)
     - Emerald:       #038666 (Links, focus rings, selected controls, success)
     - Golden Yellow: #FBB02D (Primary CTA buttons, key highlights, active accents)
   Typography:
     - Poppins (Primary application UI font)
     - NEVERA  (Brand / Display accents where available)
   ===================================================================== */

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

:root {
  /* Core Palette Tokens */
  --color-white: #FFFFFF;
  --color-forest: #081C15;
  --color-deep-green: #184322;
  --color-emerald: #038666;
  --color-golden: #FBB02D;
  --color-golden-hover: #E09E24;
  --color-emerald-hover: #02664D;

  /* Neutrals & Surfaces */
  --bg-primary: #FFFFFF;
  --bg-secondary: #F9FAFB;
  --bg-card: #FFFFFF;
  --bg-hover: #F3F4F6;
  --bg-active: #E5E7EB;
  --bg-input: #FFFFFF;
  --bg-sidebar: #184322;
  --bg-sidebar-deep: #081C15;

  /* Typography Colors */
  --text-primary: #081C15;
  --text-secondary: #374151;
  --text-muted: #6B7280;
  --text-on-dark: #FFFFFF;
  --text-on-golden: #081C15;

  /* Borders & Dividers */
  --border-subtle: #E5E7EB;
  --border-hover: #D1D5DB;
  --border-focus: #038666;
  --border-golden: #FBB02D;

  /* Backward Compatibility Aliases for Existing Views */
  --purple-primary: #038666;
  --purple-deep: #184322;
  --purple-hover: #02664D;
  --pink-accent: #081C15;
  --navy-primary: #184322;
  --navy-hover: #081C15;
  --yellow-accent: #FBB02D;
  --yellow-hover: #E09E24;
  --gradient-accent: #FBB02D;
  --gradient-purple-subtle: #F9FAFB;

  /* Status Colors */
  --status-valid-bg: #ECFDF5;
  --status-valid-text: #038666;
  --status-valid-border: #A7F3D0;

  --status-active-bg: #ECFDF5;
  --status-active-text: #184322;
  --status-active-border: #A7F3D0;

  --status-invalid-bg: #FEE2E2;
  --status-invalid-text: #DC2626;
  --status-invalid-border: #FECACA;

  --status-risky-bg: #FEF3C7;
  --status-risky-text: #92400E;
  --status-risky-border: #FDE68A;

  --status-unknown-bg: #F3F4F6;
  --status-unknown-text: #374151;
  --status-unknown-border: #E5E7EB;

  /* Typography Scales */
  --font-family-base: 'Poppins', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-family-brand: 'NEVERA', 'Poppins', sans-serif;

  --font-size-h1: 28px;
  --font-size-h2: 22px;
  --font-size-h3: 17px;
  --font-size-h4: 15px;
  --font-size-body: 13.5px;
  --font-size-small: 12.5px;
  --font-size-xs: 11.5px;

  /* Dimensions (Compact, Clean Layout) */
  --sidebar-width: 220px;
  --sidebar-collapsed-width: 68px;
  --topbar-height: 64px;

  /* Radii */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-pill: 9999px;

  /* Shadows & Rings */
  --shadow-card: 0 1px 3px rgba(8, 28, 21, 0.05), 0 1px 2px rgba(8, 28, 21, 0.03);
  --shadow-hover: 0 4px 12px rgba(8, 28, 21, 0.08);
  --shadow-dropdown: 0 10px 25px rgba(8, 28, 21, 0.12), 0 4px 10px rgba(8, 28, 21, 0.06);
  --focus-ring: 0 0 0 2px rgba(3, 134, 102, 0.25);
  --focus-ring-golden: 0 0 0 2px rgba(251, 176, 45, 0.4);

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.22s ease;
}

/* =====================================================================
   GLOBAL BASE RESETS & TYPOGRAPHY
   ===================================================================== */
body {
  font-family: var(--font-family-base);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-size: var(--font-size-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, .page-title, .card-title {
  color: var(--color-forest);
  font-weight: 600;
  letter-spacing: -0.015em;
}

a {
  color: var(--color-emerald);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--color-emerald-hover);
}

/* =====================================================================
   SIDEBAR (COMPACT, PROFESSIONAL DEEP GREEN)
   ===================================================================== */
.app-sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  background: linear-gradient(180deg, var(--color-deep-green) 0%, var(--color-forest) 100%);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: relative;
  z-index: 100;
  overflow: hidden;
  box-shadow: 2px 0 12px rgba(8, 28, 21, 0.15);
}

.sidebar-header {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}

.sidebar-header .brand-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  width: 100%;
  max-width: 100%;
  position: relative;
}

.sidebar-brand-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #FFFFFF;
  border-radius: var(--radius-md);
  padding: 4px 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  width: 100%;
  max-width: 196px;
  height: 48px;
  overflow: hidden;
  position: relative;
  box-sizing: border-box;
}

.sidebar-brand-badge:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.28);
}

.brand-logo-img {
  max-height: 40px;
  max-width: 180px;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
  flex-shrink: 0;
}

.brand-icon-compact {
  display: none;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  background: #FFFFFF;
  border-radius: var(--radius-md);
  padding: 5px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  transition: transform var(--transition-fast);
  overflow: hidden;
}

.brand-icon-img {
  width: 100%;
  height: 100%;
  max-width: 28px;
  max-height: 28px;
  object-fit: contain;
  display: block;
}

.sidebar-nav {
  flex: 1;
  padding: 14px 10px;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.sidebar-nav::-webkit-scrollbar {
  width: 4px;
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  color: rgba(255, 255, 255, 0.82);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: all var(--transition-fast);
  position: relative;
  white-space: nowrap;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #FFFFFF;
  transform: translateX(2px);
}

.nav-item.active {
  background: rgba(255, 255, 255, 0.12);
  color: #FFFFFF;
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--color-golden);
}

.nav-item .nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: rgba(255, 255, 255, 0.85);
  transition: color var(--transition-fast);
}

.nav-item:hover .nav-icon,
.nav-item.active .nav-icon {
  color: #FFFFFF;
}

.nav-item.active .nav-icon {
  color: var(--color-golden);
}

.nav-item .nav-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  margin: 8px 8px;
}

.nav-section-title {
  padding: 8px 12px 4px 12px;
  font-size: 10px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.45);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* =====================================================================
   TOPBAR & GLOBAL SEARCH
   ===================================================================== */
.app-topbar {
  height: var(--topbar-height);
  min-height: var(--topbar-height);
  background-color: #FFFFFF;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(8, 28, 21, 0.02);
  position: relative;
  z-index: 90;
  box-sizing: border-box;
}

.topbar-main-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 100%;
  gap: 16px;
}

.topbar-search {
  position: relative;
  flex: 1;
  max-width: 440px;
  display: flex;
  align-items: center;
  height: 38px;
}

.topbar-search input {
  width: 100%;
  height: 38px;
  padding: 0 14px 0 38px;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 13px;
  font-family: var(--font-family-base);
  outline: none;
  transition: all var(--transition-fast);
  box-sizing: border-box;
  line-height: 38px;
}

.topbar-search input:focus {
  background-color: #FFFFFF;
  border-color: var(--color-emerald);
  box-shadow: var(--focus-ring);
}

.search-results-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: #FFFFFF;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-dropdown);
  max-height: 380px;
  overflow-y: auto;
  z-index: 1000;
}

.search-result-group-title {
  padding: 8px 14px 4px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-subtle);
}

.search-result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 14px;
  text-decoration: none;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--transition-fast);
  cursor: pointer;
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-item:hover,
.search-result-item.selected {
  background-color: #F0FDF4;
}

.search-result-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.search-result-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 1px;
}

.search-result-type-tag {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

.search-result-type-contact {
  background: rgba(3, 134, 102, 0.12);
  color: var(--color-emerald);
}

.search-result-type-campaign {
  background: rgba(251, 176, 45, 0.2);
  color: #92400e;
}

.search-result-type-template {
  background: rgba(59, 130, 246, 0.12);
  color: #2563eb;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
  height: 38px;
}

.smtp-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  box-sizing: border-box;
  margin: 0;
}

.user-profile-badge {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  height: 38px;
  padding: 0 12px 0 5px;
  border-radius: var(--radius-pill);
  background: linear-gradient(180deg, var(--color-deep-green) 0%, var(--color-forest) 100%);
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 2px 6px rgba(8, 28, 21, 0.2);
  transition: all var(--transition-fast);
  box-sizing: border-box;
  color: #FFFFFF;
  margin: 0;
}

.user-profile-badge:hover {
  background: linear-gradient(180deg, #1d4f29 0%, #0c261d 100%);
  border-color: rgba(251, 176, 45, 0.45);
  box-shadow: 0 4px 10px rgba(8, 28, 21, 0.28);
}

.user-profile-badge .user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--color-golden);
  color: var(--color-forest);
  font-size: 12.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-profile-badge .user-name {
  font-size: 13px;
  font-weight: 600;
  color: #FFFFFF;
  white-space: nowrap;
}

.user-profile-badge .user-role-badge {
  font-size: 10px;
  font-weight: 700;
  background: var(--color-golden);
  color: var(--color-forest);
  padding: 2px 6px;
  border-radius: 8px;
  letter-spacing: 0.04em;
  line-height: 1.2;
}

.user-profile-badge .dropdown-caret {
  width: 12px;
  height: 12px;
  color: rgba(255, 255, 255, 0.7);
  stroke-width: 2.5;
}

/* =====================================================================
   BUTTONS (PRIMARY GOLDEN YELLOW, EMERALD ACCENTS)
   ===================================================================== */
.btn {
  font-family: var(--font-family-base);
  font-weight: 600;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.btn-primary {
  background-color: var(--color-golden) !important;
  color: var(--color-forest) !important;
  border: 1px solid var(--color-golden) !important;
  font-weight: 600 !important;
  box-shadow: 0 1px 2px rgba(8, 28, 21, 0.06);
}

.btn-primary:hover {
  background-color: var(--color-golden-hover) !important;
  border-color: var(--color-golden-hover) !important;
  color: var(--color-forest) !important;
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(251, 176, 45, 0.3);
}

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

.btn-secondary {
  background-color: #FFFFFF !important;
  color: var(--color-forest) !important;
  border: 1px solid var(--border-subtle) !important;
}

.btn-secondary:hover {
  background-color: var(--bg-secondary) !important;
  border-color: var(--border-hover) !important;
  color: var(--color-forest) !important;
}

.btn-emerald {
  background-color: var(--color-emerald) !important;
  color: #FFFFFF !important;
  border: 1px solid var(--color-emerald) !important;
}

.btn-emerald:hover {
  background-color: var(--color-emerald-hover) !important;
  border-color: var(--color-emerald-hover) !important;
  color: #FFFFFF !important;
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(3, 134, 102, 0.3);
}

/* =====================================================================
   CARDS, TABLES, FORMS
   ===================================================================== */
.card {
  background-color: #FFFFFF;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

.stat-card {
  background-color: #FFFFFF;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

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

.stat-accent-bar {
  background: var(--color-golden);
}

.form-input, .form-select, .form-textarea, .form-control {
  font-family: var(--font-family-base);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  background-color: #FFFFFF;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-input:focus, .form-select:focus, .form-textarea:focus, .form-control:focus {
  border-color: var(--color-emerald);
  box-shadow: var(--focus-ring);
  outline: none;
}

.data-table th {
  background-color: var(--bg-secondary);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 11.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border-subtle);
}

.data-table td {
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-subtle);
}

.data-table tbody tr:hover {
  background-color: #FAFAFA;
}

/* =====================================================================
   VECTOR SVG ICON UTILITIES
   ===================================================================== */
.icon-svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: middle;
  flex-shrink: 0;
  display: inline-block;
}

.icon-svg-sm {
  width: 15px;
  height: 15px;
  stroke-width: 2;
}

.icon-svg-lg {
  width: 22px;
  height: 22px;
  stroke-width: 2;
}

/* =====================================================================
   RESPONSIVE OVERRIDES
   ===================================================================== */
@media (max-width: 1024px) {
  :root {
    --sidebar-width: var(--sidebar-collapsed-width);
  }

  .sidebar-brand-badge, .nav-text, .nav-section-title {
    display: none !important;
  }

  .brand-icon-compact {
    display: inline-flex !important;
  }

  .nav-item {
    justify-content: center;
    padding: 10px 0;
  }
}

@media (max-width: 768px) {
  .app-sidebar {
    width: 100vw;
    height: 56px;
    flex-direction: row;
    border-right: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }

  .sidebar-header {
    height: 100%;
    padding: 0 12px;
    border-bottom: none;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
  }

  .sidebar-brand-badge {
    display: inline-flex !important;
    padding: 4px 10px;
    height: 32px;
  }

  .brand-icon-compact {
    display: none !important;
  }

  .sidebar-nav {
    flex-direction: row;
    overflow-x: auto;
    padding: 4px 8px;
    gap: 4px;
  }

  .nav-item {
    padding: 6px 10px;
  }
}
