/*
 ╔══════════════════════════════════════════════════════════════════╗
 ║  SEO TOOLKIT — SHARED DESIGN SYSTEM                             ║
 ║  toolkit-theme.css                                              ║
 ║                                                                  ║
 ║  All tools link to this file. Edit here, all tools update.      ║
 ║  Usage: <link rel="stylesheet" href="toolkit-theme.css">        ║
 ╚══════════════════════════════════════════════════════════════════╝
*/

/* ── Google Fonts ── */
@import url('https://fonts.googleapis.com/css2?family=Syne:wght@600;700;800&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,400&family=DM+Mono:wght@400;500&display=swap');

/* ════════════════════════════════════════════
   DESIGN TOKENS
   ════════════════════════════════════════════ */
:root {
  /* Brand */
  --navy:          #0b1628;
  --navy-2:        #1a2e4a;
  --navy-3:        #1e3a5f;

  /* Neutrals */
  --bg:            #f8fafc;
  --bg-2:          #f1f5f9;
  --white:         #ffffff;
  --border:        #e2e8f0;
  --border-2:      #cbd5e1;
  --text:          #0f172a;
  --text-2:        #475569;
  --text-muted:    #64748b;

  /* Semantic colours */
  --green:         #059669;
  --green-light:   #d1fae5;
  --green-mid:     #a7f3d0;

  --sky:           #0369a1;
  --sky-light:     #e0f2fe;
  --sky-mid:       #bae6fd;

  --violet:        #7c3aed;
  --violet-light:  #ede9fe;
  --violet-mid:    #ddd6fe;

  --teal:          #0f766e;
  --teal-light:    #ccfbf1;
  --teal-mid:      #99f6e4;

  --amber:         #d97706;
  --amber-light:   #fef3c7;
  --amber-mid:     #fde68a;

  --rose:          #e11d48;
  --rose-light:    #ffe4e6;
  --rose-mid:      #fecdd3;

  /* Stage accent colours (used to colour-code workflow stages) */
  --stage-research:       #0369a1;
  --stage-research-bg:    #e0f2fe;
  --stage-plan:           #7c3aed;
  --stage-plan-bg:        #ede9fe;
  --stage-create:         #0f766e;
  --stage-create-bg:      #ccfbf1;
  --stage-analyze:        #d97706;
  --stage-analyze-bg:     #fef3c7;
  --stage-track:          #e11d48;
  --stage-track-bg:       #ffe4e6;

  /* Tool-level accent (override per tool with --accent / --accent-light) */
  --accent:        var(--navy);
  --accent-light:  var(--bg-2);

  /* Typography */
  --font-display:  'Syne', sans-serif;
  --font-body:     'DM Sans', sans-serif;
  --font-mono:     'DM Mono', 'Courier New', monospace;

  /* Spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;

  /* Shape */
  --radius-sm:  6px;
  --radius:     10px;
  --radius-lg:  14px;

  /* Elevation */
  --shadow-sm:  0 1px 2px rgba(0,0,0,.05);
  --shadow:     0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
  --shadow-md:  0 4px 12px rgba(0,0,0,.10), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg:  0 8px 30px rgba(0,0,0,.14);
}

/* ════════════════════════════════════════════
   RESET & BASE
   ════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.6;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }

/* ════════════════════════════════════════════
   HEADER  (.tk-header)
   ════════════════════════════════════════════ */
.tk-header {
  background: var(--navy);
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 62px;
  position: sticky;
  top: 0;
  z-index: 200;
}

.tk-header-brand { display: flex; align-items: center; gap: 12px; }

