:root {
  /* Light theme (default) */
  --background: 0 0% 100%;
  --foreground: 222.2 84% 4.9%;
  --card: 0 0% 100%;
  --card-foreground: 222.2 84% 4.9%;
  --popover: 0 0% 100%;
  --popover-foreground: 222.2 84% 4.9%;
  --primary: 221.2 83.2% 53.3%;
  --primary-foreground: 210 40% 98%;
  --secondary: 210 40% 96.1%;
  --secondary-foreground: 222.2 47.4% 11.2%;
  --muted: 210 40% 96.1%;
  --muted-foreground: 215.4 16.3% 46.9%;
  --accent: 210 40% 96.1%;
  --accent-foreground: 222.2 47.4% 11.2%;
  --destructive: 0 84.2% 60.2%;
  --destructive-foreground: 210 40% 98%;
  --success: 142.1 76.2% 36.3%;
  --success-foreground: 355.7 100% 97.3%;
  --border: 214.3 31.8% 91.4%;
  --input: 214.3 31.8% 91.4%;
  --ring: 221.2 83.2% 53.3%;
  --radius: 0.5rem;
}

.dark {
  --background: 222.2 84% 4.9%;
  --foreground: 210 40% 98%;
  --card: 222.2 84% 4.9%;
  --card-foreground: 210 40% 98%;
  --popover: 222.2 84% 4.9%;
  --popover-foreground: 210 40% 98%;
  --primary: 217.2 91.2% 59.8%;
  --primary-foreground: 222.2 47.4% 11.2%;
  --secondary: 217.2 32.6% 17.5%;
  --secondary-foreground: 210 40% 98%;
  --muted: 217.2 32.6% 17.5%;
  --muted-foreground: 215 20.2% 65.1%;
  --accent: 217.2 32.6% 17.5%;
  --accent-foreground: 210 40% 98%;
  --destructive: 0 62.8% 50.6%;
  --destructive-foreground: 210 40% 98%;
  --success: 142.1 70.6% 45.3%;
  --success-foreground: 144.9 80.4% 10%;
  --border: 217.2 32.6% 17.5%;
  --input: 217.2 32.6% 17.5%;
  --ring: 224.3 76.3% 48%;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: hsl(var(--background));
  color: hsl(var(--foreground));
  line-height: 1.6;
  min-height: 100vh;
  padding: 2rem 1rem;
  transition:
    background-color 0.3s ease,
    color 0.3s ease;
  position: relative;
  overflow-x: hidden;
}

/* Animated Stock Chart Background */
.bg-chart {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  opacity: 0.08;
  overflow: hidden;
}

.dark .bg-chart {
  opacity: 0.12;
}

.bg-chart svg {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 200%;
  height: 100%;
  animation: chartScroll 60s linear infinite;
}

/* Grid lines */
.bg-chart .grid-line {
  stroke: hsl(var(--foreground));
  stroke-width: 0.5;
  opacity: 0.1;
}

/* Candlestick bars */
.bg-chart .candle-green {
  fill: hsl(var(--success));
  stroke: hsl(var(--success));
  stroke-width: 1;
  opacity: 0.6;
}

.bg-chart .candle-red {
  fill: hsl(var(--destructive));
  stroke: hsl(var(--destructive));
  stroke-width: 1;
  opacity: 0.6;
}

.bg-chart .candle-wick {
  stroke: hsl(var(--foreground));
  stroke-width: 1.5;
  opacity: 0.4;
}

.bg-chart .candle-wick-green {
  stroke: hsl(var(--success));
  stroke-width: 1.5;
  opacity: 0.5;
}

.bg-chart .candle-wick-red {
  stroke: hsl(var(--destructive));
  stroke-width: 1.5;
  opacity: 0.5;
}

/* Dark mode adjustments */
.dark .bg-chart .candle-green,
.dark .bg-chart .candle-red {
  opacity: 0.7;
}

.dark .bg-chart .candle-wick,
.dark .bg-chart .candle-wick-green,
.dark .bg-chart .candle-wick-red {
  opacity: 0.6;
}

@keyframes chartScroll {
  0% {
    transform: translateX(-50%);
  }
  100% {
    transform: translateX(0);
  }
}

