/* Portfolio Backtester Additional Styles */

/* =========================
   View Toggle
   ========================= */
.view-toggle {
  display: inline-flex;
  background: #e5e7eb;
  border-radius: 0.5rem;
  padding: 0.25rem;
}

.view-toggle button {
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;
  font-weight: 500;
  transition: all 0.2s;
  border: none;
  background: transparent;
  cursor: pointer;
  color: #6b7280;
}

.view-toggle button.active {
  background: white;
  box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
  color: #4f46e5;
}

/* =========================
   Portfolio items container
   ========================= */
#portfolioItems {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

/* Desktop: 2-column grid */
@media (min-width: 768px) {
  #portfolioItems {
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    max-width: 1200px;
  }
}

/* =========================
   Portfolio item row
   ========================= */
.portfolio-item {
  display: flex;
  gap: 0.25rem;
  align-items: center;
  position: relative;
}

/* Desktop layout */
@media (min-width: 769px) {
  .portfolio-item {
    gap: 0.5rem;
    min-width: 0;
  }

  .portfolio-item .autocomplete-wrapper {
    flex: 1 1 auto;
    min-width: 0;
  }

  .portfolio-item input[type="text"] {
    width: 100%;
    height: 42px;
  }

  .portfolio-item input[type="number"] {
    flex: 0 0 72px;
    width: 72px;
    height: 42px;
    text-align: center;
  }
}

/* =========================
   Buttons & Icons
   ========================= */
.portfolio-item button {
  flex-shrink: 0;
  white-space: nowrap;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
}

.ticker-logo {
  width: 32px;
  height: 32px;
  border-radius: 4px;
  object-fit: contain;
  background: #f3f4f6;
  padding: 2px;
  flex-shrink: 0;
}

/* Remove button */
.remove-ticker-btn {
  padding: 0.5rem 1rem;
  background: #ef4444;
  color: white;
  border: none;
  border-radius: 0.5rem;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.2s;
}

.remove-ticker-btn:hover:not(:disabled) {
  background: #dc2626;
}

.remove-ticker-btn:disabled {
  background: #d1d5db;
  cursor: not-allowed;
}

/* =========================
   Animations & Effects
   ========================= */
#calculateBtn:not(:disabled):hover {
  box-shadow: 0 0 40px rgba(99, 102, 241, 0.5);
}

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

.animate-spin {
  animation: spin 1s linear infinite;
}

#holdingsTableBody tr:hover {
  background-color: #f9fafb;
}

/* =========================
   Autocomplete
   ========================= */
.autocomplete-wrapper {
  position: relative;
  flex: 1;
  min-width: 0;
}

.portfolio-autocomplete-results {
  position: absolute;
  z-index: 50;
  max-height: 300px;
  overflow-y: auto;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
  margin-top: 0.25rem;
  width: 100%;
  left: 0;
  top: 100%;
}

.portfolio-autocomplete-results.hidden {
  display: none;
}

/* =========================
   Error Message
   ========================= */
#errorMessage {
  animation: slideDown 0.3s ease-out;
}

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

/* =========================
   Number coloring
   ========================= */
.text-positive {
  color: #10b981;
}

.text-negative {
  color: #ef4444;
}

/* Prevent input overflow */
.portfolio-item input {
  box-sizing: border-box;
}

/* =========================
   MOBILE LAYOUT
   ========================= */
@media (max-width: 768px) {
  /* Prevent horizontal overflow */
  #portfolioItems,
  .portfolio-item {
    max-width: 100%;
    overflow-x: hidden;
  }

  /* Switch to GRID layout to prevent overlap */
  .portfolio-item {
    display: grid;
    grid-template-columns: 1fr 60px;
    gap: 0.375rem;
    align-items: center;
  }

  .portfolio-item .autocomplete-wrapper {
    grid-column: 1;
    min-width: 0;
    width: 100%;
  }

  .portfolio-item input[type="text"] {
    width: 100% !important;
    min-width: 0 !important;
    height: 42px;
  }

  .portfolio-item input[type="number"] {
    grid-column: 2;
    width: 60px !important;
    max-width: 60px;
    flex: 0 0 60px;
    height: 42px;
    text-align: center;
  }

  .ticker-logo {
    grid-column: 1;
    width: 28px;
    height: 28px;
  }

  .portfolio-item button {
    grid-column: 1 / -1;
    width: 100%;
    margin-top: 0.25rem;
    padding: 0.75rem;
    font-size: 0.875rem;
  }
}
