/* iDream — Application styles
   Requires tokens.css loaded before this file.
   Google Fonts imported here so a single <link> suffices for app.css. */

@import url("https://fonts.googleapis.com/css2?family=Montserrat:wght@500;600;700;800&family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap");

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

html { scroll-behavior: smooth; }

body {
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
  font-family: Montserrat, system-ui, sans-serif;
  color: var(--text);
}

/* Monospace: numbers, IDs, timestamps, log lines */
.id-mono, code, kbd, pre, samp,
[class*="font-mono"] {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
}

::selection { background: var(--cyan); color: #04222a; }

/* ─── Sidebar ────────────────────────────────────────────────── */
.id-sidebar {
  width: 248px;
  background: var(--sidebar);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset-block: 0;
  left: 0;
  z-index: 1000;
  overflow-y: auto;
}

/* Offcanvas override on mobile: keep sidebar colors */
.offcanvas.id-sidebar {
  width: 248px !important;
  background: var(--sidebar) !important;
}

.id-sidebar-brand {
  padding: 22px 20px;
  display: flex;
  align-items: center;
  gap: 11px;
  text-decoration: none;
  flex-shrink: 0;
}
.id-sidebar-brand-name {
  font-family: Montserrat, sans-serif;
  font-weight: 700;
  font-size: 19px;
  letter-spacing: -.02em;
  color: #fff;
  line-height: 1;
}
.id-sidebar-brand-name .id-i { color: var(--cyan); }

.id-sidebar-nav { flex: 1; padding: 6px 0; overflow-y: auto; }

.id-sidebar-section {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #5d7299;
  padding: 20px 20px 8px;
}

.id-nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  margin: 2px 8px;
  color: var(--sidebar-text);
  border-radius: 10px;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: background .13s, color .13s;
}
.id-nav-link .id-nav-icon {
  width: 18px;
  display: flex;
  justify-content: center;
  flex-shrink: 0;
}
.id-nav-link:hover  { background: rgba(255,255,255,.06); color: #fff; }
.id-nav-link.active { background: rgba(255,255,255,.10); color: var(--sidebar-active); }

.id-run-badge {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  background: var(--cyan);
  color: #042;
  padding: 1px 7px;
  border-radius: 8px;
  margin-left: auto;
  font-weight: 600;
}

/* ── Sidebar footer: user card ───────────────────────────────── */
.id-sidebar-footer {
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}
.id-user-card {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
  transition: background .13s;
}
.id-user-card:hover { background: rgba(255,255,255,.06); }
.id-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cyan), var(--cyan-2));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #042;
  font-weight: 700;
  font-size: 13px;
  font-family: "IBM Plex Sans", sans-serif;
  flex-shrink: 0;
}
.id-user-name {
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.id-user-div {
  color: #7388a8;
  font-size: 11px;
  font-family: "IBM Plex Mono", monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.id-signout-btn {
  display: block;
  width: 100%;
  text-align: center;
  margin-top: 8px;
  padding: 8px;
  font-size: 12px;
  color: #7388a8;
  font-family: "IBM Plex Mono", monospace;
  letter-spacing: .06em;
  background: none;
  border: none;
  cursor: pointer;
  transition: color .13s;
  text-decoration: none;
}
.id-signout-btn:hover { color: var(--sidebar-text); }

/* ─── Main wrapper ───────────────────────────────────────────── */
.id-main {
  margin-left: 248px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ─── Topbar ─────────────────────────────────────────────────── */
.id-topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 28px;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 30;
}
.id-topbar-title { flex: 1; min-width: 0; }
.id-breadcrumb {
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  color: var(--text-faint);
  margin-bottom: 1px;
}
.id-page-title {
  font-family: Montserrat, sans-serif;
  font-weight: 700;
  font-size: 19px;
  color: var(--text);
  letter-spacing: -.01em;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.id-topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.id-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 13px;
  width: 240px;
  transition: border-color .15s;
}
.id-search:focus-within { border-color: var(--border-strong); }
.id-search input {
  border: none;
  background: transparent;
  outline: none;
  color: var(--text);
  font-size: 13px;
  font-family: "IBM Plex Sans", sans-serif;
  width: 100%;
}
.id-search input::placeholder { color: var(--text-faint); }
.id-search-icon { color: var(--text-faint); flex-shrink: 0; }

.id-icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color .13s, color .13s;
}
.id-icon-btn:hover { border-color: var(--border-strong); color: var(--text); }

.id-sidebar-toggle {
  padding: 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ─── Content ────────────────────────────────────────────────── */
.id-content { flex: 1; padding: 26px 28px 60px; }

/* ─── Cards ──────────────────────────────────────────────────── */
.id-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
}
.id-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.id-card-title {
  font-family: Montserrat, sans-serif;
  font-weight: 600;
  font-size: 16px;
  color: var(--text);
}
.id-card:hover { border-color: var(--cyan-2); }

/* ─── Stat cards ─────────────────────────────────────────────── */
.id-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.id-stat-label { font-size: 13px; color: var(--text-dim); }
.id-stat-value {
  font-family: "IBM Plex Mono", monospace;
  font-weight: 600;
  font-size: 30px;
  color: var(--text);
  margin-top: 10px;
  letter-spacing: -.01em;
}
.id-stat-delta {
  font-size: 12px;
  margin-top: 4px;
  font-family: "IBM Plex Mono", monospace;
}
.id-stat-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--surface-3);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ─── Status badges ──────────────────────────────────────────── */
.id-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 8px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  line-height: 1;
}
.id-badge-completed { background: rgba(39,165,103,.14); color: var(--ok); }
.id-badge-running {
  background: rgba(0,194,209,.12);
  color: var(--run);
}
.id-badge-running::before {
  content: '';
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--run);
  flex-shrink: 0;
  animation: id-pulse 1.5s ease-in-out infinite;
}
.id-badge-queued  { background: rgba(202,166,90,.14); color: var(--queue); }
.id-badge-failed  { background: rgba(226,96,79,.12);  color: var(--err);   }
.id-badge-idle    { background: var(--surface-3);     color: var(--text-faint); }
.id-badge-invited { background: rgba(133,149,170,.14); color: var(--text-dim); }

