/*
Stronghold Labs Design System
Based on specifications from DESIGN_SYSTEM.md
*/

/* CSS Custom Properties - Core Color System */
:root {
  /* Background Colors */
  --bg-primary: #1F1F1F;        /* Main dark background */
  --bg-secondary: #2a2a2a;      /* Component backgrounds */
  --bg-tertiary: #374151;       /* Input backgrounds, elevated elements */

  /* Text Colors */
  --text-primary: #C3C3C3;      /* Primary text */
  --text-secondary: #6b7280;    /* Secondary/muted text */
  --text-accent: #A5B4FC;       /* Links and interactive elements */

  /* Status Colors (Processing States) */
  --status-complete: #10b981;    /* Green - completed operations */
  --status-active: #3b82f6;      /* Blue - in progress operations */
  --status-pending: #f59e0b;     /* Orange - waiting/queued operations */
  --status-error: #ef4444;       /* Red - failed operations */
  --status-special: #A855F7;     /* Purple - LLM operations */

  /* Border & Focus Colors */
  --border-primary: #3D3D3D;    /* Component borders */
  --border-focus: #A5B4FC;      /* Focus states and active elements */

  /* Font Scale */
  --font-xs: 12px;     /* Timestamps, technical details */
  --font-sm: 14px;     /* Body text, labels */
  --font-base: 16px;   /* Default text size */
  --font-lg: 18px;     /* Component headers */
  --font-xl: 20px;     /* Section titles */
  --font-2xl: 24px;    /* Page titles */
}

/* Global Styles */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-size: var(--font-base);
  line-height: 1.5;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  margin: 0 0 1rem 0;
  font-weight: 600;
  color: var(--text-primary);
}

h1 { font-size: var(--font-2xl); }
h2 { font-size: var(--font-xl); }
h3 { font-size: var(--font-lg); }

p {
  margin: 0 0 1rem 0;
  color: var(--text-primary);
}

a {
  color: var(--text-accent);
  text-decoration: none;
  transition: opacity 0.3s ease;
}

a:hover {
  opacity: 0.8;
}

/* Layout Components */
.stronghold-container {
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 32px;
  width: 95%;
}

.stronghold-card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 24px;
}

/* Input Fields */
.stronghold-input {
  width: 100%;
  height: 48px;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-primary);
  color: var(--text-primary);
  border-radius: 8px;
  padding: 12px;
  font-size: var(--font-sm);
  font-family: inherit;
  transition: all 0.3s ease;
}

.stronghold-input:focus {
  outline: none;
  box-shadow: 0 0 0 2px var(--border-focus);
  border-color: var(--border-focus);
}

.stronghold-input::placeholder {
  color: var(--text-secondary);
}

/* Select Dropdowns */
.stronghold-select {
  width: 100%;
  height: 48px;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-primary);
  color: var(--text-primary);
  border-radius: 8px;
  padding: 12px;
  font-size: var(--font-sm);
  font-family: inherit;
  cursor: pointer;
  transition: all 0.3s ease;
}

.stronghold-select:focus {
  outline: none;
  box-shadow: 0 0 0 2px var(--border-focus);
  border-color: var(--border-focus);
}

/* Button System */
.stronghold-btn {
  font-weight: 500;
  font-size: var(--font-sm);
  height: 40px;
  padding: 0 16px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: all 0.3s ease;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.stronghold-btn-primary {
  background-color: var(--status-active);
  color: white;
}

.stronghold-btn-primary:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.stronghold-btn-success {
  background-color: var(--status-complete);
  color: white;
}

.stronghold-btn-success:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.stronghold-btn-disabled {
  background-color: var(--text-secondary);
  color: var(--text-primary);
  cursor: not-allowed;
  opacity: 0.8;
}

.stronghold-btn-disabled:hover {
  transform: none;
}

/* Google OAuth Button Specific Styling */
.stronghold-btn-google {
  background-color: #4285f4;
  color: white;
  padding: 12px 24px;
  font-size: var(--font-base);
  height: 48px;
}

.stronghold-btn-google:hover {
  background-color: #3367d6;
}

/* Progress Bar System */
.stronghold-progress {
  position: relative;
  width: 100%;
  height: 16px;
  background-color: var(--bg-tertiary);
  border-radius: 9999px;
  border: 1px solid #4b5563;
  overflow: hidden;
}

.stronghold-progress-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  border-radius: 9999px;
  transition: all 0.3s ease;
}

/* Status-based colors for progress bars */
.stronghold-progress-fill.pending { background-color: var(--text-secondary); }
.stronghold-progress-fill.active { background-color: var(--status-active); }
.stronghold-progress-fill.complete { background-color: var(--status-complete); }
.stronghold-progress-fill.error { background-color: var(--status-error); }
.stronghold-progress-fill.special { background-color: var(--status-special); }

/* Processing Checklist Items (PCI) */
.stronghold-checklist-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: 8px;
  margin-bottom: 8px;
  transition: all 0.3s ease;
}

.stronghold-checklist-icon {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
}

.stronghold-checklist-content {
  flex-grow: 1;
  min-width: 0;
}

