@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
  /* Brand Colors - Soothing, therapeutic palette */
  --color-bg: #f9fafb;
  /* Soft warm off-white */
  --color-surface: #ffffff;
  --color-primary: #334155;
  /* Darker calming slate-blue */
  --color-primary-light: #64748b;
  --color-secondary: #f6bd60;
  /* Warm sand/sun */
  --color-text-main: #333333;
  /* Soft anthracite */
  --color-text-muted: #666666;
  --color-accent-red: #e07a5f;
  /* Alert/Emergency */
  --color-accent-red-light: #f4a261;
  --color-border: #e2e8f0;
}

body {
  font-family: 'Outfit', sans-serif;
  background-color: var(--color-bg);
  color: var(--color-text-main);
  /* Prevent pull-to-refresh on mobile apps if needed */
  overscroll-behavior-y: none;
}

/* Glassmorphism effects for cards */
.glass-card {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.5);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
}

/* Highlight for completed modules */
.module-completed {
  background-color: #f0fdf4 !important;
  /* Tailwind green-50 */
  background-image: none !important;
  border-color: #bbf7d0 !important;
  transition: all 0.3s ease;
}

.dark .module-completed,
html.dark .dashboard-widget>div.module-completed,
html.dark .tracker-widget>div.module-completed,
html.dark .therapy-widget>div.module-completed {
  background-color: rgba(20, 83, 45, 0.4) !important;
  background-image: none !important;
  border-color: rgba(34, 197, 94, 0.3) !important;
}

/* Custom Scrollbar for aesthetic */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--color-primary-light);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-primary);
}

.hide-scrollbar::-webkit-scrollbar {
  display: none;
}

/* Base Layout Transitions */
.view-section {
  display: none;
  animation: fadeIn 0.4s ease-out forwards;
}

.view-section.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Mobile Bottom Nav */
.nav-item {
  position: relative;
  transition: all 0.2s ease;
}

.nav-item i {
  transition: transform 0.2s ease;
}

.nav-item.active {
  color: var(--color-primary);
  font-weight: 600;
}

.nav-item.active i {
  transform: translateY(-2px);
}

.mobile-nav-item.active::after {
  content: '';
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  width: 30px;
  height: 3px;
  background-color: var(--color-primary);
  border-radius: 0 0 4px 4px;
}

/* Desktop Top Nav */
.desktop-nav-item.active {
  background-color: #f3f4f6;
  /* Tailwind gray-100 */
  color: var(--color-primary);
  font-weight: 700;
}

/* Floating Emergency Button */
.fab-emergency {
  position: fixed;
  bottom: 6.5rem;
  /* Above Bottom Nav on Mobile */
  right: 1.5rem;
  width: 3.5rem;
  height: 3.5rem;
  background-color: #ef4444;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-accent-red), var(--color-accent-red-light));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  box-shadow: 0 4px 15px rgba(224, 122, 95, 0.4);
  cursor: pointer;
  z-index: 50;
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.fab-emergency:hover {
  transform: scale(1.1);
}

.fab-emergency.pulse {
  animation: pulse-red 2s infinite;
}

@keyframes pulse-red {
  0% {
    box-shadow: 0 0 0 0 rgba(224, 122, 95, 0.7);
  }

  70% {
    box-shadow: 0 0 0 15px rgba(224, 122, 95, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(224, 122, 95, 0);
  }
}

/* Mood Tracker Grid */
.mood-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}

.mood-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px 5px;
  border-radius: 12px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.85rem;
  color: var(--color-text-main);
}

.mood-btn span.emoji {
  font-size: 1.5rem;
  margin-bottom: 4px;
  transition: transform 0.2s ease;
}

.mood-btn:hover {
  border-color: var(--color-primary-light);
  background: #f0fdf4;
}

.mood-btn:hover span.emoji {
  transform: scale(1.1);
}

.mood-btn.selected {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
  box-shadow: 0 4px 10px rgba(107, 144, 128, 0.3);
}

/* Custom form inputs */
.custom-input {
  width: 100%;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-main);
  transition: all 0.2s ease;
  font-family: inherit;
  max-width: 100%;
}

input.custom-input,
select.custom-input {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.custom-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(107, 144, 128, 0.1);
}

textarea.custom-input {
  resize: vertical;
  min-height: 80px;
}

/* Primary Button */
.btn-primary {
  background-color: var(--color-primary);
  color: white;
  padding: 12px 24px;
  border-radius: 12px;
  font-weight: 500;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  cursor: pointer;
}

.btn-primary:hover {
  background-color: #5a7d6e;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(107, 144, 128, 0.2);
}

/* Utility classes for Desktop adjustments */
@media (min-width: 768px) {
  .fab-emergency {
    bottom: 30px;
    right: 30px;
  }
}

/* --- Dark Mode Overrides --- */
.dark body,
.dark body.bg-\[\#F9FAFB\] {
  background-color: #0f172a !important;
  /* slate-900 (softer dark background) */
  color: #f1f5f9;
  /* slate-100 */
}

/* Nav Menu Hover & Active Fixes */
.dark .desktop-nav-item:hover,
.dark .desktop-nav-item.active {
  /* override Tailwind bg-brand/10 for desktop active state */
  background-color: rgba(51, 65, 85, 0.5) !important;
  color: #f8fafc !important;
}

.dark .mobile-nav-item:hover,
.dark .mobile-nav-item.active {
  color: #f8fafc !important;
}

/* General Hover States (Settings, etc.) */
.dark .hover\:bg-gray-50:hover,
.dark .hover\:bg-gray-100:hover {
  background-color: rgba(51, 65, 85, 0.5) !important;
}

