/* MailBlast — app.css */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #0a0a0f;
  --bg2:      #111118;
  --bg3:      #1a1a24;
  --bg4:      #222230;
  --border:   #2a2a3a;
  --border2:  #3a3a52;
  --accent:   #6366f1;
  --accent2:  #818cf8;
  --accent-d: rgba(99,102,241,.15);
  --green:    #10b981;
  --red:      #ef4444;
  --yellow:   #f59e0b;
  --pink:     #f472b6;
  --text:     #e8e8f0;
  --text2:    #9090a8;
  --text3:    #55556a;
  --radius:   10px;
  --shadow:   0 4px 24px rgba(0,0,0,.5);
  --font:     'DM Sans', sans-serif;
  --mono:     'Space Mono', monospace;
}

html, body { min-height: 100vh; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 15px; }

/* ── Layout ─────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px; background: var(--bg2); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: fixed; top: 0; left: 0; height: 100vh;
  z-index: 100; transition: transform .25s;
}

.main { margin-left: 240px; flex: 1; min-height: 100vh; }

.page { padding: 32px; max-width: 1200px; }

/* ── Sidebar ─────────────────────────────────── */
.sidebar-logo {
  display: flex; align-items: center; gap: 12px;
  padding: 22px 20px; border-bottom: 1px solid var(--border);
}
.logo-icon {
  width: 36px; height: 36px; background: var(--accent); border-radius: 9px;
  display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0;
}
.logo-name  { font-size: 16px; font-weight: 700; letter-spacing: -.3px; }
.logo-sub   { font-size: 11px; color: var(--text3); }

.sidebar-nav { padding: 12px 10px; flex: 1; overflow-y: auto; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px; margin-bottom: 2px;
  text-decoration: none; font-size: 14px; font-weight: 500;
  color: var(--text2); transition: all .15s;
}
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active { background: var(--accent-d); color: var(--accent2); }

.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 14px; border-top: 1px solid var(--border);
}
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--accent-d); border: 1px solid var(--accent);
  color: var(--accent2); font-weight: 700; font-size: 14px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name  { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role  { font-size: 11px; color: var(--text3); text-transform: capitalize; }
.logout-btn { color: var(--text3); transition: color .15s; flex-shrink: 0; display: flex; }
.logout-btn:hover { color: var(--red); }
.logout-btn svg { width: 16px; height: 16px; }

/* ── Flash ───────────────────────────────────── */
.flash-message {
  position: sticky; top: 0; z-index: 200;
  padding: 12px 20px; display: flex; align-items: center; justify-content: space-between;
  font-size: 14px; transition: opacity .3s;
}
.flash-success { background: rgba(16,185,129,.12); border-bottom: 1px solid rgba(16,185,129,.3); color: #6ee7b7; }
.flash-error   { background: rgba(239,68,68,.12);  border-bottom: 1px solid rgba(239,68,68,.3);  color: #fca5a5; }
.flash-info    { background: rgba(99,102,241,.12); border-bottom: 1px solid rgba(99,102,241,.3); color: var(--accent2); }
.flash-close   { background: none; border: none; font-size: 20px; cursor: pointer; color: inherit; line-height: 1; padding: 0 4px; }

/* ── Buttons ─────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px; border-radius: 8px; border: none; cursor: pointer;
  font-family: var(--font); font-size: 14px; font-weight: 500;
  transition: all .15s; text-decoration: none; white-space: nowrap;
}
.btn svg { width: 15px; height: 15px; flex-shrink: 0; }
.btn-primary   { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent2); transform: translateY(-1px); box-shadow: 0 4px 16px rgba(99,102,241,.4); }
.btn-secondary { background: var(--bg3); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent2); }
.btn-danger    { background: rgba(239,68,68,.12); color: var(--red); border: 1px solid rgba(239,68,68,.25); }
.btn-danger:hover { background: rgba(239,68,68,.22); }
.btn-ghost     { background: transparent; color: var(--text2); }
.btn-ghost:hover { background: var(--bg3); color: var(--text); }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-lg { padding: 12px 26px; font-size: 15px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

/* ── Inputs ──────────────────────────────────── */
.input, .select, textarea.input {
  width: 100%; padding: 10px 14px; background: var(--bg3);
  border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); font-family: var(--font); font-size: 14px;
  outline: none; transition: border .15s; -webkit-appearance: none;
}
.input:focus, .select:focus, textarea.input:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-d);
}
.input::placeholder, textarea.input::placeholder { color: var(--text3); }
textarea.input { resize: vertical; min-height: 100px; }
.select { cursor: pointer; padding-right: 32px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%239090a8' d='M0 0l6 8 6-8z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
select option { background: var(--bg3); }

/* ── Cards ───────────────────────────────────── */
.card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; }
.card-sm { padding: 16px; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.card-title  { font-size: 15px; font-weight: 600; }

/* ── Tables ──────────────────────────────────── */
.table-wrap { border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; background: var(--bg2); }
thead th { padding: 10px 16px; text-align: left; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--text2); border-bottom: 1px solid var(--border); background: var(--bg3); white-space: nowrap; }
tbody td { padding: 13px 16px; border-bottom: 1px solid var(--border); font-size: 14px; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--bg3); }

