/* Variables & Reset */
:root {
  /* Dark Theme (Default) */
  --bg-gradient: linear-gradient(135deg, #0f0c29 0%, #1a1a2e 40%, #16213e 70%, #0f3460 100%);
  --text-main: #f0f0f0;
  --text-muted: rgba(255, 255, 255, 0.6);
  --glass-bg: rgba(255, 255, 255, 0.04);
  --glass-border: rgba(255, 255, 255, 0.08);
  --card-bg: rgba(255, 255, 255, 0.06);
  --accent-color: #e94560;
  --accent-secondary: #c73e54;
  --accent-glow: rgba(233, 69, 96, 0.25);
  --success-color: #2ecc71;
  --success-secondary: #27ae60;
  --success-glow: rgba(46, 204, 113, 0.25);
  --shadow-color: rgba(0, 0, 0, 0.3);
  --toggle-shadow: rgba(233, 69, 96, 0.4);
  --toggle-shadow-hover: rgba(233, 69, 96, 0.5);
  --ring-track: rgba(255, 255, 255, 0.08);
  --ring-fill: var(--accent-color);
  --ring-text: var(--text-main);

  /* Animation timings */
  --transition-speed: 0.3s;
}

[data-theme="light"] {
  /* Light Theme Overrides */
  --bg-gradient: linear-gradient(135deg, #f5f7fa 0%, #e8ecf1 50%, #dfe6ed 100%);
  --text-main: #1a1a2e;
  --text-muted: #64748b;
  --glass-bg: rgba(255, 255, 255, 0.7);
  --glass-border: rgba(0, 0, 0, 0.06);
  --card-bg: rgba(255, 255, 255, 0.8);
  --accent-color: #e94560;
  --accent-secondary: #d63851;
  --accent-glow: rgba(233, 69, 96, 0.12);
  --success-color: #2ecc71;
  --success-secondary: #27ae60;
  --success-glow: rgba(46, 204, 113, 0.15);
  --shadow-color: rgba(0, 0, 0, 0.06);
  --toggle-shadow: rgba(233, 69, 96, 0.2);
  --toggle-shadow-hover: rgba(233, 69, 96, 0.3);
  --ring-track: rgba(0, 0, 0, 0.08);
  --ring-fill: var(--accent-color);
  --ring-text: var(--text-main);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* App Container */
body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Inter', 'Segoe UI', Roboto, system-ui, sans-serif;
  background: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text-main);
  transition: background 0.5s ease, color 0.5s ease;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  overflow-y: auto;
}

/* Header / Navbar */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.8rem 2rem;
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--glass-border);
  box-shadow: 0 4px 30px var(--shadow-color);
}

.header-left,
.header-right {
  flex: 1;
  display: flex;
  align-items: center;
}

.header-right {
  justify-content: flex-end;
}

.header-center {
  flex: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.logo-text {
  font-size: 1.25rem;
  font-weight: 800;
  margin: 0;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

/* Navbar Clock */
.navbar-clock {
  display: flex;
  align-items: baseline;
  gap: 4px;
  padding: 0.4rem 1.2rem;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 999px;
  box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: all 0.3s ease;
}

[data-theme="dark"] .navbar-clock {
  background: rgba(255, 255, 255, 0.05);
  box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.05);
  text-shadow: 0 0 10px rgba(233, 69, 96, 0.3);
}

.clock-time {
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -1px;
  line-height: 1;
}

.clock-seconds {
  font-size: 1rem;
  font-weight: 400;
  color: var(--accent-color);
  opacity: 0.9;
  font-variant-numeric: tabular-nums;
}

.navbar-location {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  margin-top: 4px;
}

/* Confetti Canvas */
#confetti-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9999;
}

/* Hero Section */
.hero-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.2rem;
  width: 100%;
}

/* Progress Ring */
.progress-ring-wrapper {
  position: relative;
}

.progress-ring {
  width: 130px;
  height: 130px;
  transform: rotate(-90deg);
  filter: drop-shadow(0 0 12px var(--accent-glow));
  transition: filter 0.4s ease;
}

.progress-ring.complete {
  filter: drop-shadow(0 0 20px var(--success-glow));
}

.progress-ring__bg {
  fill: none;
  stroke: var(--ring-track);
  stroke-width: 6;
}

.progress-ring__fill {
  fill: none;
  stroke: var(--ring-fill);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 326.73;
  stroke-dashoffset: 326.73;
  transition: stroke-dashoffset 1s cubic-bezier(0.4, 0, 0.2, 1), stroke 0.4s ease;
}

