/* ===== Global Reset & Base ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-body: #f5f7fb;
  --bg-card: #ffffff;
  --bg-sidebar: #ffffff;
  --border-subtle: #e4e7f0;
  --text-main: #111827;
  --text-muted: #6b7280;
  --accent: #6366f1;
  --accent-soft: #eef2ff;
  --accent-strong: #4f46e5;
  --accent-gradient: linear-gradient(90deg, #6366f1, #a855f7);
  --success: #22c55e;
  --warning: #facc15;
  --danger: #ef4444;
  --radius-lg: 16px;
  --shadow-soft: 0 22px 70px rgba(15, 23, 42, 0.09);
  --shadow-light: 0 12px 30px rgba(15, 23, 42, 0.08);
  --font-main: system-ui, -apple-system, BlinkMacSystemFont, "Inter", sans-serif;
  --landing-bg-start: #f6f4ff;
  --landing-bg-end: #f3f7ff;
  --card-border: rgba(15, 23, 42, 0.08);
  --card-shadow: 0 18px 60px rgba(15, 23, 42, 0.07);
  --card-surface: rgba(255, 255, 255, 0.82);
  --card-gradient-soft: linear-gradient(135deg, rgba(99, 102, 241, 0.09), rgba(14, 165, 233, 0.07));
  --landing-card-text: #111827;
  --landing-card-muted: rgba(17, 24, 39, 0.72);
}

/* Dark mode */
[data-theme="dark"] {
  --bg-body: #0f172a;
  --bg-card: #1e293b;
  --bg-sidebar: #1e293b;
  --border-subtle: #334155;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --accent: #818cf8;
  --accent-soft: #312e81;
  --accent-strong: #6366f1;
  --success: #4ade80;
  --warning: #facc15;
  --danger: #f87171;
  --shadow-soft: 0 18px 45px rgba(0, 0, 0, 0.4);
  --shadow-light: 0 8px 20px rgba(0, 0, 0, 0.3);
  --landing-card-text: #050505;
  --landing-card-muted: rgba(5, 5, 5, 0.68);
}

html,
body {
  height: 100%;
}

body {
  font-family: var(--font-main);
  background: var(--bg-body);
  color: var(--text-main);
  display: flex;
}

/* ===== Sidebar (Admin Pages) ===== */

body > aside {
  width: 260px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
}

body > aside h1 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent-strong);
}

body > aside p {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.aside-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.aside-logo .brand-logo {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: conic-gradient(from 180deg, #6366f1, #a855f7, #22c55e, #6366f1);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 25px rgba(59,130,246,0.3);
  flex-shrink: 0;
}

.aside-logo .brand-logo span {
  font-size: 16px;
  font-weight: 700;
  color: #f9fafb;
}

body > aside nav ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

body > aside nav a {
  display: block;
  text-decoration: none;
  font-size: 0.95rem;
  color: var(--text-muted);
  padding: 10px 12px;
  border-radius: 999px;
  transition: background 0.15s ease, color 0.15s ease;
}

body > aside nav a:hover,
body > aside nav a:focus {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

body > aside footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.85rem;
}

/* ===== Main Layout (Admin Pages) ===== */

body > main {
  margin-left: 260px;
  flex: 1;
  padding: 24px 32px;
  display: flex;
  flex-direction: column;
}

/* Header inside main (admin) */
body > main > header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  width: 100%;
}

body > main > header h1 {
  font-size: 1.6rem;
  margin-bottom: 4px;
  flex: 1;
}

body > main > header p {
  font-size: 0.9rem;
  color: var(--text-muted);
  flex: 1;
}

body > main > header nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
}

body > main > header nav div,
body > main > header > div {
  display: flex;
  gap: 12px;
  align-items: center;
}

