@import "tailwindcss";

@layer base {
  *,
  ::after,
  ::before,
  ::backdrop,
  ::file-selector-button {
    border-color: var(--color-slate-200, #e2e8f0);
  }

  button:not(:disabled),
  [role="button"]:not([aria-disabled="true"]) {
    cursor: pointer;
  }
}

:root {
  color-scheme: light;
  --bg-page: #f8fafc;
  --text-page: #0f172a;
  --surface-card: #ffffff;
  --border-subtle: #e2e8f0;
}
body.dark-theme {
  color-scheme: dark;
  --bg-page: #090d16;
  --text-page: #f1f5f9;
  --surface-card: #111827;
  --border-subtle: #1e293b;
}
body {
  font-family: 'Inter','Noto Sans','Noto Sans Bengali','Noto Sans Arabic','Noto Sans Devanagari',system-ui,sans-serif;
  background-color: var(--bg-page);
  color: var(--text-page);
}
.font-display {
  font-family: 'Space Grotesk','Inter','Noto Sans Bengali','Noto Sans Arabic',system-ui,sans-serif;
}
/* Smooth custom scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Visible keyboard focus rings (Task 2f) */
button:focus-visible,
select:focus-visible,
input:focus-visible,
[role="button"]:focus-visible,
[role="tab"]:focus-visible,
#pdfDropZone:focus-within {
  outline: 2px solid #6366f1 !important;
  outline-offset: 2px !important;
}

/* Subtle, premium tactile hover & touch elevation */
.interactive-card {
  transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1),
              box-shadow 0.22s cubic-bezier(0.22, 1, 0.36, 1),
              border-color 0.22s ease;
}
.interactive-card:active {
  transform: translateY(-0.5px);
  box-shadow: 0 6px 16px -6px rgba(15, 23, 42, 0.06);
}

/* Clean Premium Bento Surface */
.dopamine-card {
  position: relative;
  overflow: hidden;
}

/* =====================================================================
   ARTISTIC HIGH-CONTRAST WHITE THEME (DARK THEME REMAINS UNTOUCHED)
   ===================================================================== */