@keyframes id-pulse { 0%,100%{opacity:1} 50%{opacity:.4} }

/* ─── Tables ─────────────────────────────────────────────────── */
.id-table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 640px; }
.id-table thead th {
  padding: 11px 22px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  letter-spacing: .05em;
  color: var(--text-faint);
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
}
.id-table tbody tr {
  border-top: 1px solid var(--border);
  transition: background .1s;
}
.id-table tbody tr:hover { background: var(--surface-2); }
.id-table tbody td { padding: 13px 22px; color: var(--text); vertical-align: middle; }
.id-table .id-td-mono  { font-family: "IBM Plex Mono", monospace; font-size: 13px; }
.id-table .id-td-cyan  { color: var(--cyan); }
.id-table .id-td-dim   { color: var(--text-dim); }
.id-table .id-td-faint { color: var(--text-faint); }

/* ─── Forms ──────────────────────────────────────────────────── */
.id-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 7px;
}
.id-input {
  width: 100%;
  padding: 11px 13px;
  border-radius: var(--radius-input);
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  font-family: "IBM Plex Sans", sans-serif;
  outline: none;
  transition: border-color .15s;
  display: block;
}
.id-input::placeholder { color: var(--text-faint); }
.id-input:focus { border-color: var(--cyan); }
.id-input-lg { padding: 13px 14px; font-size: 15px; }

select.id-input { appearance: auto; cursor: pointer; }

/* Bootstrap modal theming via CSS tokens */
.id-modal .modal-content {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  color: var(--text);
  box-shadow: var(--shadow-lg);
}
.id-modal .modal-header,
.id-modal .modal-footer { border-color: var(--border); }
.id-modal .modal-title  { font-family: Montserrat, sans-serif; font-weight: 700; color: var(--text); }
.id-modal .btn-close    { filter: var(--bs-btn-close-white-filter, none); }
[data-theme="dark"] .id-modal .btn-close { filter: invert(1) grayscale(1); }

/* ─── Buttons ────────────────────────────────────────────────── */
.id-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  font-family: "IBM Plex Sans", sans-serif;
  cursor: pointer;
  text-decoration: none;
  border: none;
  transition: filter .13s, border-color .13s;
  white-space: nowrap;
}
.id-btn-primary {
  background: var(--cyan);
  color: #042;
  box-shadow: 0 6px 18px rgba(0,194,209,.28);
}
.id-btn-primary:hover { filter: brightness(1.06); color: #042; }
.id-btn-primary.wide  { width: 100%; padding: 14px; font-size: 15px; }

.id-btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  box-shadow: none;
}
.id-btn-secondary:hover { border-color: var(--cyan); color: var(--text); filter: none; }

/* Topbar "New run" variant */
.id-btn-new-run {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 16px;
  border-radius: 10px;
  border: none;
  background: var(--cyan);
  color: #042;
  font-size: 14px;
  font-weight: 600;
  font-family: "IBM Plex Sans", sans-serif;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,194,209,.3);
  text-decoration: none;
  white-space: nowrap;
  transition: filter .13s;
}
.id-btn-new-run:hover { filter: brightness(1.06); color: #042; }

/* ─── Toggle switch ─────────────────────────────────────────── */
.id-toggle {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
}
.id-toggle input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}
.id-track {
  width: 42px;
  height: 24px;
  border-radius: 12px;
  background: var(--border-strong);
  position: relative;
  flex-shrink: 0;
  transition: background .18s;
}
.id-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.22);
  transition: transform .18s;
}
.id-toggle input:checked + .id-track { background: var(--cyan); }
.id-toggle input:checked + .id-track::after { transform: translateX(18px); }
.id-toggle-label {
  font-size: 14px;
  color: var(--text);
  line-height: 1.3;
}
.id-toggle-sublabel {
  font-size: 12px;
  color: var(--text-faint);
  margin-top: 2px;
}