body > main > header a {
  text-decoration: none;
  font-size: 0.9rem;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  background: #fff;
  box-shadow: var(--shadow-light);
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

body > main > header a:hover {
  background: var(--accent-gradient);
  color: #fff;
  box-shadow: var(--shadow-soft);
}

/* ===== Dashboard – Stats Cards ===== */

/* Wrapper for first group of divs after header on dashboard */
body > main > header + div {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
  width: 100%;
}

body > main > header + div > div {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-light);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

body > main > header + div > div p:first-child {
  font-size: 0.8rem;
  color: var(--success);
  font-weight: 600;
  text-align: right;
}

body > main > header + div > div p:nth-child(2) {
  font-size: 1.4rem;
  font-weight: 700;
}

body > main > header + div > div h,
body > main > header + div > div h2,
body > main > header + div > div h3 {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Modal (Add User) */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
}

.modal-overlay.open {
  display: flex;
}

.modal-card {
  background: var(--bg-card);
  border-radius: 18px;
  box-shadow: var(--shadow-soft);
  max-width: 420px;
  width: 100%;
  padding: 24px;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  border: none;
  background: transparent;
  font-size: 1.25rem;
  cursor: pointer;
  color: var(--text-muted);
}

.modal-card label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.9rem;
  color: var(--text-main);
}

.modal-card input,
.modal-card select {
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  padding: 9px 10px;
  font-size: 0.95rem;
  background: var(--bg-body);
  color: var(--text-main);
}

.modal-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.modal-message {
  min-height: 18px;
  font-size: 0.85rem;
  margin-top: 4px;
}

.modal-message.success {
  color: var(--success);
}

.modal-message.error {
  color: var(--danger);
}

/* ===== Dashboard – Chart Card ===== */

.Chart {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-light);
  min-height: 260px;
  margin-bottom: 24px;
  padding: 18px 20px;
}

/* ===== Dashboard – Popular Languages ===== */

main h2 {
  font-size: 1.1rem;
  margin-bottom: 8px;
}

main > div:nth-of-type(3),
/* generic section container after .Chart */
main section {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-light);
  padding: 18px 20px;
  margin-bottom: 24px;
  width: 100%;
}

/* Specific for the Popular Languages list in dashboard */
main > div:nth-of-type(3) ul {
  list-style: none;
  margin-top: 8px;
}

main > div:nth-of-type(3) li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border-subtle);
}

main > div:nth-of-type(3) li:last-child {
  border-bottom: none;
}

main > div:nth-of-type(3) li span:first-child {
  min-width: 90px;
}

main > div:nth-of-type(3) li div {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: #e5e7eb;
  position: relative;
  overflow: hidden;
}

/* Simple purple bar */
main > div:nth-of-type(3) li div::before {
  content: "";
  position: absolute;
  inset: 0;
  width: 70%;
  background: var(--accent-gradient);
}

/* ===== Dashboard – Recent Operations ===== */

main > div:last-of-type {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-light);
  padding: 18px 20px;
  width: 100%;
}

main > div:last-of-type > p {
  font-weight: 600;
  margin-bottom: 12px;
}

.history-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.history-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.history-heading p {
  font-weight: 600;
  font-size: 1rem;
  margin: 0;
}

.text-link {
  border: none;
  background: transparent;
  color: var(--accent-strong);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  padding: 4px 6px;
}

.text-link:hover {
  text-decoration: underline;
}

.ghost-btn {
  align-self: flex-start;
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  padding: 8px 18px;
  font-size: 0.9rem;
  background: transparent;
  color: var(--text-main);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.ghost-btn:hover {
  background: var(--accent-soft);
  color: var(--accent-strong);
  border-color: var(--accent-strong);
}

/* ===== Tables (Logs, Users, Recent Ops) ===== */

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

thead tr {
  background: #f9fafb;
}

th,
td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}

tbody tr:hover {
  background: #f3f4ff;
}

/* Status badges */
td:nth-child(4) {
  font-size: 0.8rem;
}

td:nth-child(4)::before {
  content: attr(data-status);
}

/* You can instead add classes in HTML:
   <td class="badge active">Active</td>
*/
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
}

.badge.active {
  background: #dcfce7;
  color: #15803d;
}

