/* =========================================
   AI RCA Analyzer — Frontend Styles
   ========================================= */

*, *::before, *::after { box-sizing: border-box; }

.ai-rca-wrap {
  max-width: 860px;
  margin: 24px auto;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  color: #222;
  font-size: 15px;
  line-height: 1.6;
}

/* ---- Card ---- */
.ai-rca-card {
  background: #fff;
  border: 1px solid #dde4f0;
  border-radius: 10px;
  padding: 28px 32px;
  margin-bottom: 24px;
  box-shadow: 0 2px 12px rgba(26,60,110,0.06);
}

/* ---- Header ---- */
.ai-rca-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}
.ai-rca-header h2 {
  margin: 0;
  font-size: 20px;
  color: #1a3c6e;
  font-weight: 700;
}

/* ---- Notice box ---- */
.ai-rca-notice {
  background: #f0f5ff;
  border: 1px solid #c5d5f5;
  border-radius: 7px;
  padding: 14px 18px;
  margin-bottom: 22px;
}
.ai-rca-notice strong { color: #1a3c6e; }
.ai-rca-notice ul {
  margin: 8px 0 4px 20px;
  padding: 0;
}
.ai-rca-notice ul li { margin-bottom: 3px; }
.ai-rca-notice-sub {
  margin: 8px 0 0;
  font-size: 13px;
  color: #666;
}

/* ---- Form ---- */
.ai-rca-field { margin-bottom: 18px; }
.ai-rca-label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  color: #1a3c6e;
}