.tk-header-logo {
  width: 34px; height: 34px;
  background: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.tk-header-logo svg,
.tk-header-logo span { width: 20px; height: 20px; color: #fff; font-size: 18px; }

.tk-header-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -.2px;
}
.tk-header-title em {
  font-style: normal;
  color: var(--accent-em, #5eead4);
}

.tk-header-right { display: flex; align-items: center; gap: 10px; }

.tk-header-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  background: rgba(255,255,255,.08);
  color: rgba(255,255,255,.65);
  border: 1px solid rgba(255,255,255,.12);
  white-space: nowrap;
}

.tk-header-back {
  font-size: 12px; font-weight: 600;
  color: rgba(255,255,255,.55);
  text-decoration: none;
  display: flex; align-items: center; gap: 5px;
  transition: color .15s;
}
.tk-header-back:hover { color: #fff; }

/* ════════════════════════════════════════════
   PAGE WRAPPER
   ════════════════════════════════════════════ */
.tk-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

.tk-main-wide {
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

/* ════════════════════════════════════════════
   CARD  (.tk-card)
   ════════════════════════════════════════════ */
.tk-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-6);
  box-shadow: var(--shadow);
  margin-bottom: var(--space-5);
}

.tk-card-title {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .9px;
  color: var(--text);
  margin-bottom: var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.tk-step {
  width: 22px; height: 22px; min-width: 22px;
  background: var(--navy);
  color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-mono);
}

/* ════════════════════════════════════════════
   FORM ELEMENTS
   ════════════════════════════════════════════ */
.tk-form-row {
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.tk-form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
  min-width: 200px;
}

.tk-label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-2);
}
.tk-label .tk-optional {
  font-weight: 400;
  color: var(--text-muted);
}

.tk-input,
.tk-select,
.tk-textarea {
  font-family: var(--font-body);
  font-size: 13.5px;
  color: var(--text);
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 13px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}

.tk-input:focus,
.tk-select:focus,
.tk-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent);
}

.tk-input::placeholder,
.tk-textarea::placeholder { color: var(--text-muted); }

.tk-input[type="password"] { font-family: var(--font-mono); font-size: 13px; }

.tk-select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  padding-right: 32px;
}

.tk-textarea {
  resize: vertical;
  min-height: 100px;
  line-height: 1.6;
}
.tk-textarea-mono { font-family: var(--font-mono); font-size: 12.5px; }

.tk-hint {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.5;
}
.tk-hint a { color: var(--accent); }

/* ════════════════════════════════════════════
   BUTTONS
   ════════════════════════════════════════════ */
.tk-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
  text-decoration: none;
  line-height: 1;
}

/* Primary — accent colour */
.tk-btn-primary {
  background: var(--accent);
  color: #fff;
}
.tk-btn-primary:hover:not(:disabled) {
  filter: brightness(1.08);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px color-mix(in srgb, var(--accent) 35%, transparent);
}
.tk-btn-primary:disabled { opacity: .45; cursor: not-allowed; transform: none !important; }

/* Outline */
.tk-btn-outline {
  background: var(--white);
  color: var(--text);
  border: 1.5px solid var(--border);
}
.tk-btn-outline:hover:not(:disabled) { background: var(--bg); border-color: var(--border-2); }

/* Navy / dark */
.tk-btn-dark {
  background: var(--navy);
  color: #fff;
}
.tk-btn-dark:hover:not(:disabled) { background: var(--navy-2); transform: translateY(-1px); }

/* Export */
.tk-btn-export {
  background: var(--navy);
  color: #fff;
}
.tk-btn-export:hover:not(:disabled) { background: var(--navy-2); }

/* Danger */
.tk-btn-danger {
  background: var(--rose-light);
  color: var(--rose);
  border: 1.5px solid var(--rose-mid);
}
.tk-btn-danger:hover:not(:disabled) { background: var(--rose-mid); }

/* Ghost / subtle */
.tk-btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1.5px solid var(--border);
}
.tk-btn-ghost:hover:not(:disabled) { background: var(--bg); color: var(--text); }

/* Sizes */
.tk-btn-sm  { font-size: 12px; padding: 7px 14px; }
.tk-btn-lg  { font-size: 15px; padding: 13px 28px; }
.tk-btn-block { width: 100%; }

.tk-btn:disabled { opacity: .45; cursor: not-allowed; }

/* Action row */
.tk-action-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: var(--space-5);
}

/* ════════════════════════════════════════════
   BADGES & PILLS
   ════════════════════════════════════════════ */
