/* ============================================================
   Bulk Email Sender — app.css
   Dark-mode-first, clean dashboard aesthetic.
   Font: Inter (system fallback stack)
   Accent: electric indigo #6366f1 with cyan highlights
   ============================================================ */

/* ── Variables ──────────────────────────────────────────────── */
:root {
  --bg:          #0f1117;
  --surface:     #1a1d27;
  --surface-2:   #21263a;
  --border:      #2e3348;
  --text:        #e2e5f0;
  --text-muted:  #7c84a3;
  --accent:      #6366f1;
  --accent-glow: rgba(99,102,241,.25);
  --success:     #22c55e;
  --danger:      #ef4444;
  --warning:     #f59e0b;
  --info:        #38bdf8;
  --radius:      10px;
  --radius-sm:   6px;
  --shadow:      0 4px 24px rgba(0,0,0,.45);
  --font:        'Inter', system-ui, -apple-system, sans-serif;
  --mono:        'JetBrains Mono', 'Fira Code', monospace;
  --transition:  .18s ease;
}

/* Light mode override */
[data-theme="light"] {
  --bg:         #f1f3f9;
  --surface:    #ffffff;
  --surface-2:  #f7f8fc;
  --border:     #dde1f0;
  --text:       #1a1d27;
  --text-muted: #6b7280;
  --shadow:     0 4px 24px rgba(0,0,0,.10);
}

/* ── Reset / Base ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family:      var(--font);
  background-color: var(--bg);
  color:            var(--text);
  font-size:        14px;
  line-height:      1.6;
  min-height:       100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Top bar ─────────────────────────────────────────────────── */
.topbar {
  background:  var(--surface);
  border-bottom: 1px solid var(--border);
  padding:     0 24px;
  height:      56px;
  display:     flex;
  align-items: center;
  justify-content: space-between;
  position:    sticky;
  top:         0;
  z-index:     100;
  box-shadow:  0 2px 12px rgba(0,0,0,.3);
}

.topbar-brand {
  display:     flex;
  align-items: center;
  gap:         10px;
  font-weight: 700;
  font-size:   17px;
  letter-spacing: -.3px;
}

