/* --- CSS Variables for Theming --- */
:root {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f5f9;
  --text-primary: #2d3748;
  --text-secondary: #4a5568;
  --text-muted: #a0aec0;
  --border-color: #e2e8f0;
  --accent-primary: #667eea;
  --accent-primary-hover: #5a67d8;
  --accent-secondary: #e2e8f0;
  --accent-secondary-hover: #cbd5e0;
  --danger-color: #e53e3e;
  --shadow-color: rgba(0, 0, 0, 0.05);
  --shadow-color-hover: rgba(102, 126, 234, 0.2);
}

body.dark-mode {
  --bg-primary: #1a202c;
  --bg-secondary: #2d3748;
  --bg-tertiary: #4a5568;
  --text-primary: #e2e8f0;
  --text-secondary: #cbd5e0;
  --text-muted: #718096;
  --border-color: #4a5568;
  --accent-primary: #7f9cf5;
  --accent-primary-hover: #667eea;
  --accent-secondary: #4a5568;
  --accent-secondary-hover: #718096;
  --shadow-color: rgba(0, 0, 0, 0.2);
}

/* --- General Styles --- */
* {
  font-family: "Monserat", sans-serif;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  transition: background-color 0.3s ease, color 0.3s ease,
    border-color 0.3s ease;
}

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
}

/* --- Header --- */
.header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left {
  display: flex;
  height: 100%;
}

.logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
}

.logout-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  color: var(--text-secondary);
  transition: color 0.2s;
}

.logout-btn:hover {
  color: var(--danger-color);
}

/* --- Theme Switcher --- */
.theme-switcher {
  position: relative;
}
.theme-toggle-checkbox {
  display: none;
}
.theme-toggle-label {
  background: var(--bg-tertiary);
  border-radius: 50px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px;
  position: relative;
  height: 26px;
  width: 50px;
}
.theme-toggle-label .fa-moon {
  color: #f1c40f;
}
.theme-toggle-label .fa-sun {
  color: #f39c12;
}
.theme-toggle-label::after {
  content: "";
  background: #fff;
  border-radius: 50%;
  position: absolute;
  top: 2px;
  left: 2px;
  height: 22px;
  width: 22px;
  transition: transform 0.3s ease;
}
.theme-toggle-checkbox:checked + .theme-toggle-label::after {
  transform: translateX(24px);
}
.theme-toggle-label .fa-moon {
  display: block;
}
.theme-toggle-label .fa-sun {
  display: none;
}
body.dark-mode .theme-toggle-label .fa-moon {
  display: none;
}
body.dark-mode .theme-toggle-label .fa-sun {
  display: block;
}

/* --- Main Layout --- */
.main-container {
  display: flex;
  height: calc(100vh - 73px); /* 73px is header height */
}

.sidebar {
  width: 280px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.main-content {
  flex: 1;
  padding: 24px 32px;
  overflow-y: auto;
}

.view-container {
  display: none;
}
.view-container.active {
  display: block;
}

/* --- Sidebar Components --- */
.mini-cal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.mini-cal-nav {
  background: none;
  border: none;
  cursor: pointer;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  font-size: 12px;
  display: grid;
  place-items: center;
  color: var(--text-secondary);
}
.mini-cal-nav:hover {
  background: var(--bg-tertiary);
  color: var(--accent-primary);
}
.mini-cal-title {
  font-weight: 600;
  font-size: 0.9rem;
}
.mini-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  font-size: 12px;
}
.mini-cal-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 50%;
}
.mini-cal-day.header-name {
  color: var(--text-muted);
  font-weight: 600;
  cursor: default;
}
.mini-cal-day.other-month {
  color: var(--text-muted);
}
.mini-cal-day.today {
  background: var(--accent-primary);
  color: white;
}
.mini-cal-day.selected {
  box-shadow: 0 0 0 2px var(--accent-primary);
}
.mini-cal-day:not(.header-name):not(.other-month):not(.selected):hover {
  background: var(--bg-tertiary);
}

.view-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.view-btn,
.add-item-btn {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid transparent;
  background: var(--bg-tertiary);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
}
.view-btn.active,
.add-item-btn {
  background: var(--accent-primary);
  color: white;
  border-color: var(--accent-primary);
}
.add-item-btn:hover {
  background: var(--accent-primary-hover);
}
.view-btn:hover:not(.active) {
  background: var(--accent-secondary-hover);
  color: var(--text-primary);
}

.upcoming-events h3 {
  margin-bottom: 16px;
  font-size: 1rem;
  color: var(--text-primary);
}
.event-item {
  padding: 12px;
  background: var(--bg-tertiary);
  border-left: 4px solid;
  border-radius: 6px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.2s;
}
.event-item:hover {
  background: var(--accent-secondary-hover);
  transform: translateX(2px);
}
.event-title {
  font-weight: 600;
  margin-bottom: 4px;
  font-size: 0.9rem;
}
.event-time {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* --- Dashboard View --- */
.content-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}
.content-title,
#welcomeMessage {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
}

