/* ===== TyapAI Design System (Bootstrap 5 + custom) ===== */
/* All visual values sourced from theme-preview.html */
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@600;700&family=Roboto+Condensed:wght@400;500;600;700&family=Roboto+Mono:wght@400;500&display=swap');

:root {
  --font-body: 'Roboto Condensed', -apple-system, sans-serif;
  --font-heading: 'Montserrat', -apple-system, sans-serif;
  --font-mono: 'Roboto Mono', 'Consolas', monospace;

  /* Palette */
  --slate-800: #1e293b;
  --slate-700: #334155;
  --slate-600: #475569;
  --slate-500: #64748b;
  --slate-400: #94a3b8;
  --slate-300: #cbd5e1;
  --slate-200: #e2e8f0;
  --slate-100: #f1f5f9;
  --slate-50:  #f8fafc;

  /* alt CPB orange: #FF5101 / #e54900 / #fff5f0 / #ffb899 / #ff8c52 */
  --primary: #00c9a7;
  --primary-dark: #00b896;
  --primary-light: #ecfdf5;
  --primary-border: #99f6e4;
  --primary-accent: #5eead4;

  --amber-700: #b45309;
  --amber-500: #f59e0b;
  --amber-400: #fbbf24;
  --amber-300: #fcd34d;
  --amber-100: #fef3c7;
  --amber-50:  #fffbeb;

  --red-500: #ef4444;
  --red-600: #dc2626;
  --red-50:  #fef2f2;

  --green-600: #16a34a;
  --green-200: #bbf7d0;
  --green-50:  #f0fdf4;

  --white: #ffffff;
  --radius: 6px;
  --radius-lg: 10px;
}

body { -webkit-font-smoothing: antialiased; }
[x-cloak] { display: none !important; }
.hidden { display: none !important; }

/* ===== Gradient stripes ===== */
.navbar-stripe,
.footer-stripe { height: 3px; background: linear-gradient(90deg, var(--primary), var(--primary-accent)); }

/* ===== Navbar extras (balance, nav items) ===== */
.navbar .balance {
  font-family: var(--font-mono);
  font-size: 13px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 4px;
  padding: 3px 10px;
  color: var(--primary-accent);
}

/* ===== Section Labels ===== */
.section-label {
  font-size: 14px;
  font-weight: 700;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 10px;
}

/* ===== Hints ===== */
.hint {
  font-size: 15px;
  color: #9ca3af;
  line-height: 1.4;
  border-left: 2px solid #e5e7eb;
  padding-left: 12px;
  margin: 8px 0 16px;
}

/* ===== Upload Area ===== */
.upload-area {
  border: 2px dashed #d1d5db;
  border-radius: 10px;
  padding: 40px 24px;
  text-align: center;
  color: #9ca3af;
  font-size: 16px;
  margin-bottom: 20px;
  cursor: pointer;
  transition: border-color 0.2s, background-color 0.2s;
}
.upload-area:hover { border-color: var(--primary); background: var(--primary-light); }
.upload-area.dragover { border-color: var(--primary); background: var(--primary-light); border-style: solid; }
.upload-area .upload-icon { font-size: 32px; margin-bottom: 8px; }
.upload-area .upload-link { color: var(--primary); font-weight: 500; text-decoration: underline; text-underline-offset: 2px; }

/* ===== Status Text ===== */
.status-text { text-align: center; font-size: 15px; font-weight: 600; margin-bottom: 16px; }
.status-text.ready   { color: var(--primary); }
.status-text.error   { color: var(--red-500); }
.status-text.success { color: var(--green-600); }
.status-text.warning { color: var(--amber-500); }