/* Floating particles */
.bg-particles {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.particle {
  position: absolute;
  width: 4px;
  height: 4px;
  background: hsl(var(--primary));
  border-radius: 50%;
  opacity: 0;
  animation: floatUp 15s ease-in-out infinite;
}

.particle:nth-child(1) {
  left: 10%;
  animation-delay: 0s;
  animation-duration: 12s;
}
.particle:nth-child(2) {
  left: 20%;
  animation-delay: 2s;
  animation-duration: 14s;
}
.particle:nth-child(3) {
  left: 30%;
  animation-delay: 4s;
  animation-duration: 11s;
}
.particle:nth-child(4) {
  left: 40%;
  animation-delay: 1s;
  animation-duration: 16s;
}
.particle:nth-child(5) {
  left: 50%;
  animation-delay: 3s;
  animation-duration: 13s;
}
.particle:nth-child(6) {
  left: 60%;
  animation-delay: 5s;
  animation-duration: 15s;
}
.particle:nth-child(7) {
  left: 70%;
  animation-delay: 2.5s;
  animation-duration: 12s;
}
.particle:nth-child(8) {
  left: 80%;
  animation-delay: 4.5s;
  animation-duration: 14s;
}
.particle:nth-child(9) {
  left: 90%;
  animation-delay: 1.5s;
  animation-duration: 11s;
}
.particle:nth-child(10) {
  left: 15%;
  animation-delay: 3.5s;
  animation-duration: 16s;
}

@keyframes floatUp {
  0% {
    transform: translateY(100vh) scale(0);
    opacity: 0;
  }
  10% {
    opacity: 0.4;
  }
  90% {
    opacity: 0.4;
  }
  100% {
    transform: translateY(-100px) scale(1);
    opacity: 0;
  }
}

/* Stock Ticker Tape */
.ticker-tape {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 32px;
  background: hsl(var(--card) / 0.8);
  backdrop-filter: blur(8px);
  border-top: 1px solid hsl(var(--border) / 0.5);
  overflow: hidden;
  z-index: 0;
  pointer-events: none;
}

.ticker-content {
  display: flex;
  align-items: center;
  height: 100%;
  animation: tickerScroll 40s linear infinite;
  white-space: nowrap;
}

.ticker-item {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 1.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  font-family: "SF Mono", "Monaco", "Consolas", monospace;
}

.ticker-symbol {
  color: hsl(var(--foreground));
  font-weight: 600;
}

.ticker-price {
  color: hsl(var(--muted-foreground));
}

.ticker-change {
  font-size: 0.6875rem;
  padding: 0.125rem 0.375rem;
  border-radius: 4px;
}

.ticker-change.up {
  color: hsl(var(--success));
  background: hsl(var(--success) / 0.1);
}

.ticker-change.down {
  color: hsl(var(--destructive));
  background: hsl(var(--destructive) / 0.1);
}

@keyframes tickerScroll {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(-50%);
  }
}

/* Volume bars in background */
.bg-chart .volume-bar {
  fill: hsl(var(--primary));
  opacity: 0.15;
}

.bg-chart .volume-bar.high {
  fill: hsl(var(--success));
  opacity: 0.2;
}

/* Pulsing dots for live feel */
.bg-chart .pulse-dot {
  fill: hsl(var(--success));
  animation: pulseDot 2s ease-in-out infinite;
}

@keyframes pulseDot {
  0%,
  100% {
    opacity: 0.3;
    r: 3;
  }
  50% {
    opacity: 0.8;
    r: 5;
  }
}

/* Moving average line */
.bg-chart .ma-line {
  fill: none;
  stroke: hsl(var(--ring));
  stroke-width: 1;
  stroke-dasharray: 4 4;
  opacity: 0.3;
}

.container {
  max-width: 1000px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

.main-layout {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 2rem;
  transition: all 0.4s ease;
  min-height: 300px;
}

.main-layout.has-transactions {
  justify-content: center;
}

.input-section {
  flex: 0 0 400px;
  max-width: 400px;
  transition: all 0.4s ease;
}

.results-section {
  flex: 0 0 450px;
  max-width: 450px;
  opacity: 0;
  transform: translateX(20px);
  visibility: hidden;
  transition: all 0.4s ease;
  position: absolute;
  pointer-events: none;
}

.main-layout.has-transactions .results-section {
  opacity: 1;
  transform: translateX(0);
  visibility: visible;
  position: relative;
  pointer-events: auto;
}

header {
  text-align: center;
  margin-bottom: 2rem;
  position: relative;
}

.header-content {
  display: inline-block;
}

h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: hsl(var(--foreground));
  margin-bottom: 0.5rem;
}

.subtitle {
  color: hsl(var(--muted-foreground));
  font-size: 0.95rem;
}

.theme-toggle {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid hsl(var(--foreground) / 0.1);
  background: hsl(var(--foreground) / 0.05);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: hsl(var(--foreground));
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  box-shadow: inset 0 1px 0 hsl(var(--background) / 0.5);
}

.theme-toggle:hover {
  background: hsl(var(--foreground) / 0.08);
  border-color: hsl(var(--foreground) / 0.15);
  transform: translateY(-50%) scale(1.05);
}

.theme-toggle:active {
  transform: translateY(-50%) scale(0.95);
}

.theme-toggle:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 2px hsl(var(--background)),
    0 0 0 4px hsl(var(--ring));
}

