:root {
  /* Base Variables (Dark Theme Default) */
  --bg-main: #121212;
  --bg-surface: #1e1e1e;
  --bg-surface-hover: #2d2d2d;
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --border-color: #374151;
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --danger: #ef4444;
  --success: #10b981;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 1rem;
  --radius-full: 9999px;

  /* Layout */
  --sidebar-width: 280px;
  --header-height: 70px;
}

[data-theme="light"] {
  --bg-main: #f9fafb;
  --bg-surface: #ffffff;
  --bg-surface-hover: #f3f4f6;
  --text-main: #111827;
  --text-muted: #6b7280;
  --border-color: #e5e7eb;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Outfit", sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  overflow: hidden;
  transition:
    background-color 0.3s ease,
    color 0.3s ease;
}

/* App Layout */
.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 1.5rem;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 100;
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
}

.privacy-badge {
  font-size: 0.75rem;
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.mobile-close {
  display: none;
}

/* Clock */
.clock-container {
  text-align: center;
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: var(--bg-surface-hover);
  border-radius: var(--radius-lg);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
}

.clock-time {
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -1px;
  font-variant-numeric: tabular-nums;
  color: var(--text-main);
}

.clock-date {
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* Primary Button */
.btn-primary {
  width: 100%;
  background-color: var(--accent);
  color: white;
  border: none;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.2s;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.39);
}

.btn-primary:hover {
  background-color: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45);
}

.btn-outline {
  background: transparent;
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.btn-outline:hover {
  background: var(--bg-surface-hover);
  border-color: var(--text-muted);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-danger:hover {
  background: var(--danger);
  color: white;
}

.icon-btn {
  background: transparent;
  color: var(--text-muted);
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover {
  background: var(--bg-surface-hover);
  color: var(--text-main);
}

/* Nav */
.sidebar-nav {
  margin-top: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.nav-item:hover {
  background: var(--bg-surface-hover);
  color: var(--text-main);
}

.nav-item.active {
  background: rgba(99, 102, 241, 0.1);
  color: var(--accent);
}

/* Sidebar Sections */
.sidebar-section {
  margin-top: 2rem;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.section-header h3 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
}

.section-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.alarm-list {
  list-style: none;
  max-height: 150px;
  overflow-y: auto;
}

.alarm-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border-color);
}
.alarm-item:last-child {
  border-bottom: none;
}
.alarm-info {
  display: flex;
  flex-direction: column;
}
.alarm-time-text {
  font-weight: 600;
}
.alarm-msg {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Switch Toggle */
.switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--border-color);
  transition: 0.4s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.4s;
}

input:checked + .slider {
  background-color: var(--accent);
}

input:checked + .slider:before {
  transform: translateX(16px);
}

.slider.round {
  border-radius: 34px;
}

.slider.round:before {
  border-radius: 50%;
}

/* Sidebar Bottom */
.sidebar-bottom {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.streak-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
}

.streak-icon {
  color: #f59e0b; /* orange */
  font-size: 1.25rem;
}

.settings-actions {
  display: flex;
  gap: 0.25rem;
}

/* Main Content */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.main-header {
  height: var(--header-height);
  padding: 0 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-surface);
}

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

.mobile-menu-toggle {
  display: none;
}