.tk-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 20px;
  white-space: nowrap;
}
.tk-badge::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: .6; }

.tk-badge-green    { background: var(--green-light);   color: var(--green);  border: 1px solid var(--green-mid); }
.tk-badge-sky      { background: var(--sky-light);     color: var(--sky);    border: 1px solid var(--sky-mid); }
.tk-badge-violet   { background: var(--violet-light);  color: var(--violet); border: 1px solid var(--violet-mid); }
.tk-badge-teal     { background: var(--teal-light);    color: var(--teal);   border: 1px solid var(--teal-mid); }
.tk-badge-amber    { background: var(--amber-light);   color: var(--amber);  border: 1px solid var(--amber-mid); }
.tk-badge-rose     { background: var(--rose-light);    color: var(--rose);   border: 1px solid var(--rose-mid); }
.tk-badge-neutral  { background: var(--bg-2);          color: var(--text-muted); border: 1px solid var(--border); }

/* Intent badges */
.tk-intent-I { background: var(--sky-light);    color: var(--sky);    border: 1px solid var(--sky-mid); }
.tk-intent-C { background: var(--amber-light);  color: var(--amber);  border: 1px solid var(--amber-mid); }
.tk-intent-T { background: var(--green-light);  color: var(--green);  border: 1px solid var(--green-mid); }
.tk-intent-N { background: var(--bg-2);         color: var(--text-muted); border: 1px solid var(--border); }

/* Severity */
.tk-sev-high   { background: var(--rose-light);   color: var(--rose);   border: 1px solid var(--rose-mid); }
.tk-sev-medium { background: var(--amber-light);  color: var(--amber);  border: 1px solid var(--amber-mid); }
.tk-sev-low    { background: var(--green-light);  color: var(--green);  border: 1px solid var(--green-mid); }

/* ════════════════════════════════════════════
   PROGRESS BAR & SPINNER
   ════════════════════════════════════════════ */
.tk-progress { display: none; }
.tk-progress.tk-visible { display: block; }

.tk-progress-label {
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.tk-progress-track {
  height: 5px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin: 6px 0;
}
.tk-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width .4s ease;
  width: 0%;
}

.tk-progress-hint {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 4px;
}

.tk-spinner {
  width: 14px; height: 14px; min-width: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: tk-spin .7s linear infinite;
  flex-shrink: 0;
}
@keyframes tk-spin { to { transform: rotate(360deg); } }

/* ════════════════════════════════════════════
   ALERT BOXES
   ════════════════════════════════════════════ */
.tk-alert {
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 13px;
  line-height: 1.5;
  display: none;
}
.tk-alert.tk-visible { display: block; }

.tk-alert-error   { background: var(--rose-light);   border: 1px solid var(--rose-mid);   color: var(--rose); }
.tk-alert-success { background: var(--green-light);  border: 1px solid var(--green-mid);  color: var(--green); }
.tk-alert-info    { background: var(--sky-light);    border: 1px solid var(--sky-mid);    color: var(--sky); }
.tk-alert-warning { background: var(--amber-light);  border: 1px solid var(--amber-mid);  color: var(--amber); }

/* ════════════════════════════════════════════
   STATS GRID
   ════════════════════════════════════════════ */
.tk-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: var(--space-5);
}
@media (max-width: 700px) { .tk-stats-grid { grid-template-columns: repeat(2, 1fr); } }

.tk-stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.tk-stat-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 5px;
}
.tk-stat-value {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}
.tk-stat-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ════════════════════════════════════════════
   FILTER ROW
   ════════════════════════════════════════════ */
.tk-filter-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.tk-filter-btn {
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: var(--white);
  color: var(--text-2);
  cursor: pointer;
  transition: all .15s;
}
.tk-filter-btn:hover { border-color: var(--border-2); }
.tk-filter-btn.tk-active { border-color: var(--navy); background: var(--navy); color: #fff; }

/* ════════════════════════════════════════════
   TABLE
   ════════════════════════════════════════════ */
.tk-table-wrap { overflow-x: auto; }

.tk-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.tk-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .6px;
  padding: 10px 14px;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
  background: var(--white);
}
.tk-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text);
}
.tk-table tr:last-child td { border-bottom: none; }
.tk-table tbody tr:hover td { background: var(--bg); }

