/* Dark mode CSS variables and transitions */
:root {
  --bg-primary: #f8f9fb;
  --bg-secondary: #f1f5f9;
  --bg-tertiary: #ffffff;
  --text-primary: #0f172a;
  --text-secondary: #64748b;
  --border-primary: #e2e8f0;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --border-primary: #475569;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.4);
}

/* Smooth theme transitions */
* {
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

body[data-theme="dark"] {
  background-color: var(--bg-primary);
  color: var(--text-primary);
}

/* custom scrollbar - webkit only but whatever */
::-webkit-scrollbar {
  width: 6px
}

::-webkit-scrollbar-track {
  background: transparent
}

::-webkit-scrollbar-thumb {
  background-color: #cbd5e1;
  border-radius: 20px;
}

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

.iconify {
  display: inline-block;
  vertical-align: middle;
}

/* step wizard panels */
.step-panel {
  display: none
}

.step-panel.active {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: calc(100vh - 200px);
  animation: fadeIn .4s ease-out;
}

.bento-grid-container {
  grid-auto-flow: dense
}

/* treemap grid thing */
.treemap-container {
  position: relative;
  width: 100%;
  aspect-ratio: 4/3;
  border-radius: 1.5rem;
  overflow: hidden;
}

.treemap-cell {
  position: absolute;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-sizing: border-box;
  overflow: hidden;
  cursor: pointer;
  transition: z-index 0s;
  will-change: transform;
  /* helps with hover perf */
}

.treemap-cell:hover {
  z-index: 50
}

.treemap-cell-inner {
  position: absolute;
  inset: 3px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  transition: transform .1s ease-out, box-shadow .2s ease;
}

.treemap-cell:hover .treemap-cell-inner {
  box-shadow: 0 20px 40px -10px rgba(0, 0, 0, .15);
  transform: scale(1.02);
}

.treemap-cell-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* tiny cells get centered content */
.treemap-cell.tiny .treemap-cell-inner {
  padding: 6px;
  justify-content: center;
  align-items: center;
}

/* beeswarm plot */
.beeswarm-dot {
  transition: transform 0.2s ease, z-index 0s;
  will-change: transform;
  -webkit-tap-highlight-color: transparent;
}

.beeswarm-dot:hover,
.beeswarm-dot.active {
  z-index: 100;
}

/* Show tooltip on tap for mobile */
.beeswarm-dot.active .beeswarm-tooltip {
  opacity: 1;
}

/* Prevent dots from being too small on mobile */
@media (max-width: 500px) {
  .beeswarm-dot>div:first-child {
    border-width: 1.5px;
  }
}

/* Circle pack bubbles */
.circlepack-bubble {
  transition: transform 0.2s ease, z-index 0s;
  will-change: transform;
  -webkit-tap-highlight-color: transparent;
}

.circlepack-bubble:hover,
.circlepack-bubble.active {
  z-index: 100;
}

.circlepack-bubble.active .circlepack-tooltip {
  opacity: 1;
}

/* Category styling */
.category-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.625rem;
  background-color: #f1f5f9;
  border-radius: 0.375rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: #475569;
}

.category-filter-btn {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 9999px;
  background: #f0f0f0;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s ease;
  color: #64748b;
}

.category-filter-btn.active {
  background: #6366f1;
  color: white;
}

.category-filter-btn:hover {
  background: #e2e8f0;
}

.category-filter-btn.active:hover {
  background: #4f46e5;
}

.category-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.5rem 0;
}

.category-bar-color {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  flex-shrink: 0;
}

.category-bar-label {
  min-width: 100px;
  font-size: 0.875rem;
  font-weight: 500;
}

.category-bar-fill {
  flex: 1;
  height: 20px;
  background: #e0e0e0;
  border-radius: 4px;
  overflow: hidden;
}

.category-bar-fill-inner {
  height: 100%;
  background: #6366f1;
  transition: width 0.3s ease;
}

.category-bar-value {
  min-width: 60px;
  text-align: right;
  font-size: 0.875rem;
  font-weight: 500;
}

/* Budget styling */
#budget-fill {
  transition: width 0.5s ease-out, background-color 0.5s ease-out;
}

.budget-indicator {
  animation: slideUp 0.3s ease-out;
}

/* Renewal badges and upcoming renewals */
.renewal-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  display: inline-block;
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.renewal-badge-normal {
  background: #dbeafe;
  color: #0c4a6e;
}

.renewal-badge-warning {
  background: #fef08a;
  color: #713f12;
}

.renewal-badge-urgent {
  background: #fee2e2;
  color: #991b1b;
}

.renewal-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  background: #f8f9fb;
  border-left: 4px solid #3b82f6;
  border-radius: 6px;
  font-size: 0.875rem;
}

.renewal-item-name {
  font-weight: 500;
  color: #0f172a;
  flex: 1;
}

.renewal-item-date {
  color: #64748b;
  font-size: 0.8125rem;
  margin: 0 1rem;
}

.renewal-item-days {
  padding: 3px 8px;
  background: #e0f2fe;
  border-radius: 8px;
  color: #0c4a6e;
  font-weight: 600;
  font-size: 0.75rem;
  min-width: 50px;
  text-align: center;
}

/* Trends visualization styling */
#trends-chart-container {
  display: flex;
  justify-content: center;
  align-items: center;
}

#trends-chart {
  width: 100%;
  max-width: 100%;
}

/* Trend value colors */
.trend-value-up {
  color: #22c55e;
}

.trend-value-down {
  color: #ef4444;
}

.trend-value-stable {
  color: #3b82f6;
}

.trend-icon {
  display: inline-block;
  margin-right: 4px;
}

/* Google Sheets Sync Styling */
#sheets-status {
  font-weight: 500;
}

#sheets-status:not(.connected):not(.error):not(.offline) {
  background: #f1f5f9;
  color: #64748b;
}

#sheets-status.connected {
  background: #d1fae5;
  color: #065f46;
}

#sheets-status.error {
  background: #fee2e2;
  color: #991b1b;
}

#sheets-status.offline {
  background: #fef3c7;
  color: #92400e;
}

/* Sync Status Indicator in Header/Footer */
.sync-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: #f0f9ff;
  border-radius: 6px;
  font-size: 0.875rem;
  color: #0c4a6e;
}

.sync-status.offline {
  background: #fef3c7;
  color: #92400e;
}

.sync-status.error {
  background: #fee2e2;
  color: #991b1b;
}

/* Status Dot Animation */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.status-dot.idle {
  background: #3b82f6;
}

.status-dot.syncing {
  background: #f59e0b;
  animation: pulse-sync 1.5s ease-in-out infinite;
}

.status-dot.synced {
  background: #22c55e;
}

.status-dot.error {
  background: #ef4444;
}

.status-dot.offline {
  background: #f97316;
}

/* Pulse animation for syncing state */
@keyframes pulse-sync {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* Sync indicator responsiveness */
@media (max-width: 640px) {
  .sync-status {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
  }
}