/* Minimal, self-hosted base CSS for SaaS base layout */
:root {
  --color-bg: #f8fafc;
  --color-surface: #ffffff;
  --color-border: #e2e8f0;
  --color-text: #0f172a;
  --color-text-muted: #64748b;
  --color-primary: #0284c7;
  --color-primary-hover: #0369a1;
  --color-danger: #e11d48;
  --color-success: #16a34a;
  --font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  --radius: 6px;
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
}

*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-family);
  background-color: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
}

.site-header {
  background-color: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.site-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--color-text);
  text-decoration: none;
}

.site-nav {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.site-nav a {
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: 0.95rem;
}

.site-nav a:hover {
  color: var(--color-primary);
}

.main-content {
  max-width: 800px;
  margin: 2rem auto;
  padding: 0 1rem;
}

.card {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-weight: 500;
  margin-bottom: 0.35rem;
  font-size: 0.95rem;
}

.form-control, input[type="text"], input[type="email"], input[type="password"], select, textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background-color: var(--color-surface);
  color: var(--color-text);
}

.btn {
  display: inline-block;
  font-weight: 500;
  text-align: center;
  padding: 0.5rem 1rem;
  font-size: 0.95rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
}

.btn-primary {
  background-color: var(--color-primary);
  color: #ffffff;
}

.btn-primary:hover {
  background-color: var(--color-primary-hover);
}

.btn-danger {
  background-color: var(--color-danger);
  color: #ffffff;
}

.btn-outline {
  background-color: transparent;
  border-color: var(--color-border);
  color: var(--color-text);
}

.messages {
  list-style: none;
  padding: 0;
  margin-bottom: 1.5rem;
}

.message {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
}

.message-success {
  background-color: #dcfce7;
  color: #14532d;
  border: 1px solid #bbf7d0;
}

.message-error {
  background-color: #ffe4e6;
  color: #881337;
  border: 1px solid #fecdd3;
}

.site-footer {
  text-align: center;
  padding: 2rem 0;
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

/* Session Table and Badges */
.session-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
}

.session-table th {
  padding: 0.5rem;
  border-bottom: 2px solid var(--color-border);
  text-align: left;
}

.session-table td {
  padding: 0.5rem;
  border-bottom: 1px solid var(--color-border);
}

.badge {
  display: inline-block;
  font-size: 0.8rem;
  padding: 2px 6px;
  border-radius: var(--radius);
  margin-left: 4px;
}

.badge-current {
  background-color: #e0f2fe;
  color: #0369a1;
}

.badge-status-queued,
.badge-status-sending {
  background-color: #f1f5f9;
  color: #475569;
}

.badge-status-sent {
  background-color: #e0f2fe;
  color: #0369a1;
}

.badge-status-delivered {
  background-color: #dcfce7;
  color: #15803d;
}

.badge-status-bounced,
.badge-status-failed,
.badge-status-complained,
.badge-status-suppressed {
  background-color: #fee2e2;
  color: #b91c1c;
}

.btn-sm {
  padding: 0.25rem 0.5rem;
  font-size: 0.85rem;
}

.text-muted {
  color: var(--color-text-muted);
  font-size: 0.85rem;
}