.badge.inactive {
  background: #e5e7eb;
  color: #4b5563;
}

/* Delete buttons / actions */
table button {
  border: none;
  background: transparent;
  color: var(--danger);
  cursor: pointer;
  font-size: 0.85rem;
}

/* ===== Model Settings ===== */

section > div {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-light);
  padding: 16px 18px;
  margin-bottom: 16px;
}

section > div h2 {
  font-size: 1rem;
  margin-bottom: 4px;
}

section > div p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

/* Select and inputs */
select,
input[type="text"],
input[type="number"] {
  width: 100%;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  font-size: 0.9rem;
  outline: none;
}

select:focus,
input[type="text"]:focus,
input[type="number"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.2);
}

.temperature-slider {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 10px;
}

.temperature-slider input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.temperature-slider [data-temp-value] {
  font-weight: 600;
  min-width: 48px;
  text-align: center;
}

.form-status {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: 0 0 6px;
}

.form-status.error {
  color: var(--danger);
}

/* Checkbox */
input[type="checkbox"] {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
  vertical-align: middle;
  margin-right: 6px;
}

/* Charts grid styling */
.charts-grid .chart-card {
  background: var(--bg-card);
  border-radius: 12px;
  box-shadow: var(--shadow-light);
  padding: 16px;
  min-height: 220px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
}

.charts-grid .chart-card canvas {
  width: 100% !important;
  height: 240px !important;
  max-height: 300px;
}

@media (max-width: 700px){
  .charts-grid .chart-card canvas { height: 200px !important; }
}

.chart-caption {
  font-size: 0.95rem;
  font-weight: 600;
  text-align: center;
  color: var(--text-main);
  letter-spacing: 0.01em;
}

/* Save Settings button (footer of model settings) */
main > footer {
  margin-top: 12px;
  text-align: right;
}

main > footer button,
main > footer buttton {
  /* 'buttton' handles the typo in HTML */
  padding: 10px 20px;
  border-radius: 999px;
  border: none;
  font-size: 0.95rem;
  color: #fff;
  background-image: var(--accent-gradient);
  cursor: pointer;
  box-shadow: var(--shadow-soft);
}

/* ===== Logs Page ===== */

main section > div:first-of-type p {
  font-weight: 600;
  margin-bottom: 8px;
}

/* ===== User Management Page ===== */

section > div:first-of-type {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

section > div:first-of-type h2 {
  font-size: 1.1rem;
}

section > div:first-of-type button {
  padding: 8px 14px;
  border-radius: 999px;
  border: none;
  font-size: 0.9rem;
  color: #fff;
  background-image: var(--accent-gradient);
  cursor: pointer;
  box-shadow: var(--shadow-light);
}

/* ===== Landing Page (Marketing) ===== */

body:not(:has(> aside)) {
  /* When there is no sidebar (landing page), undo flex layout */
  display: block;
  min-height: 100vh;
  background: linear-gradient(180deg, var(--landing-bg-start) 0%, var(--landing-bg-end) 100%);
  padding-bottom: 48px;
}

/* Top nav */
body:not(:has(> aside)) header nav {
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.45);
}

body:not(:has(> aside)) header nav span {
  font-weight: 700;
  font-size: 1.4rem;
  color: var(--accent-strong);
}

body:not(:has(> aside)) header nav a {
  text-decoration: none;
  margin-left: 14px;
  font-size: 0.95rem;
  color: var(--text-muted);
}

body:not(:has(> aside)) main {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 72px;
  padding: 0 32px 60px;
}

/* Hero section */
body:not(:has(> aside)) main > section:first-of-type {
  width: 100%;
  margin: 32px auto 0;
  padding: 40px 48px 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 22px;
  background: var(--card-gradient-soft), var(--card-surface);
  border: 1px solid var(--card-border);
  border-radius: 32px;
  box-shadow: var(--card-shadow);
  backdrop-filter: blur(16px);
  color: var(--landing-card-text);
}

