/* Theme Color Variables */
:root[data-theme="light"] {
  /* Primary Colors */
  --primary-blue: #0d6efd;
  --primary-blue-hover: #0b5ed7;
  --danger-red: #dc3545;
  --danger-red-hover: #bb2d3b;

  /* Backgrounds */
  --bg-primary: #ffffff;
  --bg-secondary: #f8f9fa;
  --bg-navbar: #0d6efd;

  /* Text */
  --text-primary: #212529;
  --text-secondary: #6c757d;

  /* Borders */
  --border-color: #dee2e6;

  /* Component-specific */
  --swipe-bg: #ffffff;
  --modal-bg: #ffffff;
  --modal-content-bg: #ffffff;
}

:root[data-theme="dark"] {
  /* Primary Colors */
  --primary-blue: #4d9fff;
  --primary-blue-hover: #6cb0ff;
  --danger-red: #ff4d5e;
  --danger-red-hover: #ff6b7a;

  /* Backgrounds */
  --bg-primary: #1a1d23;
  --bg-secondary: #2d3139;
  --bg-navbar: #2d3139;

  /* Text */
  --text-primary: #e9ecef;
  --text-secondary: #adb5bd;

  /* Borders */
  --border-color: #404550;

  /* Component-specific */
  --swipe-bg: #1a1d23;
  --modal-bg: #1a1d23;
  --modal-content-bg: #2d3139;
}

/* Custom styles for MKT.rip */

/* Sticky header container - keeps both bars together */
.sticky-header-container {
  z-index: 1020;
}

.sticky-header-container .navbar {
  border-bottom: 2px solid rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .sticky-header-container .navbar {
  border-bottom: 2px solid var(--border-color);
}

/* Stale price styling */
.stale-price,
.price[data-stale="true"] {
  color: var(--text-secondary) !important;
  opacity: 0.6;
  transition: opacity 0.3s ease, color 0.3s ease;
}

/* Refresh button rotating animation */
@keyframes rotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.rotating {
  animation: rotate 1s linear infinite;
}

/* Mobile optimizations */
@media (max-width: 576px) {
  .navbar-brand {
    font-size: 1rem;
  }

  .list-group-item {
    padding: 0.75rem;
  }

  h2 {
    font-size: 1.5rem;
  }

  .btn-group-sm > .btn {
    padding: 0.2rem 0.4rem;
    font-size: 0.75rem;
  }
}

/* Prevent text selection on buttons */
button {
  user-select: none;
  -webkit-user-select: none;
}

/* Better touch targets for mobile */
.list-group-item button {
  min-width: 36px;
  min-height: 36px;
}

/* Ensure adequate touch targets for bottom action bar */
#addButtonContainer button {
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#infoButton {
  padding: 0.5rem;
}

#infoButton i {
  font-size: 1.25rem;
}

/* Modal animations */
.modal.fade .modal-dialog {
  transition: transform 0.3s ease-out;
}

/* Last updated text styling */
.last-updated-text {
  font-size: 0.7rem;
  opacity: 0.4;
  margin-top: 0.25rem;
}

/* Empty state icon */
#emptyState i {
  display: block;
  margin: 0 auto;
}

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

/* Empty state add button - keep inline */
#emptyStateAddButton {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  vertical-align: baseline;
}

/* Total value emphasis */
#totalValue {
  font-weight: 700;
  color: var(--primary-blue);
}

/* Loading spinner for add button */
#addSpinner {
  width: 1rem;
  height: 1rem;
}

/* Refresh button with circular progress ring */
#refreshButton {
  position: relative;
  width: 32px;
  height: 32px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.refresh-progress-ring {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
}

.progress-ring-bg {
  opacity: 0.2;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

.progress-ring-blue {
  fill: none;
  stroke-width: 2;
  transition: stroke-dashoffset 0.1s linear;
}

.progress-ring-gray {
  fill: none;
  stroke-width: 2;
  transition: stroke-dashoffset 0.1s linear;
}

.refresh-icon {
  position: absolute;
  z-index: 1;
  width: 32px;
  height: 32px;
  top: 0;
  left: 0;
  transform-origin: 16px 16px;
}

/* Light mode - keep icon dark */
[data-theme="light"] .refresh-icon {
  opacity: 0.6;
}

/* Dark mode - invert to make icon light */
[data-theme="dark"] .refresh-icon {
  filter: invert(1);
  opacity: 0.6;
}

/* No special styling needed - rotation handled via inline transform */

/* Blue ring - always blue */
[data-theme="light"] .progress-ring-blue {
  stroke: #0d6efd;
}

[data-theme="dark"] .progress-ring-blue {
  stroke: #4d9fff;
}

/* Gray ring - solid gray that covers blue, stacks on top */
[data-theme="light"] .progress-ring-gray {
  stroke: #e9ecef;
  opacity: 1;
}

[data-theme="dark"] .progress-ring-gray {
  stroke: #3a3d45;
  opacity: 1;
}

/* Toast container positioning for mobile */
@media (max-width: 576px) {
  .toast-container {
    left: 0;
    right: 0;
    bottom: 0 !important;
    padding: 0.5rem !important;
  }

  .toast {
    width: 100%;
  }
}

/* Ensure proper spacing on mobile */
body {
  padding-bottom: env(safe-area-inset-bottom);
  background-color: var(--bg-primary);
  color: var(--text-primary);
}

/* PWA splash screen styling */
@media (display-mode: standalone) {
  body {
    background-color: var(--bg-secondary);
  }
}

/* Input styling improvements */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
}

