/**
 * Ingot POC - Source Capture UI Styles
 * Dark theme matching POC sites
 */

/* =====================================================
   CSS Variables (extend existing Ingot variables)
   ===================================================== */
:root {
  /* Source-specific colors */
  --source-bg-card: #1e1e32;
  --source-bg-card-hover: #252545;
  --source-bg-input: #0f0f1a;
  --source-border-card: #333;
  --source-accent-clip: #9c7cf4;
  --source-accent-hash: #4fc3f7;
}

/* =====================================================
   Modal Overlay
   ===================================================== */
.source-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.source-modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* =====================================================
   Modal Container
   ===================================================== */
.source-modal {
  background: linear-gradient(180deg, #1a1a2e 0%, #16213e 100%);
  border: 1px solid var(--source-border-card);
  border-radius: 12px;
  width: 90%;
  max-width: 640px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  transform: translateY(20px);
  transition: transform 0.2s ease;
}

.source-modal-overlay.active .source-modal {
  transform: translateY(0);
}

/* =====================================================
   Modal Header
   ===================================================== */
.source-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--source-border-card);
  background: rgba(0, 0, 0, 0.2);
}

.source-modal-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: #e8e8e8;
}

.source-modal-close {
  background: none;
  border: none;
  color: #888;
  font-size: 24px;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  border-radius: 4px;
  transition: all 0.15s ease;
}

.source-modal-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

/* =====================================================
   Modal Body
   ===================================================== */
.source-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

/* =====================================================
   Steps
   ===================================================== */
.source-step {
  display: none;
  margin-bottom: 24px;
}

.source-step.active {
  display: block;
}

.source-step:last-child {
  margin-bottom: 0;
}

/* =====================================================
   Form Elements
   ===================================================== */
.source-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #a0a0a0;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.source-label .label-hint {
  display: block;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: #666;
  font-size: 12px;
  margin-top: 4px;
}

.source-input,
.source-textarea {
  width: 100%;
  padding: 12px 14px;
  background: var(--source-bg-input);
  border: 1px solid var(--source-border-card);
  border-radius: 8px;
  color: #e8e8e8;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.source-input:focus,
.source-textarea:focus {
  outline: none;
  border-color: var(--source-accent-hash);
  box-shadow: 0 0 0 3px rgba(79, 195, 247, 0.15);
}

.source-input::placeholder,
.source-textarea::placeholder {
  color: #555;
}

.source-textarea {
  resize: vertical;
  min-height: 80px;
}

.source-field {
  margin-bottom: 16px;
}

.source-field:last-child {
  margin-bottom: 0;
}

/* URL Input Group */
.source-url-input-group {
  display: flex;
  gap: 8px;
}

.source-url-input-group .source-input {
  flex: 1;
}

.source-url-error {
  color: #ef5350;
  font-size: 12px;
  margin-top: 6px;
  min-height: 18px;
}

/* =====================================================
   Buttons
   ===================================================== */
.source-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.source-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.source-btn-primary {
  background: linear-gradient(135deg, #4fc3f7 0%, #29b6f6 100%);
  color: #0a0a14;
}

.source-btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #81d4fa 0%, #4fc3f7 100%);
  transform: translateY(-1px);
}

.source-btn-secondary {
  background: rgba(79, 195, 247, 0.15);
  color: #4fc3f7;
  border: 1px solid rgba(79, 195, 247, 0.3);
}

.source-btn-secondary:hover:not(:disabled) {
  background: rgba(79, 195, 247, 0.25);
}

.source-btn-ghost {
  background: transparent;
  color: #888;
}

.source-btn-ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.05);
  color: #aaa;
}

/* Loading state */
.source-btn .btn-loading {
  display: none;
}

.source-btn.loading .btn-text {
  display: none;
}

.source-btn.loading .btn-loading {
  display: inline;
}

/* =====================================================
   Preview Card
   ===================================================== */
.source-preview-card {
  display: flex;
  gap: 16px;
  padding: 16px;
  background: var(--source-bg-card);
  border: 1px solid var(--source-border-card);
  border-radius: 10px;
  margin-bottom: 16px;
}

.source-preview-thumbnail {
  width: 120px;
  height: 90px;
  flex-shrink: 0;
  border-radius: 6px;
  overflow: hidden;
  background: #0f0f1a;
  position: relative;
}