/* ===== Progress ===== */
.progress-bar { background-color: var(--primary); }
.progress-steps .step { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid #f3f4f6; font-size: 15px; }
.step.completed { color: var(--green-600); }
.step.active    { color: var(--primary); font-weight: 500; }
.step.pending   { color: var(--slate-300); }
.step-icon { font-size: 14px; width: 18px; text-align: center; }

/* ===== Checkboxes ===== */
.checkbox-row { display: flex; align-items: center; gap: 6px; font-size: 15px; color: var(--slate-700); cursor: pointer; margin-bottom: 8px; }
.checkbox-row input[type="checkbox"] { width: auto; cursor: pointer; accent-color: var(--primary); }

/* ===== History ===== */
.history-table { font-size: 15px; }
.history-date-group td { padding: 10px 6px 4px; font-size: 15px; font-weight: 600; color: #9ca3af; text-transform: uppercase; letter-spacing: 0.3px; border-bottom: 1px solid #f3f4f6; }
.history-table { border-spacing: 0 2px; border-collapse: separate; }
.history-row { cursor: pointer; transition: background 0.1s; }
.history-row:hover td { background: #f5f5f5; }
.history-row:hover td:first-child { border-radius: 6px 0 0 6px; }
.history-row:hover td:last-child { border-radius: 0 6px 6px 0; }
.history-row td { padding: 10px 12px; border-bottom: 1px solid #f3f4f6; vertical-align: top; }
.history-date { font-family: var(--font-mono); font-size: 15px; color: var(--slate-500); white-space: nowrap; font-weight: 500; }
.history-chip { display: inline-block; font-family: var(--font-mono); font-size: 15px; font-weight: 600; color: var(--white); padding: 3px 8px; border-radius: 4px; line-height: 1.4; letter-spacing: 0.02em; }
.history-file .filename { font-weight: 600; color: #111827; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.history-meta { font-size: 15px; color: #9ca3af; line-height: 1.2; }
.history-actions { text-align: center; white-space: nowrap; }
.history-delete { background: none; border: none; color: #ccc; font-size: 16px; cursor: pointer; padding: 0 4px; line-height: 1; transition: color 0.15s; }
.history-delete:hover { color: var(--red-500); }
.history-total { margin-top: 12px; padding-top: 8px; border-top: 1px solid #f0f0f0; display: flex; justify-content: space-between; font-size: 15px; color: #9ca3af; font-family: var(--font-mono); }
.pagination-info { font-family: var(--font-mono); }

/* ===== Modal ===== */
.modal-overlay { position: fixed; inset: 0; background: rgba(15,23,42,0.5); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 1050; padding: 1rem; }
.modal-box { background: var(--white); border-radius: var(--radius-lg); padding: 1.5rem; width: min(640px, 100%); max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(15,23,42,0.25); }

/* ===== Job Card (modal) ===== */
.jc-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding-bottom: 12px; }
.jc-head-left { display: flex; flex-direction: column; gap: 2px; }
.jc-head-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.jc-mode { font-family: var(--font-heading); font-size: 22px; font-weight: 700; color: #111827; }
.jc-quality { font-size: 15px; color: #6b7280; margin-top: 2px; }
.jc-badge { display: inline-block; font-size: 15px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; padding: 4px 12px; border-radius: 4px; line-height: 1.4; }
.jc-badge--status { color: var(--white); }
.jc-badge--preset { background: #f3f4f6; color: #6b7280; }
.jc-badge--ultima { background: #1a1a1a; color: #d4a843; }
.jc-badge--business { background: #2d2d2d; color: #fff; }
.jc-grid { display: grid; grid-template-columns: 100px 1fr; font-size: 16px; margin-bottom: 16px; background: #f9fafb; border-radius: 8px; padding: 12px 20px; }
.jc-grid dt { padding: 9px 0; color: #9ca3af; font-weight: 500; border-bottom: 1px solid #f0f0f0; }
.jc-grid dd { padding: 9px 0; color: #111827; border-bottom: 1px solid #f0f0f0; margin: 0; word-break: break-word; text-align: right; }
.jc-grid dt:last-of-type, .jc-grid dd:last-of-type { border-bottom: none; }
.jc-cost-bar { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; margin: 16px 0; background: #f9fafb; border-radius: 8px; }
.jc-cost-label { font-size: 15px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: #374151; }
.jc-cost-right { text-align: right; }
.jc-cost-value { font-family: var(--font-mono); font-size: 22px; font-weight: 700; color: #111827; letter-spacing: -0.02em; }
.jc-cost-dur { display: block; font-size: 15px; font-weight: 400; color: #9ca3af; margin-top: 0; }
.jc-error { margin-top: 14px; padding: 12px 16px; background: var(--red-50); border-radius: 6px; border-left: 3px solid var(--red-500); color: var(--red-600); font-size: 15px; line-height: 1.5; }
.jc-section { margin-top: 16px; }
.jc-section-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
details.jc-section > summary.section-label { font-size: 15px; font-weight: 500; color: #9ca3af; letter-spacing: 0.5px; margin-bottom: 10px; cursor: pointer; user-select: none; }
details.jc-section > summary.section-label:hover { color: var(--slate-600); }

/* ===== Summary HTML (modal) ===== */
.summary-html { padding: 16px; background: var(--slate-50); border: 1px solid var(--slate-200); border-radius: var(--radius); font-family: 'Calibri', 'Carlito', sans-serif; font-size: 17px; line-height: 1.7; overflow-y: auto; flex: 1; min-height: 100px; }
/* Headings use div.sh1/sh2/sh3 (not <h1>/<h2> — Outlook applies numbered styles to those) */
/* Inline styles on divs carry over to clipboard; classes are for CSS overrides if needed */
.summary-html ul { margin: 4px 0; padding-left: 20px; }
.summary-html li { margin: 3px 0; }
.summary-html strong { color: #111827; }

/* ===== Cost table (modal) ===== */
.cost-table { width: 100%; font-size: 12px; border-collapse: collapse; font-family: var(--font-mono); }
.cost-table th, .cost-table td { padding: 4px 8px; text-align: left; border-bottom: 1px solid #f3f4f6; }
.cost-table th { color: #9ca3af; font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; }

/* ===== Forms ===== */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
  padding: 10px 12px;
  border: 1px solid #e5e7eb;
  border-radius: var(--radius);
  font-size: 15px;
  font-family: var(--font-body);
  color: #111827;
  width: 100%;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0,201,167,0.12);
}

/* ===== Admin Panel ===== */
.admin-wrap { max-width: 1200px; margin: 0 auto; padding: 24px; display: flex; flex-direction: column; gap: 20px; }
.stat-value { font-size: 22px; font-weight: 700; font-family: var(--font-mono); color: var(--primary); white-space: nowrap; }
.stat-label { font-size: 15px; color: #9ca3af; margin-top: 4px; text-transform: uppercase; letter-spacing: 0.8px; font-weight: 600; }
.admin-form-box { background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 8px; padding: 20px; margin-bottom: 20px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-bottom: 12px; }
.table-wrap { overflow-x: auto; }

/* ===== Badges ===== */
.mode-badge { display: inline-block; font-size: 15px; font-weight: 500; padding: 2px 8px; border-radius: 3px; background: var(--primary-light); color: var(--primary); font-family: var(--font-mono); }
.status-badge { display: inline-block; font-size: 15px; font-weight: 500; padding: 2px 8px; border-radius: 3px; }
.status-active    { background: var(--green-50); color: var(--green-600); }
.status-blocked   { background: var(--red-50); color: var(--red-600); }
.status-done      { background: #dcfce7; color: var(--green-600); }
.status-failed    { background: var(--red-50); color: var(--red-600); }
.status-cancelled { background: #f3f4f6; color: #6b7280; }
.status-processing{ background: var(--primary-light); color: var(--primary); }
.status-queued    { background: var(--amber-50); color: var(--amber-500); }

/* Color helpers */
.color-green  { color: var(--green-600); font-weight: 500; }
.color-orange { color: var(--amber-500); font-weight: 500; }
.color-red    { color: var(--red-500); font-weight: 500; }

/* ===== Estimate card ===== */
.estimate-card { background: var(--primary-light); border: 1px solid var(--primary-border); border-radius: 8px; padding: 10px 14px; margin-bottom: 16px; font-size: 15px; }
.estimate-row { display: flex; justify-content: space-between; padding: 2px 0; color: #111827; }
.estimate-row span:last-child { font-weight: 600; font-family: var(--font-mono); color: var(--primary); }

/* ===== Log viewer ===== */
.log-error   { color: #f87171; }
.log-warning { color: #fbbf24; }
.log-info    { color: #94a3b8; }

/* ===== Word download buttons ===== */
.btn.btn-word {
  --bs-btn-color: #2b5797;
  --bs-btn-border-color: #93b4d4;
  --bs-btn-hover-bg: #edf2fa;
  --bs-btn-hover-border-color: #2b5797;
  --bs-btn-hover-color: #1a3d6e;
}

/* ===== Footer ===== */
.site-footer {
  text-align: center;
  padding: 16px 24px;
  font-size: 15px;
  color: #9ca3af;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .nav-tabs { overflow-x: auto; flex-wrap: nowrap; padding: 0 12px; }
  .nav-tabs .nav-link { white-space: nowrap; font-size: 15px; padding: 10px 14px; }
  .admin-wrap { padding: 16px; }
  .navbar { padding: 10px 12px !important; }
}

/* ===== Mail Module ===== */
.mail-result-panel { background: #f9fafb; border-radius: 8px; padding: 12px; }
.mail-result-panel h4 { font-weight: 600; font-size: 15px; margin-bottom: 8px; color: var(--slate-700); }
.mail-result-panel .result-body { font-size: 15px; color: #6b7280; }
.mail-result-panel .result-detail { margin-top: 8px; font-size: 15px; color: #9ca3af; }

/* Rules tree */
.rules-group { margin-bottom: 4px; border: 1px solid #f3f4f6; border-radius: 6px; overflow: hidden; }
.rules-group-header { display: flex; align-items: center; gap: 8px; padding: 8px 12px; font-size: 15px; font-weight: 600; color: var(--slate-700); background: #f9fafb; cursor: pointer; user-select: none; }
.rules-group-header::-webkit-details-marker { display: none; }
.rules-group-header::before { content: '▸'; font-size: 10px; color: #9ca3af; transition: transform 0.15s; }
.rules-group[open] > .rules-group-header::before { transform: rotate(90deg); }
.rules-group-count { font-size: 15px; font-weight: 500; color: #9ca3af; background: #f3f4f6; padding: 1px 6px; border-radius: 10px; }
.rules-group .table-wrap { margin: 0; }

/* Search */
.search-answer { font-size: 15px; line-height: 1.7; color: var(--slate-700); word-break: break-word; }
.search-answer h1, .search-answer h2, .search-answer h3 { margin-top: 1em; margin-bottom: 0.4em; color: var(--slate-800); }
.search-answer h1 { font-size: 1.3em; }
.search-answer h2 { font-size: 1.15em; }
.search-answer h3 { font-size: 1.05em; }
.search-answer p { margin-bottom: 0.6em; }
.search-answer ul, .search-answer ol { margin-bottom: 0.6em; padding-left: 1.5em; }
.search-answer code { background: #f3f4f6; padding: 1px 4px; border-radius: 3px; font-size: 0.9em; }
.search-answer pre { background: #f3f4f6; padding: 12px; border-radius: 6px; overflow-x: auto; margin-bottom: 0.8em; }
.search-answer pre code { background: none; padding: 0; }
.search-answer a:not(.citation-ref) { color: var(--blue-600, #2563eb); text-decoration: underline; }

.citation-ref { color: var(--blue-600, #2563eb); font-size: 0.8em; font-weight: 600; vertical-align: super; text-decoration: none; cursor: pointer; }
.citation-ref:hover { text-decoration: underline; }

.citation-card { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border: 1px solid #e5e7eb; border-radius: 8px; font-size: 13px; color: var(--slate-600); text-decoration: none; transition: border-color 0.15s, box-shadow 0.15s; max-width: 300px; }
.citation-card:hover { border-color: #93c5fd; box-shadow: 0 0 0 2px rgba(59,130,246,0.1); color: var(--slate-700); }
.citation-num { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 50%; background: #eff6ff; color: var(--blue-600, #2563eb); font-size: 11px; font-weight: 700; flex-shrink: 0; }
.citation-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.history-item { padding: 8px 0; border-bottom: 1px solid #f3f4f6; cursor: pointer; transition: background 0.1s; }
.history-item:hover { background: #f9fafb; }
.history-item:last-child { border-bottom: none; }
