/* ── DESIGN SYSTEM & VARIABLE TOKENS ────────────────────────────────────────── */
:root {
  /* HSL Tailored Color Palette - Emerald Green & Honey Gold Theme */
  --primary-h: 152;
  --primary-s: 69%;
  --primary-l: 19%; /* Rich Forest Green */
  
  --primary: hsl(var(--primary-h), var(--primary-s), var(--primary-l));
  --primary-light: hsl(var(--primary-h), var(--primary-s), calc(var(--primary-l) + 15%));
  --primary-soft: hsl(var(--primary-h), 40%, 94%);
  
  --accent-h: 43;
  --accent-s: 96%;
  --accent-l: 52%; /* Honey Amber Gold */
  --accent: hsl(var(--accent-h), var(--accent-s), var(--accent-l));
  --accent-light: hsl(var(--accent-h), var(--accent-s), calc(var(--accent-l) + 10%));
  
  --bg-main: #f8fafc;
  --bg-sidebar: #0b2218; /* Dark forest sidebar */
  --card-bg: #ffffff;
  --border-color: #e2e8f0;
  
  --text-main: #1e293b;
  --text-muted: #64748b;
  --text-light: #f8fafc;
  
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #3b82f6;
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -1px rgba(0,0,0,0.02);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.02);
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── RESET & BASE STYLES ────────────────────────────────────────────────────── */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  font-size: 14px;
  line-height: 1.5;
  height: 100vh;
  overflow: hidden;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  color: hsl(var(--primary-h), var(--primary-s), 10%);
}

/* Scrollbars styling */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* ── LAYOUT STRUCTURE ───────────────────────────────────────────────────────── */
.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* Sidebar Styling */
.sidebar {
  width: 260px;
  background-color: var(--bg-sidebar);
  color: var(--text-light);
  display: flex;
  flex-direction: column;
  height: 100%;
  flex-shrink: 0;
  border-right: 1px solid rgba(255,255,255,0.05);
}

.sidebar-brand {
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.brand-icon {
  background-color: var(--accent);
  color: var(--bg-sidebar);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-text h1 {
  font-size: 20px;
  font-weight: 800;
  color: #ffffff;
  line-height: 1.1;
}

.brand-text span {
  font-size: 11px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
}

.sidebar-menu {
  flex: 1;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: transparent;
  border: none;
  color: #94a3b8;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  cursor: pointer;
  text-align: left;
  font-size: 13.5px;
  font-weight: 500;
  transition: var(--transition);
}

.menu-item svg {
  flex-shrink: 0;
}

.menu-item:hover {
  background-color: rgba(255, 255, 255, 0.05);
  color: #ffffff;
}

.menu-item.active {
  background-color: var(--accent);
  color: var(--bg-sidebar);
  font-weight: 600;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.05);
  background-color: rgba(0, 0, 0, 0.15);
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 10px;
}

.profile-avatar {
  background: var(--accent);
  color: var(--bg-sidebar);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
}

.profile-info {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-weight: 600;
  font-size: 12.5px;
  color: #ffffff;
}

.user-role {
  font-size: 10px;
  color: #64748b;
}

/* Main Content Area */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100%;
}

.content-header {
  padding: 24px 32px;
  background-color: #ffffff;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-title h2 {
  font-size: 22px;
  font-weight: 700;
}

.header-title p {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 2px;
}

.header-status {
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: var(--primary-soft);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.status-indicator.online {
  background-color: var(--success);
  box-shadow: 0 0 8px var(--success);
}

/* ── TAB PAGE MANAGER ───────────────────────────────────────────────────────── */
.tab-page {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: 32px;
  height: 100%;
}

.tab-page.active {
  display: block;
}

/* ── DASHBOARD COMPONENT ────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 24px;
  margin-bottom: 32px;
}

.card {
  background-color: var(--card-bg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: var(--transition);
}

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

.card-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-header h2 {
  font-size: 16px;
  font-weight: 600;
}

.card-body {
  padding: 24px;
}

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

.stat-card .card-body {
  display: flex;
  align-items: center;
  gap: 20px;
}

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon.subscribers {
  background-color: #ecfdf5;
  color: var(--success);
}

.stat-icon.campaigns {
  background-color: #eff6ff;
  color: var(--info);
}

.stat-icon.delivered {
  background-color: #fef3c7;
  color: var(--warning);
}

.stat-info h3 {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

.stat-value {
  font-family: 'Outfit', sans-serif;
  font-size: 28px;
  font-weight: 700;
  color: hsl(var(--primary-h), var(--primary-s), 10%);
  line-height: 1.2;
  margin: 2px 0;
}

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

/* Layout section grid */
.section-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 24px;
  align-items: start;
}

