/* MailCraft AI — App Dashboard Styles */

/* ── Page system ─────────────────────────────────────── */
.page { display: none; }
.page.active { display: block; }

/* ── Top Nav ─────────────────────────────────────────── */
.app-nav {
  position: fixed; top: 0; left: 0; right: 0; height: var(--nav-h); z-index: 200;
  background: rgba(247,245,240,0.96);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 24px 0 0;
}
.nav-sidebar-space {
  width: var(--sidebar-w); flex-shrink: 0;
  display: flex; align-items: center;
  padding: 0 20px;
  border-right: 1px solid var(--border);
  height: 100%;
}
.nav-logo {
  font-family: 'Fraunces', serif; font-size: 1.2rem; font-weight: 700;
  color: var(--ink); display: flex; align-items: center; gap: 8px;
  text-decoration: none; cursor: default;
}
.nav-logo-dot {
  width: 7px; height: 7px; background: var(--green); border-radius: 50%;
}
.nav-center { flex: 1; display: flex; align-items: center; padding: 0 20px; }
.nav-tabs { display: flex; gap: 2px; }
.nav-tab {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 8px; border: none;
  background: none; color: var(--ink2);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.855rem; font-weight: 500;
  cursor: pointer; transition: all .15s;
}
.nav-tab:hover { background: var(--bg3); color: var(--ink); }
.nav-tab.active {
  background: var(--green-muted);
  color: var(--green); font-weight: 600;
}
.nav-tab .tab-ic { font-size: 0.9rem; }
.nav-right {
  margin-left: auto; display: flex; align-items: center; gap: 10px;
}
.user-pill {
  display: flex; align-items: center; gap: 9px;
  padding: 5px 12px 5px 5px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 40px; cursor: pointer;
  transition: all .15s;
}
.user-pill:hover { border-color: var(--border2); box-shadow: var(--shadow-xs); }
.user-ava {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, var(--green), var(--green3));
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.72rem; color: #fff;
  font-family: 'Fraunces', serif;
}
.user-name { font-size: 0.83rem; font-weight: 500; color: var(--ink); }

/* ── Shell & Sidebar ─────────────────────────────────── */
.app-shell { display: flex; min-height: 100vh; padding-top: var(--nav-h); }

.sidebar {
  position: fixed; top: var(--nav-h); left: 0; bottom: 0;
  width: var(--sidebar-w); overflow-y: auto;
  background: var(--surface2);
  border-right: 1px solid var(--border);
  padding: 16px 10px;
  z-index: 100;
}
.sb-section { margin-bottom: 24px; }
.sb-label {
  font-size: 0.68rem; font-weight: 700; color: var(--ink4);
  text-transform: uppercase; letter-spacing: .1em;
  padding: 0 10px; margin-bottom: 4px;
}
.sb-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--r);
  border: none; background: none;
  color: var(--ink2); font-size: 0.86rem; font-weight: 500;
  cursor: pointer; transition: all .14s;
  width: 100%; text-align: left; position: relative;
  font-family: 'Plus Jakarta Sans', sans-serif;
}
.sb-item:hover { background: var(--bg2); color: var(--ink); }
.sb-item.active {
  background: var(--green-muted);
  color: var(--green); font-weight: 600;
}
.sb-item.active::before {
  content: ''; position: absolute; left: 0; top: 25%; bottom: 25%;
  width: 3px; border-radius: 0 2px 2px 0;
  background: var(--green);
}
.sb-ic { width: 18px; text-align: center; font-size: 0.9rem; flex-shrink: 0; }
.sb-badge {
  margin-left: auto; background: var(--green);
  color: #fff; font-size: 0.65rem; font-weight: 700;
  padding: 1px 6px; border-radius: 10px;
}
.sb-div { height: 1px; background: var(--border); margin: 8px 10px 12px; }

/* ── Main content ────────────────────────────────────── */
.main-area { flex: 1; margin-left: var(--sidebar-w); padding: 32px 36px; min-height: calc(100vh - var(--nav-h)); }

/* ── View system ─────────────────────────────────────── */
.view { display: none; }
.view.active { display: block; animation: fadeUp .35s ease both; }

/* ── Page header ─────────────────────────────────────── */
.page-header { margin-bottom: 28px; }
.page-title  { font-size: 1.55rem; font-weight: 700; margin-bottom: 4px; }
.page-sub    { color: var(--ink2); font-size: 0.9rem; }

/* ── Compose Layout ──────────────────────────────────── */
.compose-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px; align-items: start;
}
.compose-left { display: flex; flex-direction: column; gap: 20px; }
.compose-right { position: sticky; top: calc(var(--nav-h) + 24px); }

