/* CoinTracking Vanilla JS - Custom Styles
 * Tailwind utilities loaded via CDN in index.html
 * This file contains only custom styles and theme variables
 */

/* Custom Properties & Theme Variables */
:root {
  --font-family: "Instrument Sans", sans-serif;
  --spacing: 0.25rem;

  /* Light Mode Colors */
  --bg-primary: #ffffff;
  --bg-secondary: #f3f6ff;
  --bg-card: #ffffff;
  --text-primary: #0b253e;
  --text-secondary: #374151;
  --text-muted: #9ca3af;
  --text-hint: #64748b;
  --border-color: #cfd4da;
  --border-hover: #e5e7eb;

  /* State Colors */
  --accent-blue: #388bf3;
  --accent-blue-hover: #2b7ce4;
  --accent-green: #10b981;
  --accent-red: #e25858;
  --accent-orange: #f59e0b;
  --bg-content: #edf4fb;
  --notification-green-border: #418f41;
  --notification-green-bg: #e0ffe0;
  --notification-green-text: #0b253e;
  --notification-red-border: #e25858;
  --notification-red-bg: #ffeded;
  --notification-yellow-border: #8f5f00;
  --notification-yellow-bg: #ffcc66;
  --notification-blue-border: #2082de;
  --notification-blue-bg: #eef7ff;

  --nice-select-bg: #fff;
  --nice-select-border: #e5e7eb;

  --input-border: #cfd4da;
  --input-focus-border: #388bf3;
  --table-header-text: #6b7a8e;
  --table-header-bg: #ccc;
  --table-row-border: #f3f4f6;
  --table-row-hover: #a0b1d3;

  --anchor: #2082de;
  --button-bg-hover: #f9fafb;
  --button-orange-bg: #ff9d47;

  --tab-nav-card-inactive: #e6e6e6;
  --tab-nav-card-hover: #dadada;

  /* Datepicker */
  --datepicker-bg: #ffffff;
  --datepicker-header-bg: #f3f6ff;
  --datepicker-header-border: #ecf0f5;
  --datepicker-title-color: #0b253e;
  --datepicker-nav-color: #374151;
  --datepicker-day-header-color: #374151;
  --datepicker-day-bg: #f3f6ff;
  --datepicker-day-color: #0b253e;
  --datepicker-day-hover-bg: #f9fafb;
  --datepicker-day-hover-color: #0b253e;
  --datepicker-day-active-bg: #388bf3;
  --datepicker-day-active-color: #ffffff;

  --floating-button-bg: #0156f9;
}

.dark {
  /* Dark Mode Colors */
  --bg-primary: #1a1d2e;
  --bg-secondary: #252838;
  --bg-card: #2a2e42;
  --bg-content: #252838;
  --text-primary: #e5e7eb;
  --text-secondary: #cbd5e1;
  --text-muted: #6b7280;
  --text-hint: #ffffff;
  --border: #2a2e42;
  --border-secondary: #3a3f58;
  --accent-blue: #388bf3;
  --accent-blue-hover: #2082de;
  --accent-blue-light: #2d3550;
  --accent-green: #10b981;
  --accent-red: #e25858;
  --accent-orange: #f59e0b;
  --notification-green-border: #418f41;
  --notification-green-bg: #006000;
  --notification-red-border: #e25858;
  --notification-red-bg: #4a1a1a;
  --notification-yellow-border: #392600;
  --notification-yellow-bg: #8f5f00;
  --notification-blue-border: #2082de;
  --notification-blue-bg: #eef7ffdc;
  --border-color: #4f5571;
  --border-hover: #4a5066;
  --nice-select-bg: #353a52;
  --nice-select-border: #3a3f58;
  --input-border: #4f5571;
  --input-focus-border: #388bf3;
  --table-header-text: #9ca3af;
  --table-header-bg: #2a2e42;
  --table-row-border: #353a52;
  --table-row-hover: #585f78;
  --anchor: #388bf3;
  --button-bg-hover: #353a52;
  --button-orange-bg: #ff9d47;
  --tab-nav-card-inactive: #1f2d3b;
  --tab-nav-card-hover: #1a1d2e;

  /* Datepicker */
  --datepicker-bg: #2a2e42;
  --datepicker-header-bg: #252838;
  --datepicker-header-border: #3a3f58;
  --datepicker-title-color: #e5e7eb;
  --datepicker-nav-color: #cbd5e1;
  --datepicker-day-header-color: #cbd5e1;
  --datepicker-day-bg: #252838;
  --datepicker-day-color: #e5e7eb;
  --datepicker-day-hover-bg: #353a52;
  --datepicker-day-hover-color: #e5e7eb;
  --datepicker-day-active-bg: #388bf3;
  --datepicker-day-active-color: #ffffff;

  --floating-button-bg: #003baa;
}

