/* ===== Tokens ===== */
:root, [data-bs-theme="light"] {
  --et-bg: #f6f7fb;
  --et-surface: #ffffff;
  --et-surface-2: #f9fafb;
  --et-border: #e6e8ef;
  --et-text: #111827;
  --et-muted: #6b7280;
  --et-primary: #4f46e5;
  --et-primary-hover: #4338ca;
  --et-primary-soft: #eef2ff;
  --et-sidebar: #0f172a;
  --et-sidebar-text: #cbd5e1;
  --et-sidebar-muted: #64748b;
  --et-sidebar-active: rgba(255, 255, 255, .08);
  --et-shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --et-radius: 14px;

  --bs-body-bg: var(--et-bg);
  --bs-body-color: var(--et-text);
  --bs-border-color: var(--et-border);
  --bs-primary: var(--et-primary);
  --bs-primary-rgb: 79, 70, 229;
  --bs-link-color: var(--et-primary);
  --bs-link-color-rgb: 79, 70, 229;
  --bs-link-hover-color: var(--et-primary-hover);
  --bs-body-font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --bs-secondary-color: var(--et-muted);
}
[data-bs-theme="dark"] {
  --et-bg: #0b1020;
  --et-surface: #121829;
  --et-surface-2: #172036;
  --et-border: #243049;
  --et-text: #e5e7eb;
  --et-muted: #94a3b8;
  --et-primary: #818cf8;
  --et-primary-hover: #a5b4fc;
  --et-primary-soft: rgba(129, 140, 248, .14);
  --et-sidebar: #070b16;
  --et-shadow: none;

  --bs-body-bg: var(--et-bg);
  --bs-body-color: var(--et-text);
  --bs-border-color: var(--et-border);
  --bs-primary-rgb: 129, 140, 248;
  --bs-link-color: var(--et-primary);
  --bs-link-color-rgb: 129, 140, 248;
  --bs-secondary-color: var(--et-muted);
  --bs-tertiary-bg: var(--et-surface-2);
}