/* ─── Segmented control (theme picker) ──────────────────────── */
.id-seg {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}
.id-seg-btn {
  padding: 7px 16px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
  font-family: "IBM Plex Sans", sans-serif;
  cursor: pointer;
  transition: background .13s, color .13s, box-shadow .13s;
  white-space: nowrap;
}
.id-seg-btn.id-seg-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}
[data-theme="dark"] .id-seg-btn.id-seg-active { background: var(--surface-3); }

/* ─── Settings section divider ───────────────────────────────── */
.id-settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
  gap: 16px;
}
.id-settings-row:last-child { border-bottom: none; }
.id-settings-label { font-size: 14px; font-weight: 500; color: var(--text); }
.id-settings-meta  { font-size: 12px; color: var(--text-faint); margin-top: 2px; }

/* ─── Flash messages ─────────────────────────────────────────── */
.id-alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 16px;
}
.id-alert-success { background: rgba(39,165,103,.12); color: var(--ok);    border: 1px solid rgba(39,165,103,.3); }
.id-alert-error   { background: rgba(226,96,79,.12);  color: var(--err);   border: 1px solid rgba(226,96,79,.3);  }
.id-alert-info    { background: rgba(0,194,209,.10);  color: var(--cyan);  border: 1px solid rgba(0,194,209,.3);  }
.id-alert-warning { background: rgba(255,179,92,.12); color: var(--orange);border: 1px solid rgba(255,179,92,.3); }

/* ─── Log output ─────────────────────────────────────────────── */
.id-log {
  font-family: "IBM Plex Mono", monospace;
  font-size: 12.5px;
  line-height: 1.9;
  color: #9fdfe6;
  background: var(--navy);
  border-radius: 14px;
  padding: 18px 22px;
  overflow-y: auto;
  max-height: 400px;
}
[data-theme="dark"] .id-log { background: #030b18; }

/* ─── Login split layout ─────────────────────────────────────── */
.id-login-split {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  min-height: 100vh;
}
.id-login-left {
  position: relative;
  overflow: hidden;
  background: linear-gradient(160deg, #071b3b 0%, #0a234a 100%);
  color: #eaf2ff;
  padding: 48px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.id-login-right {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  background: var(--surface);
}
.id-login-form { width: 100%; max-width: 380px; }

/* ─── Public page shell ──────────────────────────────────────── */
.id-public-nav {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.id-public-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  text-decoration: none;
  color: var(--text);
}
.id-public-brand-name {
  font-family: Montserrat, sans-serif;
  font-weight: 700;
  font-size: 21px;
  letter-spacing: -.02em;
}
.id-public-brand-name .id-i { color: var(--cyan); }

/* ─── Focus visible (WCAG AA) ────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
  border-radius: 4px;
}
:focus:not(:focus-visible) { outline: none; }

.id-input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(0,194,209,.2);
  outline: none;
}
.id-nav-link:focus-visible,
.id-user-card:focus-visible,
.id-btn:focus-visible,
.id-btn-primary:focus-visible,
.id-btn-secondary:focus-visible,
.id-btn-new-run:focus-visible,
.id-icon-btn:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
}

/* ─── Minimum 44 × 44 px tap targets ────────────────────────── */
.id-nav-link       { min-height: 44px; }
.id-icon-btn       { width: 44px; height: 44px; }
.id-sidebar-toggle { min-width: 44px; min-height: 44px; }
.id-signout-btn    { min-height: 44px; }

/* ─── Scrollable table wrapper ───────────────────────────────── */
.id-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ─── Responsive dashboard grids ────────────────────────────── */
.id-stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.id-dash-grid {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 16px;
}

/* ─── Mobile ─────────────────────────────────────────────────── */
@media (max-width: 1199.98px) {
  .id-stat-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 1099.98px) {
  .id-settings-grid { grid-template-columns: 1fr !important; }
}

@media (max-width: 991.98px) {
  .id-main      { margin-left: 0; }
  .id-content   { padding: 16px 16px 40px; }
  .id-topbar    { padding: 12px 16px; }
  .id-search    { display: none; }
  .id-dash-grid { grid-template-columns: 1fr; }
}

@media (max-width: 767.98px) {
  .id-login-split { grid-template-columns: 1fr; }
  .id-login-left  { display: none; }
  .id-public-nav  { padding: 12px 16px; }
  .id-stat-grid   { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 479.98px) {
  .id-stat-grid   { grid-template-columns: 1fr; }
  .id-btn-text    { display: none; }
  .id-btn-new-run { padding: 10px 12px; }
}