/* ── Use-case tabs ───────────────────────────────────── */
.uc-tabs {
  display: flex; gap: 4px;
  background: var(--bg2); border-radius: 10px;
  padding: 3px; margin-bottom: 22px;
}
.uc-tab {
  flex: 1; padding: 8px 10px; border-radius: 8px; border: none;
  background: none; color: var(--ink2);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.82rem; font-weight: 500; cursor: pointer;
  transition: all .15s; text-align: center;
}
.uc-tab.active {
  background: var(--surface); color: var(--ink); font-weight: 600;
  box-shadow: var(--shadow-xs);
}
.uc-tab:hover:not(.active) { color: var(--ink); }
.uc-pane { display: none; }
.uc-pane.active { display: block; animation: fadeIn .25s ease; }

/* ── Recipient row ───────────────────────────────────── */
.rec-row { display: flex; gap: 10px; }
.rec-row .input { flex: 1; }
.find-btn-wrap { flex-shrink: 0; }

/* ── Person resolved card ────────────────────────────── */
.person-card {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: var(--r);
  background: #f0f9f4; border: 1px solid rgba(45,106,79,0.2);
  margin-bottom: 14px; animation: slideRight .3s ease;
}
.person-ava {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, var(--green), var(--green3));
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.88rem; color: #fff; flex-shrink: 0;
  font-family: 'Fraunces', serif;
}
.person-info { flex: 1; min-width: 0; }
.person-name  { font-size: 0.9rem; font-weight: 700; color: var(--ink); }
.person-role  { font-size: 0.78rem; color: var(--ink2); }

/* ── Found emails box ────────────────────────────────── */
.found-box {
  padding: 14px 16px; border-radius: var(--r);
  background: #f0f9f4; border: 1px solid rgba(45,106,79,0.18);
  margin-bottom: 16px; animation: fadeDown .3s ease;
}
.found-box.warn { background: var(--amber-bg); border-color: rgba(212,135,10,0.2); }
.found-heading {
  font-size: 0.78rem; font-weight: 700; color: var(--green);
  margin-bottom: 10px; display: flex; align-items: center; gap: 6px;
}
.found-heading.warn { color: var(--amber); }
.chips-row { display: flex; flex-wrap: wrap; gap: 7px; }
.verified-note {
  margin-top: 10px; font-size: 0.77rem; color: var(--green);
  display: flex; align-items: center; gap: 5px;
}

/* ── Email preview card ──────────────────────────────── */
.preview-card {
  padding: 26px 28px; position: relative; overflow: hidden;
  border-top: 3px solid var(--green);
}
.preview-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px;
}
.preview-title { font-size: 1rem; font-weight: 700; }
.email-meta { padding-bottom: 14px; margin-bottom: 14px; border-bottom: 1px solid var(--border); }
.meta-row { display: flex; gap: 8px; align-items: baseline; margin-bottom: 6px; }
.meta-label {
  font-size: 0.7rem; font-weight: 700; color: var(--ink3);
  width: 50px; flex-shrink: 0; text-transform: uppercase; letter-spacing: .04em;
}
.meta-val { font-size: 0.86rem; color: var(--ink2); word-break: break-all; }
.meta-subj { font-weight: 700; color: var(--ink); font-size: 0.92rem; }
.email-body-text {
  font-size: 0.9rem; color: var(--ink2); line-height: 1.8;
  white-space: pre-wrap; max-height: 300px; overflow-y: auto;
  padding-right: 4px;
}
.email-body-text[contenteditable="true"] {
  border: 1.5px solid var(--green); border-radius: var(--r);
  padding: 12px; background: #f0f9f4; outline: none; max-height: none;
}
.preview-actions { display: flex; gap: 8px; margin-top: 18px; flex-wrap: wrap; }

/* ── AI status panel ─────────────────────────────────── */
.ai-panel { padding: 22px; }
.ai-panel-header {
  display: flex; align-items: center; gap: 8px;
  font-weight: 700; font-size: 0.9rem; margin-bottom: 18px;
  color: var(--ink);
}
.ai-live-dot {
  width: 7px; height: 7px; background: var(--green);
  border-radius: 50%; animation: pulse 2s infinite;
  box-shadow: 0 0 6px rgba(45,106,79,0.4);
}
.ai-idle-msg {
  text-align: center; color: var(--ink3); font-size: 0.82rem;
  padding: 14px 0; line-height: 1.6;
}
.ai-idle-msg strong { color: var(--green); }
.ai-typing-row { display: flex; justify-content: center; padding: 12px 0; }

/* ── Char count ──────────────────────────────────────── */
.char-wrap { position: relative; }
.char-count {
  position: absolute; bottom: 10px; right: 12px;
  font-size: 0.7rem; color: var(--ink4);
}

