:root {
  /* Brand colors inspired by kiion.io */
  --bg-left: #0FA7AC;     /* teal */
  --bg-right: #0E3A66;    /* marine */
  --surface: #f8fafc;     /* light app background (slate-50) */
  --card: #ffffff;        /* card/background surfaces */
  --accent: #0FA7AC;      /* primary brand (teal) */
  --accent2: #0E3A66;     /* secondary brand (marine) */
  --text: #111827;        /* gray-900 */
  --muted: #6b7280;       /* gray-500 */
  --error: #dc2626;       /* red-600 */
  --success: #059669;     /* emerald-600 */

  /* Header (top nav) */
  --header-bg: #ffffff;
  --header-border: #e5e7eb;

  /* Buttons (primary) */
  --button-bg: var(--accent);
  --button-bg-hover: #0b9094;
  --button-bg-active: #0a7f82;

  /* Inputs/editor background (light) */
  --input-bg: #ffffff;

  font-family: "Inter", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
body {
  /* Light base with a very subtle brand wash */
  background:
    linear-gradient(120deg, rgba(15,167,172,0.06) 0%, rgba(14,58,102,0.06) 100%),
    var(--surface);
  color: var(--text);
  margin: 0;
  min-height: 100vh;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--header-bg);
  position: sticky;
  top: 0;
  border-bottom: 1px solid var(--header-border);
  z-index: 10;
}

.brand { font-weight: 700; letter-spacing: 0.04em; color: var(--text); }
.user-info { color: var(--muted); }
.header-right { display: flex; align-items: center; gap: 10px; }

.nav { display: flex; gap: 8px; align-items: center; }
.nav a {
  color: var(--text);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid transparent;
}
.nav a:hover { background: #f3f4f6; border-color: #e5e7eb; }
.nav a.active { background: rgba(15,167,172,0.12); border-color: rgba(15,167,172,0.35); }

main { max-width: 1200px; margin: 32px auto; padding: 0 16px; }

.card {
  background: var(--card);
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 20px;
  box-shadow: 0 6px 24px rgba(2,6,23,0.06);
}

.page > .card { margin-bottom: 0; }

h2, h3 { margin-top: 0; }

label { display: block; margin-bottom: 10px; font-size: 0.95rem; }
label input, textarea, select {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid #e5e7eb;
  color: var(--text);
  padding: 10px;
  border-radius: 8px;
  margin-top: 6px;
}

/* Placeholder readability on marine input background */
label input::placeholder,
textarea::placeholder,
select::placeholder { color: var(--muted); opacity: 1; }

/* Focus state for inputs */
label input:focus,
textarea:focus,
select:focus { outline: none; border-color: rgba(15,167,172,0.7); box-shadow: 0 0 0 3px rgba(15,167,172,0.2); }

/* Do not force checkboxes/radios to full width; keep them inline and left-aligned */
label input[type="checkbox"],
label input[type="radio"] {
  width: auto;
  padding: 0;
  margin: 0 6px 0 0;
}

textarea { min-height: 110px; resize: vertical; }

button {
  background: var(--button-bg);
  border: none;
  color: #ffffff;
  padding: 10px 14px;
  border-radius: 10px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 6px;
  box-shadow: 0 6px 18px rgba(2,6,23,0.10);
  transition: transform 0.05s ease, box-shadow 0.15s ease, background-color 0.15s ease, opacity 0.2s ease;
}

button:hover {
  background: var(--button-bg-hover);
  box-shadow: 0 8px 24px rgba(2,6,23,0.14);
}

button:active {
  transform: translateY(1px);
  background: var(--button-bg-active);
}

button:disabled,
button[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
}

button.ghost {
  background: #ffffff;
  color: var(--text);
  border: 1px solid #e5e7eb;
}

button.ghost:hover {
  background: #f9fafb;
  border-color: #d1d5db;
}

.editor { height: 180px; margin: 10px 0 6px 0; background: var(--input-bg); }
/* Ensure Quill internal containers do not override the background */
.editor .ql-container,
.editor .ql-editor { background: transparent; color: var(--text); }

/* Editor toolbar and toggle */
.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0 6px 0;
}
.toggle { display: inline-flex; background: #ffffff; border: 1px solid #e5e7eb; border-radius: 8px; }
.toggle-btn {
  background: transparent;
  color: var(--text);
  border: none;
  padding: 6px 10px;
  margin: 0;
  border-right: 1px solid #e5e7eb;
}
.toggle-btn:last-child { border-right: none; }
.toggle-btn.active { background: rgba(15,167,172,0.12); color: var(--text); border-color: rgba(15,167,172,0.35); }

/* Raw editor area */
#editor-raw, #send-editor-raw { min-height: 180px; resize: vertical; background: var(--input-bg); color: var(--text); border: 1px solid #e5e7eb; }

.list { margin-top: 10px; max-height: 240px; overflow: auto; border-top: 1px solid #e5e7eb; padding-top: 10px; }
.list-item { padding: 8px 6px; border-bottom: 1px solid #e5e7eb; display: flex; justify-content: space-between; align-items: center; }
.list-item small { color: var(--muted); }

.muted { color: var(--muted); font-size: 0.9rem; }
.error { color: var(--error); margin-top: 8px; }
.hidden { display: none; }
.import textarea { margin-top: 6px; }

#template-status, #ses-status, #send-status { min-height: 20px; }

/* Links in muted blocks */
.muted a,
.muted a:visited { color: #0f766e; text-decoration: underline; }
.muted a:hover,
.muted a:focus { color: #115e59; }

/* Sent emails layout */
.sent-layout {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 16px;
  margin-top: 12px;
}
.sent-detail-panel {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 12px;
  background: #fafafa;
  min-height: 260px;
}
.sent-preview {
  margin-top: 10px;
  padding: 12px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #ffffff;
  min-height: 120px;
}
.sent-detail-actions {
  margin: 8px 0;
}
.pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.pill {
  background: rgba(15,167,172,0.14);
  color: var(--text);
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.85rem;
}

@media (max-width: 900px) {
  .sent-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  header { flex-direction: column; gap: 8px; align-items: flex-start; }
  .grid { grid-template-columns: 1fr; }
}
