/* PPC Cockpit – custom styles on top of Tailwind */

* { box-sizing: border-box; }

html, body { height: 100%; }

/* Sidebar nav items */
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 24px;
  font-size: 14px;
  color: #cbd5e1;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background-color .15s, color .15s, border-color .15s;
  user-select: none;
}
.nav-item:hover {
  background: rgba(255,255,255,.04);
  color: #fff;
}
.nav-item.active {
  background: rgba(249,115,22,.08);
  color: #fff;
  border-left-color: #f97316;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item .badge {
  margin-left: auto;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 999px;
  font-weight: 600;
}

/* KPI card */
.kpi-card {
  background: #fff;
  border: 1px solid #f1f5f9;
  border-radius: 12px;
  padding: 18px 20px;
  transition: box-shadow .15s, transform .15s;
}
.kpi-card:hover {
  box-shadow: 0 4px 14px rgba(15,23,42,.06);
}
.kpi-label { font-size: 12px; color: #64748b; text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.kpi-value { font-size: 26px; font-weight: 700; color: #0f172a; margin-top: 4px; line-height: 1.1; }
.kpi-delta { font-size: 12px; margin-top: 6px; display: inline-flex; align-items: center; gap: 4px; font-weight: 500; }
.kpi-delta.up { color: #059669; }
.kpi-delta.down { color: #dc2626; }
.kpi-delta.neutral { color: #64748b; }

/* Card */
.card {
  background: #fff;
  border: 1px solid #f1f5f9;
  border-radius: 12px;
  padding: 20px;
}
.card-title {
  font-size: 14px;
  font-weight: 600;
  color: #0f172a;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Table */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl thead th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #64748b;
  font-weight: 600;
  padding: 10px 12px;
  border-bottom: 1px solid #f1f5f9;
  background: #f8fafc;
  position: sticky; top: 0;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.tbl thead th:hover { color: #0f172a; }
.tbl thead th.sorted { color: #0f172a; }
.tbl thead th.sorted::after { content: ' ↓'; }
.tbl thead th.sorted.asc::after { content: ' ↑'; }
.tbl tbody td {
  padding: 12px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
  white-space: nowrap;
}
.tbl tbody tr:hover { background: #f8fafc; }
.tbl tbody tr.row-link { cursor: pointer; }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl td.col-name { white-space: normal; max-width: 320px; }

/* Status badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.badge-enabled { background: #dcfce7; color: #166534; }
.badge-paused  { background: #fef3c7; color: #92400e; }
.badge-archived{ background: #f1f5f9; color: #475569; }
.badge-sp { background: #dbeafe; color: #1e40af; }
.badge-sb { background: #ede9fe; color: #6b21a8; }
.badge-sd { background: #ccfbf1; color: #115e59; }
.badge-exact  { background: #f1f5f9; color: #334155; }
.badge-phrase { background: #f1f5f9; color: #334155; }
.badge-broad  { background: #f1f5f9; color: #334155; }
.badge-auto   { background: #fff7ed; color: #9a3412; }

/* Severity */
.sev-critical { color: #dc2626; }
.sev-warning  { color: #d97706; }
.sev-info     { color: #2563eb; }

.sev-bg-critical { background: #fef2f2; border-left: 3px solid #dc2626; }
.sev-bg-warning  { background: #fffbeb; border-left: 3px solid #d97706; }
.sev-bg-info     { background: #eff6ff; border-left: 3px solid #2563eb; }

/* Health bar */
.health-bar { height: 6px; border-radius: 3px; background: #f1f5f9; overflow: hidden; position: relative; }
.health-bar > div { height: 100%; transition: width .3s; }
.health-good { background: #10b981; }
.health-mid  { background: #f59e0b; }
.health-bad  { background: #ef4444; }

/* Toast */
.toast {
  pointer-events: auto;
  background: #0f172a;
  color: #fff;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 8px 24px rgba(15,23,42,.18);
  animation: toast-in .25s ease-out;
  min-width: 240px;
  max-width: 380px;
}
.toast.toast-success { background: #059669; }
.toast.toast-error   { background: #dc2626; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px);} to { opacity: 1; transform: translateY(0);} }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15,23,42,.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 40;
  animation: fade-in .15s;
}
@keyframes fade-in { from { opacity: 0;} to { opacity: 1;} }
.modal {
  background: #fff; border-radius: 14px;
  width: 90%; max-width: 520px;
  padding: 24px;
  box-shadow: 0 20px 50px rgba(15,23,42,.25);
}
.modal-lg { max-width: 760px; }

/* Inputs */
.input {
  width: 100%;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: #f97316; box-shadow: 0 0 0 3px rgba(249,115,22,.15); background: #fff; }
.input-sm { padding: 5px 8px; font-size: 12px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; font-size: 13px; font-weight: 500;
  border-radius: 8px; border: 1px solid transparent;
  cursor: pointer; transition: background-color .15s, border-color .15s, color .15s;
  white-space: nowrap;
}
.btn-primary { background: #f97316; color: #fff; }
.btn-primary:hover { background: #ea580c; }
.btn-secondary { background: #fff; border-color: #e2e8f0; color: #334155; }
.btn-secondary:hover { background: #f8fafc; }
.btn-danger { background: #fff; border-color: #fecaca; color: #dc2626; }
.btn-danger:hover { background: #fef2f2; }
.btn-ghost { background: transparent; color: #64748b; }
.btn-ghost:hover { background: #f1f5f9; color: #0f172a; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* Toggle */
.toggle {
  position: relative; display: inline-block; width: 36px; height: 20px;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; cursor: pointer; inset: 0;
  background: #cbd5e1; border-radius: 999px; transition: background .2s;
}
.toggle-slider::before {
  content: ''; position: absolute;
  height: 14px; width: 14px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: transform .2s;
  box-shadow: 0 1px 2px rgba(0,0,0,.15);
}
.toggle input:checked + .toggle-slider { background: #10b981; }
.toggle input:checked + .toggle-slider::before { transform: translateX(16px); }

/* Tabs */
.tabs {
  display: flex; gap: 4px; border-bottom: 1px solid #f1f5f9;
  margin-bottom: 20px;
}
.tab {
  padding: 10px 16px; font-size: 13px; font-weight: 500;
  color: #64748b; cursor: pointer; border-bottom: 2px solid transparent;
  margin-bottom: -1px; transition: color .15s, border-color .15s;
}
.tab:hover { color: #0f172a; }
.tab.active { color: #ea580c; border-bottom-color: #ea580c; }

/* Empty state */
.empty {
  text-align: center; padding: 60px 20px; color: #64748b;
}
.empty-icon { font-size: 32px; margin-bottom: 8px; }

/* Helpers */
.skel { background: linear-gradient(90deg,#f1f5f9,#e2e8f0,#f1f5f9); background-size: 200% 100%; animation: skel 1.2s infinite linear; border-radius: 6px; }
@keyframes skel { to { background-position: -200% 0; } }

.scroll-shadow { background:
  linear-gradient(white 30%, rgba(255,255,255,0)) center top,
  linear-gradient(rgba(255,255,255,0), white 70%) center bottom,
  radial-gradient(farthest-side at 50% 0, rgba(15,23,42,.08), transparent) center top,
  radial-gradient(farthest-side at 50% 100%, rgba(15,23,42,.08), transparent) center bottom;
  background-repeat: no-repeat;
  background-size: 100% 24px, 100% 24px, 100% 8px, 100% 8px;
  background-attachment: local, local, scroll, scroll;
}

/* Tooltip */
.tip { position: relative; }
.tip:hover::after {
  content: attr(data-tip);
  position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  background: #0f172a; color: #fff; font-size: 11px; padding: 5px 9px; border-radius: 6px;
  white-space: nowrap; pointer-events: none; z-index: 50;
}

/* Search input with icon */
.search-wrap { position: relative; }
.search-wrap input { padding-left: 32px; }
.search-wrap svg { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); color: #94a3b8; pointer-events: none; }

/* Chat assistant */
#chat-toggle {
  animation: chat-bounce 3s ease-in-out infinite;
}
@keyframes chat-bounce {
  0%, 90%, 100% { transform: translateY(0); }
  92% { transform: translateY(-4px); }
  94% { transform: translateY(0); }
  96% { transform: translateY(-3px); }
  98% { transform: translateY(0); }
}
#chat-panel {
  max-height: 100vh;
}
.chat-chip {
  display: inline-block;
  font-size: 12px;
  padding: 5px 10px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  cursor: pointer;
  color: #334155;
  transition: background-color .15s, border-color .15s;
}
.chat-chip:hover { background: #fef3e9; border-color: #fed7aa; color: #9a3412; }
.chat-bubble p { margin: 0 0 8px; line-height: 1.5; }
.chat-bubble p:last-child { margin-bottom: 0; }
.chat-bubble h4 { font-size: 13px; font-weight: 600; color: #0f172a; margin: 12px 0 4px; }
.chat-bubble ul, .chat-bubble ol { margin: 0 0 8px; padding-left: 22px; line-height: 1.5; }
.chat-bubble ul li, .chat-bubble ol li { margin-bottom: 3px; }
.chat-bubble code { background: #fff; border: 1px solid #e2e8f0; padding: 1px 5px; border-radius: 4px; font-size: 11px; }
.chat-bubble pre, .chat-bubble .font-mono { font-family: ui-monospace, SFMono-Regular, monospace; font-size: 12px; }
.chat-bubble table { width: 100%; border-collapse: collapse; margin: 6px 0; }
.chat-bubble table th, .chat-bubble table td { padding: 4px 6px; border-bottom: 1px solid #e2e8f0; }
.chat-bubble table th { text-align: left; font-weight: 600; }
.chat-bubble .border-l-4 { padding-left: 10px; border-left-width: 4px; border-left-style: solid; }
.chat-bubble .bg-emerald-50 { background: #ecfdf5; }
.chat-bubble .border-emerald-500 { border-color: #10b981; }
.chat-bubble .bg-amber-50 { background: #fffbeb; }
.chat-bubble .border-amber-500 { border-color: #f59e0b; }
.chat-bubble .bg-blue-50 { background: #eff6ff; }
.chat-bubble .border-blue-500 { border-color: #3b82f6; }
.chat-bubble .bg-ink-50 { background: #f8fafc; }
.chat-bubble .text-ink-500 { color: #64748b; }
.chat-bubble .text-ink-700 { color: #334155; }