body:not(:has(> aside)) main > section:first-of-type h1 {
  font-size: 2.1rem;
  max-width: 620px;
  text-align: center;
  line-height: 1.25;
  color: var(--landing-card-text);
}

body:not(:has(> aside)) main > section:first-of-type p {
  max-width: 560px;
  color: var(--landing-card-muted);
  font-size: 0.95rem;
  text-align: center;
  line-height: 1.6;
}

body:not(:has(> aside)) main > section:first-of-type button {
  margin-top: 4px;
  padding: 10px 18px;
  border-radius: 999px;
  border: none;
  font-size: 0.95rem;
  cursor: pointer;
  min-width: 200px;
  align-self: center;
}

body:not(:has(> aside)) main > section:first-of-type button:first-of-type {
  background-image: var(--accent-gradient);
  color: #fff;
  box-shadow: var(--shadow-soft);
  margin-right: 8px;
}

body:not(:has(> aside)) main > section:first-of-type button:last-of-type {
  background: linear-gradient(90deg, #6366f1, #a855f7);
  border: 1px solid var(--border-subtle);
}

/* Code example + explanation block */
body:not(:has(> aside)) main > section:nth-of-type(2) > div {
  max-width: 1120px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 24px;
  background: var(--card-gradient-soft), var(--card-surface);
  border-radius: 28px;
  border: 1px solid var(--card-border);
  box-shadow: var(--card-shadow);
  padding: 28px 32px;
  backdrop-filter: blur(12px);
  color: var(--landing-card-text);
}

body:not(:has(> aside)) main > section:nth-of-type(2) {
  width: 100%;
  margin: 0 auto;
}

body:not(:has(> aside)) pre {
  background: #0f172a;
  color: #e5e7eb;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 0.85rem;
  overflow-x: auto;
}

/* “Why choose” & “How it works” sections */
body:not(:has(> aside)) main > section:nth-of-type(3),
body:not(:has(> aside)) main > section:nth-of-type(4) {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 32px 32px 0;
}

body:not(:has(> aside)) main > section:nth-of-type(3) h2,
body:not(:has(> aside)) main > section:nth-of-type(4) h2 {
  margin: 12px 0 18px;
  text-align: center;
}

body:not(:has(> aside)) main > section:nth-of-type(3) > div,
body:not(:has(> aside)) main > section:nth-of-type(4) > div {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
}

body:not(:has(> aside)) main > section:nth-of-type(3) > div > div,
body:not(:has(> aside)) main > section:nth-of-type(4) > div > div {
  background: var(--card-gradient-soft), var(--card-surface);
  border-radius: 20px;
  padding: 20px 20px 22px;
  border: 1px solid var(--card-border);
  box-shadow: var(--card-shadow);
  backdrop-filter: blur(10px);
  font-size: 0.9rem;
  color: var(--landing-card-text);
}

body:not(:has(> aside)) main > section:nth-of-type(3) > div > div h4,
body:not(:has(> aside)) main > section:nth-of-type(4) > div > div h4,
body:not(:has(> aside)) main > section:nth-of-type(4) > div > div h3,
body:not(:has(> aside)) main > section:nth-of-type(4) > div > div strong,
body:not(:has(> aside)) main > section:nth-of-type(3) > div > div strong {
  color: var(--landing-card-text);
}

body:not(:has(> aside)) main > section:nth-of-type(3) > div > div p,
body:not(:has(> aside)) main > section:nth-of-type(4) > div > div p,
body:not(:has(> aside)) main > section:nth-of-type(3) > div > div span,
body:not(:has(> aside)) main > section:nth-of-type(4) > div > div span {
  color: var(--landing-card-text);
}

body:not(:has(> aside)) main > section:nth-of-type(4) h3 {
  font-size: 1.5rem;
  margin-bottom: 4px;
}

/* Landing footer */
body:not(:has(> aside)) footer {
  border-top: 1px solid var(--border-subtle);
  margin-top: 32px;
  padding: 24px 20px;
  font-size: 0.9rem;
}

body:not(:has(> aside)) footer > div {
  max-width: 1120px;
  margin: 0 auto 12px;
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}

body:not(:has(> aside)) footer > div:first-of-type {
  align-items: center;
}

body:not(:has(> aside)) footer ul {
  list-style: none;
  margin-top: 6px;
}

body:not(:has(> aside)) footer li {
  margin-bottom: 4px;
}

body:not(:has(> aside)) footer small {
  display: block;
  max-width: 1120px;
  margin: 0 auto;
  color: var(--text-muted);
}

/* ===== Improved Site Footer ===== */
.site-footer {
  border-top: 1px solid var(--border-subtle);
  background: transparent;
  padding: 32px 20px 20px;
  color: var(--text-main);
}
.site-footer__inner {
  max-width: 1120px;
  margin: 0 auto;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: flex-start;
  gap: 40px;
}
.footer-column {
  flex: 1;
  min-width: 0;
}
.footer-column h4 {
  font-size: 0.95rem;
  margin-bottom: 12px;
  color: var(--text-main);
  font-weight: 600;
}
.footer-column ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.footer-column ul li {
  margin-bottom: 10px;
}
.footer-column a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.15s ease;
}
.footer-column a:hover,
.footer-column a:focus {
  color: var(--accent-strong);
}
.footer-brand .brand-name {
  display: block;
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--accent-strong);
  margin-bottom: 8px;
}
.footer-brand .brand-tag {
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.5;
}
.site-footer__bar {
  max-width: 1120px;
  margin: 18px auto 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
}
.site-footer__social a {
  margin-right: 10px;
  font-size: 1.1rem;
  text-decoration: none;
}