/* Utility classes for using CSS variables */
.bg-primary {
  background-color: var(--bg-primary);
}

.bg-secondary {
  background-color: var(--bg-secondary);
}

.bg-card {
  background-color: var(--bg-card);
}

.text-primary {
  color: var(--text-primary);
}

.text-secondary {
  color: var(--text-secondary);
}

.text-muted {
  color: var(--text-muted);
}

.border {
  border-color: var(--border-color);
}

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

.accent-blue {
  background-color: var(--accent-blue);
}

.accent-green {
  background-color: var(--accent-green);
}

.accent-red {
  background-color: var(--accent-red);
}

.accent-orange {
  background-color: var(--accent-orange);
}

.bg-content {
  background-color: var(--bg-content);
}

/* Base Styles */
* {
  box-sizing: border-box;
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Sidebar anchor styles - prevent underlines and ensure consistent appearance */
.sidebar-button {
  text-decoration: none !important;
  font-family: Helvetica, Verdana, sans-serif;
}

.sidebar-button:hover,
.sidebar-button:focus,
.sidebar-button:active {
  text-decoration: none !important;
}

/* Custom Scrollbars */
.scrollbar-thin {
  scrollbar-width: thin;
}

.scrollbar-thin::-webkit-scrollbar {
  width: 6px;
}

.scrollbar-thin::-webkit-scrollbar-track {
  background: transparent;
}

.scrollbar-thin::-webkit-scrollbar-thumb {
  background-color: #d9e1ea;
  border-radius: 3px;
}

.scrollbar-thin:hover::-webkit-scrollbar-thumb {
  background-color: #c1cdd9;
}

/* Dark mode scrollbar */
.dark .scrollbar-thin::-webkit-scrollbar-thumb {
  background-color: #4a5066;
}

.dark .scrollbar-thin:hover::-webkit-scrollbar-thumb {
  background-color: #5a6076;
}

/* Notification Menu Custom Scrollbar */
.notification-scrollbar {
  scrollbar-width: auto;
  scrollbar-color: #c1cdd9 transparent;
  overflow-y: auto;
}

.notification-scrollbar::-webkit-scrollbar {
  width: 8px;
}

.notification-scrollbar::-webkit-scrollbar-track {
  background: transparent;
  margin: 4px 0;
}

.notification-scrollbar::-webkit-scrollbar-thumb {
  background: linear-gradient(#c1cdd9 0%, #b0bcc9 100%);
  border: 2px solid transparent;
  border-radius: 10px;
  transition: all 0.3s;
}

.notification-scrollbar::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(#a8b5c3 0%, #98a6b5 100%);
}

/* Dark mode notification scrollbar */
.dark .notification-scrollbar {
  scrollbar-color: #4a5066 transparent;
}

.dark .notification-scrollbar::-webkit-scrollbar-thumb {
  background: linear-gradient(#4a5066 0%, #3a4056 100%);
}

.dark .notification-scrollbar::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(#5a6076 0%, #4a5066 100%);
}

.notification-scrollbar-dark {
  scrollbar-color: #4a5066 transparent;
}

.notification-scrollbar-dark::-webkit-scrollbar-thumb {
  background: linear-gradient(#4a5066 0%, #3a4056 100%);
  border: 2px solid transparent;
  border-radius: 10px;
  transition: all 0.3s;
}

.notification-scrollbar-dark::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(#5a6076 0%, #4a5066 100%);
}

/* Animations */
@keyframes slideIn {
  from {
    transform: translateX(-100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOut {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(-100%);
    opacity: 0;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

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

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

@keyframes slideInFromRight {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

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

/* Animation Classes */
.animate-slideIn {
  animation: slideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.animate-slideOut {
  animation: slideOut 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.animate-fadeIn {
  animation: fadeIn 0.2s ease-out forwards;
}

.animate-fadeInSlow {
  animation: fadeIn 1s ease-out forwards;
}

.animate-fadeOut {
  animation: fadeOut 0.2s ease-out forwards;
}

.animate-slideDown {
  animation: slideDown 0.3s ease-out forwards;
}

.animate-slideInFromTop {
  animation: slideInFromTop 0.3s ease-out forwards;
}

.animate-slideInFromRight {
  animation: slideInFromRight 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

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

/* Staggered animation delays for Analysis menu */
.delay-100 {
  animation-delay: 0.1s;
}

.delay-150 {
  animation-delay: 0.15s;
}

.delay-230 {
  animation-delay: 0.23s;
}

.delay-310 {
  animation-delay: 0.31s;
}

.delay-390 {
  animation-delay: 0.39s;
}

/* Initial hidden state for animated elements */
.animate-slideInFromTop,
.animate-slideInFromRight {
  opacity: 0;
}

/* Transition Classes */
.transition-all {
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

.transition-transform {
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.transition-opacity {
  transition: opacity 0.2s ease;
}

.transition-colors {
  transition:
    color 0.15s,
    background-color 0.15s,
    border-color 0.15s;
}

/* Utility Classes */
.no-scroll {
  overflow: hidden;
}

.backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 40;
  animation: fadeIn 0.2s ease-out;
}

.backdrop.closing {
  animation: fadeOut 0.2s ease-out;
}

/* Hide/Show based on breakpoint */
@media (max-width: 1023px) {
  .lg\:flex {
    display: none !important;
  }
}

@media (min-width: 1024px) {
  .lg\:hidden {
    display: none !important;
  }
  .lg\:flex {
    display: flex !important;
  }
}

/* Icon defaults */
svg {
  display: block;
  flex-shrink: 0;
}

/* Button resets - scoped to sidebar buttons only */
/* Using :where() for zero specificity - Tailwind classes will always win */
:where(.sidebar-button) {
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  color: inherit;
}

/* Focus visible (accessibility) - keep normal specificity for this */
.sidebar-button:focus-visible {
  outline: 2px solid var(--accent-blue);
  outline-offset: 2px;
}

/* Category Toggle Hover Effect */
.category-toggle {
  transition: transform 0.3s ease-out;
}

/* Analysis Menu Containers - hide when empty */
#analysis-menu-container:empty,
#analysis-menu-mobile:empty {
  display: none;
}

/* Analysis backdrop animation */
#analysis-backdrop {
  animation: fadeInBackdrop 0.2s ease-in;
}

@keyframes fadeInBackdrop {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Hide desktop analysis menu on mobile */
@media (max-width: 1023px) {
  #analysis-menu-container {
    display: none !important;
  }
}

/* Remove underline from all sidebar links */
#language-menu-container a,
#help-button-container a,
#user-menu-container a {
  text-decoration: none !important;
}

#language-menu-container a:hover,
#help-button-container a:hover,
#user-menu-container a:hover {
  text-decoration: none !important;
}

/* Recalc Badge Styles */
.recalc-badge-container {
  position: fixed;
  left: 62px;
  top: 50px;
  z-index: 1001;
}

body.has-corporate-admin-logo .recalc-badge-container {
  top: 108px;
}

.recalc-badge {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: lab(66.244% 48.7302 60.226);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  transition:
    transform 0.15s ease,
    background-color 0.2s ease;
  animation: recalc-badge-pulse 3s ease-in-out infinite;
}

.recalc-badge:hover {
  transform: scale(1.1);
}

.recalc-badge.calculating {
  background: #388bf3;
  animation: none;
}

.recalc-badge.complete {
  background: #22c55e;
  animation: none;
}

.recalc-badge.hidden {
  display: none;
}

.recalc-badge-icon {
  color: white;
  font-size: 12px;
  font-weight: bold;
  line-height: 1;
}

.recalc-badge.calculating .recalc-badge-icon {
  display: none;
}

.recalc-badge.calculating::after {
  content: "";
  width: 12px;
  height: 12px;
  border: 2px solid transparent;
  border-top-color: white;
  border-radius: 50%;
  animation: recalc-spin 1s linear infinite;
}

.recalc-badge.complete .recalc-badge-icon {
  display: none;
}

.recalc-badge.complete::before {
  content: "✓";
  color: white;
  font-size: 12px;
  font-weight: bold;
}

@keyframes recalc-badge-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

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

/* Recalc Tooltip */
.recalc-tooltip {
  position: absolute;
  left: 28px;
  top: -8px;
  min-width: 240px;
  padding: 12px;
  border-radius: 10px;
  background: white;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.15s ease,
    visibility 0.15s ease;
}

.dark .recalc-tooltip,
[data-theme="dark"] .recalc-tooltip {
  background: #2a2e42;
}

@media (min-width: 1024px) {
  .recalc-badge-container:hover .recalc-tooltip {
    opacity: 1;
    visibility: visible;
  }
}

.recalc-tooltip.tooltip-visible {
  opacity: 1;
  visibility: visible;
}

.recalc-tooltip-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: #0b253e;
}

.dark .recalc-tooltip-header,
[data-theme="dark"] .recalc-tooltip-header {
  color: #e5e7eb;
}

.recalc-tooltip-icon {
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: bold;
  color: #ff9d47;
}

.recalc-badge.calculating ~ .recalc-tooltip .recalc-tooltip-icon {
  color: #388bf3;
  font-size: 0;
}

.recalc-badge.calculating ~ .recalc-tooltip .recalc-tooltip-icon::after {
  content: "";
  width: 14px;
  height: 14px;
  border: 2px solid transparent;
  border-top-color: #388bf3;
  border-radius: 50%;
  animation: recalc-spin 1s linear infinite;
}

.recalc-tooltip-hint {
  margin-left: 24px;
  font-size: 12px;
  color: #6b7280;
}

.dark .recalc-tooltip-hint,
[data-theme="dark"] .recalc-tooltip-hint {
  color: #9ca3af;
}

.recalc-tooltip-progress {
  display: none;
  margin-top: 12px;
  margin-left: 24px;
}

.recalc-badge.calculating ~ .recalc-tooltip .recalc-tooltip-progress {
  display: block;
}

.recalc-badge.calculating ~ .recalc-tooltip .recalc-tooltip-hint {
  display: none;
}

.recalc-badge.calculating
  ~ .recalc-tooltip
  .recalc-tooltip-header
  span:last-child {
  font-size: 0;
}

.recalc-tooltip-progress .progress-item {
  margin-bottom: 8px;
}

.recalc-tooltip-progress .progress-label {
  font-size: 11px;
  color: #6b7280;
  margin-bottom: 4px;
}

.dark .recalc-tooltip-progress .progress-label,
[data-theme="dark"] .recalc-tooltip-progress .progress-label {
  color: #9ca3af;
}

.recalc-tooltip-progress .progress-bar-container {
  height: 6px;
  background: #e5e7eb;
  border-radius: 3px;
  overflow: hidden;
}

.dark .recalc-tooltip-progress .progress-bar-container,
[data-theme="dark"] .recalc-tooltip-progress .progress-bar-container {
  background: #374151;
}

.recalc-tooltip-progress .progress-bar {
  height: 100%;
  background: #388bf3;
  border-radius: 3px;
  transition: width 0.3s ease;
}

.recalc-tooltip-progress .progress-duration {
  font-size: 11px;
  color: #6b7280;
  margin-top: 8px;
}

.dark .recalc-tooltip-progress .progress-duration,
[data-theme="dark"] .recalc-tooltip-progress .progress-duration {
  color: #9ca3af;
}

.recalc-badge.complete ~ .recalc-tooltip .recalc-tooltip-icon {
  color: #22c55e;
  font-size: 0; /* Hide the "!" */
}

.recalc-badge.complete ~ .recalc-tooltip .recalc-tooltip-icon::after {
  content: "✓";
  font-size: 14px;
}

.recalc-badge.complete
  ~ .recalc-tooltip
  .recalc-tooltip-header
  span:last-child {
  font-size: 0;
}

.recalc-badge.complete ~ .recalc-tooltip .recalc-tooltip-hint,
.recalc-badge.complete ~ .recalc-tooltip .recalc-tooltip-progress {
  display: none;
}

/* Mobile: position to the right of the logo */
@media (max-width: 1023px) {
  .recalc-badge-container {
    left: 64px;
    top: 22px;
  }

  .recalc-tooltip {
    left: 0;
    top: 28px;
  }
}

/* Hide when sidebar is collapsed (desktop only) */
@media (min-width: 1024px) {
  body.sidebar-collapsed .recalc-badge-container {
    display: none;
  }
}

.spam-center .toolbar > label {
  min-height: 36px;
}

@media (max-width: 1023px) {
  .recalc-fab-container {
    bottom: 110px;
  }
}

/* Desktop-only compact sidebar when viewport height is small */
@media (min-width: 1024px) and (max-height: 729px) {
  #sidebar-container > div > div:first-child {
    margin-bottom: 0;
  }

  /* Hide labels */
  #sidebar-container .nav-button span {
    display: none;
  }
}

/* Compact mode at higher threshold for corporate admin with logo */
@media (min-width: 1024px) and (max-height: 999px) {
  body.has-corporate-admin-logo #sidebar-container > div > div:first-child {
    margin-bottom: 0;
  }

  body.has-corporate-admin-logo #sidebar-container .nav-button span {
    display: none;
  }
}

#staging-switcher {
  color: var(--text-primary);
  display: inline-block !important;
  padding: 8px 24px 8px 16px;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-color: var(--bg-card);
  background-image: url("data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 width=%2716%27 height=%2716%27 viewBox=%270 0 24 24%27 fill=%27none%27 stroke=%27%239ca3af%27 stroke-width=%272%27 stroke-linecap=%27round%27 stroke-linejoin=%27round%27%3E%3Cpath d=%27M6 9l6 6 6-6%27/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
  background-size: 19px;
  border-color: var(--border-secondary);
  max-width: 120px;
}