/* ── Tips card ───────────────────────────────────────── */
.tips-card {
  padding: 16px 18px; border-radius: var(--r);
  background: var(--bg2); border: 1px solid var(--border);
  margin-top: 14px;
}
.tips-title { font-size: 0.78rem; font-weight: 700; color: var(--ink2); margin-bottom: 8px; }
.tips-items { font-size: 0.78rem; color: var(--ink3); line-height: 1.85; }

/* ── Template grid ───────────────────────────────────── */
.tpl-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tpl-item {
  padding: 18px 16px; border-radius: var(--r2);
  background: var(--surface); border: 1px solid var(--border);
  cursor: pointer; transition: all .18s;
}
.tpl-item:hover {
  border-color: rgba(45,106,79,0.3); background: #f0f9f4;
  transform: translateY(-2px); box-shadow: var(--shadow-sm);
}
.tpl-ico  { font-size: 1.5rem; margin-bottom: 8px; }
.tpl-name { font-size: 0.88rem; font-weight: 700; margin-bottom: 4px; }
.tpl-desc { font-size: 0.76rem; color: var(--ink3); }

/* ── Bulk campaign ───────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border2); border-radius: var(--r2);
  padding: 36px 24px; text-align: center; cursor: pointer;
  transition: all .2s; margin-bottom: 16px;
  background: var(--bg2);
}
.upload-zone:hover { border-color: var(--green); background: #f0f9f4; }
.upload-ico  { font-size: 2rem; margin-bottom: 10px; }
.upload-text { font-size: 0.9rem; color: var(--ink2); }
.upload-text strong { color: var(--green); }
.upload-note { font-size: 0.75rem; color: var(--ink3); margin-top: 5px; }
.progress-wrap { height: 3px; background: var(--bg3); border-radius: 3px; margin-top: 12px; overflow: hidden; }
.progress-bar  { height: 100%; background: var(--green); border-radius: 3px; width: 0; transition: width .35s ease; }

.stats-cards { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; margin-top: 14px; }
.stat-c {
  padding: 14px; border-radius: var(--r);
  background: var(--surface); border: 1px solid var(--border);
  text-align: center;
}
.stat-n { font-family: 'Fraunces', serif; font-size: 1.7rem; font-weight: 700; }
.stat-l { font-size: 0.7rem; color: var(--ink3); margin-top: 2px; text-transform: uppercase; letter-spacing: .05em; }

/* ── Follow-up timeline ──────────────────────────────── */
.tl-wrap { position: relative; padding-left: 22px; }
.tl-wrap::before {
  content: ''; position: absolute; left: 8px; top: 6px; bottom: 6px;
  width: 1.5px; background: linear-gradient(var(--green), var(--border));
}
.tl-item { position: relative; margin-bottom: 16px; }
.tl-dot {
  position: absolute; left: -18px; top: 5px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--green); border: 2px solid var(--surface);
  box-shadow: 0 0 0 2px var(--green-bg);
}
.tl-dot.done  { background: var(--green); }
.tl-dot.sched { background: var(--border2); box-shadow: 0 0 0 2px var(--bg3); }
.tl-body {
  padding: 12px 14px; border-radius: var(--r);
  background: var(--surface); border: 1px solid var(--border);
}
.tl-name { font-size: 0.85rem; font-weight: 600; }
.tl-desc { font-size: 0.78rem; color: var(--ink2); margin-top: 3px; }
.tl-time { font-size: 0.72rem; color: var(--ink3); margin-top: 5px; }