@media (max-width: 900px) {
  .site-footer__inner {
    flex-direction: row;
    gap: 30px;
  }
  .footer-column {
    flex: 0 1 calc(33.333% - 20px);
  }
}

@media (max-width: 640px) {
  .site-footer__inner {
    flex-direction: column;
    gap: 24px;
  }
  .footer-column {
    flex: 1 1 auto;
  }
  .site-footer__bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
}

/* ===== Aside footer small improvements ===== */
.aside-footer a {
  color: var(--text-main);
  text-decoration: none;
}
.aside-footer a:hover,
.aside-footer a:focus {
  color: var(--accent-strong);
}

/* ===== Dark Mode Theme Overrides ===== */
[data-theme="dark"] body {
  background: var(--bg-body);
  color: var(--text-main);
}

[data-theme="dark"] aside {
  background: var(--bg-sidebar);
  border-right-color: var(--border-subtle);
}

[data-theme="dark"] aside h1 {
  color: var(--accent-strong);
}

[data-theme="dark"] aside p {
  color: var(--text-muted);
}

[data-theme="dark"] aside nav a {
  color: var(--text-muted);
}

[data-theme="dark"] aside nav a:hover,
[data-theme="dark"] aside nav a:focus {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

[data-theme="dark"] aside footer,
[data-theme="dark"] .aside-footer {
  border-top-color: var(--border-subtle);
}

[data-theme="dark"] main {
  background: var(--bg-body);
  color: var(--text-main);
}

[data-theme="dark"] main header {
  background: var(--bg-body);
}

[data-theme="dark"] main header h1,
[data-theme="dark"] main header p {
  color: var(--text-main);
}

[data-theme="dark"] main header a {
  background: var(--bg-card);
  color: var(--text-main);
  border-color: var(--border-subtle);
}

[data-theme="dark"] main header a:hover {
  background: var(--accent-gradient);
  color: #fff;
}

[data-theme="dark"] main > div > div {
  background: var(--bg-card);
  box-shadow: var(--shadow-light);
}

[data-theme="dark"] main > div > div p {
  color: var(--text-main);
}

[data-theme="dark"] main > div > div h,
[data-theme="dark"] main > div > div h2 {
  color: var(--text-muted);
}

[data-theme="dark"] main > div > p {
  color: var(--text-main);
}

[data-theme="dark"] main h2 {
  color: var(--text-main);
}

[data-theme="dark"] .chart-card {
  background: var(--bg-card);
  box-shadow: var(--shadow-light);
}

[data-theme="dark"] table {
  background: var(--bg-card);
  color: var(--text-main);
}

[data-theme="dark"] thead tr {
  background: rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] th,
[data-theme="dark"] td {
  color: var(--text-main);
  border-bottom-color: var(--border-subtle);
}

[data-theme="dark"] tbody tr:hover {
  background: rgba(99, 102, 241, 0.15);
}

[data-theme="dark"] table button {
  color: var(--danger);
}

[data-theme="dark"] section {
  background: transparent;
  color: var(--text-main);
}

[data-theme="dark"] section > div {
  background: var(--bg-card);
  box-shadow: var(--shadow-light);
}

[data-theme="dark"] section > div > div {
  background: var(--bg-card);
  border-color: var(--border-subtle);
  color: var(--text-main);
}

[data-theme="dark"] section > div > div h4,
[data-theme="dark"] section > div h2 {
  color: var(--text-main);
}

[data-theme="dark"] section > div > div p,
[data-theme="dark"] section > div p {
  color: var(--text-muted);
}

[data-theme="dark"] section > div > div span {
  color: var(--text-muted);
}

[data-theme="dark"] pre {
  background: var(--bg-card);
  color: var(--text-main);
  border-color: var(--border-subtle);
}

[data-theme="dark"] .modal {
  background: var(--bg-card);
  color: var(--text-main);
}

[data-theme="dark"] .modal input {
  background: var(--bg-body);
  border-color: var(--border-subtle);
  color: var(--text-main);
}

[data-theme="dark"] .modal input::placeholder {
  color: var(--text-muted);
}

[data-theme="dark"] .modal-overlay {
  background: rgba(0, 0, 0, 0.65);
}

[data-theme="dark"] footer {
  background: var(--bg-body);
  color: var(--text-main);
  border-top-color: var(--border-subtle);
}

[data-theme="dark"] footer h4 {
  color: var(--text-main);
}

[data-theme="dark"] footer p {
  color: var(--text-muted);
}

[data-theme="dark"] footer a {
  color: var(--accent);
}

[data-theme="dark"] footer a:hover {
  color: var(--accent-strong);
}

[data-theme="dark"] select,
[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="number"] {
  background: var(--bg-body);
  color: var(--text-main);
  border-color: var(--border-subtle);
}

[data-theme="dark"] select:focus,
[data-theme="dark"] input[type="text"]:focus,
[data-theme="dark"] input[type="number"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.2);
}