.source-preview-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.source-preview-thumb-placeholder {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  color: #444;
}

.source-preview-info {
  flex: 1;
  min-width: 0;
}

.source-preview-info h3 {
  margin: 0 0 6px 0;
  font-size: 15px;
  font-weight: 600;
  color: #e8e8e8;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.source-preview-info p {
  margin: 0 0 8px 0;
  font-size: 12px;
  color: #888;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.source-preview-url {
  font-size: 11px;
  color: #4fc3f7;
  font-family: monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 8px;
}

.source-preview-meta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.source-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: #666;
}

.source-meta-item .meta-icon {
  font-size: 12px;
}

/* =====================================================
   Hash Info Box
   ===================================================== */
.source-hash-info {
  display: none;
  background: rgba(79, 195, 247, 0.05);
  border: 1px solid rgba(79, 195, 247, 0.2);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 16px;
}

.hash-info-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: #4fc3f7;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.hash-info-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hash-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.hash-item .hash-label {
  color: #888;
  min-width: 80px;
}

.hash-item .hash-value {
  font-family: 'SF Mono', Monaco, monospace;
  font-size: 11px;
  color: #4fc3f7;
  background: rgba(0, 0, 0, 0.3);
  padding: 2px 6px;
  border-radius: 4px;
}

/* =====================================================
   Clips
   ===================================================== */
.source-clips-list {
  margin-bottom: 12px;
}

.source-clip-item {
  background: rgba(156, 124, 244, 0.08);
  border: 1px solid rgba(156, 124, 244, 0.2);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 8px;
}

.source-clip-item:last-child {
  margin-bottom: 0;
}

.clip-quote {
  font-size: 13px;
  color: #d0d0d0;
  line-height: 1.5;
  font-style: italic;
}

.clip-mark {
  color: var(--source-accent-clip);
  font-size: 18px;
  font-weight: bold;
  font-style: normal;
}

.clip-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(156, 124, 244, 0.15);
}

.clip-hash {
  font-family: 'SF Mono', Monaco, monospace;
  font-size: 10px;
  color: #666;
}

.clip-remove {
  background: none;
  border: none;
  color: #666;
  font-size: 18px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1;
}

.clip-remove:hover {
  background: rgba(239, 83, 80, 0.2);
  color: #ef5350;
}

.source-clip-input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.source-clip-input-group .source-btn {
  align-self: flex-end;
}

/* =====================================================
   Modal Footer
   ===================================================== */
.source-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 20px;
  border-top: 1px solid var(--source-border-card);
  background: rgba(0, 0, 0, 0.2);
}

/* =====================================================
   Source List
   ===================================================== */
.source-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.source-list-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: #e8e8e8;
}

.source-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: linear-gradient(135deg, #4fc3f7 0%, #29b6f6 100%);
  color: #0a0a14;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.source-add-btn:hover {
  background: linear-gradient(135deg, #81d4fa 0%, #4fc3f7 100%);
  transform: translateY(-1px);
}

.source-add-btn .btn-icon {
  font-size: 16px;
  font-weight: bold;
}

/* Button variants */
.source-add-btn-small {
  padding: 6px 10px;
  font-size: 12px;
}

.source-add-btn-large {
  padding: 12px 20px;
  font-size: 15px;
}

.source-add-btn-secondary {
  background: rgba(79, 195, 247, 0.15);
  color: #4fc3f7;
  border: 1px solid rgba(79, 195, 247, 0.3);
}

.source-add-btn-secondary:hover {
  background: rgba(79, 195, 247, 0.25);
}

.source-add-btn-ghost {
  background: transparent;
  color: #888;
  border: 1px dashed #444;
}

.source-add-btn-ghost:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #aaa;
  border-color: #555;
}

/* =====================================================
   Source List Items
   ===================================================== */