/* Uppercase ticker input */
#tickerInput {
  text-transform: uppercase;
}

/* Better focus states for accessibility */
button:focus,
input:focus {
  outline: 2px solid var(--primary-blue);
  outline-offset: 2px;
}

/* List group item hover effect */
.list-group-item {
  transition: background-color 0.2s ease;
}

.list-group-item:hover {
  background-color: var(--bg-secondary);
}

/* Price display styling */
.price {
  font-weight: 600;
}

/* Smooth transitions */
* {
  transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out;
}

button, a, input {
  transition: all 0.15s ease-in-out;
}

/* Swipeable list items */
.swipeable-item {
  position: relative;
  overflow: hidden;
  padding: 0 !important;
  touch-action: pan-y; /* Allow vertical scrolling */
}

.swipe-content {
  position: relative;
  background: var(--swipe-bg);
  padding: 0.75rem 1rem;
  z-index: 2;
  will-change: transform;
}

.swipe-actions {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: stretch;
  z-index: 1;
}

.swipe-action {
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  padding: 0;
  width: 70px;
  color: white;
  font-size: 1.2rem;
  cursor: pointer;
  transition: background-color 0.2s;
}

.swipe-action:active {
  opacity: 0.8;
}

.edit-action {
  background-color: var(--primary-blue);
}

.edit-action:hover {
  background-color: var(--primary-blue-hover);
}

.delete-action {
  background-color: var(--danger-red);
}

.delete-action:hover {
  background-color: var(--danger-red-hover);
}

/* Compressed row layout */
.list-group-item h6 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.25rem !important;
}

.list-group-item small {
  font-size: 0.8rem;
  line-height: 1.2;
}

.list-group-item .price {
  font-size: 0.95rem;
}

/* Remove hover effect on swipeable items */
.swipeable-item:hover {
  background-color: transparent;
}

/* Reduce spacing on mobile */
@media (max-width: 576px) {
  .swipe-content {
    padding: 0.6rem 0.8rem;
  }

  .list-group-item h6 {
    font-size: 1rem;
  }

  .list-group-item small {
    font-size: 0.75rem;
  }

  .swipe-action {
    width: 65px;
    font-size: 1.1rem;
  }
}

/* Desktop hover behavior - reveal edit/delete buttons on hover */
@media (hover: hover) and (pointer: fine) {
  .swipeable-item:not(.swiped) .swipe-content {
    transition: transform 0.3s ease;
  }

  .swipeable-item:not(.swiped):hover .swipe-content {
    transform: translateX(-140px);
  }

  /* Keep buttons visible and clickable while hovering over them */
  .swipeable-item:not(.swiped):hover .swipe-actions {
    pointer-events: auto;
  }
}

/* Bootstrap class overrides for dark mode */
[data-theme="dark"] .bg-light {
  background-color: var(--bg-secondary) !important;
  color: var(--text-primary) !important;
}

[data-theme="dark"] .bg-primary {
  background-color: var(--bg-navbar) !important;
}

[data-theme="dark"] .text-muted {
  color: var(--text-secondary) !important;
}

[data-theme="dark"] .list-group-item {
  background-color: var(--bg-primary);
  border-color: var(--border-color);
  color: var(--text-primary);
}

/* Bootstrap handles modal styling in dark mode automatically via data-bs-theme */

/* Bootstrap handles form-control, btn-light, and btn-outline-primary in dark mode automatically via data-bs-theme */

[data-theme="dark"] .border-bottom {
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .toast {
  background-color: var(--modal-content-bg);
  color: var(--text-primary);
  border-color: var(--border-color);
}

/* Percent change color coding */
.percent-positive {
  color: #22c55e;
  font-weight: 600;
}

.percent-negative {
  color: #ef4444;
  font-weight: 600;
}

.percent-neutral {
  color: var(--text-secondary);
  font-weight: 600;
}

/* Holding row column layout */
.holding-row {
  gap: 0.75rem;
}

.holding-col-left {
  flex: 0 0 30%;
  min-width: 0;
}

.holding-col-center {
  flex: 0 0 35%;
  text-align: center;
}

.holding-col-right {
  flex: 0 0 30%;
  text-align: right;
}

/* Mobile adjustments */
@media (max-width: 576px) {
  .holding-col-left {
    flex: 0 0 28%;
  }

  .holding-col-center {
    flex: 0 0 36%;
  }

  .holding-col-right {
    flex: 0 0 32%;
  }
}