[data-theme="dark"] input[type="checkbox"] {
  border-color: var(--border-subtle);
}

[data-theme="dark"] button {
  background: var(--accent-gradient);
  color: #fff;
}

[data-theme="dark"] button:hover {
  opacity: 0.92;
}

[data-theme="dark"] .icon-btn {
  background: var(--bg-card);
  color: var(--text-muted);
  border-color: var(--border-subtle);
}

[data-theme="dark"] .icon-btn:hover {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

/* ===== Email Form Styles ===== */
.email-section,
.email-history-section {
  margin-bottom: 24px;
  width: 100%;
}

.email-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-light);
  padding: 24px;
  width: 100%;
}

.email-card h2 {
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text-main);
}

.email-history-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.email-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  width: 100%;
}

.email-history-header h2 {
  margin: 0;
  text-align: left;
  margin-right: auto;
}

.email-history-header .text-link {
  padding: 4px 0;
  display: inline-flex;
  align-items: center;
}

.email-history-footer {
  display: flex;
  justify-content: center;
  margin-top: 8px;
}

.show-more-history-btn {
  min-width: 180px;
  justify-content: center;
  display: inline-flex;
  align-items: center;
}

.section-subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 20px;
}

/* Charts Grid for dashboard */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
  margin: 18px 0;
  width: 100%;
}

