/* CarbonLens - Custom Styles & Tailwind Overrides */

/* Focus visible for keyboard navigation */
*:focus-visible {
  outline: 2px solid #16a34a;
  outline-offset: 2px;
  border-radius: 4px;
}

/* Smooth scrolling */
html {
  scroll-behavior: smooth;
}

/* Custom scrollbar for activity log & insights */
.activity-log-scroll::-webkit-scrollbar,
.insights-scroll::-webkit-scrollbar {
  width: 6px;
}
.activity-log-scroll::-webkit-scrollbar-track,
.insights-scroll::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 3px;
}
.activity-log-scroll::-webkit-scrollbar-thumb,
.insights-scroll::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}
.activity-log-scroll::-webkit-scrollbar-thumb:hover,
.insights-scroll::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Dark scrollbar */
.dark .activity-log-scroll::-webkit-scrollbar-track,
.dark .insights-scroll::-webkit-scrollbar-track {
  background: #334155;
}
.dark .activity-log-scroll::-webkit-scrollbar-thumb,
.dark .insights-scroll::-webkit-scrollbar-thumb {
  background: #475569;
}
.dark .activity-log-scroll::-webkit-scrollbar-thumb:hover,
.dark .insights-scroll::-webkit-scrollbar-thumb:hover {
  background: #64748b;
}

/* Modal backdrop animation */
#modal-api-key {
  transition: opacity 0.2s ease;
}
#modal-api-key.hidden {
  opacity: 0;
  pointer-events: none;
}
#modal-api-key:not(.hidden) {
  opacity: 1;
}

/* Modal content animation */
#modal-api-key > div {
  transition: transform 0.2s ease, opacity 0.2s ease;
}
#modal-api-key.hidden > div {
  transform: scale(0.95);
  opacity: 0;
}
#modal-api-key:not(.hidden) > div {
  transform: scale(1);
  opacity: 1;
}

/* Activity log item enter animation */
.log-item-enter {
  animation: slideIn 0.3s ease forwards;
}
@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Insight card enter animation */
.insight-enter {
  animation: fadeInUp 0.4s ease forwards;
}
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Loading spinner pulse */
@keyframes pulse-dot {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}
.loading-dots span {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #16a34a;
  animation: pulse-dot 1.4s infinite ease-in-out both;
}
.loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.loading-dots span:nth-child(2) { animation-delay: -0.16s; }

/* Toast notification */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  padding: 0.75rem 1.25rem;
  border-radius: 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  z-index: 100;
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
.toast-success {
  background: #16a34a;
  color: white;
}
.toast-error {
  background: #dc2626;
  color: white;
}
.toast-info {
  background: #1e293b;
  color: white;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(10px); }
}

/* Print styles */
@media print {
  header, footer, #btn-get-insights, #btn-log-activity, #btn-key-config, #btn-units, #btn-delete-menu, #delete-menu-wrapper {
    display: none !important;
  }
  body {
    background: white;
  }
  .shadow-sm, .shadow-2xl {
    box-shadow: none;
  }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  html {
    scroll-behavior: auto;
  }
}

/* High contrast mode support */
@media (forced-colors: active) {
  .bg-forest-600 {
    border: 1px solid ButtonText;
  }
  .bg-carbon-800 {
    border: 1px solid ButtonText;
  }
}

/* Calendar day cell */
.cal-day {
  aspect-ratio: 1;
  border-radius: 0.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2px;
  cursor: default;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  position: relative;
  min-height: 44px;
}
.cal-day:hover {
  transform: scale(1.05);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  z-index: 1;
}
.cal-day-num {
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1;
}
.cal-day-co2 {
  font-size: 0.6rem;
  font-weight: 600;
  line-height: 1;
  margin-top: 2px;
}

/* Calendar color levels (0-5+ kg CO2) */
.cal-level-0 { background: #f0fdf4; color: #166534; }
.cal-level-1 { background: #dcfce7; color: #166534; }
.cal-level-2 { background: #fef08a; color: #854d0e; }
.cal-level-3 { background: #fed7aa; color: #9a3412; }
.cal-level-4 { background: #fecaca; color: #991b1b; }
.cal-level-5 { background: #fca5a5; color: #991b1b; }

/* Calendar dark mode overrides */
.dark .cal-level-0 { background: #14532d; color: #86efac; }
.dark .cal-level-1 { background: #166534; color: #86efac; }
.dark .cal-level-2 { background: #854d0e; color: #fef08a; }
.dark .cal-level-3 { background: #9a3412; color: #fed7aa; }
.dark .cal-level-4 { background: #991b1b; color: #fecaca; }
.dark .cal-level-5 { background: #991b1b; color: #fca5a5; }

.cal-today {
  outline: 2px solid #16a34a;
  outline-offset: 1px;
}
.cal-empty {
  background: transparent;
  pointer-events: none;
}

/* Yearly calendar cell */
.cal-year-cell {
  border-radius: 0.75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 0.5rem;
  min-height: 80px;
  gap: 2px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.cal-year-cell:hover {
  transform: scale(1.03);
  z-index: 1;
}
.cal-year-month-name {
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.2;
}
.cal-year-total {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.2;
}
.cal-year-unit {
  font-size: 0.6rem;
  font-weight: 500;
  opacity: 0.7;
  line-height: 1;
}
.cal-year-days {
  font-size: 0.6rem;
  font-weight: 500;
  opacity: 0.6;
  line-height: 1;
  margin-top: 2px;
}