.progress-ring.complete .progress-ring__fill {
  stroke: var(--success-color);
}

.progress-ring__count {
  fill: var(--ring-text);
  font-size: 2rem;
  font-weight: 800;
  transform: rotate(90deg);
  transform-origin: 60px 60px;
}

.progress-ring__label {
  fill: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transform: rotate(90deg);
  transform-origin: 60px 60px;
}

/* Streak Badge */
.streak-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1.2rem;
  border-radius: 999px;
  background: var(--card-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(10px);
  animation: badgePop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 4px 20px var(--shadow-color);
}

.streak-badge.hidden {
  display: none;
}

.streak-badge__icon {
  font-size: 1.2rem;
}

.streak-badge__text {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: 0.02em;
}

.streak-badge.milestone-7 { border-color: #f39c12; box-shadow: 0 0 20px rgba(243, 156, 18, 0.2); }
.streak-badge.milestone-14 { border-color: #9b59b6; box-shadow: 0 0 20px rgba(155, 89, 182, 0.2); }
.streak-badge.milestone-30 { border-color: #e94560; box-shadow: 0 0 20px rgba(233, 69, 96, 0.2); }
.streak-badge.milestone-100 { border-color: #f1c40f; box-shadow: 0 0 25px rgba(241, 196, 15, 0.3); }

/* Language Selector */ 
.lang-select {
  background: var(--card-bg);
  color: var(--text-main);
  border: 1px solid var(--glass-border);
  padding: 0.45rem 0.6rem;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  margin-right: 0.5rem;
  backdrop-filter: blur(10px);
  transition: all 0.2s ease;
  outline: none;
}

.lang-select:hover,
.lang-select:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 12px var(--accent-glow);
}

/* Default (Dark Theme) */
.lang-select option {
  background-color: #16213e; /* Solid dark color matching your gradient */
  color: var(--text-main);
}

/* Light Theme Override */
[data-theme="light"] .lang-select option {
  background-color: #ffffff; /* Solid white for light mode */
  color: var(--text-main);
}

/* Theme Toggle (Moved to header) */
.theme-toggle {
  position: static;
  /* removed absolute */
  background: transparent;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 50%;
  color: var(--text-main);
  transition: transform 0.2s ease, background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-toggle:hover {
  background: rgba(125, 125, 125, 0.1);
  transform: rotate(15deg);
}

/* Main Content Area */
.main-content {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center; /* Pushes to vertical center */
  padding: 1.5rem; 
  padding-bottom: 5rem; /* Room for the absolute footer clock */
  position: relative; /* Needed for absolute positioning of footer */
  width: 100%;
  animation: fadeIn 0.8s ease-out;
}

/* The wrapper holding both Left & Right columns */
.content-wrapper {
  display: flex;
  flex-direction: column; /* Stacked by default for mobile */
  align-items: center;
  justify-content: center;
  gap: 2.5rem; /* Space between the two main cards */
  width: 100%;
  max-width: 1200px;
  margin: auto; /* Forces absolute centering in the flex parent */
}

/* Left Column: Core Tracking */
.tracker-core {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 500px; 
  background: var(--glass-bg); 
  padding: 2.5rem 2rem; 
  border-radius: 20px;
  box-shadow: 0 4px 15px var(--shadow-color);
  gap: 1.2rem; 
}

/* Right Column: Dashboard Stats */
.dashboard-container {
  width: 100%;
  max-width: 500px; 
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center; /* Centers dashboard content vertically */
  gap: 1.5rem;
  background: var(--glass-bg);
  padding: 2.5rem 2rem; 
  border-radius: 20px;
  box-shadow: 0 4px 15px var(--shadow-color);
}

/* Elements inside the Tracker */
.date-text {
  font-size: 1rem;
  color: var(--text-muted);
  font-weight: 500;
  text-align: center;
  margin: 0;
}

.graphic-container {
  position: relative;
  width: min(280px, 75vw);
  /* Responsive width */
  height: min(280px, 75vw);
  flex-shrink: 0;
  border-radius: 20px;
  overflow: hidden;
  background: var(--card-bg);
  box-shadow: 0 8px 32px var(--shadow-color);
  transition: transform 0.3s ease;
  margin: 0.5rem 0; 
}

.graphic-container:hover {
  transform: translateY(-5px);
}

.graphic-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 0.4s ease, transform 0.4s ease;
  background: var(--card-bg);
}

.graphic-img.hidden {
  opacity: 0;
  transform: scale(0.95);
  pointer-events: none;
}

.status-area {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-height: 60px;
}

.status {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 500;
}

.streak-text {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--success-color);
  animation: pulse 2s infinite;
}

/* History Log */
.history-log {
  display: flex;
  justify-content: center;
  gap: 0.8rem;
  background: rgba(0, 0, 0, 0.1); 
  padding: 1rem;
  border-radius: 16px;
  width: 100%;
}

[data-theme="light"] .history-log {
  background: rgba(0, 0, 0, 0.05);
}

.history-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
}

.day-label {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.day-status {
  font-size: 1.2rem;
  line-height: 1;
}

/* Motivational Quote */
.motivational-quote {
  font-size: 0.95rem;
  font-weight: bold;
  color: var(--text-muted);
  text-align: center;
  margin: 0;
  font-style: italic;
  opacity: 0.9;
}

/* Toggle Button */
.toggle-btn {
  padding: 1rem 2.5rem;
  font-size: 1.1rem;
  font-weight: 700;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  background: linear-gradient(135deg, var(--accent-color) 0%, var(--accent-secondary) 100%);
  color: white;
  box-shadow: 0 4px 15px var(--toggle-shadow);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-transform: uppercase;
  letter-spacing: 1px;
  width: 100%; 
  max-width: 300px; 
}

.toggle-btn:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 6px 20px var(--toggle-shadow-hover);
}

.toggle-btn:active {
  transform: translateY(1px) scale(0.98);
}

.toggle-btn[aria-pressed="true"] {
  background: linear-gradient(135deg, var(--success-color) 0%, var(--success-secondary) 100%);
  box-shadow: 0 4px 15px rgba(46, 204, 113, 0.3);
}

.secondary-btn {
  padding: 0.8rem 1.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 50px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.3s ease;
  backdrop-filter: blur(5px);
}

.secondary-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: var(--text-main);
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.2);
}

