/* Subscription Analyzer - Tool-specific styles */
@import "../common.css";

/* ==========================================================================
   Color Palette Variables
   ========================================================================== */

:root {
  /* Subscription color palette - Dark theme */
  --sub-sky: #38bdf8;
  --sub-emerald: #10b981;
  --sub-amber: #f59e0b;
  --sub-rose: #f43f5e;
  --sub-violet: #8b5cf6;
  --sub-cyan: #22d3ee;
  --sub-orange: #fb923c;
  --sub-pink: #f472b6;
  
  /* Pastel backgrounds for containers */
  --sub-sky-bg: rgba(56, 189, 248, 0.15);
  --sub-emerald-bg: rgba(16, 185, 129, 0.15);
  --sub-amber-bg: rgba(245, 158, 11, 0.15);
  --sub-rose-bg: rgba(244, 63, 94, 0.15);
  --sub-violet-bg: rgba(139, 92, 246, 0.15);
  --sub-cyan-bg: rgba(34, 211, 238, 0.15);
  --sub-orange-bg: rgba(251, 146, 60, 0.15);
  --sub-pink-bg: rgba(244, 114, 182, 0.15);
}

[data-theme="light"] {
  /* Light theme adjustments */
  --sub-sky: #0369a1;
  --sub-emerald: #059669;
  --sub-amber: #d97706;
  --sub-rose: #e11d48;
  --sub-violet: #7c3aed;
  --sub-cyan: #0891b2;
  --sub-orange: #ea580c;
  --sub-pink: #db2777;
  
  --sub-sky-bg: rgba(3, 105, 161, 0.12);
  --sub-emerald-bg: rgba(5, 150, 105, 0.12);
  --sub-amber-bg: rgba(217, 119, 6, 0.12);
  --sub-rose-bg: rgba(225, 29, 72, 0.12);
  --sub-violet-bg: rgba(124, 58, 237, 0.12);
  --sub-cyan-bg: rgba(8, 145, 178, 0.12);
  --sub-orange-bg: rgba(234, 88, 12, 0.12);
  --sub-pink-bg: rgba(219, 39, 119, 0.12);
}

/* ==========================================================================
   Layout
   ========================================================================== */

.container {
  max-width: 900px;
}

/* ==========================================================================
   Header
   ========================================================================== */

header {
  text-align: center;
  margin-bottom: 1rem;
}

