/* ===================================================
   ProMail — App Stylesheet
   Glassmorphism + Dark/Light mode — Bootstrap 5 base
   =================================================== */

/* ── Variables ── */
:root {
  --accent:        #6366f1;
  --accent-hover:  #4f52d4;
  --accent-glow:   rgba(99,102,241,.35);

  /* dark */
  --bg-base:       #0d0e1c;
  --bg-layer1:     rgba(255,255,255,.04);
  --bg-layer2:     rgba(255,255,255,.08);
  --bg-layer3:     rgba(255,255,255,.12);
  --border-glass:  rgba(255,255,255,.1);
  --text-primary:  #e8eaff;
  --text-muted:    rgba(232,234,255,.5);
  --scrollbar:     rgba(99,102,241,.3);
}

[data-theme="light"] {
  --bg-base:       #eef1fb;
  --bg-layer1:     rgba(255,255,255,.6);
  --bg-layer2:     rgba(255,255,255,.8);
  --bg-layer3:     #fff;
  --border-glass:  rgba(0,0,0,.08);
  --text-primary:  #1a1c2e;
  --text-muted:    rgba(26,28,46,.5);
  --scrollbar:     rgba(99,102,241,.25);
}

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

html, body { height: 100%; margin: 0; padding: 0; }

body {
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: .9rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--accent); color: #fff; }

/* ── Scrollbar ── */
::-webkit-scrollbar       { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 99px; }

/* ── Auth ── */
.auth-body {
  background: var(--bg-base);
  min-height: 100vh;
  overflow: hidden;
}
.auth-bg {
  position: fixed; inset: 0; z-index: 0;
  background:
    radial-gradient(ellipse 60% 60% at 30% 20%, rgba(99,102,241,.25) 0%, transparent 70%),
    radial-gradient(ellipse 50% 50% at 80% 80%, rgba(168,85,247,.2)  0%, transparent 70%);
  pointer-events: none;
}
.auth-card {
  position: relative; z-index: 1;
  width: 100%; max-width: 420px;
  padding: 2.5rem;
  border-radius: 1.25rem;
}
.auth-logo .logo-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 60px; height: 60px; border-radius: 1rem;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  font-size: 1.6rem; color: #fff;
  box-shadow: 0 8px 32px rgba(99,102,241,.4);
}

/* ── Glass Primitives ── */
.glass-card {
  background: var(--bg-layer1);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border: 1px solid var(--border-glass);
  border-radius: .875rem;
}
.glass-nav {
  background: var(--bg-layer1);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-bottom: 1px solid var(--border-glass);
}
.glass-dropdown {
  background: rgba(18,20,38,.96) !important;
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-glass) !important;
  border-radius: .75rem !important;
  padding: .5rem !important;
  color: var(--text-primary);
}
[data-theme="light"] .glass-dropdown { background: rgba(255,255,255,.98) !important; }
.glass-dropdown .dropdown-item {
  border-radius: .5rem; padding: .5rem .75rem; color: var(--text-primary);
  font-size: .85rem;
}
.glass-dropdown .dropdown-item:hover { background: var(--bg-layer2) !important; }
.glass-modal .modal-content {
  background: rgba(14,16,30,.97);
  backdrop-filter: blur(24px);
  border: 1px solid var(--border-glass);
  border-radius: 1rem;
  color: var(--text-primary);
}
[data-theme="light"] .glass-modal .modal-content { background: rgba(255,255,255,.98); }
.glass-toast {
  background: rgba(99,102,241,.9) !important;
  backdrop-filter: blur(10px);
}
.glass-alert {
  background: var(--bg-layer2);
  border: 1px solid var(--border-glass);
  color: var(--text-primary);
}

/* ── Inputs ── */
.glass-input {
  background: var(--bg-layer2) !important;
  border: 1px solid var(--border-glass) !important;
  color: var(--text-primary) !important;
  border-radius: .625rem !important;
  padding: .55rem .9rem;
  transition: border-color .2s, box-shadow .2s;
}
.glass-input:focus {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px var(--accent-glow) !important;
  outline: none;
}
.glass-input::placeholder { color: var(--text-muted) !important; }
.glass-input-group .input-group-text,
.glass-input-addon {
  background: var(--bg-layer2) !important;
  border: 1px solid var(--border-glass) !important;
  color: var(--text-muted) !important;
  border-radius: .625rem 0 0 .625rem !important;
}