.last-time {
  margin: 0;
}

/* Footer Clocks - Pin to the bottom center */
.footer-clocks {
  position: absolute;
  bottom: 1.5rem; 
  left: 50%;
  transform: translateX(-50%) scale(0.9); 
  margin: 0;
  width: 100%;
  opacity: 0.8;
}

.world-clocks {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.world-clock-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
}

.city-name {
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
}

.city-time {
  font-family: monospace;
  font-size: 0.9rem;
}

/* --- Badges & Gamification --- */
.section-title {
  font-size: 1.1rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  position: relative;
  overflow: hidden;
}

.toggle-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.15) 0%, transparent 50%);
  pointer-events: none;
}

.badges-container {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}

.badge {
  font-size: 2rem;
  padding: 0.5rem;
  border-radius: 50%;
  background: var(--bg-gradient);
  transition: all 0.3s ease;
  filter: grayscale(100%) opacity(0.4); 
}

.badge.unlocked {
  filter: grayscale(0%) opacity(1);
  transform: scale(1.1);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

/* --- Monthly Stats Toggle --- */
.collapsible-section {
  width: 100%;
  max-height: 200px;
  overflow: hidden;
  transition: max-height 0.4s ease, opacity 0.4s ease;
  opacity: 1;
}

.collapsible-section.hidden {
  max-height: 0;
  opacity: 0;
  pointer-events: none;
}

.stats-text {
  text-align: center;
  font-weight: bold;
  margin-bottom: 0.8rem;
}

.progress-bar-container {
  background: rgba(0,0,0,0.2);
  border-radius: 10px;
  height: 14px;
  width: 100%;
  overflow: hidden;
  box-shadow: inset 0 2px 5px rgba(0,0,0,0.2);
}

[data-theme="light"] .progress-bar-container {
  background: #e0e0e0;
}

.progress-fill {
  background: linear-gradient(90deg, #2ecc71, #27ae60);
  height: 100%;
  width: 0%;
  transition: width 0.8s ease-in-out;
}

/* --- GitHub-Style Heatmap --- */
.heatmap-section {
  width: 100%;
  margin: 0; 
}

.heatmap-scroll-wrapper {
  width: 100%;
  overflow-x: auto;
  padding: 0.5rem 0;
  scroll-behavior: smooth;
  
  -ms-overflow-style: none;  
  scrollbar-width: none;  
  
  -webkit-mask-image: linear-gradient(to right, transparent, black 5%, black 95%, transparent);
  mask-image: linear-gradient(to right, transparent, black 5%, black 95%, transparent);
}

.heatmap-scroll-wrapper::-webkit-scrollbar {
  display: none;
}

.heatmap-grid {
  display: grid;
  grid-template-rows: repeat(7, 1fr);
  grid-auto-flow: column;
  gap: 4px;
  padding: 0 15px; 
}

.heatmap-grid::after {
  content: "";
  display: block;
  width: 25px;
}

.heatmap-cell {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background-color: rgba(255,255,255,0.05);
  transition: background-color 0.2s ease;
}

[data-theme="light"] .heatmap-cell {
  background-color: rgba(0,0,0,0.05);
}

.heatmap-cell.active {
  background-color: var(--success-color);
}

/* Desktop Media Query (Laptops/Desktops) */
@media (min-width: 900px) {
  .content-wrapper {
    flex-direction: row; 
    align-items: stretch; /* Makes both cards the exact same height */
    justify-content: center;
    gap: 3rem; 
  }

  .tracker-core, .dashboard-container {
    flex: 1; 
    max-width: 450px;  
  }

  .graphic-container {
    width: min(280px, 100%);
  }
}

/* MOBILE RESPONSIVE TWEAKS */
@media (max-width: 600px) {
  .app-header {
    padding: 0.8rem 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .logo-text {
    font-size: 1rem;
  }
  .navbar-clock {
    font-size: 1.25rem;
  }

  .header-left {
    flex: 0 0 auto;
    margin-right: auto;
  }

  .header-center {
    flex: 1 0 100%;
    /* force to new row on very small screens? or keep inline */
    order: 3;
    /* if we want to move clock to bottom of header */
    padding-top: 0.5rem;
    border-top: 1px solid rgba(127, 127, 127, 0.1);
    margin-top: 0.5rem;
  }

  .main-content {
    padding: 1.5rem 1rem;
    padding-bottom: 5rem;
  }

  .tracker-core, .dashboard-container {
    padding: 1.5rem; 
  } 
  
  .footer-clocks {
    position: static;
    transform: none; /* remove the translateX(-50%) */
    margin-top: 2rem; /* Add some space above it instead */
  }
 
  .main-content {
    padding-bottom: 2rem; 
  }
}

/* Animations & Prefs */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0% { opacity: 1; }
  50% { opacity: 0.7; }
  100% { opacity: 1; }
}

/* Respect user reduced-motion preferences */
@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* ── HISTORY TABLE SECTION ── */
.history-table-section {
  width: 100%;
  max-width: 620px;
  margin-top: 2rem;
  background: var(--glass-bg);
  border-radius: 16px;
  box-shadow: 0 4px 15px var(--shadow-color);
  overflow: hidden;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.07);
}

.history-table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.4rem;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}

