@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600&display=swap');

:root {
  --primary: #10a37f;
  --background: #343541;
  --surface: #444654;
  --surface-light: #565869;
  --surface-hover: #4b4b5d;
  --text-primary: #ececf1;
  --text-secondary: #8e8ea0;
}

body {
  background-color: var(--background);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  overflow-x: hidden;
}

img {
  max-width: 100%;
  height: auto;
}

.navbar {
  background-color: var(--surface);
}
.navbar .navbar-brand,
.navbar .nav-link,
.navbar .btn-outline-light {
  color: var(--text-primary) !important;
}
.navbar .btn-outline-light {
  border-color: var(--text-secondary);
}
.navbar img {
  height: 40px;
  width: auto;
}

/* Reduce logo and title size on small screens */
@media (max-width: 576px) {
  .navbar img {
    height: 32px;
  }
  .navbar .navbar-brand {
    font-size: 1.25rem !important;
  }
}

#sideNav {
  width: 220px;
  background-color: var(--surface);
}
#sideNav .nav-link {
  color: var(--text-primary);
}
#sideNav .nav-link:hover {
  background-color: var(--surface-hover);
}

.card {
  background-color: var(--surface);
  color: var(--text-primary);
}
.card-header {
  background-color: var(--surface-light);
  color: var(--text-primary);
}

.profit-card-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
}

.profit-card-title {
  flex: 1 1 260px;
  min-width: 0;
}

.profit-card-select {
  width: 100%;
}

.profit-card-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: flex-start;
}

.profit-card-actions .btn {
  flex: 1 1 auto;
}

@media (min-width: 576px) {
  .profit-card-actions .btn {
    flex: 0 0 auto;
  }
}

.table {
  color: var(--text-primary);
}
.table thead {
  background-color: var(--surface-light);
  color: var(--text-primary);
}
.table-striped tbody tr:nth-of-type(odd) {
  background-color: var(--surface-light);
}
.table-hover tbody tr:hover {
  background-color: var(--surface-hover);
}

.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
  color: var(--text-primary);
}

.dataTables_wrapper .dataTables_filter label {
  width: 100%;
}

.dataTables_wrapper .dataTables_filter input {
  width: 100%;
  margin-left: 0 !important;
}

@media (min-width: 768px) {
  .dataTables_wrapper .dataTables_filter label {
    width: auto;
  }

  .dataTables_wrapper .dataTables_filter input {
    width: auto;
    margin-left: 0.5rem !important;
  }
}

@media (max-width: 767.98px) {
  .dataTables_wrapper .row {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
  }

  .dataTables_wrapper .dataTables_length,
  .dataTables_wrapper .dataTables_filter,
  .dataTables_wrapper .dataTables_info,
  .dataTables_wrapper .dataTables_paginate {
    float: none !important;
    text-align: left !important;
  }

  .dataTables_wrapper .dataTables_paginate {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
  }
}

table.dataTable > tbody > tr.child {
  background-color: var(--surface-light) !important;
}

table.dataTable > tbody > tr.child .dtr-details {
  width: 100%;
}

table.dataTable > tbody > tr.child .dtr-details li {
  border-bottom-color: rgba(255, 255, 255, 0.1);
}

.btn-primary {
  background-color: var(--primary);
  border-color: var(--primary);
}
.btn-outline-secondary {
  color: var(--text-secondary);
  border-color: var(--text-secondary);
}
.btn-outline-secondary:hover {
  background-color: var(--surface-hover);
  color: var(--text-primary);
}
.btn-outline-light {
  border-color: var(--text-secondary);
}

.btn-secondary {
  background-color: var(--surface-hover);
  border-color: var(--surface-hover);
  color: var(--text-primary);
}

.btn-info {
  background-color: #2f71b7;
  border-color: #2f71b7;
  color: var(--text-primary);
}

.form-control,
.form-select {
  background-color: var(--surface-light);
  color: var(--text-primary);
  border-color: var(--surface-hover);
}
.form-control::placeholder {
  color: var(--text-secondary);
}

