/* Set default weight for all Google Icons */
.material-symbols-outlined {
  font-weight: 200;
}

/* General Body Styling */

/* Prevent scrolling when a dialog is open */
body.dialog-open {
  overflow: hidden;
}

.container {
  max-width: 400px;
  width: 100%;
  margin: 0 auto;
  animation: slide-in-from-right 0.3s cubic-bezier(0.42, 0, 0.58, 1) forwards;
}

/* Page Transitions */
@keyframes slide-in-from-right {
  from {
    transform: translateX(100vw);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slide-out-right {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100vw);
    opacity: 0;
  }
}

@keyframes slide-out-left {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(-100vw);
    opacity: 0;
  }
}

body.page-exit-right .container {
  animation: slide-out-right 0.3s cubic-bezier(0.42, 0, 0.58, 1) forwards;
}
body.page-exit-left .container {
  animation: slide-out-left 0.3s cubic-bezier(0.42, 0, 0.58, 1) forwards;
}

/* Header Styling from Index.css */
/* Make this selector more specific to avoid affecting other pages */
.container > .header {
  padding-top: 20px;
}

.back-button .material-symbols-outlined {
  color: var(--color-text-muted);
  font-size: 48px;
  font-weight: 200;
}

.header h1 {
  font-size: 28px;
  font-weight: bold;
  color: #1f2937;
  margin: 0;
}

.header-title {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
}

/* Profile Card */
.profile-card {
  background-color: white;
  border-radius: 16px;
  padding: 1rem;
  margin-bottom: 24px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.profile-info {
  display: flex;
  align-items: center;
  gap: 16px;
}

.profile-avatar {
  background-color: #eef2ff;
  color: #4338ca;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
}

.profile-avatar .material-symbols-outlined {
  font-size: 40px;
  font-weight: 200;
}

.profile-details p {
  margin: 0;
  font-size: 14px;
  color: #6b7280;
}

.avatar-container {
  position: relative;
  cursor: pointer;
}

.profile-avatar {
  overflow: hidden; /* To clip the image */
}

.profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover; /* Ensures the image covers the area without distortion */
}

.avatar-container::after {
  content: "edit";
  font-family: "Material Symbols Outlined";
  font-weight: 200;
  font-size: 24px;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none; /* Allow click to pass through to container */
}

.avatar-container.uploading::after {
  content: ""; /* Hide edit icon during upload */
  background-color: rgba(0, 0, 0, 0.7); /* Darker overlay during upload */
  opacity: 1;
}

.avatar-container .avatar-spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 32px;
  height: 32px;
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  display: none; /* Hidden by default */
  z-index: 2;
}

.username-container {
  display: flex;
  align-items: center;
  gap: 8px;
}

.username-edit-button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  transition: background-color 0.2s ease, color 0.2s ease;
}

.username-edit-button .material-symbols-outlined {
  font-size: 20px;
}

.username-input {
  font-size: 20px;
  font-weight: 600;
  color: var(--color-text-primary);
  border: 2px solid var(--color-primary-base);
  border-radius: 8px;
  padding: 4px 8px;
  box-sizing: border-box;
  width: 100%;
}

.username-edit-actions {
  display: flex;
  gap: 4px;
}

.username-edit-actions button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease;
}

.username-edit-actions .save-button {
  color: var(--color-success-base);
}

.username-edit-actions .cancel-button {
  color: #ef4444;
}

.sign-out-button {
  width: 100%;
  padding: 12px;
  background-color: #fee2e2;
  color: #dc2626;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.sign-out-button .material-symbols-outlined {
  font-size: 24px;
  font-weight: 200;
}

/* Settings Card */
.settings-card {
  background-color: white;
  border-radius: 16px;
  padding: 16px 24px;
  margin-bottom: 24px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
}

.setting-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0;
}

.setting-item:not(:last-child) {
  border-bottom: 1px solid var(--color-border-default);
}

.setting-text h3 {
  margin: 0 0 4px 0;
  font-size: 16px;
  font-weight: 600;
  color: #1f2937;
  text-align: left;
}

.setting-text p {
  margin: 0;
  font-size: 14px;
  color: #6b7280;
  padding-right: 8px;
}

/* --- New Unit Selector (Segmented Control) --- */
.unit-selector {
  height: 2.5rem;
  background-color: var(--color-surface-track);
  cursor: pointer;
  position: relative;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 0.25rem;
  box-shadow: inset 0 2px 4px 0 rgb(0 0 0 / 0.05);
}