.source-list-items {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.source-list-empty {
  text-align: center;
  padding: 40px 20px;
  background: var(--source-bg-card);
  border: 2px dashed var(--source-border-card);
  border-radius: 10px;
}

.source-list-empty .empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.source-list-empty p {
  margin: 0;
  color: #888;
  font-size: 14px;
}

.source-list-empty .empty-hint {
  font-size: 12px;
  color: #555;
  margin-top: 4px;
}

/* =====================================================
   Source Card
   ===================================================== */
.source-card {
  background: var(--source-bg-card);
  border: 1px solid var(--source-border-card);
  border-radius: 10px;
  overflow: hidden;
  transition: all 0.15s ease;
}

.source-card:hover {
  border-color: #444;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.source-card-header {
  display: flex;
  gap: 12px;
  padding: 12px;
  cursor: pointer;
  position: relative;
}

.source-card-thumbnail {
  width: 80px;
  height: 60px;
  flex-shrink: 0;
  border-radius: 6px;
  overflow: hidden;
  background: #0f0f1a;
}

.source-card-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.source-card-thumb-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: #444;
}

.source-card-info {
  flex: 1;
  min-width: 0;
}

.source-card-title {
  margin: 0 0 4px 0;
  font-size: 14px;
  font-weight: 600;
  color: #e8e8e8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.source-card-url {
  font-size: 11px;
  color: #4fc3f7;
  font-family: monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 6px;
}

.source-card-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.meta-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
  font-size: 10px;
  color: #888;
}

.source-card-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  background: none;
  border: none;
  color: #555;
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  line-height: 1;
  opacity: 0;
  transition: all 0.15s ease;
}

.source-card:hover .source-card-remove {
  opacity: 1;
}

.source-card-remove:hover {
  background: rgba(239, 83, 80, 0.2);
  color: #ef5350;
}

/* =====================================================
   Source Card Body (expanded)
   ===================================================== */
.source-card-body {
  display: none;
  padding: 0 12px 12px 12px;
  border-top: 1px solid var(--source-border-card);
}

.source-card.expanded .source-card-body {
  display: block;
  padding-top: 12px;
}

.source-card-reason,
.source-card-attribution {
  font-size: 13px;
  color: #c0c0c0;
  margin-bottom: 10px;
  line-height: 1.5;
}

.source-card-reason strong,
.source-card-attribution strong {
  color: #888;
  font-weight: 600;
}

/* Clips in card */
.source-card-clips {
  margin: 12px 0;
  padding: 10px;
  background: rgba(156, 124, 244, 0.05);
  border-radius: 6px;
}

.clips-header {
  font-size: 12px;
  font-weight: 600;
  color: var(--source-accent-clip);
  margin-bottom: 8px;
}

.clips-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.clip-preview {
  font-size: 12px;
  color: #999;
  font-style: italic;
  padding: 6px 8px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
  border-left: 2px solid var(--source-accent-clip);
}

/* Hashes in card */
.source-card-hashes {
  margin: 12px 0;
  padding: 10px;
  background: rgba(79, 195, 247, 0.05);
  border-radius: 6px;
}

.hash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
}

.hash-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.hash-cell .hash-label {
  font-size: 10px;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.hash-cell .hash-value {
  font-family: 'SF Mono', Monaco, monospace;
  font-size: 10px;
  color: #4fc3f7;
  word-break: break-all;
}

.source-card-timestamp {
  font-size: 11px;
  color: #555;
  text-align: right;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

/* =====================================================
   Toast Notifications
   ===================================================== */
.source-toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 10001;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.source-toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: #1e1e32;
  border: 1px solid #333;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  color: #e8e8e8;
  font-size: 13px;
  pointer-events: auto;
  animation: toastSlideIn 0.2s ease;
}

.source-toast.fading {
  animation: toastFadeOut 0.3s ease forwards;
}

@keyframes toastSlideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes toastFadeOut {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

.source-toast-success {
  border-left: 3px solid #66bb6a;
}

.source-toast-error {
  border-left: 3px solid #ef5350;
}

.source-toast-info {
  border-left: 3px solid #4fc3f7;
}

.toast-message {
  flex: 1;
}

.toast-close {
  background: none;
  border: none;
  color: #666;
  font-size: 18px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.toast-close:hover {
  color: #888;
}

/* =====================================================
   Responsive
   ===================================================== */
@media (max-width: 640px) {
  .source-modal {
    width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
  }
  
  .source-preview-card {
    flex-direction: column;
  }
  
  .source-preview-thumbnail {
    width: 100%;
    height: 120px;
  }
  
  .source-card-header {
    flex-direction: column;
  }
  
  .source-card-thumbnail {
    width: 100%;
    height: 100px;
  }
  
  .hash-grid {
    grid-template-columns: 1fr;
  }
}
