/* Estorra Email Marketing Manager — Admin UI */
:root {
  --estorra-navy: #0b3d4a;
  --estorra-teal: #1fa7a0;
  --estorra-teal-dark: #178a84;
  --estorra-navy-light: #0f4d5c;
  --sidebar-width: 260px;
  --topnav-height: 60px;
  --body-bg: #f4f7f9;
  --card-border: #e2e8f0;
  --text-muted: #5c6b7a;
  --shadow-sm: 0 1px 3px rgba(11, 61, 74, 0.08);
  --shadow-md: 0 4px 12px rgba(11, 61, 74, 0.1);
}

* {
  box-sizing: border-box;
}

body.admin-body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 0.9375rem;
  color: #1a2b36;
  background: var(--body-bg);
  min-height: 100vh;
}

a {
  color: var(--estorra-teal-dark);
  text-decoration: none;
}

a:hover {
  color: var(--estorra-navy);
}

/* Auth (login) layout */
body.auth-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: linear-gradient(135deg, var(--estorra-navy) 0%, #0a5568 50%, var(--estorra-teal-dark) 100%);
}

body.auth-body .auth-card {
  width: 100%;
  max-width: 420px;
}

.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: linear-gradient(135deg, var(--estorra-navy) 0%, #0a5568 50%, var(--estorra-teal-dark) 100%);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  padding: 2rem;
}

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

.auth-brand h1 {
  font-size: 1.25rem;
  color: var(--estorra-navy);
  margin: 0.5rem 0 0;
  font-weight: 700;
}

.auth-brand .logo-mark {
  display: inline-flex;
  width: 48px;
  height: 48px;
  border-radius: 10px;
  background: var(--estorra-teal);
  color: #fff;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.25rem;
}

/* Shell layout */
.admin-shell {
  display: flex;
  min-height: 100vh;
}

.admin-sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: linear-gradient(180deg, #0a3540 0%, var(--estorra-navy) 55%, #083039 100%);
  color: #e8f4f6;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 1040;
  display: flex;
  flex-direction: column;
  transition: transform 0.25s ease;
  box-shadow: 4px 0 24px rgba(8, 40, 48, 0.25);
}

.admin-sidebar-brand {
  padding: 1.15rem 1.1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

.admin-sidebar-brand a {
  color: #fff;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

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

.admin-sidebar-brand .logo-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--estorra-teal);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 700;
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(31, 167, 160, 0.35);
}

.admin-sidebar-brand .brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  min-width: 0;
}

.admin-sidebar-brand .brand-text strong {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.admin-sidebar-brand .brand-text small {
  margin-top: 0.2rem;
  font-size: 0.72rem;
  font-weight: 500;
  color: rgba(232, 244, 246, 0.65);
  letter-spacing: 0.02em;
}

.admin-sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 0.65rem 0 1.25rem;
}

.admin-nav {
  list-style: none;
  margin: 0;
  padding: 0 0.75rem;
}

.admin-nav > li {
  margin: 0;
}

.admin-nav-section {
  list-style: none;
  margin: 1rem 0 0.35rem;
  padding: 0 0.75rem;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.42);
}

.admin-nav-section:first-child {
  margin-top: 0.35rem;
}

.admin-nav li a {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.7rem 0.85rem;
  margin-bottom: 0.2rem;
  color: rgba(255, 255, 255, 0.82);
  border-radius: 8px;
  border-left: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.admin-nav li a:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.admin-nav li a.active {
  background: rgba(31, 167, 160, 0.22);
  color: #fff;
  box-shadow: inset 3px 0 0 var(--estorra-teal);
}

.admin-nav li a .nav-icon {
  width: 1.35rem;
  height: 1.35rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.9;
  flex-shrink: 0;
}

.admin-nav li a .nav-icon svg {
  display: block;
}

.admin-nav li a.active .nav-icon {
  color: #7ee0da;
  opacity: 1;
}

.admin-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.admin-topbar {
  height: var(--topnav-height);
  background: #fff;
  border-bottom: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 1030;
  box-shadow: var(--shadow-sm);
}

.admin-topbar-title {
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--estorra-navy);
  margin: 0;
}

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

.admin-user-menu {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.admin-user-menu .user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--estorra-teal);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.85rem;
}

.sidebar-toggle {
  display: none;
  border: none;
  background: transparent;
  color: var(--estorra-navy);
  font-size: 1.35rem;
  padding: 0.25rem 0.5rem;
  cursor: pointer;
}

.admin-content {
  padding: 1.5rem;
  flex: 1;
}

/* Cards & stats */
.stat-card {
  background: #fff;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 1.25rem;
  height: 100%;
  box-shadow: var(--shadow-sm);
}

.stat-card .stat-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.stat-card .stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--estorra-navy);
  line-height: 1.2;
}

.stat-card .stat-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

.stat-card.stat-accent {
  border-top: 3px solid var(--estorra-teal);
}

.card-panel {
  background: #fff;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
}

.card-panel-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.card-panel-header h2,
.card-panel-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--estorra-navy);
}

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

.card-panel-body.p-0 {
  padding: 0;
}

/* Tables */
.table-admin {
  margin-bottom: 0;
  font-size: 0.875rem;
}

.table-admin thead th {
  background: #f8fafb;
  color: var(--estorra-navy);
  font-weight: 600;
  border-bottom-width: 1px;
  white-space: nowrap;
}

.table-admin tbody tr:hover {
  background: #f8fcfc;
}

.table-empty {
  text-align: center;
  padding: 2rem !important;
  color: var(--text-muted);
}

/* Forms */
.form-label {
  font-weight: 500;
  color: #334155;
}

.btn-estorra {
  background: var(--estorra-teal);
  border-color: var(--estorra-teal);
  color: #fff;
}

.btn-estorra:hover,
.btn-estorra:focus {
  background: var(--estorra-teal-dark);
  border-color: var(--estorra-teal-dark);
  color: #fff;
}

.btn-outline-estorra {
  border-color: var(--estorra-teal);
  color: var(--estorra-teal-dark);
}

.btn-outline-estorra:hover {
  background: var(--estorra-teal);
  color: #fff;
}

.filter-bar {
  background: #fff;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
}

/* Footer */
.admin-footer {
  padding: 1rem 1.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-top: 1px solid var(--card-border);
  background: #fff;
}

/* Toast container */
#toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 380px;
}

.toast-custom {
  animation: toastIn 0.3s ease;
}

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

/* Confirm modal overlay */
.confirm-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(11, 61, 74, 0.45);
  z-index: 1055;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.confirm-modal {
  background: #fff;
  border-radius: 10px;
  max-width: 420px;
  width: 100%;
  box-shadow: var(--shadow-md);
  padding: 1.5rem;
}

/* Loading overlay */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.65);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
}

.loading-overlay.active {
  display: flex;
}

.spinner-estorra {
  width: 48px;
  height: 48px;
  border: 3px solid var(--card-border);
  border-top-color: var(--estorra-teal);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.chart-wrap {
  position: relative;
  height: 280px;
}

/* Responsive */
@media (max-width: 991.98px) {
  .admin-sidebar {
    transform: translateX(-100%);
  }

  .admin-sidebar.open {
    transform: translateX(0);
  }

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

  .sidebar-toggle {
    display: inline-flex;
  }

  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1035;
  }

  .sidebar-backdrop.show {
    display: block;
  }
}

@media (max-width: 575.98px) {
  .admin-content {
    padding: 1rem;
  }

  .stat-card .stat-value {
    font-size: 1.4rem;
  }
}