.history-table-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--text-main);
}

.export-btns {
  display: flex;
  gap: 0.5rem;
}

.export-btn {
  padding: 0.4rem 0.9rem;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 50px;
  border: 1px solid;
  cursor: pointer;
  transition: all 0.2s ease;
  letter-spacing: 0.03em;
  background: transparent;
}

.export-csv {
  border-color: var(--success-color);
  color: var(--success-color);
}
.export-csv:hover {
  background: rgba(46, 204, 113, 0.12);
  transform: translateY(-1px);
}

.export-pdf {
  border-color: var(--accent-color);
  color: var(--accent-color);
}
.export-pdf:hover {
  background: rgba(233, 69, 96, 0.12);
  transform: translateY(-1px);
}

.history-table-wrap {
  overflow-x: auto;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.history-table thead th {
  text-align: left;
  padding: 0.7rem 1.4rem;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  background: rgba(0,0,0,0.12);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

[data-theme="light"] .history-table thead th {
  background: rgba(0,0,0,0.04);
}

.history-table tbody tr {
  border-bottom: 1px solid rgba(255,255,255,0.05);
  transition: background 0.15s;
}

[data-theme="light"] .history-table tbody tr {
  border-bottom: 1px solid rgba(0,0,0,0.05);
}

.history-table tbody tr:last-child {
  border-bottom: none;
}

.history-table tbody tr:hover {
  background: rgba(255,255,255,0.04);
}

[data-theme="light"] .history-table tbody tr:hover {
  background: rgba(0,0,0,0.03);
}

.history-table td {
  padding: 0.75rem 1.4rem;
  color: var(--text-main);
  vertical-align: middle;
}

.history-table td.td-date { font-weight: 600; white-space: nowrap; }
.history-table td.td-day { color: var(--text-muted); font-size: 0.8rem; }
.history-table td.td-time { color: var(--text-muted); font-size: 0.8rem; font-family: monospace; }
.history-table td.td-status { font-size: 1rem; }

.history-table-empty {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Notification Alert Animations */
@keyframes slideIn {
  from {
    transform: translateX(400px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOut {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(400px);
    opacity: 0;
  }
}