/* ── Inbox ───────────────────────────────────────────── */
.inbox-list { display: flex; flex-direction: column; gap: 6px; }
.inbox-item {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 14px 16px; border-radius: var(--r2);
  background: var(--surface); border: 1px solid var(--border);
  cursor: pointer; transition: all .15s;
}
.inbox-item:hover { border-color: var(--border2); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.inbox-item.unread { border-left: 3px solid var(--green); }
.inbox-item.unread .i-from { font-weight: 700; }
.i-ava {
  width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.82rem; color: #fff; flex-shrink: 0;
  font-family: 'Fraunces', serif;
}
.i-body { flex: 1; min-width: 0; }
.i-from { font-size: 0.88rem; font-weight: 500; margin-bottom: 2px; }
.i-subj { font-size: 0.82rem; color: var(--ink); margin-bottom: 2px; }
.i-prev { font-size: 0.78rem; color: var(--ink3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.i-time { font-size: 0.73rem; color: var(--ink3); flex-shrink: 0; white-space: nowrap; }

/* ── Sent overlay ────────────────────────────────────── */
.overlay {
  display: none; position: fixed; inset: 0; z-index: 8000;
  background: rgba(247,245,240,0.85);
  backdrop-filter: blur(8px);
  align-items: center; justify-content: center;
}
.overlay.show { display: flex; animation: fadeIn .3s ease; }
.overlay-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r3); padding: 52px 44px;
  max-width: 420px; width: 100%; text-align: center;
  box-shadow: var(--shadow-xl);
  animation: scaleIn .4s ease both;
}
.ov-icon {
  width: 72px; height: 72px; border-radius: 50%;
  background: var(--green-bg); border: 2px solid rgba(45,106,79,0.2);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.8rem; margin: 0 auto 22px;
}
.ov-title { font-size: 1.6rem; font-weight: 700; margin-bottom: 10px; }
.ov-desc  { color: var(--ink2); font-size: 0.9rem; line-height: 1.7; }
.ov-link  { display: block; margin-top: 10px; font-size: 0.82rem; color: var(--green); }

/* ── Revise modal ────────────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0; z-index: 7000;
  background: rgba(26,26,24,0.35); backdrop-filter: blur(4px);
  align-items: center; justify-content: center;
}
.modal-overlay.show { display: flex; animation: fadeIn .25s ease; }
.modal {
  background: var(--surface); border-radius: var(--r2);
  border: 1px solid var(--border); padding: 32px 30px;
  max-width: 460px; width: 100%; box-shadow: var(--shadow-xl);
  animation: scaleIn .3s ease both;
}
.modal-title { font-size: 1.15rem; font-weight: 700; margin-bottom: 18px; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; justify-content: flex-end; }

/* ── Analytics ───────────────────────────────────────── */
.analytics-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; margin-bottom: 24px; }
.a-card {
  padding: 20px; border-radius: var(--r2);
  background: var(--surface); border: 1px solid var(--border);
}
.a-val { font-family: 'Fraunces', serif; font-size: 2rem; font-weight: 700; margin-bottom: 4px; }
.a-lbl { font-size: 0.75rem; color: var(--ink2); }
.a-trend { font-size: 0.73rem; color: var(--green); margin-top: 4px; }

/* ── Empty state ─────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 60px 40px;
  color: var(--ink2);
}
.empty-ico { font-size: 2.5rem; margin-bottom: 14px; opacity: .5; }
.empty-title { font-size: 1.05rem; font-weight: 700; margin-bottom: 6px; color: var(--ink); }
.empty-desc  { font-size: 0.875rem; }

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 1100px) {
  .compose-grid { grid-template-columns: 1fr; }
  .compose-right { position: static; }
}
@media (max-width: 800px) {
  .sidebar { display: none; }
  .main-area { margin-left: 0; padding: 24px 20px; }
  .nav-sidebar-space { display: none; }
  .nav-tabs { display: none; }
  .analytics-grid { grid-template-columns: 1fr 1fr; }
}


/* ════════════════════════════════════════════════════
   PROFILE DROPDOWN
════════════════════════════════════════════════════ */
.nav-right { position: relative; }

.profile-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 240px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  box-shadow: var(--shadow-xl);
  z-index: 999;
  overflow: hidden;
  animation: fadeDown .2s ease both;
}
.profile-dropdown.open { display: block; }

/* Header section inside dropdown */
.pd-header {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 16px 14px;
  background: var(--bg2);
}
.pd-ava {
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, var(--green), var(--green3));
  display: flex; align-items: center; justify-content: center;
  font-family: 'Fraunces', serif; font-weight: 700;
  font-size: 1rem; color: #fff; flex-shrink: 0;
}
.pd-info { flex: 1; min-width: 0; }
.pd-name {
  font-size: 0.88rem; font-weight: 700;
  color: var(--ink); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.pd-email {
  font-size: 0.75rem; color: var(--ink3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-top: 1px;
}

.pd-divider { height: 1px; background: var(--border); }

/* Menu items */
.pd-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 11px 16px;
  background: none; border: none;
  color: var(--ink2); font-size: 0.865rem; font-weight: 500;
  cursor: pointer; transition: all .14s; text-align: left;
  font-family: 'Plus Jakarta Sans', sans-serif;
}
.pd-item:hover {
  background: var(--bg2); color: var(--ink);
}
.pd-item-danger { color: var(--red); }
.pd-item-danger:hover { background: var(--red-bg); color: var(--red); }

/* User pill — active state when dropdown open */
.user-pill.active {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(45,106,79,0.1);
}

/* ── CSV Upload drag states ── */
.upload-zone.dragging {
  border-color: var(--green);
  background: #f0f9f4;
  transform: scale(1.01);
}
.upload-zone input[type="file"] { display: none; }