/* Backgrounds */
/* Main app background is #020617 (slate-950) */
.dark .bg-white,
.dark .bg-gray-50,
.dark .bg-\[\#F9FAFB\] {
  background-color: rgba(51, 65, 85, 0.5) !important;
  /* Unified 1%-Methode Look */
  border-color: rgba(255, 255, 255, 0.1) !important;
  color: #f8fafc !important;
  /* slate-50 */
}

/* For slightly elevated elements, use slate-700 to stand out from slate-800 widgets */
.dark .glass-card {
  background: rgba(30, 41, 59, 0.9) !important;
  /* darker glass */
  border-color: rgba(255, 255, 255, 0.1) !important;
}

.dark .bg-white\/80,
.dark .bg-white\/90 {
  background-color: rgba(30, 41, 59, 0.8) !important;
}

/* Text Colors */
.dark .text-slate-900,
.dark .text-gray-800,
.dark .text-\[\#333333\] {
  color: #f8fafc !important;
  /* Fixed library titles readability */
}

.dark .text-gray-700,
.dark .text-gray-600 {
  color: #e2e8f0 !important;
  /* slate-200 for better visibility */
}

.dark .text-gray-500,
.dark .text-gray-400 {
  color: #cbd5e1 !important;
  /* slate-300 */
}

/* Brand overrides */
.dark .text-brand {
  color: #f8fafc !important;
  /* changed from slate-400 to slate-50 for headings readability */
}

.dark .text-brand-dark,
.dark .text-brand-light {
  color: #f8fafc !important;
  /* slate-50 (Fixed quote text readability) */
}

/* Borders */
.dark .border-gray-100,
.dark .border-gray-200 {
  border-color: #334155 !important;
  /* slate-700 */
}

/* Custom inputs */
.dark .custom-input {
  background-color: rgba(51, 65, 85, 0.5) !important;
  border-color: rgba(255, 255, 255, 0.2) !important;
  color: #f8fafc !important;
}

.dark select.custom-input,
.dark select,
.dark select option,
.dark select.custom-input option {
  background-color: #1e293b !important;
  color: #f8fafc !important;
}

.dark .custom-input:focus {
  border-color: var(--color-primary-light);
}

.dark .custom-input::placeholder {
  color: #94a3b8;
  /* slate-400 */
}

/* Modals */
.dark #history-modal>div,
.dark #edit-tracker-modal>div,
.dark #dashboard-config-modal>div {
  background-color: #1e293b !important;
  color: #f8fafc !important;
}

.dark #schema-tip-container,
.dark [id^="history-tab"] {
  background-color: #1e293b !important;
}

.dark #history-tabs {
  background-color: #334155 !important;
  border-bottom-color: #475569 !important;
}

.dark .bg-brand\/5 {
  background-color: rgba(51, 65, 85, 0.5) !important;
}

/* --- Module Specific Dark Mode Colors --- */
/* Unified Dark Mode Module Look (1%-Methode Style) */
.dark .bg-yellow-50,
.dark .bg-amber-50\/50,
.dark .bg-red-50,
.dark .bg-alert\/10,
.dark .bg-purple-50,
.dark .bg-indigo-50,
.dark .bg-purple-50\/50,
.dark .bg-green-50,
.dark .bg-emerald-100,
.dark .bg-orange-50,
.dark .bg-orange-100,
.dark .bg-blue-50,
.dark .bg-cyan-100,
.dark .bg-teal-50\/30,
.dark .bg-teal-100,
.dark .bg-gray-100 {
  background-color: rgba(51, 65, 85, 0.5) !important;
}

.dark .border-yellow-200,
.dark .border-amber-100,
.dark .border-amber-200,
.dark .border-red-200,
.dark .border-red-100,
.dark .border-alert\/20,
.dark .border-alert,
.dark .border-purple-200,
.dark .border-purple-100,
.dark .border-indigo-200,
.dark .border-indigo-100,
.dark .border-green-200,
.dark .border-green-100,
.dark .border-orange-200,
.dark .border-orange-100,
.dark .border-blue-200,
.dark .border-blue-100,
.dark .border-teal-200,
.dark .border-teal-100,
.dark .border-gray-800,
.dark .border-sand {
  border-color: rgba(255, 255, 255, 0.2) !important;
}

.dark .text-yellow-700,
.dark .text-yellow-800,
.dark .text-amber-500,
.dark .text-amber-600,
.dark .text-red-700,
.dark .text-alert,
.dark .text-red-600,
.dark .text-red-500,
.dark .text-purple-700,
.dark .text-indigo-800,
.dark .text-indigo-700,
.dark .text-purple-500,
.dark .text-purple-600,
.dark .text-green-700,
.dark .text-green-600,
.dark .text-green-500,
.dark .text-emerald-600,
.dark .text-orange-700,
.dark .text-orange-600,
.dark .text-orange-500,
.dark .text-blue-700,
.dark .text-blue-600,
.dark .text-blue-500,
.dark .text-cyan-600,
.dark .text-teal-700,
.dark .text-teal-600,
.dark .text-sand,
.dark .text-stone-700 {
  color: #f8fafc !important;
  /* slate-50 */
}

.dark .bg-stone-200 {
  background-color: rgba(51, 65, 85, 0.5) !important;
}

/* Specific Buttons Defaults */
.dark .schema-btn:hover {
  background-color: #334155 !important;
}

/* Make completed modules visibly green in dark mode */
.dark .module-completed {
  background-color: rgba(34, 197, 94, 0.4) !important;
  /* visibly brighter green bg */
  border-color: rgba(34, 197, 94, 0.6) !important;
}

/* Ensure the icon inside a completed module also turns bright green in dark mode */
.dark .module-completed i {
  color: #4ade80 !important;
  /* Tailwind green-400 */
}