/* style.css - CSS Design System for Incident Storyboard Platform */

/* Core Variables */
:root {
  --bg-color: #0b1220;
  --panel-bg: #131c2e;
  --border-color: #25324a;
  --text-highlight: #f8fafc;
  --text-muted: #94a3b8;
  --accent-color: #38bdf8;
  
  --severity-1-3: #22c55e;
  --severity-4-6: #facc15;
  --severity-7-8: #f97316;
  --severity-9-10: #ef4444;

  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --transition-speed: 0.2s;
  --radius-lg: 12px;
  --radius-md: 8px;
  --radius-sm: 4px;
}

/* Reset and Layout Base */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-color);
  color: var(--text-highlight);
  font-family: var(--font-family);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
  padding: 0 20px;
}

/* Header Component */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 0 10px;
  border-bottom: 1px solid var(--border-color);
}

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

.logo-icon {
  font-size: 28px;
}

.header-logo h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.05em;
  background: linear-gradient(90deg, var(--text-highlight), var(--accent-color));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Stats Counter */
.stats-panel {
  display: flex;
  gap: 16px;
}

.stat-card {
  background: var(--panel-bg);
  border: 1px solid var(--border-color);
  padding: 8px 16px;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  min-width: 120px;
}

.stat-label {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.stat-val {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-highlight);
}

/* Crimson Pulse for critical alarms */
.text-pulse {
  animation: pulse-red 2s infinite alternate;
}

@keyframes pulse-red {
  0% {
    color: var(--text-highlight);
    text-shadow: 0 0 2px rgba(239, 68, 68, 0.2);
  }
  100% {
    color: var(--severity-9-10);
    text-shadow: 0 0 10px rgba(239, 68, 68, 0.8);
  }
}

/* Toolbar Component */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0;
  border-bottom: 1px solid var(--border-color);
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 20px;
}

.btn-primary {
  background-color: var(--accent-color);
  color: #040914;
  border: none;
  font-family: var(--font-family);
  font-weight: 600;
  font-size: 13.5px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: transform var(--transition-speed), background-color var(--transition-speed);
}

.btn-primary:hover {
  background-color: #60cbf9;
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background-color: var(--panel-bg);
  color: var(--text-highlight);
  border: 1px solid var(--border-color);
  font-family: var(--font-family);
  font-size: 13px;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background-color var(--transition-speed);
}

.btn-secondary:hover:not(:disabled) {
  background-color: var(--border-color);
}

.btn-secondary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Toggle Switch */
.toggle-container {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.toggle-container input {
  display: none;
}

.toggle-slider {
  width: 40px;
  height: 20px;
  background-color: #1e293b;
  border-radius: 999px;
  position: relative;
  transition: background-color var(--transition-speed);
  border: 1px solid var(--border-color);
}

.toggle-slider::before {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background-color: var(--text-muted);
  top: 2px;
  left: 2px;
  transition: transform var(--transition-speed), background-color var(--transition-speed);
}

.toggle-container input:checked + .toggle-slider {
  background-color: rgba(56, 189, 248, 0.2);
  border-color: var(--accent-color);
}

.toggle-container input:checked + .toggle-slider::before {
  transform: translateX(20px);
  background-color: var(--accent-color);
}

.toggle-label {
  font-size: 13px;
  color: var(--text-muted);
  transition: color var(--transition-speed);
}

.toggle-container input:checked ~ .toggle-label {
  color: var(--text-highlight);
}

.status-indicator-text {
  font-size: 12px;
  color: var(--text-muted);
  background: rgba(255,255,255,0.03);
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-color);
}

/* Split Pane Grid */
.split-pane {
  display: grid;
  grid-template-columns: 380px 1fr;
  flex: 1;
  overflow: hidden;
  margin: 16px 0;
  gap: 20px;
}

/* Master Pane (Left List) */
.pane-master {
  display: flex;
  flex-direction: column;
  background: var(--panel-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.pane-title {
  font-size: 14px;
  text-transform: uppercase;
  color: var(--accent-color);
  letter-spacing: 0.1em;
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
}

.feed-list {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Feed Cards */
.storyline-card {
  background: rgba(255,255,255,0.015);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.storyline-card:hover {
  background: rgba(255,255,255,0.035);
  border-color: #38bdf850;
  transform: translateY(-1px);
}

.storyline-card.active {
  background: rgba(56, 189, 248, 0.05);
  border-color: var(--accent-color);
}

/* Color tabs on left boundary of cards */
.storyline-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background-color: var(--severity-1-3);
}

.storyline-card.severity-low::before { background-color: var(--severity-1-3); }
.storyline-card.severity-medium::before { background-color: var(--severity-4-6); }
.storyline-card.severity-high::before { background-color: var(--severity-7-8); }
.storyline-card.severity-critical::before { 
  background-color: var(--severity-9-10);
  animation: bg-pulse-red 1.5s infinite alternate; 
}

@keyframes bg-pulse-red {
  0% { opacity: 0.5; }
  100% { opacity: 1; }
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
  gap: 8px;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-highlight);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.severity-pill {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  color: #040914;
}

.severity-pill.low { background-color: var(--severity-1-3); }
.severity-pill.medium { background-color: var(--severity-4-6); }
.severity-pill.high { background-color: var(--severity-7-8); }
.severity-pill.critical { background-color: var(--severity-9-10); color: #fff; }

.card-summary {
  font-size: 12px;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 8px;
  line-height: 1.4;
}

.card-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
}

.card-meta-left {
  display: flex;
  gap: 8px;
}

/* Pagination panel */
.pagination-controls {
  padding: 12px 16px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12.5px;
  color: var(--text-muted);
}

/* Detail Pane (Right List) */
.pane-detail {
  background: var(--panel-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state h3 {
  color: var(--text-highlight);
  font-size: 16px;
  margin-bottom: 8px;
}

.empty-state p {
  max-width: 320px;
  font-size: 13px;
  line-height: 1.5;
}

/* Loaded Detail View layout */
.detail-content {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  flex: 1;
}

.detail-header {
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 16px;
}

.detail-header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  gap: 16px;
}

.detail-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-highlight);
}

.detail-desc {
  font-size: 14px;
  color: #cdd9e5;
  line-height: 1.6;
}

/* Detail Metrics Grid */
.detail-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
}

.metric-box {
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 14px;
}

.metric-box-label {
  font-size: 10.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
  letter-spacing: 0.05em;
}

.metric-box-val {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-highlight);
}