.email-form {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group:has(textarea) {
  grid-column: 1 / -1;
}

.form-group:has(#email-body) {
  grid-column: 1 / -1;
}

.form-group:last-of-type {
  grid-column: 1 / -1;
}

.form-group label {
  font-weight: 500;
  color: var(--text-main);
  font-size: 0.95rem;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group select,
.form-group textarea {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-body);
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input[type="text"]:focus,
.form-group input[type="email"]:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

.form-group textarea {
  resize: vertical;
  min-height: 150px;
  font-family: "Monaco", "Courier New", monospace;
}

.form-help {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Custom Users List */
.users-list-container {
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 12px;
  background: var(--bg-body);
  max-height: 200px;
  overflow-y: auto;
}

.user-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  margin-bottom: 4px;
}

.user-item input[type="checkbox"] {
  cursor: pointer;
  width: 16px;
  height: 16px;
}

.user-item label {
  cursor: pointer;
  margin: 0;
  font-weight: normal;
  font-size: 0.9rem;
}

/* Preview Section */
.preview-section {
  cursor: pointer;
  user-select: none;
}

.preview-section summary {
  padding: 10px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 500;
  margin-bottom: 10px;
  transition: background 0.2s;
}

.preview-section summary:hover {
  background: rgba(99, 102, 241, 0.2);
}

.email-preview {
  background: var(--bg-body);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 12px;
  margin-top: 8px;
}

.preview-header {
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.preview-header strong {
  color: var(--text-main);
}

.preview-header span {
  color: var(--text-muted);
  margin-left: 8px;
}

.preview-body {
  color: var(--text-main);
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Form Actions */
.form-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 12px;
  grid-column: 1 / -1;
}

.btn-primary,
.btn-secondary {
  padding: 10px 18px;
  border-radius: 8px;
  border: none;
  font-weight: 500;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-primary {
  background: var(--accent-gradient);
  color: #fff;
}

.btn-primary:hover {
  opacity: 0.9;
  transform: translateY(-1px);
  box-shadow: var(--shadow-light);
}

.btn-secondary {
  background: var(--bg-body);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
}

.btn-secondary:hover {
  background: var(--accent-soft);
  color: var(--accent-strong);
  border-color: var(--accent);
}

/* Email History Table */
.email-history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.email-history-table thead tr {
  background: rgba(0, 0, 0, 0.02);
}

.email-history-table th,
.email-history-table td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-main);
}

.email-history-table tbody tr:hover {
  background: rgba(99, 102, 241, 0.06);
}

/* Status Badges */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-success {
  background: rgba(34, 197, 94, 0.15);
  color: var(--success);
}

.badge-info {
  background: rgba(99, 102, 241, 0.15);
  color: var(--accent-strong);
}

/* Dark Mode Support for Email Styles */
[data-theme="dark"] .email-card {
  background: var(--bg-card);
}

[data-theme="dark"] .form-group label {
  color: var(--text-main);
}

[data-theme="dark"] .form-group input[type="text"],
[data-theme="dark"] .form-group input[type="email"],
[data-theme="dark"] .form-group select,
[data-theme="dark"] .form-group textarea {
  background: var(--bg-body);
  color: var(--text-main);
  border-color: var(--border-subtle);
}

[data-theme="dark"] .form-group input:focus,
[data-theme="dark"] .form-group select:focus,
[data-theme="dark"] .form-group textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

[data-theme="dark"] .users-list-container {
  background: var(--bg-body);
  border-color: var(--border-subtle);
}

[data-theme="dark"] .user-item {
  color: var(--text-main);
}

[data-theme="dark"] .preview-section summary {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

[data-theme="dark"] .preview-section summary:hover {
  background: rgba(99, 102, 241, 0.2);
}

[data-theme="dark"] .email-preview {
  background: var(--bg-body);
  border-color: var(--border-subtle);
}

[data-theme="dark"] .preview-header {
  border-bottom-color: var(--border-subtle);
}

[data-theme="dark"] .preview-header strong {
  color: var(--text-main);
}

[data-theme="dark"] .preview-header span {
  color: var(--text-muted);
}

[data-theme="dark"] .preview-body {
  color: var(--text-main);
}

[data-theme="dark"] .btn-secondary {
  background: var(--bg-body);
  color: var(--text-main);
  border-color: var(--border-subtle);
}

[data-theme="dark"] .btn-secondary:hover {
  background: var(--accent-soft);
  color: var(--accent-strong);
  border-color: var(--accent);
}

[data-theme="dark"] .email-history-table thead tr {
  background: rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .email-history-table th,
[data-theme="dark"] .email-history-table td {
  color: var(--text-main);
  border-bottom-color: var(--border-subtle);
}

[data-theme="dark"] .email-history-table tbody tr:hover {
  background: rgba(99, 102, 241, 0.1);
}

[data-theme="dark"] .section-subtitle {
  color: var(--text-muted);
}

/* ===== Index Page Specific Styles ===== */
body {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
}

header nav {
  width: 100%;
  max-width: 1100px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 24px;
  position: relative;
}

.top-actions {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  gap: 10px;
  align-items: center;
}

/* Reusable icon button used for theme toggle and small actions */
.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  color: var(--text-muted);
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease, transform 0.12s;
}

.icon-btn:hover {
  background: var(--accent-soft);
  color: var(--accent-strong);
  transform: translateY(-1px);
}

.logo-section {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-main);
}

.logo-section .brand-logo {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: conic-gradient(from 180deg, #6366f1, #a855f7, #22c55e, #6366f1);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 25px rgba(59,130,246,0.3);
  flex-shrink: 0;
}

.logo-section .brand-logo span {
  font-size: 16px;
  font-weight: 700;
  color: #f9fafb;
}

#pageContent {
  width: 100%;
  max-width: 1100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
}

#pageContent section {
  width: 100%;
  max-width: 900px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 12px;
}

.site-footer__bar {
  width: 100%;
  max-width: 1100px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}

.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(8px);
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal {
  background: var(--bg-card);
  width: 420px;
  padding: 35px 40px;
  border-radius: 24px;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.15);
  animation: modalPop 0.28s ease-out;
  position: relative;
}

