/* 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;
  --border-color: #ecf0f5;
  --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-focus-border: #388bf3;
  --table-header-text: #6b7a8e;
  --table-header-bg: #ccc;
  --table-row-border: #f3f4f6;
  --table-row-hover: #f3f4f6;

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

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

.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;
  --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: #3a3f58;
  --border-hover: #4a5066;
  --nice-select-bg: #353a52;
  --nice-select-border: #3a3f58;
  --input-focus-border: #388bf3;
  --table-header-text: #9ca3af;
  --table-header-bg: #2a2e42;
  --table-row-border: #353a52;
  --table-row-hover: #353a52;
  --anchor: #388bf3;
  --button-bg-hover: #353a52;
  --button-orange-bg: #ff9d47;
  --tab-nav-card-inactive: #1f2d3b;
  --tab-nav-card-hover: #1a1d2e;
}

/* 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);
  }
}

/* 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 1.0s 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;
}

/* 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-fab-container {
    position: fixed;
    bottom: 170px;
    right: .5rem;
    z-index: 40;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
}

.progress-panel {
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    width: 400px;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: all 0.3s ease;
}

.progress-panel.active {
    max-height: 300px;
    opacity: 1;
}

.progress-header {
    background: #1976d2;
    color: white;
    padding: 12px 16px;
    font-weight: 600;
    font-size: 14px;
}

.progress-content {
    padding: 16px;
}

.progress-item {
    margin-bottom: 16px;
}

.progress-label {
    font-size: 13px;
    color: #666;
    margin-bottom: 8px;
}

.progress-bar-container {
    width: 100%;
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: #1976d2;
    transition: width 0.3s ease;
    border-radius: 4px;
}

.progress-bar.complete {
    background: #4caf50;
}

.progress-duration {
    text-align: right;
    font-size: 12px;
    color: #999;
    margin-top: 12px;
}

.recalc-fab {
    height: 56px;
    min-width: 56px;
    background: var(--button-orange-bg);
    border-radius: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    cursor: pointer;
    border: none;
    color: white;
    font-size: 28px;
    font-weight: bold;
    transition: all 0.3s ease;
    padding: 0;
    position: relative;
}

.recalc-fab:hover {
    background: var(--button-orange-bg);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.4);
}

.recalc-fab-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    flex-shrink: 0;
    transition: all 0.3s ease;
    overflow: hidden;
}

.recalc-fab-text {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    max-width: 0;
    opacity: 0;
    overflow: hidden;
    transition: all 0.3s ease;
    padding-right: 0;
}

.recalc-fab:hover {
    padding-right: 20px;
    padding-left: 4px;
}

.recalc-fab:hover .recalc-fab-text {
    max-width: 200px;
    opacity: 1;
    padding-right: 8px;
}

.recalc-fab::before {
    content: '';
    position: absolute;
    top: -6px;
    left: -6px;
    right: -6px;
    bottom: -6px;
    border-radius: 34px;
    border: 3px solid var(--button-orange-bg);
    animation: pulse 2s infinite;
    pointer-events: none;
}

@keyframes recalc-pulse {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }
    100% {
        transform: scale(1.4);
        opacity: 0;
    }
}

.recalc-fab:hover::before,
.recalc-fab.calculating::before {
    animation: none;
    opacity: 0;
}

.recalc-fab.calculating {
    background: #1976d2;
}

.recalc-fab.calculating .recalc-fab-icon {
    animation: spin 1s linear infinite;
}

.recalc-fab.complete {
    background: #4caf50;
}

.recalc-fab.hidden {
    opacity: 0;
    transform: scale(0.8);
    pointer-events: none;
}

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

.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;
}