.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
  position: absolute;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-toggle .icon-sun svg,
.theme-toggle .icon-moon svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 1.5;
  fill: none;
}

.theme-toggle .icon-sun {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

.theme-toggle .icon-moon {
  opacity: 0;
  transform: rotate(-90deg) scale(0.5);
}

.dark .theme-toggle .icon-sun {
  opacity: 0;
  transform: rotate(90deg) scale(0.5);
}

.dark .theme-toggle .icon-moon {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

.card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: 8px;
  box-shadow:
    0 1px 3px 0 rgb(0 0 0 / 0.1),
    0 1px 2px -1px rgb(0 0 0 / 0.1);
  padding: 1.5rem;
  margin-bottom: 1rem;
  transition: all 0.2s ease;
}

.input-section .card {
  margin-bottom: 0;
}

.card-title {
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
  color: hsl(var(--foreground));
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-title::before {
  content: "";
  display: inline-block;
  width: 3px;
  height: 1em;
  background: hsl(var(--primary));
  border-radius: 2px;
}

.form-row {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
}

.form-group {
  flex: 1;
}

label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: hsl(var(--foreground));
}

input[type="number"] {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1px solid hsl(var(--border));
  border-radius: 6px;
  font-size: 0.875rem;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  transition: all 0.15s ease;
  height: 40px;
}

input[type="number"]::placeholder {
  color: hsl(var(--muted-foreground));
}

input[type="number"]:hover {
  border-color: hsl(var(--foreground) / 0.2);
}

input[type="number"]:focus {
  outline: none;
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 2px hsl(var(--ring) / 0.2);
}

/* Remove number input spinners for cleaner look */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] {
  -moz-appearance: textfield;
}

.btn-row {
  display: flex;
  gap: 0.5rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0 1.25rem;
  height: 42px;
  border: none;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  user-select: none;
  position: relative;
  overflow: hidden;
}

.btn:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 2px hsl(var(--background)),
    0 0 0 4px hsl(var(--ring));
}

.btn:disabled {
  opacity: 0.5;
  pointer-events: none;
}

.btn-primary {
  flex: 1;
  background: linear-gradient(135deg, hsl(var(--primary)) 0%, hsl(var(--primary) / 0.85) 100%);
  color: hsl(var(--primary-foreground));
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid hsl(var(--primary-foreground) / 0.1);
  box-shadow:
    0 2px 8px -2px hsl(var(--primary) / 0.4),
    inset 0 1px 0 hsl(var(--primary-foreground) / 0.15);
}

.btn-primary:hover {
  background: linear-gradient(135deg, hsl(var(--primary) / 0.95) 0%, hsl(var(--primary) / 0.8) 100%);
  box-shadow:
    0 4px 12px -2px hsl(var(--primary) / 0.5),
    inset 0 1px 0 hsl(var(--primary-foreground) / 0.2);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0) scale(0.98);
  box-shadow:
    0 1px 4px -1px hsl(var(--primary) / 0.4),
    inset 0 1px 0 hsl(var(--primary-foreground) / 0.1);
}

.btn-secondary {
  background: hsl(var(--foreground) / 0.05);
  color: hsl(var(--foreground));
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid hsl(var(--foreground) / 0.1);
  box-shadow: inset 0 1px 0 hsl(var(--background) / 0.5);
}

.btn-secondary:hover {
  background: hsl(var(--foreground) / 0.08);
  border-color: hsl(var(--foreground) / 0.15);
  transform: translateY(-1px);
}

.btn-secondary:active {
  transform: translateY(0) scale(0.98);
  background: hsl(var(--foreground) / 0.1);
}

.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
}

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

.error-message {
  background: hsl(var(--destructive) / 0.1);
  color: hsl(var(--destructive));
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.875rem;
  margin-bottom: 1rem;
  display: none;
  border: 1px solid hsl(var(--destructive) / 0.2);
}

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

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

.summary-item {
  background: hsl(var(--muted));
  padding: 1rem;
  border-radius: 8px;
  text-align: center;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

.summary-item:hover {
  border-color: hsl(var(--border));
}

.summary-item.highlight {
  grid-column: span 2;
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  position: relative;
  overflow: hidden;
}

.summary-item.highlight::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, transparent 0%, hsl(0 0% 100% / 0.1) 100%);
  pointer-events: none;
}

.summary-label {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.7;
  margin-bottom: 0.375rem;
  font-weight: 500;
}