h1 {
  font-family: 'Outfit', 'Inter', sans-serif;
  font-size: 2.5rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
  background: linear-gradient(135deg, #7dd3fc, var(--primary-color));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.025em;
}

[data-theme="light"] h1 {
  background: linear-gradient(135deg, #0284c7, var(--primary-color));
  -webkit-background-clip: text;
  background-clip: text;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 1.1rem;
}

/* ==========================================================================
   Input Section
   ========================================================================== */

.input-section {
  padding: 1.5rem;
}

.input-section h2 {
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.25rem;
}

@media (max-width: 640px) {
  .form-row {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
}

.cost-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.currency-symbol {
  position: absolute;
  left: 0.75rem;
  color: var(--text-secondary);
  font-weight: 500;
  pointer-events: none;
}

.cost-input input {
  padding-left: 2rem;
}

/* Billing Toggle */
.billing-toggle {
  display: flex;
  gap: 0.5rem;
}

.billing-toggle input[type="radio"] {
  display: none;
}

.toggle-btn {
  flex: 1;
  padding: 0.625rem 1rem;
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  text-align: center;
  transition: var(--transition);
}

.toggle-btn:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.billing-toggle input[type="radio"]:checked + .toggle-btn {
  background: var(--primary-color);
  border-color: var(--primary-color);
  color: var(--bg-color);
}

/* Color Swatches */
.color-swatches {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.color-swatch {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: var(--transition);
  position: relative;
}

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

.color-swatch.selected {
  border-color: var(--text-primary);
  box-shadow: 0 0 0 2px var(--bg-color), 0 0 0 4px var(--text-primary);
}

.color-swatch.selected::after {
  content: '✓';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: bold;
  color: white;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

/* Form Actions */
.form-actions {
  display: flex;
  gap: 1rem;
  margin-top: 0.5rem;
}

.primary-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  background: var(--primary-color);
  color: var(--bg-color);
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

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

.secondary-btn {
  padding: 0.75rem 1.5rem;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

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

/* Backup Controls */
.backup-controls {
  display: flex;
  gap: 1rem;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color);
}

.backup-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.backup-btn:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.import-label {
  cursor: pointer;
}

/* ==========================================================================
   Visualization Controls
   ========================================================================== */

.viz-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.viz-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.viz-toggle {
  display: flex;
  gap: 0.5rem;
  background: var(--surface-color);
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.viz-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 0.875rem;
  background: transparent;
  color: var(--text-secondary);
  border: none;
  border-radius: 6px;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.viz-btn:hover {
  color: var(--text-primary);
  background: rgba(56, 189, 248, 0.1);
}

.viz-btn.active {
  background: var(--primary-color);
  color: var(--bg-color);
}

/* ==========================================================================
   Visualization Area
   ========================================================================== */

.visualization-area {
  min-height: 300px;
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 250px;
  border: 2px dashed var(--border-color);
  border-radius: var(--radius);
  color: var(--text-secondary);
  text-align: center;
  padding: 2rem;
}

.empty-icon {
  width: 80px;
  height: 80px;
  background: rgba(56, 189, 248, 0.1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
  color: var(--primary-color);
}

[data-theme="light"] .empty-icon {
  background: rgba(3, 105, 161, 0.1);
}

.empty-state h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.empty-state p {
  font-size: 0.9375rem;
  color: var(--text-secondary);
}

/* ==========================================================================
   Container Visualization
   ========================================================================== */

.container-viz {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-start;
}

.sub-container {
  position: relative;
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  transition: var(--transition);
  overflow: hidden;
  cursor: default;
}

.sub-container:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px -5px rgba(0, 0, 0, 0.2);
}

.sub-container:hover .sub-actions {
  opacity: 1;
}

.sub-actions {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  display: flex;
  gap: 0.25rem;
  opacity: 0;
  transition: var(--transition);
}

.sub-action-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: none;
  background: rgba(0, 0, 0, 0.4);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  font-size: 14px;
  line-height: 1;
  padding: 0;
}

.sub-action-btn:hover {
  background: rgba(0, 0, 0, 0.6);
  transform: scale(1.1);
}

.sub-action-btn.delete:hover {
  background: var(--error-color);
}

.sub-percentage {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.5rem;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 9999px;
  color: inherit;
}

.sub-name {
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 0.25rem;
  color: inherit;
}

.sub-cost {
  font-size: 1.5rem;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
}

.sub-yearly {
  font-size: 0.75rem;
  opacity: 0.7;
  margin-top: 0.25rem;
}

/* ==========================================================================
   Bar Visualization
   ========================================================================== */

.bar-viz {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.bar-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  position: relative;
}

.bar-label {
  width: 160px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.bar-name {
  font-weight: 500;
  font-size: 0.9375rem;
  color: var(--text-primary);
  word-break: break-word;
}

.bar-actions {
  display: flex;
  gap: 0.25rem;
  opacity: 0;
  transition: var(--transition);
}

.bar-item:hover .bar-actions {
  opacity: 1;
}

.bar-track {
  flex: 1;
  height: 32px;
  background: var(--bg-color);
  border-radius: 6px;
  overflow: hidden;
  position: relative;
}

.bar-fill {
  height: 100%;
  border-radius: 6px;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 0.75rem;
}

.bar-value {
  font-size: 0.8125rem;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
  color: white;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  white-space: nowrap;
}

/* ==========================================================================
   Pie Visualization
   ========================================================================== */

.pie-viz {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  flex-wrap: wrap;
}

.pie-chart {
  width: 250px;
  height: 250px;
  position: relative;
}

.pie-chart svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.pie-slice {
  opacity: 0.85;
  cursor: pointer;
  transition: opacity 0.2s ease, filter 0.2s ease;
  transform-origin: center;
}

/* When any slice is hovered, dim all slices first */
.pie-chart:hover .pie-slice {
  opacity: 0.4;
  filter: brightness(0.8);
}

/* Then highlight the hovered slice */
.pie-chart:hover .pie-slice:hover,
.pie-chart:hover .pie-slice.active {
  opacity: 1;
  filter: brightness(1.1);
}

.pie-center-text {
  transform: rotate(90deg);
  transform-origin: center;
}

.pie-percentage {
  font-size: 24px;
  font-weight: 700;
  fill: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
}

.pie-name {
  font-size: 11px;
  font-weight: 500;
  fill: var(--text-secondary);
  font-family: 'Inter', sans-serif;
}

.pie-legend {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-width: 200px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem;
  border-radius: 6px;
  transition: var(--transition);
}

.legend-item:hover {
  background: rgba(56, 189, 248, 0.05);
}

.legend-item:hover .legend-actions {
  opacity: 1;
}

.legend-color {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}

.legend-info {
  flex: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.5rem;
}

.legend-name {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
}

.legend-value {
  font-size: 0.8125rem;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-secondary);
}

.legend-actions {
  display: flex;
  gap: 0.25rem;
  opacity: 0;
  transition: var(--transition);
}

/* ==========================================================================
   Cost Summary
   ========================================================================== */

.cost-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 2rem;
}

.summary-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.summary-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.summary-value {
  font-size: 2rem;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-primary);
}

.summary-value.yearly {
  color: var(--primary-color);
}

.summary-divider {
  width: 1px;
  height: 50px;
  background: var(--border-color);
}

@media (max-width: 640px) {
  .cost-summary {
    flex-direction: column;
    gap: 1rem;
    text-align: center;
  }
  
  .summary-divider {
    width: 50px;
    height: 1px;
  }
  
  .summary-value {
    font-size: 1.5rem;
  }
}

/* ==========================================================================
   Error Message
   ========================================================================== */

.error-message {
  display: none;
  color: var(--error-color);
  background-color: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: var(--radius-sm);
  padding: 1rem;
  font-size: 0.875rem;
  font-weight: 500;
}

.error-message.active {
  display: block;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 640px) {
  h1 {
    font-size: 2rem;
  }
  
  .input-section {
    padding: 1.25rem;
  }
  
  .visualization-area {
    padding: 1rem;
  }
  
  .backup-controls {
    flex-direction: column;
  }
  
  .backup-btn {
    justify-content: center;
  }
  
  .pie-viz {
    flex-direction: column;
  }
}

/* ==========================================================================
   Delete Confirmation Modal
   ========================================================================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 1rem;
}

.modal-content {
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.modal-content h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
}

.modal-content p {
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.modal-warning {
  color: var(--error-color);
  font-size: 0.875rem;
  font-weight: 500;
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 1.5rem;
}

.danger-btn {
  padding: 0.625rem 1.25rem;
  background: var(--error-color);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

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

/* ==========================================================================
   Aurora Theme - Subscription Analyzer Specific Styles
   ========================================================================== */

/* Aurora subscription color palette - more vibrant versions */
[data-theme="aurora"] {
  --sub-sky: #7dd3fc;
  --sub-emerald: #34d399;
  --sub-amber: #fbbf24;
  --sub-rose: #fb7185;
  --sub-violet: #a78bfa;
  --sub-cyan: #22d3ee;
  --sub-orange: #fb923c;
  --sub-pink: #f472b6;
  
  --sub-sky-bg: rgba(125, 211, 252, 0.2);
  --sub-emerald-bg: rgba(52, 211, 153, 0.2);
  --sub-amber-bg: rgba(251, 191, 36, 0.2);
  --sub-rose-bg: rgba(251, 113, 133, 0.2);
  --sub-violet-bg: rgba(167, 139, 250, 0.2);
  --sub-cyan-bg: rgba(34, 211, 238, 0.2);
  --sub-orange-bg: rgba(251, 146, 60, 0.2);
  --sub-pink-bg: rgba(244, 114, 182, 0.2);
}

/* Aurora h1 gradient */
[data-theme="aurora"] h1 {
  background: linear-gradient(135deg, #7dd3fc 0%, #c084fc 50%, #f472b6 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Aurora input section glassmorphism */
[data-theme="aurora"] .input-section {
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-color: rgba(255, 255, 255, 0.12);
}

/* Aurora toggle buttons - high contrast */
[data-theme="aurora"] .toggle-btn {
  background: rgba(0, 0, 0, 0.4);
  border-color: rgba(255, 255, 255, 0.2);
  color: #f0f4ff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

[data-theme="aurora"] .toggle-btn:hover {
  border-color: rgba(125, 211, 252, 0.5);
  color: #7dd3fc;
}

[data-theme="aurora"] .billing-toggle input[type="radio"]:checked + .toggle-btn {
  background: linear-gradient(135deg, #7dd3fc 0%, #a78bfa 100%);
  border-color: transparent;
  color: #0f0f1a;
  text-shadow: none;
}

/* Aurora viz toggle - high contrast */
[data-theme="aurora"] .viz-toggle {
  background: rgba(0, 0, 0, 0.4);
  border-color: rgba(255, 255, 255, 0.15);
}

[data-theme="aurora"] .viz-btn {
  color: #f0f4ff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

[data-theme="aurora"] .viz-btn:hover {
  color: #7dd3fc;
  background: rgba(125, 211, 252, 0.2);
}

[data-theme="aurora"] .viz-btn.active {
  background: linear-gradient(135deg, #7dd3fc 0%, #a78bfa 100%);
  color: #0f0f1a;
  text-shadow: none;
}

/* Aurora visualization area */
[data-theme="aurora"] .visualization-area {
  background: rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-color: rgba(255, 255, 255, 0.1);
}

/* Aurora empty state */
[data-theme="aurora"] .empty-state {
  border-color: rgba(255, 255, 255, 0.15);
}

[data-theme="aurora"] .empty-icon {
  background: rgba(125, 211, 252, 0.15);
  color: #7dd3fc;
}

/* Aurora subscription containers with glassmorphism */
[data-theme="aurora"] .sub-container {
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* Aurora bar track */
[data-theme="aurora"] .bar-track {
  background: rgba(0, 0, 0, 0.3);
}

/* Aurora pie legend item hover */
[data-theme="aurora"] .legend-item:hover {
  background: rgba(125, 211, 252, 0.08);
}

/* Aurora cost summary */
[data-theme="aurora"] .cost-summary {
  background: rgba(255, 255, 255, 0.04);
}

[data-theme="aurora"] .summary-value.yearly {
  color: #7dd3fc;
}

/* Aurora backup buttons */
[data-theme="aurora"] .backup-btn {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.7);
}

[data-theme="aurora"] .backup-btn:hover {
  border-color: rgba(125, 211, 252, 0.4);
  color: #7dd3fc;
}

/* Aurora modal */
[data-theme="aurora"] .modal-overlay {
  background: rgba(15, 15, 26, 0.8);
}

[data-theme="aurora"] .modal-content {
  background: rgba(30, 30, 50, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-color: rgba(255, 255, 255, 0.15);
}

/* Aurora color swatches - add glow effect */
[data-theme="aurora"] .color-swatch {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

[data-theme="aurora"] .color-swatch:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}