.unit-selector-handle {
  /* The handle is now positioned by JS, and CSS handles the animation */
  transition: left 0.3s cubic-bezier(0.2, 0.8, 0.5, 1.2),
    width 0.3s cubic-bezier(0.2, 0.8, 0.5, 1.2);
  position: absolute;
  top: 0.25rem;
  height: calc(100% - 0.5rem);
  background-color: #ffffff;
  z-index: 0;
  border-radius: 9999px;
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

.unit-selector-option {
  transition: color 0.3s ease;
  position: relative;
  z-index: 1;
  flex-grow: 1;
  text-align: center;
  font-weight: 600;
  display: flex; /* Add flex to center content */
  align-items: center; /* Vertically center */
  justify-content: center; /* Horizontally center */
  font-size: 0.875rem; /* 14px */
  min-width: 3rem; /* Ensures options have a minimum width, creating uniform toggles */
  color: var(--color-text-muted);
}

.unit-selector-option.active {
  color: var(--color-text-primary);
}

/* In dark mode, the active text needs to be dark to contrast with the light handle */
html.dark-mode .unit-selector-option.active {
  color: var(--color-text-dark-static);
}

/* In dark mode, for any toggle in its default (left) position, the active text must be dark to contrast with the white handle. */
html.dark-mode .unit-selector:not(.toggled) .unit-selector-option.active {
  color: var(
    --color-text-dark-static
  ); /* Use the static dark color for readability */
}

/* --- On/Off Toggle Specific Colors --- */
/* When these specific toggles are "On", make the background blue */
#darkModeToggle.toggled,
#deviceReminderToggle.toggled,
#autoResetToggle.toggled {
  background-color: var(--color-primary-base);
}

/* For the inactive "Off" option, use the muted text color */
#darkModeToggle.toggled .unit-selector-option:not(.active),
#deviceReminderToggle.toggled .unit-selector-option:not(.active),
#autoResetToggle.toggled .unit-selector-option:not(.active) {
  color: var(--color-border-default);
}

/* For the active "On" option, use the primary text color for a "punched-out" look */
#darkModeToggle.toggled .unit-selector-option.active,
#deviceReminderToggle.toggled .unit-selector-option.active,
#autoResetToggle.toggled .unit-selector-option.active {
  color: var(--color-text-dark-static);
}