/* Expandable rows */
.tk-row-expand { cursor: pointer; }
.tk-expand-icon {
  width: 20px; height: 20px; min-width: 20px;
  border-radius: 5px;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px;
  color: var(--text-muted);
  transition: transform .2s;
}
.tk-row-expand.tk-expanded .tk-expand-icon { transform: rotate(90deg); }
.tk-row-detail { display: none; }
.tk-row-detail.tk-visible { display: table-row; }
.tk-row-detail td {
  padding: 0 14px 16px 50px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

/* ════════════════════════════════════════════
   CHIP / TAG
   ════════════════════════════════════════════ */
.tk-chips { display: flex; flex-wrap: wrap; gap: 6px; }

.tk-chip {
  font-size: 12px;
  font-family: var(--font-mono);
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-2);
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}
.tk-chip-primary {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}
.tk-chip-accent {
  background: var(--accent-light);
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 25%, transparent);
}

/* ════════════════════════════════════════════
   UPLOAD ZONE
   ════════════════════════════════════════════ */
.tk-upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 36px 24px;
  text-align: center;
  cursor: pointer;
  transition: all .15s;
  background: var(--bg);
}
.tk-upload-zone:hover,
.tk-upload-zone.tk-drag {
  border-color: var(--accent);
  background: var(--accent-light, var(--bg-2));
}
.tk-upload-zone .tk-upload-icon { font-size: 32px; margin-bottom: 10px; }
.tk-upload-zone p { font-size: 13.5px; color: var(--text-muted); }
.tk-upload-zone strong { color: var(--text); }
.tk-upload-zone.tk-loaded {
  border-style: solid;
  border-color: var(--green);
  background: var(--green-light);
}
.tk-upload-zone.tk-loaded p { color: var(--green); font-weight: 600; }

/* ════════════════════════════════════════════
   SECTION DIVIDER
   ════════════════════════════════════════════ */
.tk-divider {
  display: flex; align-items: center; gap: 12px;
  margin: 24px 0;
  font-size: 12px; font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .5px;
}
.tk-divider::before,
.tk-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ════════════════════════════════════════════
   RESULTS HEADER
   ════════════════════════════════════════════ */
.tk-results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
  gap: 12px;
}
.tk-results-title {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}

/* ════════════════════════════════════════════
   EMPTY STATE
   ════════════════════════════════════════════ */
.tk-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.tk-empty .tk-empty-icon { font-size: 40px; margin-bottom: 14px; }
.tk-empty p { font-size: 14px; }

/* ════════════════════════════════════════════
   MODEL PICKER  (.tk-model-grid)
   ════════════════════════════════════════════ */
.tk-model-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
}
.tk-model-card {
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  transition: all .15s;
  background: var(--bg);
  position: relative;
  text-align: left;
}
.tk-model-card:hover { background: var(--white); border-color: var(--border-2); }
.tk-model-card.tk-selected { background: var(--white); border-color: var(--accent); }
.tk-model-card.tk-selected::after {
  content: '✓';
  position: absolute; top: 8px; right: 10px;
  font-size: 12px; font-weight: 700; color: var(--accent);
}
.tk-model-name { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.tk-model-tag  { font-size: 10.5px; font-weight: 600; padding: 2px 7px; border-radius: 10px; }
.tk-model-note { font-size: 11px; color: var(--text-muted); margin-top: 6px; line-height: 1.4; }

/* ════════════════════════════════════════════
   RESPONSIVE
   ════════════════════════════════════════════ */
@media (max-width: 700px) {
  .tk-header { padding: 0 16px; }
  .tk-main, .tk-main-wide { padding: 20px 14px 60px; }
  .tk-form-row { flex-direction: column; }
  .tk-card { padding: var(--font-body, 18px) 16px; }
}