.topbar-brand .brand-icon {
  width:  30px;
  height: 30px;
  background: var(--accent);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.theme-toggle {
  background: var(--surface-2);
  border:     1px solid var(--border);
  color:      var(--text-muted);
  padding:    6px 12px;
  border-radius: var(--radius-sm);
  cursor:     pointer;
  font-size:  13px;
  transition: var(--transition);
}
.theme-toggle:hover { color: var(--text); border-color: var(--accent); }

/* ── Layout ──────────────────────────────────────────────────── */
.page-wrap {
  max-width:  1280px;
  margin:     0 auto;
  padding:    28px 20px 60px;
  display:    grid;
  grid-template-columns: 340px 1fr;
  gap:        24px;
  align-items: start;
}

@media (max-width: 900px) {
  .page-wrap { grid-template-columns: 1fr; }
}

/* ── Cards ───────────────────────────────────────────────────── */
.card {
  background:    var(--surface);
  border:        1px solid var(--border);
  border-radius: var(--radius);
  padding:       22px 24px;
  box-shadow:    var(--shadow);
}

.card + .card { margin-top: 20px; }

.card-header {
  display:       flex;
  align-items:   center;
  gap:           10px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.card-header h2 {
  font-size:   15px;
  font-weight: 600;
  letter-spacing: -.2px;
  color: var(--text);
}

.card-header .icon {
  width:  32px;
  height: 32px;
  background: var(--accent-glow);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}

/* ── Form controls ───────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }

label {
  display:     block;
  font-size:   12px;
  font-weight: 600;
  color:       var(--text-muted);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: .5px;
}

input[type="text"],
input[type="email"],
input[type="number"],
input[type="password"],
select,
textarea {
  width:         100%;
  background:    var(--surface-2);
  border:        1px solid var(--border);
  border-radius: var(--radius-sm);
  color:         var(--text);
  padding:       9px 12px;
  font-family:   var(--font);
  font-size:     14px;
  transition:    border-color var(--transition), box-shadow var(--transition);
  outline:       none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow:   0 0 0 3px var(--accent-glow);
}

textarea { resize: vertical; min-height: 130px; }

select option { background: var(--surface); }

.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

/* Checkbox row */
.check-row {
  display:     flex;
  align-items: center;
  gap:         8px;
  margin:      6px 0;
}

.check-row input[type="checkbox"] {
  width:  16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

.check-row label {
  margin: 0;
  text-transform: none;
  font-size: 13px;
  letter-spacing: 0;
  cursor: pointer;
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display:       inline-flex;
  align-items:   center;
  gap:           6px;
  padding:       9px 18px;
  border-radius: var(--radius-sm);
  border:        none;
  font-family:   var(--font);
  font-size:     13px;
  font-weight:   600;
  cursor:        pointer;
  transition:    all var(--transition);
  text-decoration: none;
  white-space:   nowrap;
}

.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary  { background: var(--accent);  color: #fff; }
.btn-primary:hover:not(:disabled)  { background: #4f46e5; box-shadow: 0 0 14px var(--accent-glow); }

.btn-success  { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled)  { background: #16a34a; }

.btn-danger   { background: var(--danger);  color: #fff; }
.btn-danger:hover:not(:disabled)   { background: #dc2626; }

.btn-warning  { background: var(--warning); color: #000; }
.btn-warning:hover:not(:disabled)  { background: #d97706; }

.btn-outline  { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover:not(:disabled)  { border-color: var(--accent); color: var(--accent); }

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

.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Progress bar ────────────────────────────────────────────── */
.progress-wrap {
  background:    var(--surface-2);
  border-radius: 100px;
  height:        10px;
  overflow:      hidden;
  border:        1px solid var(--border);
}

.progress-bar {
  height:        100%;
  background:    linear-gradient(90deg, var(--accent), var(--info));
  border-radius: 100px;
  transition:    width .3s ease;
  width:         0%;
}

.progress-stats {
  display:        flex;
  justify-content: space-between;
  font-size:      12px;
  color:          var(--text);
  margin-top:     6px;
}

/* ── Validation summary badges ───────────────────────────────── */
.val-grid {
  display:               grid;
  grid-template-columns: repeat(4, 1fr);
  gap:                   10px;
  margin-top:            14px;
}

.val-card {
  background:    var(--surface-2);
  border:        1px solid var(--border);
  border-radius: var(--radius-sm);
  padding:       10px 12px;
  text-align:    center;
}

.val-card .val-num {
  font-size:   22px;
  font-weight: 700;
  line-height: 1;
}

.val-card .val-lbl {
  font-size:  10px;
  color:      var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-top: 3px;
}

.val-card.c-total  .val-num { color: var(--text); }
.val-card.c-valid  .val-num { color: var(--success); }
.val-card.c-invalid .val-num { color: var(--danger); }
.val-card.c-dup    .val-num { color: var(--warning); }

/* ── Results table ───────────────────────────────────────────── */
.results-wrap {
  max-height:   380px;
  overflow-y:   auto;
  border:       1px solid var(--border);
  border-radius: var(--radius-sm);
}

table {
  width:           100%;
  border-collapse: collapse;
  font-size:       13px;
}

thead th {
  background:      var(--surface-2);
  padding:         9px 12px;
  text-align:      left;
  font-size:       11px;
  font-weight:     700;
  text-transform:  uppercase;
  letter-spacing:  .5px;
  color:           var(--text-muted);
  position:        sticky;
  top:             0;
}

tbody tr { border-top: 1px solid var(--border); }
tbody tr:hover { background: var(--surface-2); }
tbody td { padding: 8px 12px; color: var(--text); }

.badge {
  display:        inline-flex;
  align-items:    center;
  gap:            4px;
  padding:        2px 8px;
  border-radius:  100px;
  font-size:      11px;
  font-weight:    600;
}

.badge-sent    { background: rgba(34,197,94,.18);  color: var(--success); }
.badge-failed  { background: rgba(239,68,68,.18);  color: var(--danger);  }
.badge-pending { background: rgba(99,102,241,.18); color: var(--accent);  }
.badge-retry   { background: rgba(245,158,11,.18); color: var(--warning); }

/* ── Toast notifications ─────────────────────────────────────── */
.toast-stack {
  position:   fixed;
  bottom:     24px;
  right:      24px;
  z-index:    9999;
  display:    flex;
  flex-direction: column;
  gap:        10px;
  max-width:  360px;
}

.toast {
  background:    var(--surface);
  border:        1px solid var(--border);
  border-radius: var(--radius);
  padding:       13px 16px;
  display:       flex;
  align-items:   flex-start;
  gap:           10px;
  box-shadow:    var(--shadow);
  animation:     toast-in .22s ease;
  font-size:     13px;
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger);  }
.toast.info    { border-left: 3px solid var(--accent);  }
.toast.warning { border-left: 3px solid var(--warning); }

.toast-icon { font-size: 16px; flex-shrink: 0; line-height: 1.3; }
.toast-msg  { flex: 1; }
.toast-close { cursor: pointer; color: var(--text-muted); font-size: 16px; line-height: 1; }
.toast-close:hover { color: var(--text); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Attachments ─────────────────────────────────────────────── */
.attach-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }

.attach-item {
  display:       flex;
  align-items:   center;
  gap:           10px;
  background:    var(--surface-2);
  border:        1px solid var(--border);
  border-radius: var(--radius-sm);
  padding:       8px 12px;
  font-size:     13px;
}

.attach-item .attach-name { flex: 1; font-weight: 500; }
.attach-item .attach-size { color: var(--text-muted); font-size: 12px; }

/* Upload drop zone */
.dropzone {
  border:        2px dashed var(--border);
  border-radius: var(--radius);
  padding:       24px;
  text-align:    center;
  color:         var(--text-muted);
  cursor:        pointer;
  transition:    var(--transition);
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--accent);
  background:   var(--accent-glow);
  color:        var(--text);
}

/* ── Summary panel ───────────────────────────────────────────── */
.summary-grid {
  display:               grid;
  grid-template-columns: repeat(3, 1fr);
  gap:                   12px;
  margin-bottom:         18px;
}

.sum-item {
  background:    var(--surface-2);
  border:        1px solid var(--border);
  border-radius: var(--radius-sm);
  padding:       14px;
  text-align:    center;
}

.sum-item .sum-num {
  font-size:   28px;
  font-weight: 800;
  line-height: 1;
  color: var(--text);
}

.sum-item .sum-lbl {
  font-size:   11px;
  color:       var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-top:  4px;
}

/* ── Scrollbar ───────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Misc ────────────────────────────────────────────────────── */
.text-muted   { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-warning { color: var(--warning); }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 14px; }
.mt-4 { margin-top: 20px; }
.mb-2 { margin-bottom: 8px; }
.d-none { display: none !important; }
.w-100  { width: 100%; }
hr.divider { border: none; border-top: 1px solid var(--border); margin: 18px 0; }
small { font-size: 11px; color: var(--text); }

/* ── Spinner ─────────────────────────────────────────────────── */
.spinner {
  display:          inline-block;
  width:            14px;
  height:           14px;
  border:           2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius:    50%;
  animation:        spin .6s linear infinite;
}

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

/* ── Quill editor dark-mode overrides ────────────────────────── */
.ql-toolbar {
  background:    var(--surface-2) !important;
  border-color:  var(--border) !important;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.ql-container {
  background:    var(--surface-2) !important;
  border-color:  var(--border) !important;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  font-family:   var(--font) !important;
  font-size:     14px !important;
  color:         var(--text) !important;
  min-height:    220px;
}

.ql-editor { min-height: 220px; color: var(--text) !important; }
.ql-editor.ql-blank::before { color: var(--text-muted) !important; font-style: normal !important; }

.ql-toolbar .ql-stroke { stroke: var(--text-muted) !important; }
.ql-toolbar .ql-fill   { fill:   var(--text-muted) !important; }
.ql-toolbar button:hover .ql-stroke,
.ql-toolbar button.ql-active .ql-stroke { stroke: var(--accent) !important; }
.ql-toolbar button:hover .ql-fill,
.ql-toolbar button.ql-active .ql-fill   { fill:   var(--accent) !important; }

.ql-picker-label { color: var(--text-muted) !important; }
.ql-picker-options {
  background: var(--surface) !important;
  border-color: var(--border) !important;
  color: var(--text) !important;
}

[data-theme="light"] .ql-toolbar { background: #f7f8fc !important; }
[data-theme="light"] .ql-container { background: #fff !important; color: #1a1d27 !important; }
[data-theme="light"] .ql-editor { color: #1a1d27 !important; }
[data-theme="light"] .ql-toolbar .ql-stroke { stroke: #6b7280 !important; }
[data-theme="light"] .ql-toolbar .ql-fill   { fill:   #6b7280 !important; }

/* ── Recipient source toggle ─────────────────────────────────── */
.source-toggle {
  display:       grid;
  grid-template-columns: 1fr 1fr;
  gap:           8px;
  margin-bottom: 4px;
}

.source-opt {
  display:       flex;
  align-items:   center;
  gap:           8px;
  padding:       10px 14px;
  border:        1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor:        pointer;
  font-size:     13px;
  font-weight:   500;
  color:         var(--text-muted);
  transition:    var(--transition);
  text-transform: none;
  letter-spacing: 0;
  margin:        0;
}

.source-opt input[type="radio"] { display: none; }

.source-opt:hover { border-color: var(--accent); color: var(--text); }

.source-opt.active {
  border-color: var(--accent);
  background:   var(--accent-glow);
  color:        var(--text);
}

/* ── Excel drop zone ─────────────────────────────────────────── */
.excel-dropzone {
  border:        2px dashed var(--border);
  border-radius: var(--radius);
  padding:       28px 20px;
  text-align:    center;
  color:         var(--text-muted);
  cursor:        pointer;
  transition:    var(--transition);
  font-size:     14px;
}

.excel-dropzone:hover,
.excel-dropzone.dragover {
  border-color: var(--accent);
  background:   var(--accent-glow);
  color:        var(--text);
}

/* ── Excel preview table badge ───────────────────────────────── */
.badge-ok  { background: rgba(34,197,94,.15); color: var(--success); }
.badge-bad { background: rgba(239,68,68,.15); color: var(--danger);  }

/* ── Editor mode toggle buttons ──────────────────────────────── */
.editor-mode-btns {
  display:  flex;
  gap:      4px;
}

.mode-btn {
  background:    var(--surface-2);
  border:        1px solid var(--border);
  border-radius: var(--radius-sm);
  color:         var(--text-muted);
  padding:       4px 10px;
  font-size:     12px;
  font-weight:   600;
  cursor:        pointer;
  font-family:   var(--font);
  transition:    var(--transition);
  text-transform: none;
  letter-spacing: 0;
}

.mode-btn:hover  { border-color: var(--accent); color: var(--text); }
.mode-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Quill min height */
#quill-editor { min-height: 260px; }

/* HTML textarea monospace */
#email_body_html {
  font-family: var(--mono);
  font-size:   13px;
  line-height: 1.6;
  min-height:  280px;
}

/* ── Dark mode visibility fixes ─────────────────────────────── */
/* Ensure all card header text, table data, and hints are always visible */
.card-header h2,
thead th,
tbody td,
.progress-stats span,
.val-card .val-lbl,
.sum-item .sum-lbl,
.attach-item .attach-name,
.attach-item .attach-size,
.source-opt,
.excel-dropzone,
label {
  color: var(--text);
}

/* Muted stays slightly dimmed but still readable */
.text-muted,
small,
.val-card .val-lbl,
.sum-item .sum-lbl,
thead th {
  color: var(--text-muted);
  opacity: 1;
}

/* Results table time column */
tbody td { color: var(--text) !important; }

/* Summary total & duration numbers */
#sum-total, #sum-duration { color: var(--text) !important; }

/* ── Batch password modal ────────────────────────────────────── */
.modal-overlay {
  position:        fixed;
  inset:           0;
  background:      rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  z-index:         9999;
  display:         flex;
  align-items:     center;
  justify-content: center;
  animation:       fadeIn .18s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-box {
  background:    var(--surface);
  border:        1px solid var(--border);
  border-radius: var(--radius);
  padding:       32px;
  width:         100%;
  max-width:     400px;
  box-shadow:    0 20px 60px rgba(0, 0, 0, 0.5);
  animation:     slideUp .2s ease;
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.modal-header {
  display:       flex;
  align-items:   center;
  gap:           12px;
  margin-bottom: 10px;
}

.modal-header h3 {
  margin:      0;
  font-size:   18px;
  font-weight: 700;
  color:       var(--text);
}

.modal-desc {
  font-size:     14px;
  color:         var(--text-muted);
  margin:        0 0 20px 0;
  line-height:   1.6;
}

.modal-error {
  background:    rgba(239, 68, 68, .12);
  border:        1px solid var(--danger);
  border-radius: var(--radius-sm);
  color:         var(--danger);
  padding:       9px 12px;
  font-size:     13px;
  margin-bottom: 14px;
}

.modal-footer {
  display:         flex;
  justify-content: flex-end;
  gap:             10px;
  margin-top:      20px;
}