.widget-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: 24px;
}
.widget {
  background: var(--bg-secondary);
  border-radius: 12px;
  border: 1px solid var(--border-color);
  box-shadow: 0 2px 8px var(--shadow-color);
  padding: 24px;
  display: flex;
  flex-direction: column;
}
.widget h3 {
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Tasks Widget */
.tasks-widget {
  grid-column: 1 / -1;
} /* Make it full width on larger screens if needed */
@media (min-width: 1024px) {
  .tasks-widget {
    grid-column: span 2;
  }
} /* Example for large screens */

.task-list {
  flex-grow: 1;
  max-height: 300px;
  overflow-y: auto;
  margin-bottom: 16px;
}
.task-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-color);
}
.task-item:last-child {
  border-bottom: none;
}
.task-item-checkbox {
  accent-color: var(--accent-primary);
  width: 18px;
  height: 18px;
  cursor: pointer;
}
.task-item-title {
  flex-grow: 1;
}
.task-item.completed .task-item-title {
  text-decoration: line-through;
  color: var(--text-muted);
}

.add-task-container {
  display: flex;
  gap: 8px;
}
#newTaskInput {
  flex-grow: 1;
  padding: 10px;
  border-radius: 8px;
  font-size: 0.9rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
}
#addTaskBtn {
  background: var(--accent-primary);
  color: white;
  border: none;
  border-radius: 8px;
  width: 40px;
  height: 40px;
  cursor: pointer;
  font-size: 1rem;
}

/* Notes Widget */
#quickNotes {
  width: 100%;
  flex-grow: 1;
  resize: none;
  border-radius: 8px;
  padding: 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  font-size: 0.9rem;
  color: var(--text-primary);
  min-height: 200px;
}
#quickNotes:focus,
#newTaskInput:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--shadow-color-hover);
}

/* --- Month View --- */
.nav-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}
.nav-btn {
  padding: 8px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}
.nav-btn:hover {
  background: var(--bg-tertiary);
  border-color: var(--text-secondary);
}
.today-btn {
  background: var(--accent-primary);
  color: white;
  border-color: var(--accent-primary);
}
.today-btn:hover {
  background: var(--accent-primary-hover);
}

.calendar-container {
  background: var(--bg-secondary);
  border-radius: 12px;
  border: 1px solid var(--border-color);
  overflow: hidden;
  box-shadow: 0 2px 8px var(--shadow-color);
}
.month-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
}
.month-header div {
  padding: 16px 8px;
  text-align: right;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.9rem;
}
.month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: minmax(120px, auto);
}
.month-day {
  border-right: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  padding: 8px;
  position: relative;
  cursor: pointer;
}
.month-day:nth-child(7n) {
  border-right: none;
}
.month-day:nth-child(n + 36) {
  border-bottom: none;
}

.month-day:hover {
  background: var(--bg-tertiary);
}
.month-day.other-month {
  background: var(--bg-tertiary);
  color: var(--text-muted);
}
.month-day.today .month-day-number {
  background-color: var(--accent-primary);
  color: white;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.month-day-number {
  font-weight: 600;
  margin-bottom: 8px;
  text-align: right;
}
.event-bubble {
  background: var(--accent-primary);
  color: white;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  margin-bottom: 4px;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- Modal --- */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.modal.show {
  display: flex;
}
.modal-content {
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: 32px;
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}
.modal-content.small-modal {
  max-width: 400px;
  text-align: center;
}
.small-modal h3 {
  margin-bottom: 8px;
  font-size: 1.2rem;
}
.small-modal p {
  margin-bottom: 24px;
  color: var(--text-secondary);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}
.modal-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
}
.close-btn {
  background: none;
  border: none;
  font-size: 1.8rem;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
}
.close-btn:hover {
  color: var(--text-primary);
}

.form-group {
  margin-bottom: 20px;
}
.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: var(--text-primary);
}
.required-field {
  color: var(--danger-color);
}
.time-group {
  display: flex;
  gap: 16px;
}
.time-group .form-group {
  flex: 1;
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 1rem;
  background: var(--bg-tertiary);
  color: var(--text-primary);
}
.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--shadow-color-hover);
}
.form-group textarea {
  resize: vertical;
  min-height: 100px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
}
.small-modal .modal-actions {
  justify-content: center;
}

.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s;
}
.btn-primary {
  background: var(--accent-primary);
  color: white;
}
.btn-primary:hover {
  background: var(--accent-primary-hover);
}
.btn-secondary {
  background: var(--accent-secondary);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}
.btn-secondary:hover {
  background: var(--accent-secondary-hover);
}
.btn-danger {
  background: var(--danger-color);
  color: white;
}
.btn-danger:hover {
  background: #c53030;
}

.color-picker {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.color-option {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid transparent;
  transition: all 0.2s;
}
.color-option.selected {
  border-color: var(--bg-secondary);
  box-shadow: 0 0 0 2px var(--accent-primary);
}
.color-option:nth-child(1) {
  background-color: #667eea;
}
.color-option:nth-child(2) {
  background-color: #e53e3e;
}
.color-option:nth-child(3) {
  background-color: #38a169;
}
.color-option:nth-child(4) {
  background-color: #d69e2e;
}
.color-option:nth-child(5) {
  background-color: #9f7aea;
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .main-container {
    flex-direction: column;
    height: auto;
  }
  .sidebar {
    width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
  }
  .main-content {
    padding: 16px;
  }
  #userName {
    display: none;
  }
  .content-title,
  #welcomeMessage {
    font-size: 1.5rem;
  }
  .month-grid {
    grid-auto-rows: minmax(100px, auto);
  }
}