/* ── Badges ──────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 500; }
.badge-draft     { background: rgba(85,85,106,.2);   color: var(--text2); }
.badge-scheduled { background: rgba(245,158,11,.12); color: var(--yellow); }
.badge-sending   { background: rgba(99,102,241,.12); color: var(--accent2); }
.badge-completed { background: rgba(16,185,129,.12); color: var(--green); }
.badge-failed    { background: rgba(239,68,68,.12);  color: var(--red); }
.badge-sub       { background: rgba(16,185,129,.12); color: var(--green); }
.badge-unsub     { background: rgba(239,68,68,.12);  color: var(--red); }

/* ── Stat Cards ──────────────────────────────── */
.stat-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 24px; }
.stat-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .6px; color: var(--text2); }
.stat-value { font-size: 34px; font-weight: 700; margin-top: 6px; line-height: 1; }
.stat-sub   { font-size: 12px; color: var(--text2); margin-top: 6px; }

/* ── Form Helpers ────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 13px; font-weight: 500; color: var(--text2); }
.form-group .hint  { font-size: 12px; color: var(--text3); }

.alert { padding: 12px 16px; border-radius: 8px; font-size: 14px; margin-bottom: 16px; }
.alert-error   { background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.3); color: #fca5a5; }
.alert-success { background: rgba(16,185,129,.1); border: 1px solid rgba(16,185,129,.3); color: #6ee7b7; }
.alert-info    { background: rgba(99,102,241,.1); border: 1px solid rgba(99,102,241,.3); color: var(--accent2); }

/* ── Grid/Flex Helpers ───────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; }
.flex   { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }  .gap-3 { gap: 12px; }  .gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; }   .mt-4 { margin-top: 16px; }  .mt-6 { margin-top: 24px; }
.mb-4 { margin-bottom: 16px; } .mb-6 { margin-bottom: 24px; }

/* ── Typography ──────────────────────────────── */
.page-title { font-size: 24px; font-weight: 700; letter-spacing: -.4px; }
.page-sub   { color: var(--text2); font-size: 14px; margin-top: 4px; }
.text-sm  { font-size: 13px; }  .text-xs { font-size: 12px; }
.text-muted  { color: var(--text2); } .text-accent { color: var(--accent2); }
.text-green  { color: var(--green); } .text-red    { color: var(--red); }
.text-yellow { color: var(--yellow); }
.mono { font-family: var(--mono); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fw-600 { font-weight: 600; }

/* ── Empty State ─────────────────────────────── */
.empty-state { text-align: center; padding: 60px 32px; color: var(--text2); }
.empty-state .icon { font-size: 48px; margin-bottom: 16px; }
.empty-state h3 { color: var(--text); font-size: 18px; margin-bottom: 8px; }
.empty-state p  { font-size: 14px; }

/* ── Modal ───────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.75);
  z-index: 1000; display: none; align-items: center; justify-content: center;
  padding: 24px; backdrop-filter: blur(4px);
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 14px; padding: 28px; width: 100%; max-width: 560px;
  max-height: 90vh; overflow-y: auto; animation: modalIn .2s ease;
}
.modal-lg { max-width: 840px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-title  { font-size: 18px; font-weight: 700; }
.modal-close  { background: none; border: none; color: var(--text2); cursor: pointer; font-size: 22px; padding: 0 4px; line-height: 1; }
.modal-close:hover { color: var(--text); }

@keyframes modalIn { from { opacity:0; transform:translateY(12px) scale(.97); } to { opacity:1; transform:none; } }

/* ── Progress bar ────────────────────────────── */
.progress-bar { background: var(--bg3); border-radius: 4px; height: 6px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 4px; transition: width .5s; }

/* ── Tabs ────────────────────────────────────── */
.tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab-btn {
  padding: 10px 20px; background: none; border: none; border-bottom: 2px solid transparent;
  margin-bottom: -1px; cursor: pointer; font-family: var(--font); font-size: 14px; font-weight: 500;
  color: var(--text2); transition: all .15s;
}
.tab-btn.active { color: var(--accent2); border-bottom-color: var(--accent); }
.tab-btn:hover  { color: var(--text); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ── Code / Pre-view ─────────────────────────── */
.html-preview { background: #fff; border-radius: 8px; overflow: hidden; }
.html-preview iframe { width: 100%; border: none; display: block; }

/* ── Checkbox ────────────────────────────────── */
input[type="checkbox"] { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }

/* ── Misc ────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner { width: 20px; height: 20px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .6s linear infinite; display: inline-block; }
@keyframes fadeIn { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:none; } }
.fade-in { animation: fadeIn .2s ease; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

/* ── Responsive ──────────────────────────────── */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: none; }
  .main { margin-left: 0; }
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .page { padding: 16px; }
}