/* ── Buttons ── */
.btn-primary {
  background: linear-gradient(135deg, #6366f1, #8b5cf6) !important;
  border: none !important;
  color: #fff !important;
  border-radius: .625rem !important;
  font-weight: 500;
}
.btn-primary:hover { background: linear-gradient(135deg, #4f52d4, #7c3aed) !important; }
.btn-glow        { box-shadow: 0 4px 20px var(--accent-glow); }
.btn-glow:hover  { box-shadow: 0 6px 28px rgba(99,102,241,.5); transform: translateY(-1px); }
.btn-ghost {
  background: transparent !important;
  border: none !important;
  color: var(--text-muted) !important;
  border-radius: .5rem !important;
}
.btn-ghost:hover { background: var(--bg-layer2) !important; color: var(--text-primary) !important; }
.btn-icon   { width: 36px; height: 36px; padding: 0 !important; display: inline-flex; align-items: center; justify-content: center; }
.btn-icon-xs { width: 28px; height: 28px; padding: 0 !important; display: inline-flex; align-items: center; justify-content: center; font-size: .8rem; }
.btn-xs      { font-size: .75rem; padding: .2rem .5rem !important; }

/* ── Gradient text ── */
.gradient-text {
  background: linear-gradient(135deg, #a5b4fc, #e879f9);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}

/* ── App Shell ── */
.app-shell {
  display: flex; height: 100vh; overflow: hidden;
}

/* ── Sidebar ── */
.app-sidebar {
  width: 240px; min-width: 240px;
  height: 100vh; overflow-y: auto;
  background: var(--bg-layer1);
  backdrop-filter: blur(24px);
  border-right: 1px solid var(--border-glass);
  display: flex; flex-direction: column;
  transition: transform .25s ease;
  z-index: 200;
}
@media (max-width: 767px) {
  .app-sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); }
  .app-sidebar.open { transform: translateX(0); }
  .sidebar-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 199; display: none; }
  .sidebar-overlay.visible { display: block; }
}
.sidebar-inner { display: flex; flex-direction: column; height: 100%; padding: 1rem .75rem; }
.sidebar-logo {
  display: flex; align-items: center; gap: .75rem;
  padding: .5rem .5rem 1rem;
}
.logo-mark {
  width: 34px; height: 34px; border-radius: .625rem;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1rem;
}
.logo-text { font-weight: 700; font-size: 1.1rem; letter-spacing: -.3px; }
.account-badge {
  display: flex; align-items: center; gap: .6rem;
  background: var(--bg-layer2); border: 1px solid var(--border-glass);
  border-radius: .625rem; padding: .5rem .75rem;
  margin-bottom: .75rem;
}
.account-dot { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; flex-shrink: 0; }
.account-info { flex: 1; min-width: 0; }
.account-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.compose-btn { margin-bottom: .5rem; }
.sidebar-section-label {
  font-size: .68rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .08em; color: var(--text-muted);
  padding: .5rem .5rem .3rem;
}
.sidebar-nav { display: flex; flex-direction: column; gap: 1px; }
.sidebar-item {
  display: flex; align-items: center; gap: .7rem;
  padding: .5rem .75rem; border-radius: .625rem;
  color: var(--text-muted); text-decoration: none;
  font-size: .85rem; font-weight: 500;
  transition: background .15s, color .15s;
  cursor: pointer;
}
.sidebar-item:hover { background: var(--bg-layer2); color: var(--text-primary); }
.sidebar-item.active {
  background: rgba(99,102,241,.2); color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(99,102,241,.3);
}
.sidebar-icon { font-size: 1rem; width: 20px; text-align: center; flex-shrink: 0; }
.sidebar-label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-badge {
  font-size: .7rem; font-weight: 700; min-width: 18px; height: 18px;
  background: var(--accent); color: #fff; border-radius: 99px;
  display: flex; align-items: center; justify-content: center; padding: 0 5px;
}
.label-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.sidebar-bottom { margin-top: auto; padding-top: .75rem; border-top: 1px solid var(--border-glass); }

/* ── Main ── */
.app-main {
  flex: 1; min-width: 0; display: flex; flex-direction: column; height: 100vh; overflow: hidden;
}

/* ── Topbar ── */
.app-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: .5rem 1rem; min-height: 56px;
  flex-shrink: 0;
}
.search-wrapper { position: relative; }
.search-icon { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
.glass-search {
  padding-left: 2.4rem !important;
  width: 320px; max-width: 90vw;
  background: var(--bg-layer2) !important;
  border: 1px solid var(--border-glass) !important;
  color: var(--text-primary) !important;
  border-radius: .625rem !important;
}
.glass-search:focus {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px var(--accent-glow) !important;
  width: 400px;
}
.glass-search::placeholder { color: var(--text-muted) !important; }
.user-avatar-sm {
  width: 32px; height: 32px; border-radius: .5rem;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 700; color: #fff;
}

/* ── Flash ── */
.flash-container { padding: .5rem 1rem 0; flex-shrink: 0; }

/* ── Content ── */
.app-content { flex: 1; overflow-y: auto; padding: 1rem; }

/* ── Page container ── */
.page-container { max-width: 1100px; margin: 0 auto; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; flex-wrap: wrap; gap: .5rem; }

/* ── Inbox ── */
.inbox-layout { display: flex; height: calc(100vh - 120px); gap: 1rem; }
.email-list-pane { flex: 0 0 560px; min-width: 0; display: flex; flex-direction: column; height: 100%; }
.email-preview-pane { flex: 1; min-width: 0; border-radius: .875rem; overflow: hidden; }
@media (max-width: 1200px) { .email-preview-pane { display: none !important; } .email-list-pane { flex: 1; } }
.pane-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: .75rem 1rem; background: var(--bg-layer1);
  backdrop-filter: blur(20px); border: 1px solid var(--border-glass);
  border-radius: .875rem .875rem 0 0; flex-shrink: 0;
}
.pane-title { font-size: 1.1rem; font-weight: 700; }
.pane-footer {
  padding: .5rem 1rem; background: var(--bg-layer1);
  border: 1px solid var(--border-glass); border-top: none;
  border-radius: 0 0 .875rem .875rem; flex-shrink: 0;
}
.email-list { flex: 1; overflow-y: auto; background: var(--bg-layer1); border-left: 1px solid var(--border-glass); border-right: 1px solid var(--border-glass); }
.email-row {
  display: flex; align-items: center; gap: .6rem;
  padding: .65rem 1rem; cursor: pointer;
  border-bottom: 1px solid var(--border-glass);
  transition: background .12s;
}
.email-row:hover { background: var(--bg-layer2); }
.email-row.unread { background: rgba(99,102,241,.06); }
.email-row.unread .email-from,
.email-row.unread .email-subject { font-weight: 700; color: var(--text-primary); }
.email-check { flex-shrink: 0; }
.email-star { flex-shrink: 0; color: var(--text-muted); }
.email-star.starred { color: #f59e0b !important; }
.email-avatar {
  width: 36px; height: 36px; border-radius: .5rem; flex-shrink: 0;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  display: flex; align-items: center; justify-content: center;
  font-size: .85rem; font-weight: 700; color: #fff;
}
.email-meta { flex: 1; min-width: 0; }
.email-from { font-size: .82rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.email-subject-preview { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .82rem; }
.email-subject { font-weight: 500; }
.email-preview { color: var(--text-muted); }
.email-info { flex-shrink: 0; text-align: right; }
.email-date { font-size: .72rem; color: var(--text-muted); white-space: nowrap; }
.preview-placeholder { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; }
.preview-placeholder-icon { font-size: 4rem; color: var(--text-muted); margin-bottom: 1rem; }
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 4rem 2rem; text-align: center; }
.empty-icon { font-size: 3.5rem; color: var(--text-muted); margin-bottom: 1rem; }

/* ── Email view ── */
.email-view-layout { display: flex; flex-direction: column; height: calc(100vh - 120px); }
.view-toolbar { display: flex; align-items: center; justify-content: space-between; padding: .6rem 1rem; flex-shrink: 0; border-radius: .875rem .875rem 0 0; }
.glass-toolbar { background: var(--bg-layer1); border: 1px solid var(--border-glass); }
.view-subject { font-size: 1rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60vw; }
.view-body { flex: 1; overflow-y: auto; padding: 1rem; background: var(--bg-layer1); border-left: 1px solid var(--border-glass); border-right: 1px solid var(--border-glass); border-bottom: 1px solid var(--border-glass); border-radius: 0 0 .875rem .875rem; }
.sender-avatar-lg {
  width: 48px; height: 48px; border-radius: .75rem;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; font-weight: 700; color: #fff; flex-shrink: 0;
}
.sender-avatar-sm {
  width: 32px; height: 32px; border-radius: .5rem;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 700; color: #fff; flex-shrink: 0;
}
.email-iframe { width: 100%; min-height: 200px; border: none; background: #fff; border-radius: .5rem; }
.email-text-body { white-space: pre-wrap; font-size: .85rem; color: var(--text-primary); }
.thread-item { cursor: pointer; transition: background .12s; }
.thread-item:hover { background: var(--bg-layer2); }
.quick-reply textarea { resize: vertical; }
.label-badge { font-size: .75rem; }

/* ── Compose ── */
.compose-layout { height: calc(100vh - 120px); display: flex; flex-direction: column; }
.compose-card { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.compose-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: .75rem 1rem; border-bottom: 1px solid var(--border-glass); flex-shrink: 0;
}
.compose-row {
  display: flex; align-items: flex-start; gap: .75rem;
  padding: .5rem 1rem; border-bottom: 1px solid var(--border-glass);
  position: relative;
}
.compose-label { width: 52px; flex-shrink: 0; color: var(--text-muted); font-size: .82rem; padding-top: .45rem; }
.compose-input { flex: 1; background: transparent !important; border: none !important; box-shadow: none !important; padding: .3rem 0 !important; color: var(--text-primary) !important; }
.compose-input:focus { outline: none; box-shadow: none !important; border: none !important; }
.compose-select { flex: 1; background: transparent !important; border: none !important; box-shadow: none !important; color: var(--text-primary) !important; cursor: pointer; }
.compose-editor-wrapper { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.editor-toolbar {
  display: flex; align-items: center; gap: 2px; flex-wrap: wrap;
  padding: .4rem .75rem; border-bottom: 1px solid var(--border-glass);
  background: var(--bg-layer2); flex-shrink: 0;
}
.editor-btn {
  background: transparent; border: none; color: var(--text-muted);
  padding: .3rem .4rem; border-radius: .4rem; cursor: pointer; font-size: .9rem;
  transition: background .12s, color .12s;
}
.editor-btn:hover { background: var(--bg-layer3); color: var(--text-primary); }
.editor-sep { width: 1px; height: 20px; background: var(--border-glass); margin: 0 3px; }
.editor-select { background: var(--bg-layer2); border: 1px solid var(--border-glass); color: var(--text-muted); border-radius: .4rem; padding: .2rem .4rem; font-size: .8rem; }
.compose-editor {
  flex: 1; overflow-y: auto; padding: 1rem;
  color: var(--text-primary); min-height: 200px;
  outline: none; line-height: 1.7;
}
.compose-footer {
  display: flex; align-items: center; gap: .75rem;
  padding: .75rem 1rem; border-top: 1px solid var(--border-glass); flex-shrink: 0;
}
.attachment-btn { cursor: pointer !important; }
.autocomplete-dropdown {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 1000;
  background: rgba(14,16,30,.98); border: 1px solid var(--border-glass);
  border-radius: 0 0 .625rem .625rem; max-height: 200px; overflow-y: auto;
}
.autocomplete-item {
  padding: .5rem .75rem; cursor: pointer; font-size: .85rem;
  border-bottom: 1px solid var(--border-glass);
}
.autocomplete-item:hover { background: var(--bg-layer2); }

/* ── Contacts ── */
.contacts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.contact-card { display: flex; align-items: center; gap: .75rem; padding: 1rem; }
.contact-avatar {
  width: 42px; height: 42px; border-radius: .625rem; flex-shrink: 0;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; font-weight: 700; color: #fff;
}
.contact-info { flex: 1; min-width: 0; }
.contact-actions { display: flex; gap: 2px; }

/* ── Account cards ── */
.account-card {}
.account-icon-badge {
  width: 44px; height: 44px; border-radius: .75rem; flex-shrink: 0;
  background: rgba(99,102,241,.2); border: 1px solid rgba(99,102,241,.3);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; color: var(--accent);
}

/* ── Template cards ── */
.template-card { display: flex; align-items: center; gap: .75rem; padding: 1rem; }
.template-icon { width: 40px; height: 40px; border-radius: .625rem; background: rgba(99,102,241,.15); display: flex; align-items: center; justify-content: center; color: var(--accent); font-size: 1.2rem; }
.template-info { flex: 1; min-width: 0; }
.template-actions { display: flex; gap: 2px; }

/* ── Stats ── */
.stat-card { transition: transform .2s; }
.stat-card:hover { transform: translateY(-2px); }
.stat-icon { font-size: 1.75rem; margin-bottom: .5rem; }
.stat-value { font-size: 2rem; font-weight: 700; line-height: 1.2; }
.stat-label { margin-top: .25rem; }

/* ── Activity ── */
.activity-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* ── Table ── */
.table { color: var(--text-primary) !important; }
.table td, .table th { border-color: var(--border-glass) !important; padding: .75rem 1rem; }
.table thead th { color: var(--text-muted) !important; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }

/* ── Animate ── */
@keyframes fadeUp { from { opacity:0; transform: translateY(16px); } to { opacity:1; transform: translateY(0); } }
.animate-in { animation: fadeUp .4s ease both; }

/* ── Badge ── */
.badge.bg-primary-subtle { background: rgba(99,102,241,.15) !important; }
.badge.bg-success-subtle { background: rgba(34,197,94,.15) !important; }
.badge.bg-secondary-subtle { background: var(--bg-layer2) !important; }
.badge.bg-danger-subtle   { background: rgba(239,68,68,.15) !important; }

/* ── Glass Badge ── */
.glass-badge {
  background: var(--bg-layer2);
  border: 1px solid var(--border-glass);
  border-radius: .625rem;
  padding: .4rem .6rem;
  margin-bottom: .75rem;
  display: flex; align-items: center; gap: .5rem;
}