.stronghold-checklist-status {
  flex-shrink: 0;
  font-size: var(--font-sm);
  font-weight: 500;
}

/* PCI State Classes */
.stronghold-checklist-item.pending {
  opacity: 0.6;
}

.stronghold-checklist-item.active {
  opacity: 0.9;
}

.stronghold-checklist-item.complete {
  opacity: 1;
}

/* Animations */
@keyframes stronghold-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.stronghold-pulse-active {
  animation: stronghold-pulse 2s infinite;
}

@keyframes stronghold-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.stronghold-spinner {
  border: 2px solid #525252;
  border-top: 2px solid var(--text-primary);
  border-radius: 50%;
  width: 16px;
  height: 16px;
  animation: stronghold-spin 1s linear infinite;
}

/* Layout Grids */
.stronghold-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 24px;
}

@media (max-width: 768px) {
  .stronghold-grid-3 {
    grid-template-columns: 1fr;
  }
}

/* Four-Column Grid Layout */
.stronghold-grid-4 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 24px;
}

@media (max-width: 1024px) {
  .stronghold-grid-4 {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 768px) {
  .stronghold-grid-4 {
    grid-template-columns: 1fr;
  }
}

/* Two-Column Layout for Dashboard */
.stronghold-grid-2-column {
  display: grid;
  grid-template-columns: 1fr 3fr;
  gap: 24px;
  width: 100%;
}

@media (max-width: 1024px) {
  .stronghold-grid-2-column {
    grid-template-columns: 1fr 2fr;
  }
}

@media (max-width: 768px) {
  .stronghold-grid-2-column {
    grid-template-columns: 1fr;
  }
}

/* Column Stacking */
.stronghold-column-stack {
  display: flex;
  flex-direction: column;
  gap: 24px;
}


/* Header Styles */
.stronghold-header {
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-primary);
  padding: 16px 0;
}

.stronghold-header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stronghold-logo {
  font-size: var(--font-xl);
  font-weight: 600;
  color: var(--text-primary);
}

/* Event Log Component */
.stronghold-event-log {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-primary);
  border-radius: 8px;
  padding: 16px;
  font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
  font-size: var(--font-xs);
  max-height: 400px;
  overflow-y: auto;
}

.stronghold-event-log-entry {
  margin-bottom: 8px;
  color: var(--text-secondary);
}

.stronghold-event-log-timestamp {
  color: var(--status-active);
}

/* Form Groups */
.stronghold-form-group {
  margin-bottom: 24px;
}

.stronghold-form-label {
  display: block;
  margin-bottom: 8px;
  font-size: var(--font-sm);
  font-weight: 500;
  color: var(--text-primary);
}

/* Status Indicators */
.stronghold-status-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: var(--font-xs);
  font-weight: 500;
  text-transform: uppercase;
}

.stronghold-status-badge.pending {
  background-color: var(--status-pending);
  color: white;
}

.stronghold-status-badge.active {
  background-color: var(--status-active);
  color: white;
}

.stronghold-status-badge.complete {
  background-color: var(--status-complete);
  color: white;
}

.stronghold-status-badge.error {
  background-color: var(--status-error);
  color: white;
}

/* M10.6: Phase-specific status badges */
.stronghold-status-badge.requested {
  background-color: var(--status-pending);
  color: white;
}

.stronghold-status-badge.downloading {
  background-color: var(--status-active);
  color: white;
}

.stronghold-status-badge.segmenting {
  background-color: var(--status-special);
  color: white;
}

.stronghold-status-badge.llm_processing {
  background-color: var(--status-complete);
  color: white;
}

.stronghold-status-badge.completed {
  background-color: var(--text-secondary);
  color: white;
}

.stronghold-status-badge.failed {
  background-color: var(--status-error);
  color: white;
}

/* M12.9.1: Partial success status badge (orange/yellow warning color) */
.stronghold-status-badge.partial_success {
  background-color: var(--status-pending);
  color: white;
}

/* Utility Classes */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.p-4 { padding: 16px; }
.p-6 { padding: 24px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-4 { gap: 16px; }
.w-full { width: 100%; }

/* ===================================
   M10.5: Highlight Display Styles
   =================================== */

/* Container */
.highlights-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 0;
}