@keyframes modalPop {
  from {
    opacity: 0;
    transform: scale(0.85) translateY(15px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.close-btn {
  position: absolute;
  top: 14px;
  right: 18px;
  font-size: 22px;
  cursor: pointer;
  color: #777;
  transition: 0.2s;
}

[data-theme="dark"] .close-btn {
  color: #aaa;
}

.close-btn:hover {
  color: #333;
}

[data-theme="dark"] .close-btn:hover {
  color: #eee;
}

.modal h2 {
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 22px;
  background: linear-gradient(90deg, #6366f1, #a855f7);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.modal input {
  width: 100%;
  padding: 14px 16px;
  margin-bottom: 15px;
  border-radius: 14px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-body);
  font-size: 15px;
  transition: 0.2s;
  outline: none;
  color: var(--text-main);
}

.modal input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.15);
}

.modal input::placeholder {
  color: var(--text-muted);
}

.modal button {
  width: 100%;
  padding: 14px;
  margin-top: 5px;
  background: linear-gradient(to right, #6366f1, #a855f7);
  color: white;
  border: none;
  border-radius: 14px;
  font-size: 17px;
  cursor: pointer;
  font-weight: 600;
  transition: 0.25s;
}

.modal button:hover {
  opacity: 0.92;
  transform: translateY(-1px);
}

.blur {
  filter: blur(6px);
  transition: 0.3s ease;
}

/* Wrapper for Google button */
.google-btn {
  margin-top: 18px;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
}

/* Slight zoom for better visibility */
.google-btn > div {
  transform: scale(1.08);
}

/* OR divider text */
.google-divider {
  margin: 14px 0 8px;
  text-align: center;
  font-size: 13px;
  color: #6b7280;
  position: relative;
  width: 100%;
}

.google-divider::before,
.google-divider::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 42%;
  height: 1px;
  background: #e5e7eb;
}

.google-divider::before {
  left: 0;
}

.google-divider::after {
  right: 0;
}