body:not(.dark-theme) {
  background-color: #eef2f6;
  background-image:
    radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.08) 0px, transparent 50%),
    radial-gradient(at 100% 0%, rgba(16, 185, 129, 0.06) 0px, transparent 45%),
    linear-gradient(180deg, #eef2f7 0%, #f1f5f9 100%);
  color: #0f172a;
}
body:not(.dark-theme) header {
  background-color: rgba(255, 255, 255, 0.94) !important;
  border-bottom: 1.5px solid #cbd5e1 !important;
  box-shadow: 0 4px 20px -4px rgba(15, 23, 42, 0.06);
}
body:not(.dark-theme) .interactive-card {
  background-color: #ffffff;
  border: 1.5px solid #cbd5e1 !important;
  box-shadow:
    0 10px 26px -8px rgba(15, 23, 42, 0.08),
    0 2px 6px -1px rgba(15, 23, 42, 0.04) !important;
}
body:not(.dark-theme) .dopamine-card {
  background: linear-gradient(180deg, #ffffff 0%, #fcfdff 100%) !important;
}
/* Crisp, clearly visible ring tracks in White Theme */
body:not(.dark-theme) #weekDonutCircleBg {
  stroke: #cbd5e1 !important;
}
body:not(.dark-theme) .mini-donut-bg {
  stroke: #cbd5e1 !important;
}
/* Distinct, artistic Week Ring Cards (W1..W5) in White Theme */
body:not(.dark-theme) .week-ring-card-active {
  background: linear-gradient(180deg, #eef2ff 0%, #e0e7ff 100%) !important;
  border: 1.5px solid #4f46e5 !important;
  box-shadow: 0 8px 20px -6px rgba(79, 70, 229, 0.25) !important;
}
body:not(.dark-theme) .week-ring-card-idle {
  background-color: #f8fafc !important;
  border: 1.5px solid #cbd5e1 !important;
  box-shadow: 0 2px 5px rgba(15, 23, 42, 0.04);
}
body:not(.dark-theme) .week-ring-card-idle:hover {
  background-color: #f1f5f9 !important;
  border-color: #94a3b8 !important;
}
/* Clearly visible recessed bar tracks & progress tracks in White Theme */
body:not(.dark-theme) .rhythm-bar-track {
  background-color: #e2e8f0 !important;
  border: 1px solid #cbd5e1 !important;
  box-shadow: inset 0 2px 4px rgba(15, 23, 42, 0.06);
}
body:not(.dark-theme) .stat-strip-box {
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%) !important;
  border: 1.5px solid #cbd5e1 !important;
  box-shadow: inset 0 1px 0 #ffffff;
}
body:not(.dark-theme) .stat-strip-box > div + div {
  border-color: #cbd5e1 !important;
}
/* Sharper typography & contrast for muted labels in White Theme */
body:not(.dark-theme) .text-slate-400 {
  color: #475569 !important;
}
body:not(.dark-theme) .text-slate-500 {
  color: #334155 !important;
}
/* Clearly visible section dividers, table borders, and input fields in White Theme */
body:not(.dark-theme) .border-slate-100,
body:not(.dark-theme) .border-slate-100\/80,
body:not(.dark-theme) .border-slate-200\/70,
body:not(.dark-theme) .border-slate-200\/80 {
  border-color: #cbd5e1 !important;
}
body:not(.dark-theme) .divide-slate-100 > :not([hidden]) ~ :not([hidden]),
body:not(.dark-theme) .divide-slate-100 > :not(:last-child) {
  border-color: #e2e8f0 !important;
}
body:not(.dark-theme) .bg-slate-100,
body:not(.dark-theme) .bg-slate-100\/90 {
  background-color: #e2e8f0 !important;
}
body:not(.dark-theme) input[type="text"],
body:not(.dark-theme) input[type="number"],
body:not(.dark-theme) select {
  background-color: #f8fafc !important;
  border: 1.5px solid #94a3b8 !important;
  color: #0f172a !important;
}
body:not(.dark-theme) input[type="text"]::placeholder {
  color: #64748b !important;
}
body:not(.dark-theme) input[type="text"]:focus,
body:not(.dark-theme) input[type="number"]:focus,
body:not(.dark-theme) select:focus {
  background-color: #ffffff !important;
  border-color: #4f46e5 !important;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}
/* High-visibility tactile checkboxes in White Theme */
body:not(.dark-theme) .check-btn[aria-pressed="false"] {
  background-color: #f8fafc !important;
  border: 1.5px solid #94a3b8 !important;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.06);
}
body:not(.dark-theme) .check-btn[aria-pressed="false"]:hover {
  background-color: #eef2ff !important;
  border-color: #4f46e5 !important;
}
body:not(.dark-theme) #habitTableHeaderRow {
  background-color: #f1f5f9 !important;
  border-bottom: 1.5px solid #cbd5e1 !important;
}
body:not(.dark-theme) #habitTableHeaderRow th {
  color: #334155 !important;
  font-weight: 700 !important;
}
body:not(.dark-theme) #habitTableFooter {
  background-color: #f1f5f9 !important;
  border-top: 1.5px solid #cbd5e1 !important;
}
body.dark-theme .week-ring-card-active {
  background: linear-gradient(180deg, rgba(99, 102, 241, 0.16) 0%, rgba(30, 41, 59, 0.75) 100%) !important;
  border-color: #6366f1 !important;
  box-shadow: 0 8px 24px -6px rgba(99, 102, 241, 0.28) !important;
}
body.dark-theme .week-ring-card-idle {
  background-color: rgba(15, 23, 42, 0.75) !important;
  border-color: #1e293b !important;
}
body.dark-theme .week-ring-card-idle:hover {
  border-color: #334155 !important;
  background-color: rgba(30, 41, 59, 0.8) !important;
}
@keyframes xpFloatUp {
  0% { opacity: 1; transform: translateY(0) scale(0.9); }
  50% { opacity: 1; transform: translateY(-16px) scale(1.08); }
  100% { opacity: 0; transform: translateY(-30px) scale(0.95); }
}
.xp-float-pop {
  animation: xpFloatUp 0.9s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  pointer-events: none;
}
@keyframes ringPulseGlow {
  0%, 100% { filter: drop-shadow(0 0 6px rgba(99, 102, 241, 0.25)); }
  50% { filter: drop-shadow(0 0 14px rgba(16, 185, 129, 0.45)); }
}
.donut-glow-active {
  animation: ringPulseGlow 3s ease-in-out infinite;
}
@keyframes calendarExpandIn {
  0% { opacity: 0; transform: translateY(-8px) scale(0.97); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
.calendar-popover-open {
  animation: calendarExpandIn 0.22s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

/* Interactive buttons, pills & calendar cells */
button,
select,
.interactive-item {
  transition: transform 0.16s cubic-bezier(0.22, 1, 0.36, 1),
              box-shadow 0.18s cubic-bezier(0.22, 1, 0.36, 1),
              background-color 0.16s ease,
              border-color 0.16s ease,
              color 0.16s ease;
  -webkit-tap-highlight-color: transparent;
}
button:active:not(:disabled),
.interactive-item:active {
  transform: translateY(0px) scale(0.97);
  box-shadow: 0 2px 6px -2px rgba(15, 23, 42, 0.06);
}

/* Checkbox pop & halo animation */
.check-btn {
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.18s ease,
              background-color 0.15s ease,
              border-color 0.15s ease;
}
.check-btn:active {
  transform: scale(0.88);
}

/* Subtle row highlight for habit table */
.habit-row {
  transition: background-color 0.16s ease, box-shadow 0.18s ease;
}

/* Task 2e: Wrap hover lifts in @media (hover:hover) so touch screens don't stick */
@media (hover: hover) {
  .interactive-card:hover,
  .interactive-card:focus-within {
    transform: translateY(-2px);
    box-shadow: 0 14px 30px -10px rgba(15, 23, 42, 0.07),
                0 4px 12px -3px rgba(79, 70, 229, 0.05);
    border-color: #cbd5e1;
  }
  button:hover:not(:disabled),
  select:hover,
  .interactive-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px -4px rgba(15, 23, 42, 0.09),
                0 2px 6px -2px rgba(15, 23, 42, 0.05);
  }
  .check-btn:hover {
    transform: translateY(-1px) scale(1.05);
    box-shadow: 0 6px 14px -3px rgba(79, 70, 229, 0.22);
  }
  .habit-row:hover {
    box-shadow: inset 0 1px 0 0 #e2e8f0, inset 0 -1px 0 0 #e2e8f0, 0 4px 12px -4px rgba(15, 23, 42, 0.04);
  }
  body.dark-theme .interactive-card:hover,
  body.dark-theme .interactive-card:focus-within {
    border-color: #334155 !important;
    box-shadow: 0 14px 32px -10px rgba(0, 0, 0, 0.6),
                0 4px 14px -2px rgba(99, 102, 241, 0.16) !important;
  }
  body.dark-theme button:hover:not(:disabled),
  body.dark-theme select:hover,
  body.dark-theme .interactive-item:hover {
    box-shadow: 0 6px 16px -4px rgba(0, 0, 0, 0.55),
                0 2px 8px -2px rgba(99, 102, 241, 0.18);
  }
}

/* Task 2f: Minimum 44px touch targets on mobile */
@media (max-width: 768px) {
  button,
  select,
  .check-btn,
  .tab-btn,
  .cal-day-btn {
    min-height: 44px;
    min-width: 44px;
  }
}

/* Task 2e: Respect prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .interactive-card:hover,
  button:hover:not(:disabled),
  .interactive-item:hover,
  .check-btn:hover {
    transform: none !important;
  }
}

/* =====================================================================
   GLOWING BULB THEME SWITCH (WHITE THEME & DARK THEME GLOW)
   ===================================================================== */
.bulb-switch-btn {
  position: relative;
  width: 92px;
  height: 44px;
  border-radius: 9999px;
  padding: 4px;
  cursor: pointer;
  transition: all 0.35s cubic-bezier(0.22, 1, 0.36, 1);
  display: inline-flex;
  align-items: center;
  direction: ltr;
}
/* White Theme Switch Track & Warm Bulb Glow */
.bulb-switch-btn.is-light {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 55%, #fcd34d 100%);
  border: 1.5px solid #fbbf24;
  box-shadow: 0 0 22px 4px rgba(251, 191, 36, 0.45),
              0 0 44px 10px rgba(245, 158, 11, 0.22),
              inset 0 1px 3px rgba(255, 255, 255, 0.9);
}
.bulb-switch-btn.is-light:hover {
  box-shadow: 0 0 28px 7px rgba(251, 191, 36, 0.65),
              0 0 55px 14px rgba(245, 158, 11, 0.32),
              inset 0 1px 4px rgba(255, 255, 255, 1);
}
/* Dark Theme Switch Track & Night Neon Bulb Glow */
.bulb-switch-btn.is-dark {
  background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 55%, #312e81 100%);
  border: 1.5px solid #6366f1;
  box-shadow: 0 0 24px 5px rgba(99, 102, 241, 0.55),
              0 0 48px 12px rgba(56, 189, 248, 0.28),
              inset 0 1px 3px rgba(129, 140, 248, 0.35);
}
.bulb-switch-btn.is-dark:hover {
  box-shadow: 0 0 32px 8px rgba(99, 102, 241, 0.78),
              0 0 60px 16px rgba(56, 189, 248, 0.4),
              inset 0 1px 4px rgba(165, 180, 252, 0.5);
}

/* Switch Sliding Bulb Orb */
.bulb-orb {
  width: 34px;
  height: 34px;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.38s cubic-bezier(0.34, 1.56, 0.64, 1),
              background 0.3s ease,
              box-shadow 0.3s ease;
  z-index: 2;
}
.bulb-switch-btn.is-light .bulb-orb {
  transform: translateX(0px);
  background: radial-gradient(circle at 35% 35%, #ffffff 0%, #fef08a 60%, #f59e0b 100%);
  color: #b45309;
  box-shadow: 0 0 16px 5px rgba(251, 191, 36, 0.85),
              0 0 30px 10px rgba(254, 240, 138, 0.7);
}
.bulb-switch-btn.is-dark .bulb-orb {
  transform: translateX(48px);
  background: radial-gradient(circle at 35% 35%, #e0e7ff 0%, #818cf8 55%, #4f46e5 100%);
  color: #ffffff;
  box-shadow: 0 0 18px 6px rgba(129, 140, 248, 0.9),
              0 0 34px 12px rgba(56, 189, 248, 0.55);
}

/* =====================================================================
   DARK THEME OVERRIDES (DEFAULT IS WHITE THEME)
   ===================================================================== */
body.dark-theme {
  background-color: #090d16;
  color: #f1f5f9;
}
body.dark-theme header {
  background-color: rgba(15, 23, 42, 0.92) !important;
  border-color: #1e293b !important;
}
body.dark-theme .bg-white {
  background-color: #111827 !important;
}
body.dark-theme .bg-slate-50,
body.dark-theme .bg-slate-50\/80,
body.dark-theme .bg-slate-50\/70,
body.dark-theme .bg-slate-50\/60,
body.dark-theme .bg-slate-50\/50,
body.dark-theme .bg-slate-50\/40,
body.dark-theme .bg-slate-50\/95 {
  background-color: #0f172a !important;
}
body.dark-theme .bg-slate-100,
body.dark-theme .bg-slate-100\/90 {
  background-color: #1e293b !important;
}
body.dark-theme .bg-slate-200 {
  background-color: #334155 !important;
}
body.dark-theme .text-slate-900,
body.dark-theme .text-slate-800 {
  color: #f8fafc !important;
}
body.dark-theme .text-slate-700,
body.dark-theme .text-slate-600 {
  color: #cbd5e1 !important;
}
body.dark-theme .text-slate-500,
body.dark-theme .text-slate-400 {
  color: #94a3b8 !important;
}
body.dark-theme .border-slate-200,
body.dark-theme .border-slate-200\/80,
body.dark-theme .border-slate-200\/90,
body.dark-theme .border-slate-200\/70,
body.dark-theme .border-slate-300,
body.dark-theme .border-slate-100,
body.dark-theme .border-slate-100\/80 {
  border-color: #1e293b !important;
}
body.dark-theme .divide-slate-100 > :not([hidden]) ~ :not([hidden]),
body.dark-theme .divide-slate-100 > :not(:last-child) {
  border-color: #1e293b !important;
}
body.dark-theme input,
body.dark-theme select {
  background-color: #0f172a !important;
  color: #f8fafc !important;
  border-color: #334155 !important;
}
body.dark-theme .habit-row:hover td {
  background-color: #162033 !important;
}
body.dark-theme .habit-row {
  background-color: #111827 !important;
}
body.dark-theme .habit-row td {
  background-color: #111827 !important;
  transition: background-color 0.16s ease;
}
body.dark-theme .habit-row:hover {
  background-color: #162033 !important;
  box-shadow: inset 0 1px 0 0 #1e293b, inset 0 -1px 0 0 #1e293b, 0 4px 12px -4px rgba(0, 0, 0, 0.45) !important;
}
body.dark-theme .hover\:bg-slate-50:hover,
body.dark-theme .hover\:bg-slate-50\/70:hover,
body.dark-theme .group:hover .group-hover\:bg-slate-50\/70,
body.dark-theme .hover\:bg-slate-100:hover,
body.dark-theme .hover\:bg-slate-100\/70:hover,
body.dark-theme .hover\:bg-slate-100\/80:hover {
  background-color: #162033 !important;
}
body.dark-theme #weekDonutCircleBg,
body.dark-theme .mini-donut-bg {
  stroke: #1e293b !important;
}
/* Dark-mode pastel badge, pill, active column & card surface fixes */
body.dark-theme :is([class~="bg-indigo-50"],[class~="bg-indigo-50/90"],[class~="bg-indigo-100"]) { background-color: rgba(99, 102, 241, 0.18) !important; }
body.dark-theme :is([class~="bg-emerald-50"],[class~="bg-emerald-50/60"],[class~="bg-emerald-50/70"]) { background-color: rgba(16, 185, 129, 0.15) !important; }
body.dark-theme :is([class~="bg-pink-50"],[class~="bg-pink-50/60"],[class~="bg-pink-100"]) { background-color: rgba(236, 72, 153, 0.15) !important; }
body.dark-theme :is([class~="bg-amber-50"],[class~="bg-amber-100"]) { background-color: rgba(245, 158, 11, 0.15) !important; }
body.dark-theme :is([class~="bg-rose-50"],[class~="bg-rose-100"]) { background-color: rgba(244, 63, 94, 0.15) !important; }
body.dark-theme [class~="bg-blue-50"]   { background-color: rgba(59, 130, 246, 0.15) !important; }
body.dark-theme [class~="bg-purple-50"] { background-color: rgba(168, 85, 247, 0.15) !important; }
body.dark-theme [class~="bg-sky-50"]    { background-color: rgba(14, 165, 233, 0.15) !important; }

body.dark-theme :is(.text-indigo-700,.text-indigo-900,.text-indigo-600) { color: #a5b4fc !important; }
body.dark-theme :is(.text-emerald-700,.text-emerald-800,.text-emerald-600) { color: #6ee7b7 !important; }
body.dark-theme :is(.text-amber-700,.text-amber-800,.text-amber-600) { color: #fcd34d !important; }
body.dark-theme :is(.text-rose-700,.text-rose-900,.text-pink-700,.text-pink-800) { color: #fda4af !important; }
body.dark-theme :is(.text-blue-700,.text-purple-700,.text-sky-700) { color: #93c5fd !important; }
body.dark-theme :is([class*="border-emerald-200"],[class*="border-pink-200"],[class*="border-rose-100"],[class*="border-rose-200"],[class*="border-amber-200"],[class*="border-blue-200"],[class*="border-purple-200"],[class*="border-sky-200"]) { border-color: #334155 !important; }

/* Task 1: SVG Venn text, slate-300, dropzone, rank #2 badge & out-of-month calendar contrast fixes */
body.dark-theme svg text[fill="#881337"]{fill:#fda4af}
body.dark-theme svg text[fill="#1e3a8a"]{fill:#93c5fd}
body.dark-theme svg text[fill="#064e3b"]{fill:#6ee7b7}
body.dark-theme svg text[fill="#78350f"]{fill:#fcd34d}
body.dark-theme svg text[fill="#be123c"]{fill:#fb7185}
body.dark-theme svg text[fill="#1d4ed8"]{fill:#60a5fa}
body.dark-theme svg text[fill="#047857"]{fill:#34d399}
body.dark-theme svg text[fill="#b45309"]{fill:#fbbf24}
body.dark-theme svg text[fill="#475569"]{fill:#94a3b8}
body.dark-theme .bg-slate-300{background-color:#64748b!important}
body.dark-theme .text-slate-300{color:#475569!important}
body.dark-theme [class~="bg-indigo-50/50"]{background-color:rgba(99,102,241,.10)!important}

/* WCAG AA contrast for Rank #1 and #2 badges, upload dropzone, and out-of-month calendar days */
body.dark-theme .rank-badge-1 {
  background-color: #fbbf24 !important;
  color: #090d16 !important;
}
body.dark-theme .rank-badge-2 {
  background-color: #475569 !important;
  color: #f8fafc !important;
}
body.dark-theme #pdfDropZone {
  border-color: #6366f1 !important;
}
body.dark-theme #pdfDropZone:hover {
  background-color: rgba(99, 102, 241, 0.18) !important;
  border-color: #818cf8 !important;
}
.cal-day-outside {
  color: #64748b;
}
body.dark-theme .cal-day-outside {
  color: #94a3b8 !important;
  opacity: 0.75;
}

body.dark-theme ::-webkit-scrollbar-track {
  background: #0f172a;
}
body.dark-theme ::-webkit-scrollbar-thumb {
  background: #334155;
}

/* Task 2g: Print stylesheet */
@media print {
  header nav,
  #btnDownloadPDF,
  #btnOpenUploadModal,
  #toastBox,
  #storageWarningBanner,
  #pdfSyncReportBanner {
    display: none !important;
  }
  body,
  body.dark-theme {
    background: #ffffff !important;
    color: #000000 !important;
    padding-bottom: 0 !important;
  }
  .interactive-card {
    box-shadow: none !important;
    border-color: #cbd5e1 !important;
    break-inside: avoid;
  }
  #tabContent-tracker,
  #tabContent-quests {
    display: block !important;
  }
  #tabContent-settings {
    display: none !important;
  }
}