body { background: var(--et-bg); color: var(--et-text); font-size: .925rem; -webkit-font-smoothing: antialiased; }
a { text-decoration: none; }
a:hover { text-decoration: underline; }
.text-muted, .text-body-secondary { color: var(--et-muted) !important; }
code { color: #db2777; }
[data-bs-theme="dark"] code { color: #f472b6; }

/* ===== Buttons ===== */
.btn { border-radius: 10px; font-weight: 500; padding: .5rem .95rem; }
.btn-sm { border-radius: 8px; padding: .3rem .65rem; }
.btn-primary {
  --bs-btn-bg: var(--et-primary); --bs-btn-border-color: var(--et-primary);
  --bs-btn-hover-bg: var(--et-primary-hover); --bs-btn-hover-border-color: var(--et-primary-hover);
  --bs-btn-active-bg: var(--et-primary-hover); --bs-btn-active-border-color: var(--et-primary-hover);
  --bs-btn-disabled-bg: var(--et-primary); --bs-btn-disabled-border-color: var(--et-primary);
}
[data-bs-theme="dark"] .btn-primary { --bs-btn-color: #0b1020; --bs-btn-hover-color: #0b1020; --bs-btn-active-color: #0b1020; --bs-btn-disabled-color: #0b1020; }
.btn-outline-primary {
  --bs-btn-color: var(--et-primary); --bs-btn-border-color: var(--et-primary);
  --bs-btn-hover-bg: var(--et-primary); --bs-btn-hover-border-color: var(--et-primary);
  --bs-btn-active-bg: var(--et-primary);
}
.btn-light { --bs-btn-bg: var(--et-surface); --bs-btn-border-color: var(--et-border); --bs-btn-hover-bg: var(--et-surface-2); --bs-btn-hover-border-color: var(--et-border); --bs-btn-color: var(--et-text); --bs-btn-hover-color: var(--et-text); }
.btn-icon { width: 34px; height: 34px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; color: var(--et-muted); }
.btn-icon:hover { background: var(--et-surface-2); color: var(--et-text); }
.btn-icon.text-danger:hover { background: rgba(220, 53, 69, .1); }

/* ===== Forms ===== */
.form-control, .form-select { border-radius: 10px; border-color: var(--et-border); background-color: var(--et-surface); padding: .55rem .8rem; }
.form-control:focus, .form-select:focus { border-color: var(--et-primary); box-shadow: 0 0 0 .2rem var(--et-primary-soft); }
.form-label { font-weight: 500; font-size: .85rem; margin-bottom: .35rem; }
.form-text { font-size: .8rem; }
.form-check-input:checked { background-color: var(--et-primary); border-color: var(--et-primary); }
.input-group .btn { border-color: var(--et-border); }

/* ===== Layout ===== */
.app { display: flex; min-height: 100vh; }
.sidebar {
  --bs-offcanvas-width: 260px; --bs-offcanvas-bg: var(--et-sidebar);
  width: 260px; flex-shrink: 0; background: var(--et-sidebar); color: var(--et-sidebar-text);
}
@media (min-width: 992px) {
  /* Bootstrap's .offcanvas-lg forces a transparent background on desktop */
  .sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background-color: var(--et-sidebar) !important; }
  .sidebar .offcanvas-body { display: flex; flex-direction: column; height: 100%; }
}
.sidebar .offcanvas-body { padding: 0; display: flex; flex-direction: column; }
.sidebar-brand { display: flex; align-items: center; gap: .6rem; padding: 1.25rem 1.25rem 1rem; color: #fff; font-weight: 700; font-size: 1.05rem; }
.sidebar-brand:hover { text-decoration: none; color: #fff; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, #6366f1, #a855f7); display: grid; place-items: center; color: #fff; font-size: 1rem; }
.nav-section { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--et-sidebar-muted); padding: 1rem 1.25rem .4rem; font-weight: 600; }
.side-nav { list-style: none; margin: 0; padding: 0 .75rem; }
.side-nav a { display: flex; align-items: center; gap: .75rem; padding: .55rem .75rem; border-radius: 10px; color: var(--et-sidebar-text); font-weight: 500; }
.side-nav a i { font-size: 1.05rem; opacity: .8; width: 20px; text-align: center; }
.side-nav a:hover { background: var(--et-sidebar-active); color: #fff; text-decoration: none; }
.side-nav a.active { background: rgba(99, 102, 241, .22); color: #fff; }
.side-nav a.active i { opacity: 1; color: #a5b4fc; }
.side-nav .pill { margin-left: auto; font-size: .7rem; background: #6366f1; color: #fff; padding: .1rem .45rem; border-radius: 999px; }
.side-nav .pill.live::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #4ade80; margin-right: 4px; vertical-align: middle; animation: pulse 1.5s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.sidebar-user { margin-top: auto; padding: .75rem; border-top: 1px solid rgba(255, 255, 255, .06); }
.sidebar-user > button { width: 100%; display: flex; align-items: center; gap: .65rem; background: none; border: 0; color: var(--et-sidebar-text); padding: .5rem; border-radius: 10px; text-align: left; }
.sidebar-user > button:hover { background: var(--et-sidebar-active); }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; font-size: .8rem; background: #334155; color: #fff; flex-shrink: 0; }
.avatar-lg { width: 40px; height: 40px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: .75rem; padding: .75rem 1rem; background: var(--et-surface); border-bottom: 1px solid var(--et-border); position: sticky; top: 0; z-index: 1020; }
.content { padding: 1.75rem 2rem 4rem; max-width: 1400px; width: 100%; }
@media (max-width: 991.98px) { .content { padding: 1.25rem 1rem 3rem; } }

/* ===== Page header ===== */
.page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.page-header h1 { font-size: 1.5rem; font-weight: 700; margin: 0; letter-spacing: -.01em; }
.page-header .subtitle { color: var(--et-muted); margin: .25rem 0 0; }
.page-header .actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.back-link { display: inline-flex; align-items: center; gap: .25rem; font-size: .85rem; color: var(--et-muted); margin-bottom: .35rem; }

/* ===== Cards ===== */
.card { --bs-card-bg: var(--et-surface); --bs-card-border-color: var(--et-border); --bs-card-border-radius: var(--et-radius); --bs-card-inner-border-radius: calc(var(--et-radius) - 1px); box-shadow: var(--et-shadow); }
.card-header { background: transparent; font-weight: 600; padding: 1rem 1.25rem; display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.card-header .sub { font-weight: 400; color: var(--et-muted); font-size: .85rem; }
.card-body { padding: 1.25rem; }
.card-footer { background: var(--et-surface-2); padding: .9rem 1.25rem; }

.stat-card { display: flex; align-items: center; gap: 1rem; }
.stat-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 1.2rem; flex-shrink: 0; }
.tone-primary { background: var(--et-primary-soft); color: var(--et-primary); }
.tone-success { background: rgba(16, 185, 129, .12); color: #059669; }
.tone-warning { background: rgba(245, 158, 11, .14); color: #d97706; }
.tone-danger { background: rgba(239, 68, 68, .12); color: #dc2626; }
.tone-info { background: rgba(14, 165, 233, .12); color: #0284c7; }
.tone-muted { background: var(--et-surface-2); color: var(--et-muted); }
.stat-value { font-size: 1.5rem; font-weight: 700; line-height: 1.1; letter-spacing: -.01em; }
.stat-label { color: var(--et-muted); font-size: .8rem; font-weight: 500; }
.stat-sub { font-size: .75rem; color: var(--et-muted); }

/* ===== Tables ===== */
.table { --bs-table-bg: transparent; margin: 0; }
.table > :not(caption) > * > * { padding: .75rem 1rem; border-color: var(--et-border); }
.table thead th { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--et-muted); font-weight: 600; background: var(--et-surface-2); border-bottom-width: 1px; white-space: nowrap; }
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: var(--et-surface-2); }
.table td { vertical-align: middle; }
.table .row-title { font-weight: 600; color: var(--et-text); }
.table .row-sub { font-size: .8rem; color: var(--et-muted); }
.text-truncate-300 { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===== Badges ===== */
.badge { font-weight: 600; border-radius: 999px; padding: .32em .65em; font-size: .72rem; letter-spacing: .01em; }
.badge-soft { display: inline-flex; align-items: center; gap: .35em; }
.badge-soft::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-soft.tone-primary, .badge-soft.tone-success, .badge-soft.tone-warning, .badge-soft.tone-danger, .badge-soft.tone-info, .badge-soft.tone-muted { }

/* ===== Empty state ===== */
.empty { text-align: center; padding: 3rem 1.5rem; }
.empty .empty-icon { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; margin: 0 auto 1rem; font-size: 1.5rem; }
.empty h3 { font-size: 1.05rem; font-weight: 600; }
.empty p { color: var(--et-muted); max-width: 420px; margin: .25rem auto 1.25rem; }

/* ===== Onboarding checklist ===== */
.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li { display: flex; align-items: center; gap: .85rem; padding: .85rem 1.25rem; border-top: 1px solid var(--et-border); }
.checklist li:first-child { border-top: 0; }
.checklist .check { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--et-border); display: grid; place-items: center; flex-shrink: 0; font-size: .8rem; }
.checklist li.done .check { background: #10b981; border-color: #10b981; color: #fff; }
.checklist li.done .title { color: var(--et-muted); text-decoration: line-through; }
.checklist .title { font-weight: 500; }

/* ===== Dropzone ===== */
.dropzone { position: relative; border: 2px dashed var(--et-border); border-radius: var(--et-radius); padding: 2rem 1rem; text-align: center; background: var(--et-surface-2); transition: border-color .15s, background .15s; cursor: pointer; }
.dropzone:hover, .dropzone.dragover { border-color: var(--et-primary); background: var(--et-primary-soft); }
.dropzone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dropzone .dz-icon { font-size: 2rem; color: var(--et-primary); }
.dropzone .dz-file { font-weight: 600; color: var(--et-text); }

/* ===== Tabs (pills) ===== */
.seg { display: inline-flex; background: var(--et-surface-2); border: 1px solid var(--et-border); border-radius: 12px; padding: 4px; gap: 2px; flex-wrap: wrap; }
.seg a, .seg button { border: 0; background: none; padding: .4rem .85rem; border-radius: 9px; color: var(--et-muted); font-weight: 500; font-size: .875rem; }
.seg a:hover, .seg button:hover { color: var(--et-text); text-decoration: none; }
.seg .active { background: var(--et-surface); color: var(--et-text); box-shadow: var(--et-shadow); }

/* Bootstrap only hides direct children (.tab-content > .tab-pane); settings panes sit inside a <form> */
.tab-content .tab-pane:not(.active) { display: none; }

/* ===== Progress ===== */
.progress { background: var(--et-surface-2); border-radius: 999px; }
.progress-bar { background: var(--et-primary); border-radius: 999px; transition: width .4s ease; }

/* ===== Template editor ===== */
.tag-btn { font-family: var(--bs-font-monospace); font-size: .75rem; padding: .2rem .5rem; }
textarea.code { font-family: var(--bs-font-monospace); font-size: .82rem; line-height: 1.5; }
.preview-shell { background: var(--et-surface-2); border-radius: 12px; padding: 1rem; display: flex; justify-content: center; }
.preview-frame { width: 100%; height: 640px; border: 1px solid var(--et-border); border-radius: 10px; background: #fff; transition: width .25s ease; }
.preview-shell.mobile .preview-frame { width: 375px; }
.preview-subject { font-size: .85rem; padding: .6rem .9rem; border-bottom: 1px solid var(--et-border); }

/* ===== Logs ===== */
.log-view { background: #0b1020; color: #cbd5e1; font-family: var(--bs-font-monospace); font-size: .78rem; line-height: 1.6; padding: 1rem 1.25rem; height: 60vh; overflow: auto; border-radius: 0 0 var(--et-radius) var(--et-radius); white-space: pre-wrap; word-break: break-word; }
.log-view .ln-time { color: #64748b; }
.log-view .ln-err { color: #fca5a5; }
.log-view .ln-ok { color: #86efac; }
.log-view .ln-info { color: #93c5fd; }
.log-empty { color: #64748b; text-align: center; padding-top: 20vh; }

/* ===== Auth pages ===== */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-side { background: linear-gradient(135deg, #312e81, #6d28d9 60%, #a21caf); color: #fff; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between; }
.auth-side h2 { font-weight: 700; font-size: 2rem; line-height: 1.2; max-width: 420px; }
.auth-side ul { list-style: none; padding: 0; margin: 1.5rem 0 0; }
.auth-side li { display: flex; gap: .6rem; margin-bottom: .75rem; opacity: .92; }
.auth-main { display: grid; place-items: center; padding: 2rem 1rem; background: var(--et-surface); }
.auth-card { width: 100%; max-width: 380px; }
@media (max-width: 991.98px) { .auth-wrap { grid-template-columns: 1fr; } .auth-side { display: none; } }

/* ===== Toasts ===== */
.toast-container { z-index: 1090; }
.toast { border: 0; border-radius: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, .15); background: var(--et-surface); min-width: 300px; }
.toast .toast-body { display: flex; gap: .65rem; align-items: flex-start; padding: .9rem 1rem; }
.toast .toast-icon { font-size: 1.15rem; line-height: 1; }

/* ===== Misc ===== */
.kbd-hint { font-size: .75rem; color: var(--et-muted); }
.result-card { border-radius: 12px; padding: 1rem 1.1rem; border: 1px solid var(--et-border); background: var(--et-surface-2); }
.dl-grid { display: grid; grid-template-columns: max-content 1fr; gap: .5rem 1.25rem; margin: 0; }
.dl-grid dt { color: var(--et-muted); font-weight: 500; }
.dl-grid dd { margin: 0; }
.modal-content { border-radius: var(--et-radius); border: 0; background: var(--et-surface); }
.modal-header, .modal-footer { border-color: var(--et-border); }
.dropdown-menu { border-radius: 12px; border-color: var(--et-border); box-shadow: 0 10px 30px rgba(0, 0, 0, .1); padding: .35rem; background: var(--et-surface); }
.dropdown-item { border-radius: 8px; padding: .45rem .75rem; }
.pagination { --bs-pagination-border-radius: 8px; --bs-pagination-active-bg: var(--et-primary); --bs-pagination-active-border-color: var(--et-primary); --bs-pagination-bg: var(--et-surface); }
.spin { animation: spin 1s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Brand ===== */
.brand-icon { width: 34px; height: 34px; object-fit: contain; }
.brand-chip { width: 38px; height: 38px; border-radius: 10px; background: #fff; display: grid; place-items: center; }
.brand-chip img { width: 26px; height: 26px; }
.auth-main { grid-template-rows: 1fr auto; }
.auth-card { align-self: center; justify-self: center; }
.auth-logo { margin-bottom: 1.75rem; }
.auth-logo img { height: 44px; width: auto; display: block; }
/* the logo's dark lettering needs a light backdrop in dark mode */
[data-bs-theme="dark"] .auth-logo img { background: #fff; padding: 8px 14px; border-radius: 12px; box-sizing: content-box; }

/* ===== Footer ===== */
.app-footer { text-align: center; font-size: .8rem; color: var(--et-muted); padding: 1.25rem 1rem 1.5rem; }
.app-footer strong { color: var(--et-text); font-weight: 600; letter-spacing: .02em; }
.main .app-footer { margin-top: auto; border-top: 1px solid var(--et-border); }