/* Drop zone */
.ai-rca-file-wrapper {
  position: relative;
  border: 2px dashed #9bb5e0;
  border-radius: 8px;
  padding: 30px 20px;
  text-align: center;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.ai-rca-file-wrapper:hover,
.ai-rca-file-wrapper.drag-over {
  background: #f0f5ff;
  border-color: #1a3c6e;
}
.ai-rca-file-wrapper input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}
.ai-rca-file-ui p {
  margin: 8px 0 0;
  color: #555;
}
.ai-rca-file-ui span { color: #1a3c6e; text-decoration: underline; }
.ai-rca-file-hint { font-size: 12px; color: #999; margin-top: 4px !important; }

/* ---- Error ---- */
.ai-rca-error {
  background: #fff3f3;
  border: 1px solid #f5c6c6;
  border-radius: 7px;
  color: #c0392b;
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 14px;
}

/* ---- Button ---- */
.ai-rca-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #1a3c6e;
  color: #fff;
  border: none;
  border-radius: 7px;
  padding: 11px 24px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  text-decoration: none;
}
.ai-rca-btn:hover { background: #142d56; }
.ai-rca-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.ai-rca-btn-outline {
  background: transparent;
  border: 2px solid #1a3c6e;
  color: #1a3c6e;
}
.ai-rca-btn-outline:hover { background: #f0f5ff; }

/* ---- Spinner ---- */
.ai-rca-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: ai-rca-spin 0.7s linear infinite;
}

/* ---- Loading card ---- */
.ai-rca-loading-card { text-align: center; padding: 48px 32px; }
.ai-rca-loading-inner h3 { color: #1a3c6e; margin: 16px 0 4px; font-size: 18px; }
.ai-rca-loading-inner p  { color: #666; margin: 0; }
.ai-rca-big-spinner {
  display: inline-block;
  width: 48px;
  height: 48px;
  border: 4px solid #c5d5f5;
  border-top-color: #1a3c6e;
  border-radius: 50%;
  animation: ai-rca-spin 0.9s linear infinite;
}

@keyframes ai-rca-spin {
  to { transform: rotate(360deg); }
}

/* ---- Results ---- */
.ai-rca-result-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 24px;
}
.ai-rca-result-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 20px;
  color: #1a3c6e;
  margin: 0 0 4px;
}
.ai-rca-result-date { color: #888; font-size: 13px; margin: 0; }
.ai-rca-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ---- Sections ---- */
.ai-rca-section {
  margin-bottom: 24px;
  border: 1px solid #dde4f0;
  border-radius: 8px;
  overflow: hidden;
}
.ai-rca-section-head {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f0f5ff;
  color: #1a3c6e;
  font-weight: 700;
  font-size: 15px;
  padding: 10px 16px;
  border-bottom: 1px solid #dde4f0;
}
.ai-rca-section-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #1a3c6e;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}
.ai-rca-section-body {
  padding: 14px 16px;
}
.ai-rca-section-body p { margin: 0 0 8px; }
.ai-rca-section-body ul {
  margin: 0 0 0 20px;
  padding: 0;
}
.ai-rca-section-body ul li { margin-bottom: 5px; }

/* Root cause table */
.ai-rca-rc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.ai-rca-rc-table th {
  background: #1a3c6e;
  color: #fff;
  padding: 7px 12px;
  text-align: left;
  font-weight: 600;
}
.ai-rca-rc-table td {
  padding: 8px 12px;
  border-bottom: 1px solid #eef;
  vertical-align: top;
}
.ai-rca-rc-table tr:last-child td { border-bottom: none; }
.ai-rca-rc-table tr:nth-child(even) td { background: #f8faff; }

.ai-rca-badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}
.ai-rca-badge-high   { background: #fde8e8; color: #c0392b; }
.ai-rca-badge-medium { background: #fff3cd; color: #856404; }
.ai-rca-badge-low    { background: #d4edda; color: #155724; }

/* Fishbone grid */
.ai-rca-fishbone-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.ai-rca-fb-cat {
  background: #f8faff;
  border: 1px solid #dde4f0;
  border-radius: 7px;
  padding: 10px 14px;
}
.ai-rca-fb-cat-title {
  font-weight: 700;
  color: #1a3c6e;
  margin-bottom: 6px;
  font-size: 13px;
}

/* 5 WHY */
.ai-rca-why-list { list-style: none; margin: 0; padding: 0; }
.ai-rca-why-list li {
  padding: 7px 12px;
  border-left: 3px solid #9bb5e0;
  margin-bottom: 6px;
  background: #f8faff;
  border-radius: 0 5px 5px 0;
}
.ai-rca-why-list li.why-q {
  border-left-color: #1a3c6e;
  font-weight: 600;
  color: #1a3c6e;
}

/* Checklist */
.ai-rca-checklist { list-style: none; margin: 0; padding: 0; }
.ai-rca-checklist li {
  padding: 5px 0;
  display: flex;
  gap: 8px;
  align-items: flex-start;
  border-bottom: 1px dashed #eee;
}
.ai-rca-checklist li:last-child { border-bottom: none; }
.ai-rca-checklist li::before {
  content: "☐";
  font-size: 16px;
  color: #1a3c6e;
  flex-shrink: 0;
  line-height: 1.4;
}

/* ---- Responsive ---- */
@media (max-width: 600px) {
  .ai-rca-card { padding: 18px 16px; }
  .ai-rca-result-header { flex-direction: column; }
  .ai-rca-fishbone-grid { grid-template-columns: 1fr; }
  .ai-rca-btn { width: 100%; justify-content: center; }
  .ai-rca-actions { width: 100%; }
  .ai-rca-actions form, .ai-rca-actions button { width: 100%; }
}

/* =========================================
   v1.1 Additions
   ========================================= */

/* Tagline */
.ai-rca-tagline {
  margin: 0;
  font-size: 12px;
  color: #5a7ab0;
  font-style: italic;
}

/* Usage bar */
.ai-rca-usage-bar {
  background: #f0f5ff;
  border: 1px solid #c5d5f5;
  border-radius: 7px;
  padding: 10px 16px;
  margin-bottom: 18px;
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  align-items: center;
}
.ai-rca-usage-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 130px;
}
.ai-rca-usage-label {
  font-size: 11px;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.ai-rca-usage-track {
  height: 6px;
  background: #dde4f0;
  border-radius: 3px;
  overflow: hidden;
}
.ai-rca-usage-fill {
  height: 100%;
  border-radius: 3px;
  background: #1a3c6e;
  transition: width 0.4s ease;
}
.ai-rca-usage-fill.warn  { background: #f57c00; }
.ai-rca-usage-fill.full  { background: #d32f2f; }
.ai-rca-usage-count {
  font-size: 11px;
  color: #444;
  font-weight: 600;
}
.ai-rca-usage-unlimited {
  font-size: 12px;
  color: #388e3c;
  font-weight: 600;
}

/* Incident metadata grid */
.ai-rca-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}
.ai-rca-meta-cell {
  background: #f0f5ff;
  border: 1px solid #c5d5f5;
  border-radius: 7px;
  padding: 10px 14px;
}
.ai-rca-meta-cell .meta-label {
  font-size: 11px;
  color: #5a7ab0;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
  margin-bottom: 3px;
}
.ai-rca-meta-cell .meta-value {
  font-size: 14px;
  color: #1a1a1a;
  font-weight: 600;
}

/* Powered by footer */
.ai-rca-powered {
  text-align: center;
  color: #999;
  font-size: 11px;
  margin-top: 24px;
  padding-top: 12px;
  border-top: 1px solid #eee;
}

/* Responsive meta grid */
@media (max-width: 600px) {
  .ai-rca-meta-grid { grid-template-columns: 1fr; }
  .ai-rca-usage-bar { flex-direction: column; gap: 12px; }
}