/* Profile Action Card (for What's New) */
.profile-action-card {
  background-color: white;
  border-radius: 16px;
  padding: 16px 24px;
  margin-bottom: 24px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

/* When a button is used as an action card, reset its default styles. */
button.profile-action-card {
  width: 100%; /* Ensure it spans the full width like a div */
  border: none; /* Remove default button border */
  font: inherit; /* Use the page's font styles */
  color: inherit; /* Use the page's text color */
}

/* When an anchor tag is used as an action card, remove the underline. */
a.profile-action-card {
  text-decoration: none;
  color: inherit;
}

.profile-action-card .material-symbols-outlined {
  color: var(--color-text-muted);
}

/* Styles for "What's New" update cards inside the modal */
.update-card {
  background-color: white;
  border-radius: 16px;
  padding: 16px 24px;
  margin-bottom: 16px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.update-card:last-child {
  margin-bottom: 0;
}

.whats-new-header {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #1f2937;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--color-border-default);
}

.whats-new-header .material-symbols-outlined {
  color: var(--primary-color);
  font-size: 28px;
}

.whats-new-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.whats-new-list {
  list-style-type: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.whats-new-list li {
  display: flex;
  align-items: flex-start; /* Align to top for multi-line text */
  gap: 12px;
  font-size: 14px;
  color: #6b7280;
  line-height: 1.5;
}

.whats-new-list li .material-symbols-outlined {
  color: var(--color-success-base);
  font-size: 24px;
  margin-top: 2px; /* Small adjustment for vertical alignment */
}

/* Footer Styling */
.footer {
  text-align: center;
  margin-top: 40px;
  padding-top: 20px;
}

.footer p {
  color: #9ca3af;
  font-size: 14px;
  margin: 0;
}

.version-link {
  text-decoration: none;
  color: inherit;
  transition: color 0.2s ease;
}

html.dark-mode body {
  background-color: var(--color-bg-body);
  color: var(--color-text-primary);
}

html.dark-mode .header h1,
html.dark-mode .profile-details h2, /* This is handled by username-input style */
html.dark-mode .setting-text h3 {
  color: var(--color-text-primary);
}

html.dark-mode .setting-text p {
  color: var(--color-text-primary);
}

html.dark-mode .profile-details p,
html.dark-mode .footer p {
  color: var(--color-text-muted);
}

html.dark-mode .profile-avatar {
  background-color: var(--color-primary-light);
  color: var(--color-primary-dark);
}

html.dark-mode .profile-card,
html.dark-mode .settings-card,
html.dark-mode .profile-action-card,
html.dark-mode .danger-zone-card,
html.dark-mode .bottom-nav {
  background-color: var(--color-surface-subtle);
}
html.dark-mode .sign-out-button {
  background-color: #3f1a1a;
  color: #fca5a5;
}

html.dark-mode .setting-item:not(:last-child) {
  border-bottom-color: var(--color-border-default);
}

.modal-header {
  display: flex;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--color-border-default);
  flex-shrink: 0; /* Prevent header from shrinking */
}

html.dark-mode .modal-header {
  border-bottom-color: var(--color-border-default);
}

html.dark-mode .modal-title {
  color: var(--color-text-primary);
}

.reset-week-button {
  width: 100%;
  padding: 12px 16px;
  margin-top: 24px; /* Add space above the button */
  background-color: #fee2e2;
  color: #dc2626;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.reset-week-button .material-symbols-outlined {
  font-size: 24px;
  font-weight: 200;
}

/* Dialog Overlays */
.dialog-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1100; /* Increased to be above nav bar */
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.dialog-overlay.show {
  opacity: 1;
  visibility: visible;
}
.dialog-overlay.show {
  opacity: 1;
  visibility: visible;
}

.dialog-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background-color: white;
  border-radius: 16px;
  padding: 24px;
  gap: 0.5rem;
  max-width: 400px;
  width: 100%;
  text-align: center;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

.dialog-overlay.show .dialog-content {
  transform: scale(1);
}

.dialog-overlay.show .dialog-content {
  transform: scale(1);
}

.dialog-content .material-symbols-outlined.dialog-icon {
  font-size: 48px;
  margin-bottom: 12px;
  color: #f59e0b; /* Warning orange */
}

.dialog-content h3 {
  margin: 0 0 12px 0;
  font-size: 20px;
  color: #1f2937;
  font-weight: 700;
}

.dialog-content p {
  margin: 0 0 20px 0;
  color: #6b7280;
  font-size: 16px;
  line-height: 1.5;
}

.dialog-buttons {
  display: flex;
  justify-content: center;
  width: 100%;
  gap: 12px;
}

.dialog-buttons button {
  flex: 1;
  border: none;
  border-radius: 12px;
  padding: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.dialog-buttons .red-button {
  background-color: #ef4444; /* Red for destructive actions */
  color: white;
}

.dialog-buttons .red-button:hover {
  background-color: #dc2626; /* Darker red */
}

.dialog-buttons .grey-button {
  background-color: #6b7280;
  color: white;
}

.dialog-buttons .grey-button:hover {
  background-color: #4b5563;
}

.dialog-buttons .orange-button {
  background-color: var(--color-warning-base);
  color: white;
}

.dialog-buttons .orange-button:hover {
  background-color: var(--color-warning-dark);
}

/* --- Manage Templates Modal --- */
.user-templates-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.user-templates-list p {
  text-align: center;
  color: var(--color-text-muted);
  padding: 20px;
}

.user-template-card {
  background-color: white;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.user-template-card .template-name-link {
  text-decoration: none;
  color: inherit;
  flex-grow: 1;
}

.user-template-card .template-name {
  font-weight: 600;
  color: #1f2937;
}

.user-template-card .delete-template-button {
  background: none;
  border: none;
  color: #ef4444; /* Red */
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease;
  flex-shrink: 0; /* Prevent button from shrinking */
}

.user-template-card .delete-template-button .material-symbols-outlined {
  font-size: 24px;
}

html.dark-mode .user-template-card {
  background-color: var(--color-surface-subtle);
  box-shadow: none;
}

html.dark-mode .user-template-card .template-name {
  color: var(--color-text-primary);
}

.danger-zone-card {
  background-color: white;
  border-radius: 16px;
  padding: 16px 24px;
  margin-top: 24px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  border: 1px solid #fee2e2; /* Light red border */
}

.danger-zone-card .setting-title-with-info {
  width: 100%;
  border-bottom: 1px solid #fee2e2;
  padding-bottom: 12px;
  margin-bottom: 16px;
}

.danger-zone-card h3 {
  /* Properties moved to the container above */
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: #ef4444; /* Red text for the header */
  text-align: left;
}

.danger-zone-card .reset-week-button {
  margin-top: 0; /* Remove top margin since it's now inside a card */
}

/* --- Toast Notification --- */
.toast-container {
  position: fixed;
  bottom: 90px; /* Above the bottom nav bar */
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  pointer-events: none; /* Allow clicks to pass through the container */
}

.toast-notification {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 12px;
  color: white;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: auto; /* Re-enable pointer events for the toast itself */
}

.toast-notification.show {
  opacity: 1;
  transform: translateY(0);
}

.toast-notification.success {
  background-color: var(--color-success-base);
}
.toast-notification.error {
  background-color: #ef4444; /* Red */
}
@keyframes spin {
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

/* --- Hover states for devices that support it --- */
@media (hover: hover) and (pointer: fine) {
  .back-button:hover {
    transform: translateY(-2px);
  }

  .avatar-container:hover::after {
    opacity: 1;
  }

  .username-edit-button:hover {
    background-color: #f3f4f6;
    color: var(--color-primary-base);
  }

  .profile-action-card:hover {
    background-color: #f9fafb;
  }

  .version-link:hover {
    color: var(--color-primary-base);
    text-decoration: underline;
  }

  .sign-out-button:hover {
    background-color: #fecaca;
  }

  .reset-week-button:hover {
    background-color: #fecaca;
  }

  .user-template-card .delete-template-button:hover {
    background-color: #fee2e2; /* Light red */
  }

  /* --- About Modal --- */
  .about-card {
    background-color: white;
    border-radius: 16px;
    padding: 32px 24px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  }

  .about-logo {
    width: 80px;
    height: 80px;
    margin-bottom: 16px;
  }

  .app-name {
    font-family: "Montserrat", sans-serif;
    font-size: 24px;
    font-weight: 700;
    color: var(--color-text-primary);
    margin: 0;
  }

  .app-version {
    font-size: 14px;
    color: var(--color-text-muted);
    margin: 0 0 24px 0;
    padding: 2px 8px;
    background-color: var(--color-surface-track);
    border-radius: 8px;
  }

  .developer-info,
  .tech-info {
    font-size: 16px;
    color: var(--color-text-muted);
    line-height: 1.5;
    margin: 0;
  }

  .developer-info a {
    color: var(--color-primary-base);
    font-weight: 600;
    text-decoration: none;
  }

  .github-link {
    margin-top: 24px;
    padding: 12px 24px;
    background-color: #333;
    color: white;
    text-decoration: none;
    border-radius: 12px;
    font-weight: 600;
    transition: background-color 0.2s ease;
  }

  html.dark-mode .about-card {
    background-color: var(--color-surface-subtle);
    box-shadow: none;
  }

  html.dark-mode .sign-out-button:hover {
    background-color: #7f1d1d;
  }

  html.dark-mode .danger-zone-card {
    background-color: var(--color-surface-subtle);
    border-color: #3f1a1a; /* Darker red for border */
  }

  html.dark-mode .avatar-container:hover::after {
    background-color: rgba(0, 0, 0, 0.5);
  }
}
/* --- Setting Title with Info Button --- */
.setting-title-with-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.info-button {
  background: none;
  border: none;
  padding: 4px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 6px;
  color: var(--color-primary-base);
  transition: background-color 0.2s ease, color 0.2s ease;
}

.info-button:hover {
  background-color: var(--color-surface-track);
  color: var(--color-primary-base);
}

.info-button .material-symbols-outlined {
  font-size: 20px;
}

/* --- Info Modal Specific Styles --- */
.info-section {
  text-align: center;
  padding: 16px;
  background-color: var(--color-primary-light);
  border-radius: 16px;
  margin-bottom: 24px;
}

.info-section .material-symbols-outlined {
  font-size: 48px;
  color: var(--color-primary-base);
  margin-bottom: 12px;
}

.info-section h3 {
  margin: 0 0 8px 0;
  font-size: 20px;
  color: var(--color-text-primary);
}

.info-section p {
  margin: 0;
  color: var(--color-text-muted);
  line-height: 1.5;
}

.info-explanation-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.info-explanation-item h4 {
  margin: 0 0 4px 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text-primary);
}

.info-explanation-item p {
  margin: 0;
  font-size: 14px;
  color: var(--color-text-muted);
  line-height: 1.5;
}

/* --- Vertical Layout for Setting Items --- */
.setting-item.vertical-layout {
  flex-direction: column;
  align-items: flex-start; /* Align text to the left */
  gap: 12px; /* Add space between text and control */
}

.setting-item.vertical-layout .unit-selector {
  width: 100%; /* Make the control full width */
}