.date-navigation {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.date-navigation h2 {
  font-size: 1.25rem;
  font-weight: 600;
  min-width: 180px;
  text-align: center;
}

/* Search/NLP Bar */
.search-bar {
  display: flex;
  align-items: center;
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  padding: 0.5rem 1rem;
  width: 300px;
  transition: all 0.2s;
}

.search-bar:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.search-bar i {
  color: var(--text-muted);
  margin-right: 0.5rem;
}

.search-bar input {
  background: transparent;
  border: none;
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.875rem;
  width: 100%;
  outline: none;
}

/* Calendar Container */
.calendar-container {
  flex: 1;
  padding: 1.5rem;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
}

/* Grid & View Layouts */
.month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: auto repeat(5, 1fr); /* header + 5 or 6 weeks */
  height: 100%;
  gap: 1px;
  background: var(--border-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.weekday-header {
  background: var(--bg-surface);
  padding: 0.75rem;
  text-align: center;
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.month-cell {
  background: var(--bg-surface);
  padding: 0.5rem;
  min-height: 100px;
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  flex-direction: column;
}

.month-cell:hover {
  background: var(--bg-surface-hover);
}

.month-cell.other-month {
  background: var(--bg-main);
  color: var(--text-muted);
}

.month-cell.today .date-num {
  background: var(--accent);
  color: white;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.date-num {
  font-weight: 500;
  margin-bottom: 0.5rem;
  align-self: flex-end;
}

.cell-events {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  overflow-y: auto;
}

.event-pill {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: rgba(99, 102, 241, 0.2);
  color: var(--text-main);
  border-left: 3px solid var(--accent);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.task-pill {
  background: rgba(16, 185, 129, 0.1);
  border-left: 3px solid var(--success);
}
.task-pill.completed {
  text-decoration: line-through;
  opacity: 0.5;
}

/* Week View */
.week-grid {
  display: flex;
  height: 100%;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
}

.week-time-labels {
  width: 60px;
  flex-shrink: 0;
  border-right: 1px solid var(--border-color);
  position: relative;
  background: var(--bg-main);
}

.week-day-col {
  flex: 1;
  min-width: 120px;
  border-right: 1px solid var(--border-color);
  position: relative;
}

.week-day-col:last-child {
  border-right: none;
}

.week-day-header {
  height: 50px;
  border-bottom: 1px solid var(--border-color);
  text-align: center;
  padding: 0.5rem;
  position: sticky;
  top: 0;
  background: var(--bg-surface);
  z-index: 10;
}

.week-day-header .day-name {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
}
.week-day-header .day-num {
  font-size: 1.25rem;
  font-weight: 600;
}
.week-day-header.today .day-num {
  color: var(--accent);
}

.week-day-body {
  position: relative;
  height: 1440px; /* 24 * 60 */
  background: var(--bg-surface);
}

.week-grid-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--border-color);
}

.week-time-label {
  position: absolute;
  right: 10px;
  font-size: 0.75rem;
  color: var(--text-muted);
  transform: translateY(-50%);
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 450px;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.modal-overlay.active .modal-content {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.modal-body {
  padding: 1.5rem;
}

.tabs {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.tab-btn {
  background: transparent;
  border: none;
  padding: 0.5rem 0;
  color: var(--text-muted);
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.form-group {
  margin-bottom: 1rem;
}

.form-row {
  display: flex;
  gap: 1rem;
}

.form-row .form-group {
  flex: 1;
}

label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: var(--text-muted);
}

input[type="text"],
input[type="date"],
input[type="time"],
select {
  width: 100%;
  padding: 0.75rem;
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-family: inherit;
  transition: border-color 0.2s;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
}

.checkbox-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.checkbox-group label {
  margin-bottom: 0;
}

.form-actions {
  display: flex;
  margin-top: 2rem;
}
.spacer {
  flex: 1;
}

.color-picker-group {
  display: flex;
  align-items: center;
  gap: 1rem;
}

input[type="color"] {
  appearance: none;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: none;
}
input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}
input[type="color"]::-webkit-color-swatch {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}

/* Animations */
@keyframes shake {
  0%,
  100% {
    transform: rotate(0);
  }
  25% {
    transform: rotate(-10deg);
  }
  75% {
    transform: rotate(10deg);
  }
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
  .app-container {
    flex-direction: column;
  }

  .sidebar {
    position: fixed;
    left: -100%;
    top: 0;
    bottom: 0;
    width: 80%;
    max-width: 300px;
    box-shadow: var(--shadow-lg);
  }

  .sidebar.open {
    left: 0;
  }

  .mobile-menu-toggle {
    display: block;
  }

  .mobile-close {
    display: block;
  }

  .search-bar {
    display: none; /* Hide on small screens or make it a button */
  }

  .month-grid {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
  }

  .weekday-header {
    display: none;
  }

  .month-cell {
    min-height: auto;
    border-bottom: 1px solid var(--border-color);
  }
}

.cell-header {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
  margin-bottom: 0.5rem;
  position: relative;
}

.date-num {
  margin-bottom: 0 !important;
}

.daily-score {
  font-size: 0.65rem;
  background: rgba(99, 102, 241, 0.2);
  color: var(--accent);
  padding: 0.1rem 0.3rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
}

.daily-mood {
  font-size: 0.8rem;
}

.mood-selector {
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.25rem;
  display: none;
  gap: 0.25rem;
  z-index: 10;
  box-shadow: var(--shadow-md);
}

.month-cell:hover .mood-selector {
  display: flex;
}

.mood-selector span {
  cursor: pointer;
  font-size: 1rem;
  transition: transform 0.1s;
}

.mood-selector span:hover {
  transform: scale(1.2);
}

.prod-bar {
  flex: 1;
  background: var(--accent);
  border-radius: 2px 2px 0 0;
  min-height: 2px;
  opacity: 0.8;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-surface);
  color: var(--text-main);
  padding: 1rem 1.5rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 9999;
  font-weight: 500;
  text-align: center;
  border: 1px solid var(--accent);
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from {
    bottom: -50px;
    opacity: 0;
  }
  to {
    bottom: 20px;
    opacity: 1;
  }
}