.summary-value {
  font-size: 1.375rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.summary-item.highlight .summary-label {
  opacity: 0.9;
}

.summary-item.highlight .summary-value {
  font-size: 1.75rem;
}

.transactions-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.transaction-count {
  background: hsl(var(--primary) / 0.1);
  padding: 0.25rem 0.625rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
  color: hsl(var(--primary));
}

.transactions-list {
  max-height: 300px;
  overflow-y: auto;
}

.empty-state {
  text-align: center;
  padding: 2rem;
  color: hsl(var(--muted-foreground));
  font-size: 0.95rem;
}

.transaction-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.625rem 0.75rem;
  background: hsl(var(--muted));
  border-radius: 6px;
  margin-bottom: 0.5rem;
  transition: all 0.15s ease;
  border: 1px solid transparent;
}

.transaction-item:hover {
  background: hsl(var(--muted) / 0.8);
  border-color: hsl(var(--border));
}

.transaction-item:last-child {
  margin-bottom: 0;
}

.transaction-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.transaction-number {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 0.1875rem 0.5rem;
  border-radius: 4px;
  min-width: 28px;
  text-align: center;
}

.transaction-details {
  font-size: 0.8125rem;
  color: hsl(var(--foreground));
}

.transaction-amount {
  font-weight: 600;
  color: hsl(var(--success));
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
}

.delete-btn {
  width: 28px;
  height: 28px;
  border: none;
  background: hsl(var(--destructive) / 0.08);
  color: hsl(var(--destructive) / 0.7);
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  border: 1px solid hsl(var(--destructive) / 0.1);
}

.delete-btn svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

.transaction-item:hover .delete-btn {
  opacity: 1;
}

.delete-btn:hover {
  background: hsl(var(--destructive) / 0.15);
  color: hsl(var(--destructive));
  border-color: hsl(var(--destructive) / 0.2);
  transform: scale(1.05);
}

.delete-btn:active {
  transform: scale(0.95);
}

.delete-btn:focus-visible {
  opacity: 1;
  outline: none;
  box-shadow:
    0 0 0 2px hsl(var(--background)),
    0 0 0 4px hsl(var(--ring));
}

footer {
  text-align: center;
  margin-top: 2rem;
  color: hsl(var(--muted-foreground));
  font-size: 0.875rem;
}

@media (max-width: 860px) {
  .main-layout {
    flex-direction: column;
    align-items: center;
  }

  .main-layout.has-transactions {
    justify-content: center;
  }

  .input-section {
    flex: 0 0 auto;
    width: 100%;
    max-width: 500px;
  }

  .results-section {
    width: 100%;
    max-width: 500px;
    flex: 0 0 auto;
  }

  .main-layout.has-transactions .results-section {
    transform: translateY(0);
  }

  .results-section {
    transform: translateY(20px);
  }

  .theme-toggle {
    position: static;
    transform: none;
    margin-top: 1rem;
  }

  header {
    display: flex;
    flex-direction: column;
    align-items: center;
  }
}

@media (max-width: 480px) {
  .form-row {
    flex-direction: column;
  }

  .summary-grid {
    grid-template-columns: 1fr;
  }

  .summary-item.highlight {
    grid-column: span 1;
  }

  .transaction-info {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
  }

  .input-section {
    flex: 0 0 auto;
    max-width: 100%;
  }
}

/* Price Chart Styles */
.chart-container {
  position: relative;
  width: 100%;
  height: 140px;
  margin-bottom: 1rem;
  border-radius: 8px;
  overflow: hidden;
  background: hsl(var(--muted) / 0.3);
}

.price-chart {
  width: 100%;
  height: 100%;
  display: block;
}

.chart-area {
  fill: url(#areaGradient);
  opacity: 0.6;
  transition: d 0.5s ease-out;
}

.chart-line {
  fill: none;
  stroke: hsl(var(--primary));
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: d 0.5s ease-out;
}

.gradient-start {
  stop-color: hsl(var(--primary));
  stop-opacity: 0.4;
}

.gradient-end {
  stop-color: hsl(var(--primary));
  stop-opacity: 0.05;
}

.chart-dot {
  fill: hsl(var(--primary));
  transition:
    cx 0.5s ease-out,
    cy 0.5s ease-out,
    opacity 0.3s ease;
}

.chart-dot.trend-up {
  fill: hsl(var(--success));
}

.chart-dot.trend-down {
  fill: hsl(var(--destructive));
}

.chart-dot-ring {
  fill: none;
  stroke: hsl(var(--primary) / 0.3);
  stroke-width: 2;
  transition:
    cx 0.5s ease-out,
    cy 0.5s ease-out,
    opacity 0.3s ease;
}

.chart-label {
  font-size: 10px;
  font-weight: 600;
  fill: hsl(var(--foreground));
  text-anchor: middle;
  transition:
    all 0.5s ease-out,
    opacity 0.3s ease;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* Dark mode chart adjustments */
.dark .chart-area {
  opacity: 0.4;
}

.dark .gradient-start {
  stop-opacity: 0.5;
}

.dark .gradient-end {
  stop-opacity: 0.05;
}