.layout-main {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.layout-side {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.hero-gradient {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #ffffff;
}

.hero-gradient h2 {
  color: #ffffff;
  font-size: 20px;
  margin-bottom: 8px;
}

.hero-gradient p {
  color: #cbd5e1;
  font-size: 13px;
  margin-bottom: 20px;
  line-height: 1.5;
}

.status-summary-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.summary-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  padding-bottom: 12px;
  border-bottom: 1px dashed var(--border-color);
}

.summary-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.summary-item .label {
  color: var(--text-muted);
}

.summary-item .value {
  font-weight: 600;
}

.badge {
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}

.badge.active, .badge.success {
  background-color: #d1fae5;
  color: #065f46;
}

.badge.inactive, .badge.danger {
  background-color: #fee2e2;
  color: #991b1b;
}

.badge.warning {
  background-color: #fef3c7;
  color: #92400e;
}

/* ── COMPOSER SCREEN ────────────────────────────────────────────────────────── */
.composer-layout {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 24px;
  height: calc(100vh - 160px);
  overflow: hidden;
}

.composer-form {
  overflow-y: auto;
  padding-right: 4px;
}

.composer-preview {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.preview-header-tabs {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background-color: #f1f5f9;
  border: 1px solid var(--border-color);
  border-bottom: none;
  border-top-left-radius: var(--radius-md);
  border-top-right-radius: var(--radius-md);
}

.preview-label {
  font-weight: 600;
  font-size: 12.5px;
  color: var(--text-muted);
}

.viewport-buttons {
  display: flex;
  background-color: #e2e8f0;
  padding: 2px;
  border-radius: 6px;
}

.viewport-btn {
  border: none;
  background: transparent;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 4px;
  transition: var(--transition);
}

.viewport-btn.active {
  background-color: #ffffff;
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
}

.preview-iframe-wrapper {
  flex: 1;
  background-color: #e2e8f0;
  border: 1px solid var(--border-color);
  border-bottom-left-radius: var(--radius-md);
  border-bottom-right-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow: hidden;
  transition: var(--transition);
}

.preview-iframe-wrapper iframe {
  width: 100%;
  height: 100%;
  border: none;
  background-color: #ffffff;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  transition: var(--transition);
}

/* Mobile responsive preview dimensions inside wrapper */
.preview-iframe-wrapper.mobile iframe {
  width: 375px;
  height: 667px;
  border: 12px solid #1e293b;
  border-radius: 24px;
}

.subscribers-count-display {
  background-color: var(--primary-soft);
  color: var(--primary);
  border: 1px solid hsl(var(--primary-h), var(--primary-s), 80%);
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 14px;
  text-align: center;
}

/* ── FORMS & CONTROLS ───────────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 18px;
}

.form-group-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 18px;
}

.form-group-row .form-group {
  margin-bottom: 0;
}

label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-main);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 13.5px;
  color: var(--text-main);
  background-color: #ffffff;
  outline: none;
  transition: var(--transition);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px hsl(var(--accent-h), var(--accent-s), 90%);
}

textarea {
  resize: vertical;
}

.help-text {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

.tips-input, .modal-tips-input {
  margin-bottom: 8px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
}

.checkbox-label input {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  font-family: 'Outfit', sans-serif;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
}

.btn-primary {
  background-color: var(--primary);
  color: #ffffff;
}

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

.btn-secondary {
  background-color: #e2e8f0;
  color: var(--text-main);
}

.btn-secondary:hover {
  background-color: #cbd5e1;
}

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

.btn-danger:hover {
  background-color: #dc2626;
}

.btn-light {
  background-color: #ffffff;
  color: var(--primary);
}

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

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.btn-block {
  display: flex;
  width: 100%;
}

.actions-bar {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

/* ── TABLES ─────────────────────────────────────────────────────────────────── */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13.5px;
}

.data-table th {
  background-color: #f1f5f9;
  padding: 14px 20px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
}

.data-table td {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
}

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

.data-table tr:last-child td {
  border-bottom: none;
}

.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.py-4 { padding-top: 24px; padding-bottom: 24px; }
.mt-4 { margin-top: 24px; }
.mb-4 { margin-bottom: 24px; }
.p-0 { padding: 0 !important; }

/* ── TEMPLATES GRID ─────────────────────────────────────────────────────────── */
.library-header-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
}

.template-card {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  background-color: #ffffff;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

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

.template-card-category {
  align-self: flex-start;
  background-color: var(--primary-soft);
  color: var(--primary);
  font-size: 10.5px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.template-card h3 {
  font-size: 15px;
  line-height: 1.3;
}

.template-card p {
  color: var(--text-muted);
  font-size: 12.5px;
  line-height: 1.4;
  flex: 1;
}

.template-card-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  border-top: 1px solid var(--border-color);
  padding-top: 12px;
}

/* ── MODALS ─────────────────────────────────────────────────────────────────── */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(15, 34, 24, 0.4); /* Forest overlay */
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal.active {
  display: flex;
}

.modal-content {
  background-color: #ffffff;
  border-radius: var(--radius-lg);
  width: 600px;
  max-width: 90%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 18px;
}

.close-btn {
  background: transparent;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-muted);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* ── NOTIFICATION TOAST ──────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: -100px;
  right: 32px;
  background-color: #1e293b;
  color: #ffffff;
  padding: 16px 24px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 1100;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  opacity: 0;
  max-width: 360px;
}

.toast.show {
  bottom: 32px;
  opacity: 1;
}

.toast-content {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

#toast-icon {
  background-color: var(--accent);
  color: var(--bg-sidebar);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  flex-shrink: 0;
  font-size: 14px;
}

.toast-text h4 {
  color: #ffffff;
  font-size: 13.5px;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
}

.toast-text p {
  color: #94a3b8;
  font-size: 12px;
  margin-top: 2px;
}

/* ── SUBSCRIBERS CUSTOM FILTERS ─────────────────────────────────────────────── */
.header-search-filter {
  display: flex;
  gap: 12px;
  flex: 1;
  max-width: 500px;
}

.header-search-filter input {
  flex: 2;
}

.header-search-filter select {
  flex: 1;
}

.action-icon-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  transition: var(--transition);
  padding: 4px;
  border-radius: 4px;
}

.action-icon-btn:hover {
  background-color: #f1f5f9;
  color: var(--danger);
}