/* Workspace pages and account switcher (no inline styles: CSP style-src 'self') */
.account-switcher { display: inline-block; position: relative; }
.switcher-summary { cursor: pointer; padding: 0.25rem 0.5rem; }
.switcher-dropdown {
  position: absolute;
  left: 0;
  background: #fff;
  border: 1px solid var(--color-border);
  padding: 0.5rem;
  min-width: 220px;
  z-index: 100;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
.switcher-org-list { list-style: none; padding: 0; margin: 0; }
.switcher-org-item { margin-bottom: 0.75rem; }
.switcher-ws-list { list-style: none; padding-left: 1rem; margin: 0.25rem 0 0 0; }
.badge-client { font-size: 0.75rem; background: #eee; padding: 2px 4px; }

.inline-actions { display: flex; gap: 0.5rem; }
.search-form { margin-bottom: 1.5rem; }
.search-input { padding: 0.5rem; flex: 1; }
.pagination { margin-top: 1.5rem; }

.danger-card, .danger-zone {
  border: 1px solid var(--color-danger, #e53e3e);
  padding: 1.5rem;
  border-radius: var(--radius);
  margin-top: 1.5rem;
}
.danger-title { color: var(--color-danger, #e53e3e); }
.btn-danger { background-color: var(--color-danger, #e53e3e); color: #fff; }
.form-group-spaced { margin: 1.5rem 0; }
.form-actions-row { display: flex; gap: 1rem; }

/* Support Impersonation Banner (high-contrast red styling) */
.impersonation-banner {
  background-color: #991b1b;
  color: #ffffff;
  padding: 0.5rem 1.5rem;
  font-size: 0.9rem;
  border-bottom: 2px solid #7f1d1d;
  width: 100%;
}
.impersonation-banner-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.impersonation-banner-text {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.impersonation-target-name {
  font-weight: 700;
}
.impersonation-badge {
  background-color: #fee2e2;
  color: #991b1b;
  font-weight: 700;
  font-size: 0.75rem;
  padding: 2px 6px;
  border-radius: var(--radius);
  text-transform: uppercase;
}
.impersonation-time-remaining {
  font-variant-numeric: tabular-nums;
  opacity: 0.95;
}
.impersonation-end-form {
  margin: 0;
  display: inline-block;
}
.impersonation-end-button {
  background-color: #ffffff;
  color: #991b1b;
  border: 1px solid #fecaca;
  font-weight: 600;
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius);
  cursor: pointer;
}
.impersonation-end-button:hover {
  background-color: #fee2e2;
  color: #7f1d1d;
}

/* Navigation: sidebar, account menu, dashboard cards (no inline styles: CSP style-src 'self') */
.layout { display: block; }
.layout.has-sidebar {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 1.5rem;
  max-width: 1100px;
  margin: 2rem auto;
  padding: 0 1rem;
}
.layout.has-sidebar .main-content { margin: 0; max-width: none; padding: 0; }
.side-nav { font-size: 0.95rem; }
.side-nav-list { list-style: none; padding: 0; margin: 0 0 1rem 0; }
.side-nav-heading { font-weight: 600; margin: 1rem 0 0.25rem 0; color: var(--color-text-muted); }
.side-nav-link {
  display: block;
  padding: 0.35rem 0.6rem;
  border-radius: var(--radius);
  color: var(--color-text);
  text-decoration: none;
}
.side-nav-link:hover { background-color: var(--color-surface); }
.side-nav-link.is-active { background-color: var(--color-surface); font-weight: 600; }
.side-nav-link.is-disabled { color: var(--color-text-muted); cursor: not-allowed; }
.side-nav-hint { display: block; padding: 0 0.6rem 0.35rem; font-size: 0.8rem; }
.account-menu { position: relative; }
.account-menu-summary { cursor: pointer; padding: 0.25rem 0.5rem; list-style: none; }
.account-menu-list {
  position: absolute;
  right: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  list-style: none;
  margin: 0.25rem 0 0 0;
  padding: 0.5rem;
  min-width: 200px;
  z-index: 100;
}
.account-menu-list li { padding: 0.2rem 0; }
.nav-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; }
.nav-card h2 { margin-top: 0; font-size: 1.1rem; }
@media (max-width: 720px) {
  .layout.has-sidebar { grid-template-columns: 1fr; }
}

/* HTMX indicators and swap states */
.htmx-indicator,
.js-indicator {
  display: none;
}
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator,
.htmx-request .js-indicator,
.htmx-request.js-indicator {
  display: inline-block;
}
.htmx-swapping {
  opacity: 0.5;
  transition: opacity 200ms ease-out;
}
.htmx-settling {
  opacity: 1;
  transition: opacity 200ms ease-in;
}

/* Toast region (status & error notifications) */
.toast-region {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 400px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}
.toast-error {
  background-color: #991b1b;
  color: #ffffff;
  border: 1px solid #7f1d1d;
}
.toast-message {
  flex: 1;
}
.toast-action {
  background-color: #ffffff;
  color: #991b1b;
  border: none;
  cursor: pointer;
  font-weight: 600;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius);
}
.toast-close {
  background: transparent;
  border: none;
  color: inherit;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.8;
}
.toast-close:hover {
  opacity: 1;
}

/* Minimal public layout */
.public-layout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--color-background);
  color: var(--color-text);
}
.public-main {
  flex: 1;
  max-width: 800px;
  margin: 2rem auto;
  padding: 0 1rem;
  width: 100%;
}