/* Horizontal Highlight Card */
.highlight-card {
    display: flex;
    gap: 4px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    padding: 16px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.highlight-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* M12.9.3: Number column (left of thumbnail) */
.highlight-number-column {
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
    flex-shrink: 0;
    width: auto;
    min-width: 20px;
    padding: 0;
    margin-right: 6px;
}

.highlight-list-number {
    font-size: 15px;
    font-weight: bold;
    color: var(--text-secondary);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

.highlight-list-number::after {
    content: ':';
}

/* Left column: Thumbnail + Button */
.highlight-left {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
    margin-right: 16px;
}

/* Thumbnail */
.highlight-thumbnail {
    position: relative;
    flex-shrink: 0;
    width: 280px; /* M12.9.3: Increased 40% from 200px */
    height: 157px; /* M12.9.3: Increased 40% from 112px (16:9 ratio maintained) */
    border-radius: 6px;
    overflow: hidden;
    background: var(--bg-tertiary);
    border: 2px solid var(--border-primary, #d1d5db); /* M12.9.3: Added border with fallback */
}

.highlight-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 0.3s ease;
}

/* M12.9.3: Commented out - number overlay removed from thumbnails
.highlight-number {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: bold;
    font-size: 14px;
    z-index: 1;
}
*/

/* Content Area */
.highlight-content {
    flex: 1;
    min-width: 0; /* Allow text truncation */
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.highlight-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.4;
}

.highlight-meta {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0;
}

.highlight-time {
    display: flex;
    align-items: center;
    gap: 4px;
}

.highlight-confidence {
    color: var(--status-complete);
    font-weight: 600;
}

.highlight-description {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
}

.highlight-quote {
    margin: 0;
    padding-left: 12px;
    border-left: 3px solid var(--status-active);
    font-style: italic;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Players */
.highlight-players {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 4px;
}

.player-chip {
    background: var(--status-special);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

/* Tags */
.highlight-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.highlight-tags .tag {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

/* Empty State (add specificity for highlights container) */
#highlights-container .empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    text-align: center;
    color: var(--text-secondary);
}

/* Spinner (if not already in global styles) */
.stronghold-spinner {
    border: 3px solid var(--bg-tertiary);
    border-top: 3px solid var(--status-active);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .highlight-card {
        flex-direction: column;
    }

    .highlight-thumbnail {
        width: 100%;
        height: auto;
        aspect-ratio: 16 / 9;
    }
}

/* ========================================
   M12: Clip Download Button Styles
   ======================================== */

/* Highlight Actions Container */
.highlight-actions {
    margin-top: 12px;
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: center;
}

/* Download Clip Button */
.download-clip-btn {
    background-color: #10b981;  /* Green - success/complete color */
    color: white;
    font-weight: 500;
    font-size: 14px;
    height: 36px; /* M12.9.3: Reduced by 4px (2px top + 2px bottom) */
    padding: 0 14px; /* M12.9.3: Reduced by 2px each side (16px -> 14px) */
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 140px;
}

/* Hover effect (only when not disabled) */
.download-clip-btn:not(:disabled):hover {
    background-color: #059669;  /* Darker green on hover */
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

/* Active state */
.download-clip-btn:not(:disabled):active {
    transform: translateY(0);
    box-shadow: 0 1px 4px rgba(16, 185, 129, 0.2);
}

/* Disabled state for processing */
.download-clip-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background-color: #10b981;  /* Keep green color */
}

/* Animated ellipsis for "downloading clip..." */
.animated-ellipsis {
    display: inline-block;
    min-width: 20px;
}

@keyframes ellipsis-animation {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

.animated-ellipsis::after {
    content: '';
    animation: ellipsis-animation 1.5s infinite;
}

/* ===================================
   M14.0: Unified Jobs Table Styles
   =================================== */

/* Pulsing Blue Progress Bar for Live Streams */
.stream-live-progress-bar {
    height: 24px;
    background: var(--bg-tertiary);
    border-radius: 12px;
    overflow: hidden;
    position: relative;
}

.pulsing-blue-fill {
    height: 100%;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulsing-blue 2s ease-in-out infinite;
}

@keyframes pulsing-blue {
    0%, 100% { background-color: #bfdbfe; } /* light blue */
    25% { background-color: #3b82f6; }      /* blue */
    50% { background-color: #1e40af; }      /* dark blue */
    75% { background-color: #3b82f6; }      /* blue */
}

/* Diagonal Stripe Pattern */
.pulsing-blue-fill.striped {
    background-image: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 10px,
        rgba(255, 255, 255, 0.1) 10px,
        rgba(255, 255, 255, 0.1) 20px
    );
    background-size: 28px 28px;
    animation: pulsing-blue 2s ease-in-out infinite,
               stripe-animation 1s linear infinite;
}

@keyframes stripe-animation {
    0% { background-position: 0 0; }
    100% { background-position: 28px 0; }
}

.live-badge {
    color: white;
    font-weight: 600;
    font-size: 13px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    z-index: 1;
}

/* Job Row Backgrounds and Hover Effects */
tr.job-row.vod:hover {
    background-color: rgba(16, 185, 129, 0.08) !important;
}

tr.job-row.stream:hover {
    background-color: rgba(168, 85, 247, 0.08) !important;
}

/* Filter Tabs */
.jobs-filter-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.filter-tab {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    color: var(--text-primary);
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.filter-tab:hover:not(.active) {
    background: var(--bg-tertiary);
}

.filter-tab.active {
    background: var(--status-active) !important;
    color: white !important;
    border-color: var(--status-active) !important;
}

/* Capturing status badge for stream jobs */
.stronghold-status-badge.capturing {
    background-color: var(--status-active);
    color: white;
}

/* Running status badge (for processing) */
.stronghold-status-badge.running {
    background-color: var(--status-special);
    color: white;
}

/* Downloading status for progress bars */
.stronghold-progress-fill.downloading {
    background-color: var(--status-active);
}