/* =========================================================
   WebSupportHQ Mail System — Design System v2
   Same class names as before, restyled for a polished,
   modern "full product" look. No markup changes required.
   ========================================================= */

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

:root {
  --brand: #4f46e5;
  --brand-dark: #4338ca;
  --brand-light: #eef2ff;
  --ink: #0f172a;
  --ink-soft: #475569;
  --muted: #64748b;
  --border: #e2e8f0;
  --surface: #ffffff;
  --bg: #f4f6fb;
  --success: #16a34a;
  --success-bg: #dcfce7;
  --warn: #d97706;
  --warn-bg: #fef3c7;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --info: #2563eb;
  --info-bg: #dbeafe;
  --purple: #6d28d9;
  --purple-bg: #ede9fe;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(15,23,42,.04), 0 4px 14px rgba(15,23,42,.06);
  --shadow-hover: 0 6px 20px rgba(15,23,42,.10);
}

* { box-sizing: border-box; }

body {
  font-family: 'Inter', -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  background: var(--bg);
  margin: 0;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

/* ---------- Top navigation ---------- */
.topbar {
  background: linear-gradient(180deg, #111827 0%, #0b1120 100%);
  color: #fff;
  display: flex;
  align-items: center;
  padding: 12px 26px;
  flex-wrap: wrap;
  gap: 14px;
  box-shadow: 0 2px 10px rgba(0,0,0,.18);
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar .brand {
  font-weight: 800;
  font-size: 16.5px;
  margin-right: 20px;
  letter-spacing: .1px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.topbar .brand::before {
  content: "✦";
  color: #818cf8;
  font-size: 16px;
}
.topbar .nav { flex: 1; display: flex; gap: 4px; flex-wrap: wrap; }
.topbar .nav a {
  color: #cbd5e1;
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  padding: 7px 12px;
  border-radius: 7px;
  transition: background .15s ease, color .15s ease;
}
.topbar .nav a.active { color: #fff; background: rgba(99,102,241,.22); }
.topbar .nav a:hover { color: #fff; background: rgba(255,255,255,.08); }
.topbar .user { font-size: 13px; color: #94a3b8; white-space: nowrap; }
.topbar .user a { color: #a5b4fc; text-decoration: none; }
.topbar .user a:hover { text-decoration: underline; }

.container { max-width: 1500px; margin: 28px auto; padding: 0 24px; width: 95%; }

h1 { font-size: 23px; margin-bottom: 12px; font-weight: 800; letter-spacing: -.2px; }
h2 { font-size: 17px; margin-top: 30px; font-weight: 700; color: var(--ink); }
h3 { font-size: 15px; font-weight: 700; }
.muted { color: var(--muted); font-size: 14px; }
.muted.small { font-size: 12px; }

/* ---------- Stat cards ---------- */
.cards { display: flex; gap: 14px; flex-wrap: wrap; margin: 16px 0; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 22px;
  box-shadow: var(--shadow);
  min-width: 130px;
  transition: box-shadow .15s ease, transform .15s ease;
}
.card:hover { box-shadow: var(--shadow-hover); transform: translateY(-1px); }
.card-num { font-size: 27px; font-weight: 800; color: var(--brand); letter-spacing: -.5px; }
.card-label { font-size: 12.5px; color: var(--muted); font-weight: 500; margin-top: 2px; }

/* ---------- Module quick-access grid (dashboard) ---------- */
.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  margin: 18px 0 8px;
}
.module-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  text-decoration: none;
  color: var(--ink);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: box-shadow .15s ease, transform .15s ease, border-color .15s ease;
  position: relative;
  overflow: hidden;
}
.module-card::before {
  content: "";
  position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--module-color, var(--brand));
}
.module-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); border-color: var(--module-color, var(--brand)); }
.module-card .module-icon { font-size: 22px; line-height: 1; }
.module-card .module-title { font-weight: 700; font-size: 15px; }
.module-card .module-desc { font-size: 12.5px; color: var(--muted); line-height: 1.4; }
.module-card .module-badge {
  position: absolute; top: 14px; right: 16px;
  background: var(--danger); color: #fff; font-size: 11px; font-weight: 700;
  border-radius: 10px; padding: 1px 7px;
}

/* ---------- Buttons ---------- */
.btn {
  background: var(--brand); color: #fff; border: none; padding: 9px 18px;
  border-radius: var(--radius-sm); cursor: pointer; font-size: 13.5px; font-weight: 600;
  margin-bottom: 14px; transition: background .15s ease, box-shadow .15s ease, transform .05s ease;
  box-shadow: 0 1px 2px rgba(79,70,229,.25); display: inline-block; text-align: center;
}
.btn:hover { background: var(--brand-dark); }
.btn:active { transform: translateY(1px); }
.btn-secondary { background: #64748b; box-shadow: none; }
.btn-secondary:hover { background: #475569; }
.btn-small { padding: 5px 11px; font-size: 12.5px; margin: 3px 3px; border-radius: 6px; }
.btn-danger { background: var(--danger); box-shadow: none; }
.btn-danger:hover { background: #b91c1c; }

/* ---------- Tables ---------- */
.data-table {
  width: 100%; border-collapse: collapse; background: var(--surface);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.data-table th, .data-table td {
  text-align: left; padding: 11px 14px; border-bottom: 1px solid #f1f5f9; font-size: 13.5px;
}
.data-table th { background: #f8fafc; font-weight: 700; color: #334155; font-size: 12px; text-transform: uppercase; letter-spacing: .3px; }
.data-table tbody tr:hover { background: #fafbff; }
.table-scroll { max-height: 480px; overflow-y: auto; }

/* ---------- Badges ---------- */
.badge { padding: 3px 11px; border-radius: 20px; font-size: 11.5px; font-weight: 600; white-space: nowrap; letter-spacing: .1px; }
.badge-active { background: var(--success-bg); color: var(--success); }
.badge-error { background: var(--danger-bg); color: var(--danger); }
.badge-failed { background: var(--danger-bg); color: var(--danger); }
.badge-none { background: #f1f5f9; color: var(--muted); }
.badge-pending { background: var(--warn-bg); color: var(--warn); }
.badge-sent { background: var(--info-bg); color: var(--info); }
.badge-followup { background: var(--purple-bg); color: var(--purple); }

.contact-name-link { color: var(--brand); text-decoration: none; font-weight: 600; }
.contact-name-link:hover { text-decoration: underline; }

/* ---------- Login ---------- */
.login-body { display: flex; align-items: center; justify-content: center; height: 100vh; background: radial-gradient(circle at top, #1e293b, #0b1120); font-family: 'Inter', sans-serif; }
.login-box { background: #fff; padding: 36px; border-radius: 16px; width: 340px; box-shadow: 0 20px 50px rgba(0,0,0,.35); }
.login-box h2 { margin-top: 0; text-align: center; font-weight: 800; }

label { display: block; margin: 12px 0 4px; font-size: 12.5px; font-weight: 600; color: #334155; }
input[type=text], input[type=password], input[type=email], input[type=number], input[type=date], input[type=file], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13.5px;
  font-family: inherit; transition: border-color .15s ease, box-shadow .15s ease; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79,70,229,.12); }
textarea { font-family: inherit; resize: vertical; }

.form-box { background: var(--surface); padding: 22px; border-radius: var(--radius); max-width: 500px; box-shadow: var(--shadow); border: 1px solid var(--border); }

.upload-box { background: var(--surface); padding: 20px 22px; border-radius: var(--radius); margin-bottom: 20px; box-shadow: var(--shadow); border: 1px solid var(--border); }

.filter-box { background: var(--surface); padding: 16px 20px; border-radius: var(--radius); margin-bottom: 16px; box-shadow: var(--shadow); border: 1px solid var(--border); }
.filter-row { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; }
.filter-row > div { display: flex; flex-direction: column; min-width: 140px; }
.filter-row label { margin: 0 0 4px; }
.filter-actions { display: flex; flex-direction: row; gap: 8px; }
.filter-actions .btn { margin: 0; }
#uploadForm { display: flex; gap: 10px; align-items: center; margin-top: 10px; }
#uploadForm .btn { margin: 0; }

.alert { padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13px; margin: 10px 0; font-weight: 500; border: 1px solid transparent; }
.alert-error { background: var(--danger-bg); color: #991b1b; border-color: #fecaca; }
.alert-success { background: var(--success-bg); color: #15803d; border-color: #bbf7d0; }

.info-box { background: var(--brand-light); border: 1px solid #c7d2fe; padding: 14px 16px; border-radius: var(--radius-sm); font-size: 13px; margin-top: 20px; color: #3730a3; }

.modal-overlay {
  position: fixed; top:0; left:0; right:0; bottom:0; background: rgba(15,23,42,.55);
  display: flex; align-items: center; justify-content: center; z-index: 999; padding: 20px; backdrop-filter: blur(2px);
}
.modal { background: #fff; border-radius: 14px; padding: 26px; width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; box-shadow: 0 25px 60px rgba(0,0,0,.3); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

.contact-picker { max-height: 220px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px; margin-top: 8px; }
.contact-picker label { display: flex; align-items: center; gap: 6px; font-weight: 400; margin: 4px 0; }
.contact-picker input[type=checkbox] { width: auto; }

.progress-bar { background: #e5e7eb; border-radius: 20px; height: 8px; width: 120px; overflow: hidden; }
.progress-fill { background: var(--success); height: 100%; transition: width .4s ease; }

.filter-row { margin: 16px 0; }
.filter-row select { width: auto; display: inline-block; padding: 6px 10px; }

.clickable-row { cursor: pointer; }
.clickable-row:hover { background: #f8fafc; }

.history-item { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; margin-bottom: 10px; background: #fff; }
.history-item .campaign-name { font-weight: 700; margin-bottom: 6px; }
.history-item .row-line { font-size: 13px; margin: 4px 0; color: var(--ink-soft); }

::selection { background: rgba(79,70,229,.2); }

@media (max-width: 720px) {
  .topbar { padding: 10px 14px; }
  .topbar .nav a { padding: 6px 8px; font-size: 12.5px; }
  .container { padding: 0 12px; }
}
