/**
 * RE::DACT Sparks Extension
 * =========================
 * Gold-Orange theme matching RE::DACT design system
 */

/* ============================================
   CSS VARIABLES
   ============================================ */

:root {
  /* Colors */
  --bg: #0a0a0a;
  --bg-secondary: #111;
  --bg-tertiary: #1a1a1a;
  --border: #333;
  --text: #fff;
  --text-dim: #888;
  --text-muted: #666;
  
  /* Accent - Gold/Orange (Sparks theme) */
  --spark-gold: #FF9A00;
  --spark-orange: #FF6D00;
  --spark-amber: #FFAB00;
  --spark-gradient: linear-gradient(135deg, #FF9A00 0%, #FF6D00 100%);
  
  /* Status colors */
  --success: #4ade80;
  --error: #ef4444;
  --warning: #f59e0b;
  
  /* Sizing */
  --popup-width: 320px;
  --border-radius: 6px;
  --border-radius-sm: 4px;
}

/* ============================================
   BASE STYLES
   ============================================ */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
  width: var(--popup-width);
  min-height: 200px;
  overflow-x: hidden;
}

/* ============================================
   VIEWS (screens)
   ============================================ */

.view {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.view.hidden {
  display: none;
}

/* ============================================
   HEADER
   ============================================ */

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}

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

.spark-icon {
  width: 20px;
  height: 20px;
  stroke: var(--spark-gold);
}

.brand {
  font-size: 14px;
  font-weight: 700;
  background: var(--spark-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-title {
  font-size: 14px;
  font-weight: 600;
}

.header-actions {
  display: flex;
  gap: 4px;
}

/* ============================================
   CONTENT AREA
   ============================================ */

.content {
  flex: 1;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ============================================
   LOGIN VIEW
   ============================================ */

.login-content {
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 32px 24px;
}

.login-message {
  margin-bottom: 24px;
}

.login-message p {
  color: var(--text-dim);
  line-height: 1.5;
}

.login-hint {
  margin-top: 16px;
  font-size: 12px;
  color: var(--text-muted);
}

.login-hint a {
  color: var(--spark-gold);
  text-decoration: none;
}

.login-hint a:hover {
  text-decoration: underline;
}

/* ============================================
   PAGE INFO (current tab)
   ============================================ */

.page-info {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-tertiary);
  border-radius: var(--border-radius);
  border: 1px solid var(--border);
}

.page-favicon {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  background: var(--bg-secondary);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.page-favicon img {
  width: 16px;
  height: 16px;
}

.page-details {
  flex: 1;
  min-width: 0;
}

.page-title {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.page-url {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

/* ============================================
   FORM ELEMENTS
   ============================================ */

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.optional {
  font-weight: 400;
  text-transform: none;
  color: var(--text-muted);
}

input[type="text"],
textarea,
select {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--border-radius-sm);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  transition: border-color 0.2s;
}

input[type="text"]:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--spark-gold);
}

input[type="text"]::placeholder,
textarea::placeholder {
  color: var(--text-muted);
}

textarea {
  min-height: 60px;
  resize: vertical;
}

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

select option {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

/* Topic selector with add button */
.topic-selector {
  display: flex;
  gap: 6px;
}

.topic-selector select {
  flex: 1;
}

/* ============================================
   SELECTION PREVIEW
   ============================================ */

.selection-preview {
  padding: 10px 12px;
  background: var(--bg-tertiary);
  border-radius: var(--border-radius);
  border: 1px solid var(--border);
  border-left: 3px solid var(--spark-gold);
}

.selection-preview label {
  display: block;
  margin-bottom: 6px;
}

.selection-text {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.5;
  max-height: 60px;
  overflow: hidden;
  position: relative;
}

.selection-text::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 20px;
  background: linear-gradient(transparent, var(--bg-tertiary));
}

/* ============================================
   BUTTONS
   ============================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border: none;
  border-radius: var(--border-radius-sm);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
}

.btn svg {
  width: 16px;
  height: 16px;
}

.btn-primary {
  background: var(--spark-gradient);
  color: #000;
}

.btn-primary:hover {
  box-shadow: 0 0 16px rgba(255, 154, 0, 0.4);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-secondary {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-secondary:hover {
  border-color: var(--spark-gold);
  color: var(--spark-gold);
}

.btn-text {
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 6px 12px;
  font-size: 12px;
}

.btn-text:hover {
  color: var(--spark-gold);
}

.btn-full {
  width: 100%;
}

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--border-radius-sm);
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-icon svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
}

.btn-icon:hover {
  background: var(--spark-gold);
  border-color: var(--spark-gold);
  color: #000;
}

/* ============================================
   COLOR PICKER
   ============================================ */

.color-picker {
  display: flex;
  gap: 8px;
}

.color-option {
  width: 28px;
  height: 28px;
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.2s;
}

.color-option:hover {
  transform: scale(1.1);
}

.color-option.selected {
  border-color: var(--text);
  box-shadow: 0 0 0 2px var(--bg);
}

/* ============================================
   SUCCESS VIEW
   ============================================ */

.success-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  text-align: center;
  gap: 12px;
}

.success-icon {
  width: 56px;
  height: 56px;
  background: rgba(74, 222, 128, 0.15);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.success-icon svg {
  width: 28px;
  height: 28px;
  stroke: var(--success);
}

.success-title {
  font-size: 18px;
  font-weight: 600;
}

.success-topic {
  font-size: 13px;
  color: var(--text-dim);
}

/* ============================================
   FOOTER
   ============================================ */

.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
}

.user-info {
  font-size: 11px;
  color: var(--text-muted);
}

/* ============================================
   LOADING OVERLAY
   ============================================ */

.loading {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.loading.hidden {
  display: none;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--spark-gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */

.toast {
  position: fixed;
  bottom: 16px;
  left: 16px;
  right: 16px;
  padding: 10px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  font-size: 12px;
  text-align: center;
  z-index: 200;
  animation: slideUp 0.3s ease-out;
}

.toast.hidden {
  display: none;
}

.toast.error {
  border-color: var(--error);
  color: var(--error);
}

.toast.success {
  border-color: var(--success);
  color: var(--success);
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

.hidden {
  display: none !important;
}