/* Timeline Audit Trail */
.timeline-section h3 {
  font-size: 14px;
  text-transform: uppercase;
  color: var(--accent-color);
  letter-spacing: 0.05em;
  margin-bottom: 16px;
}

.timeline-trail {
  display: flex;
  flex-direction: column;
  position: relative;
  padding-left: 20px;
  margin-left: 10px;
}

.timeline-trail::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background-color: var(--border-color);
}

.timeline-node {
  position: relative;
  padding-bottom: 20px;
}

.timeline-node:last-child {
  padding-bottom: 0;
}

/* Circular ring indicator on the line */
.timeline-dot {
  position: absolute;
  left: -24px;
  top: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--bg-color);
  border: 2px solid var(--accent-color);
  z-index: 1;
}

.timeline-card-inner {
  background: rgba(255,255,255,0.015);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  transition: border-color var(--transition-speed);
}

.timeline-card-inner:hover {
  border-color: #38bdf830;
}

.timeline-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.timeline-meta-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.event-icon-badge {
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.event-type-label {
  text-transform: uppercase;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.timeline-text {
  font-size: 13px;
  color: var(--text-highlight);
  line-height: 1.5;
}

.timeline-source {
  margin-top: 6px;
  font-size: 11px;
}

.source-link {
  color: var(--accent-color);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.source-link:hover {
  text-decoration: underline;
}

/* Loading/Error views */
.loading-spinner {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
  font-size: 13px;
}

.error-message {
  text-align: center;
  padding: 40px;
  color: var(--severity-9-10);
  font-size: 13px;
}

/* Footer Section */
.app-footer {
  text-align: center;
  padding: 16px 0;
  font-size: 11px;
  color: var(--text-muted);
  border-top: 1px solid var(--border-color);
  margin-top: auto;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-color);
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 99px;
}

::-webkit-scrollbar-thumb:hover {
  background: #334155;
}

/* Responsive Overrides */
@media (max-width: 800px) {
  .app-container {
    height: auto;
  }
  
  .split-pane {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
  }
  
  .pane-master, .pane-detail {
    height: 500px;
    overflow-y: auto;
  }
  
  .app-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
    padding-bottom: 20px;
  }
  
  .stats-panel {
    width: 100%;
  }
  
  .stat-card {
    flex: 1;
  }
  
  .toolbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  
  .toolbar-right {
    align-self: flex-end;
  }
}

/* Modal Overlay & Archive Manager Styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(4, 9, 20, 0.8);
  backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  transition: opacity var(--transition-speed);
}

.modal-overlay.hidden {
  display: none !important;
}

.modal-content {
  background-color: var(--panel-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 850px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 10px 10px -5px rgba(0, 0, 0, 0.5);
  animation: modal-enter 0.2s ease-out;
}

@keyframes modal-enter {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent-color);
}

.btn-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 28px;
  cursor: pointer;
  line-height: 1;
  transition: color var(--transition-speed);
}

.btn-close:hover {
  color: var(--text-highlight);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-subtitle {
  font-size: 13px;
  color: var(--text-muted);
}

.archive-table-container {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  max-height: 350px;
  overflow-y: auto;
  background: rgba(255,255,255,0.005);
}

.archive-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  text-align: left;
}

.archive-table th, .archive-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

.archive-table th {
  background: rgba(4, 9, 20, 0.3);
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.05em;
}

.archive-table tr:last-child td {
  border-bottom: none;
}

.archive-table td code {
  color: var(--accent-color);
  font-family: monospace;
  font-size: 12px;
}

/* Status Badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
  text-transform: uppercase;
}

.status-badge.processed {
  background-color: rgba(34, 197, 94, 0.1);
  color: var(--severity-1-3);
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.status-badge.pending {
  background-color: rgba(148, 163, 184, 0.1);
  color: var(--text-muted);
  border: 1px solid rgba(148, 163, 184, 0.2);
}

.btn-table-action {
  font-size: 11.5px;
  padding: 4px 10px;
  font-weight: 500;
}