.dropdown-menu {
  background-color: var(--surface);
  color: var(--text-primary);
}
.dropdown-menu .form-check-label {
  color: var(--text-primary);
}

.modal-content {
  background-color: var(--surface);
  color: var(--text-primary);
}

#loaderOverlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  color: #fff;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.login-card {
  max-width: 420px;
  margin: 80px auto;
  background-color: var(--surface);
  color: var(--text-primary);
}

.session-card {
  border: none;
}

.btn-drastic {
  animation: pulse 1s infinite;
}

#priceHistoryModal .modal-body {
  max-height: 70vh;
  overflow-y: auto;
}

#profitDetailModal .modal-body {
  max-height: 75vh;
  overflow-y: auto;
}

#priceHistoryCanvas {
  width: 100%;
  height: 300px;
}

.chart-container {
  position: relative;
  width: 100%;
}

.chart-container canvas {
  width: 100% !important;
  height: 100% !important;
}

@keyframes pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
  }
}

.session-grid {
  width: 100%;
}

.session-grid-header,
.session-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr 1fr 1fr;
  gap: 0.5rem;
  align-items: center;
}

.session-grid-header {
  font-weight: 600;
  border-bottom: 1px solid var(--surface-light);
  padding-bottom: 0.5rem;
}

.session-row {
  border-bottom: 1px solid var(--surface-light);
  padding: 0.5rem 0;
}

@keyframes priceBlink {
  0%, 100% {
    color: red;
  }
  50% {
    color: darkred;
  }
}

.price-increase {
  color: red;
  animation: priceBlink 1s infinite;
  font-weight: 600;
}

.suggested-higher {
  color: #dc3545;
  animation: suggestedPulse 0.6s ease;
}

.suggested-lower {
  color: #198754;
  animation: suggestedPulse 0.6s ease;
}

@keyframes suggestedPulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.08);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes pulseWarning {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(255, 193, 7, 0.7);
  }
  70% {
    transform: scale(1.05);
    box-shadow: 0 0 0 10px rgba(255, 193, 7, 0);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(255, 193, 7, 0);
  }
}

.pulse-warning {
  animation: pulseWarning 1.5s infinite;
}

.return-alert {
  animation: subtlePulse 2s infinite;
}

.return-alert td {
  background-color: #f8d7da !important;
  color: #58151c !important;
}

@keyframes subtlePulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.02);
  }
  100% {
    transform: scale(1);
  }
}

@media (max-width: 768px) {
  .navbar .container-fluid {
    flex-wrap: wrap;
    row-gap: 0.65rem;
  }

  .navbar .ms-auto {
    width: 100%;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 0.5rem !important;
  }

  .navbar #navUserEmail {
    max-width: 58vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #menuToggle {
    position: relative;
    z-index: 1201;
  }

  body > .d-flex {
    flex-direction: column;
  }

  #sideNav {
    position: fixed;
    top: var(--mobile-nav-offset, 72px);
    left: 0;
    z-index: 1200;
    height: calc(100dvh - var(--mobile-nav-offset, 72px));
    max-height: calc(100dvh - var(--mobile-nav-offset, 72px));
    width: min(84vw, 320px);
    padding-top: 1rem !important;
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 1rem) !important;
    margin-bottom: 0;
    display: block;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    transform: translateX(-105%);
    opacity: 0;
    visibility: hidden;
    box-shadow: 0 0 0 rgba(0, 0, 0, 0);
    transition: transform 0.28s ease, opacity 0.2s ease, visibility 0.2s ease, box-shadow 0.28s ease;
  }


  #sideNav .nav {
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 0.5rem);
  }

  #sideNav .nav-link {
    white-space: normal;
  }

  #sideNav.open {
    transform: translateX(0);
    opacity: 1;
    visibility: visible;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.45);
  }

  body.menu-open {
    overflow: hidden;
  }

  body.menu-open::before {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(2px);
    z-index: 1190;
  }

  .session-grid-header,
  .session-row {
    grid-template-columns: 1fr;
  }
}
