/* 
 * Material Design 3 (M3) CSS
 * Based on official M3 design system: https://m3.material.io/
 */

:root {
  /* Material Design 3 Color Tokens (default theme) */
  --md-sys-color-primary: #6750a4;
  --md-sys-color-primary-rgb: 103, 80, 164; /* Added RGB values for primary color */
  --md-sys-color-primary-container: #eaddff;
  --md-sys-color-on-primary: #ffffff;
  --md-sys-color-on-primary-container: #21005d;
  --md-sys-color-secondary: #625b71;
  --md-sys-color-secondary-container: #e8def8;
  --md-sys-color-on-secondary: #ffffff;
  --md-sys-color-on-secondary-container: #1d192b;
  --md-sys-color-tertiary: #7d5260;
  --md-sys-color-tertiary-container: #ffd8e4;
  --md-sys-color-on-tertiary: #ffffff;
  --md-sys-color-on-tertiary-container: #31111d;
  --md-sys-color-error: #b3261e;
  --md-sys-color-error-container: #f9dedc;
  --md-sys-color-on-error: #ffffff;
  --md-sys-color-on-error-container: #410e0b;
  --md-sys-color-outline: #79747e;
  --md-sys-color-background: #fffbfe;
  --md-sys-color-on-background: #1c1b1f;
  --md-sys-color-surface: #fffbfe;
  --md-sys-color-on-surface: #1c1b1f;
  --md-sys-color-surface-variant: #e7e0ec;
  --md-sys-color-on-surface-variant: #49454f;
  --md-sys-color-inverse-surface: #313033;
  --md-sys-color-inverse-on-surface: #f4eff4;

  /* Material Design 3 Typography Scale (Roboto) */
  --md-sys-typescale-display-large-font-family: 'Roboto', sans-serif;
  --md-sys-typescale-display-large-font-weight: 400;
  --md-sys-typescale-display-large-font-size: 57px;
  --md-sys-typescale-display-large-line-height: 64px;
  --md-sys-typescale-display-large-letter-spacing: -0.25px;

  --md-sys-typescale-display-medium-font-family: 'Roboto', sans-serif;
  --md-sys-typescale-display-medium-font-weight: 400;
  --md-sys-typescale-display-medium-font-size: 45px;
  --md-sys-typescale-display-medium-line-height: 52px;
  --md-sys-typescale-display-medium-letter-spacing: 0px;

  --md-sys-typescale-display-small-font-family: 'Roboto', sans-serif;
  --md-sys-typescale-display-small-font-weight: 400;
  --md-sys-typescale-display-small-font-size: 36px;
  --md-sys-typescale-display-small-line-height: 44px;
  --md-sys-typescale-display-small-letter-spacing: 0px;

  --md-sys-typescale-headline-large-font-family: 'Roboto', sans-serif;
  --md-sys-typescale-headline-large-font-weight: 400;
  --md-sys-typescale-headline-large-font-size: 32px;
  --md-sys-typescale-headline-large-line-height: 40px;
  --md-sys-typescale-headline-large-letter-spacing: 0px;

  --md-sys-typescale-headline-medium-font-family: 'Roboto', sans-serif;
  --md-sys-typescale-headline-medium-font-weight: 400;
  --md-sys-typescale-headline-medium-font-size: 28px;
  --md-sys-typescale-headline-medium-line-height: 36px;
  --md-sys-typescale-headline-medium-letter-spacing: 0px;

  --md-sys-typescale-headline-small-font-family: 'Roboto', sans-serif;
  --md-sys-typescale-headline-small-font-weight: 400;
  --md-sys-typescale-headline-small-font-size: 24px;
  --md-sys-typescale-headline-small-line-height: 32px;
  --md-sys-typescale-headline-small-letter-spacing: 0px;

  --md-sys-typescale-title-large-font-family: 'Roboto', sans-serif;
  --md-sys-typescale-title-large-font-weight: 400;
  --md-sys-typescale-title-large-font-size: 22px;
  --md-sys-typescale-title-large-line-height: 28px;
  --md-sys-typescale-title-large-letter-spacing: 0px;

  --md-sys-typescale-title-medium-font-family: 'Roboto', sans-serif;
  --md-sys-typescale-title-medium-font-weight: 500;
  --md-sys-typescale-title-medium-font-size: 16px;
  --md-sys-typescale-title-medium-line-height: 24px;
  --md-sys-typescale-title-medium-letter-spacing: 0.15px;

  --md-sys-typescale-title-small-font-family: 'Roboto', sans-serif;
  --md-sys-typescale-title-small-font-weight: 500;
  --md-sys-typescale-title-small-font-size: 14px;
  --md-sys-typescale-title-small-line-height: 20px;
  --md-sys-typescale-title-small-letter-spacing: 0.1px;

  --md-sys-typescale-body-large-font-family: 'Roboto', sans-serif;
  --md-sys-typescale-body-large-font-weight: 400;
  --md-sys-typescale-body-large-font-size: 16px;
  --md-sys-typescale-body-large-line-height: 24px;
  --md-sys-typescale-body-large-letter-spacing: 0.5px;

  --md-sys-typescale-body-medium-font-family: 'Roboto', sans-serif;
  --md-sys-typescale-body-medium-font-weight: 400;
  --md-sys-typescale-body-medium-font-size: 14px;
  --md-sys-typescale-body-medium-line-height: 20px;
  --md-sys-typescale-body-medium-letter-spacing: 0.25px;

  --md-sys-typescale-body-small-font-family: 'Roboto', sans-serif;
  --md-sys-typescale-body-small-font-weight: 400;
  --md-sys-typescale-body-small-font-size: 12px;
  --md-sys-typescale-body-small-line-height: 16px;
  --md-sys-typescale-body-small-letter-spacing: 0.4px;

  --md-sys-typescale-label-large-font-family: 'Roboto', sans-serif;
  --md-sys-typescale-label-large-font-weight: 500;
  --md-sys-typescale-label-large-font-size: 14px;
  --md-sys-typescale-label-large-line-height: 20px;
  --md-sys-typescale-label-large-letter-spacing: 0.1px;

  --md-sys-typescale-label-medium-font-family: 'Roboto', sans-serif;
  --md-sys-typescale-label-medium-font-weight: 500;
  --md-sys-typescale-label-medium-font-size: 12px;
  --md-sys-typescale-label-medium-line-height: 16px;
  --md-sys-typescale-label-medium-letter-spacing: 0.5px;

  --md-sys-typescale-label-small-font-family: 'Roboto', sans-serif;
  --md-sys-typescale-label-small-font-weight: 500;
  --md-sys-typescale-label-small-font-size: 11px;
  --md-sys-typescale-label-small-line-height: 16px;
  --md-sys-typescale-label-small-letter-spacing: 0.5px;

  /* Material Design 3 Elevation */
  --md-sys-elevation-level1: 0px 1px 2px rgba(0, 0, 0, 0.3), 0px 1px 3px 1px rgba(0, 0, 0, 0.15);
  --md-sys-elevation-level2: 0px 1px 2px rgba(0, 0, 0, 0.3), 0px 2px 6px 2px rgba(0, 0, 0, 0.15);
  --md-sys-elevation-level3: 0px 1px 3px rgba(0, 0, 0, 0.3), 0px 4px 8px 3px rgba(0, 0, 0, 0.15);
  --md-sys-elevation-level4: 0px 2px 3px rgba(0, 0, 0, 0.3), 0px 6px 10px 4px rgba(0, 0, 0, 0.15);
  --md-sys-elevation-level5: 0px 4px 4px rgba(0, 0, 0, 0.3), 0px 8px 12px 6px rgba(0, 0, 0, 0.15);

  /* Material Design 3 Shape Scale */
  --md-sys-shape-corner-none: 0px;
  --md-sys-shape-corner-extra-small: 4px;
  --md-sys-shape-corner-small: 8px;
  --md-sys-shape-corner-medium: 12px;
  --md-sys-shape-corner-large: 16px;
  --md-sys-shape-corner-extra-large: 28px;
  --md-sys-shape-corner-full: 9999px;

  /* Material Design 3 State Layers */
  --md-sys-state-hover-opacity: 0.08;
  --md-sys-state-focus-opacity: 0.12;
  --md-sys-state-pressed-opacity: 0.12;
  --md-sys-state-dragged-opacity: 0.16;
}

/* General Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--md-sys-typescale-body-large-font-family);
  font-weight: var(--md-sys-typescale-body-large-font-weight);
  font-size: var(--md-sys-typescale-body-large-font-size);
  line-height: var(--md-sys-typescale-body-large-line-height);
  letter-spacing: var(--md-sys-typescale-body-large-letter-spacing);
  color: var(--md-sys-color-on-surface);
  background-color: var(--md-sys-color-background);
}

/* App Bar */
.md-app-bar {
  background-color: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  box-shadow: var(--md-sys-elevation-level2);
  display: flex;
  flex-direction: column;
  width: 100%;
  position: sticky;
  top: 0;
  z-index: 4;
}

.md-app-bar-header {
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: nowrap;
  gap: 16px;
}

.md-app-bar-title {
  font-family: var(--md-sys-typescale-title-large-font-family);
  font-weight: var(--md-sys-typescale-title-large-font-weight);
  font-size: var(--md-sys-typescale-title-large-font-size);
  line-height: var(--md-sys-typescale-title-large-line-height);
  flex-grow: 1;
  display: flex;
  align-items: center;
  gap: 16px;
}

.md-app-bar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Navigation */
.md-navigation {
  display: flex;
  overflow-x: auto;
  border-bottom: 1px solid var(--md-sys-color-outline);
}

.md-nav-tab {
  font-family: var(--md-sys-typescale-label-large-font-family);
  font-weight: var(--md-sys-typescale-label-large-font-weight);
  font-size: var(--md-sys-typescale-label-large-font-size);
  line-height: var(--md-sys-typescale-label-large-line-height);
  letter-spacing: var(--md-sys-typescale-label-large-letter-spacing);
  padding: 12px 16px;
  color: var(--md-sys-color-on-surface-variant);
  position: relative;
  cursor: pointer;
  text-decoration: none;
  text-transform: uppercase;
  white-space: nowrap;
}

.md-nav-tab.active {
  color: var(--md-sys-color-primary);
}

.md-nav-tab.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background-color: var(--md-sys-color-primary);
}

/* Search */
.md-search {
  position: relative;
  min-width: 200px;
  max-width: 600px;
}

.md-search-bar {
  width: 100%;
  padding: 12px 16px 12px 48px;
  border: none;
  border-radius: var(--md-sys-shape-corner-full);
  background-color: var(--md-sys-color-surface-variant);
  color: var(--md-sys-color-on-surface);
  font-family: var(--md-sys-typescale-body-large-font-family);
  font-size: var(--md-sys-typescale-body-large-font-size);
  line-height: var(--md-sys-typescale-body-large-line-height);
}

.md-search-bar:focus {
  outline: none;
  background-color: var(--md-sys-color-surface-variant);
}

.md-search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--md-sys-color-on-surface-variant);
  font-size: 24px;
}

/* Container */
.md-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px;
}

/* Cards */
.md-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.md-card {
  background-color: var(--md-sys-color-surface);
  border-radius: var(--md-sys-shape-corner-medium);
  box-shadow: var(--md-sys-elevation-level1);
  padding: 16px;
  overflow: hidden;
  transition: box-shadow 0.3s, transform 0.3s;
  position: relative;
}

.md-card:hover {
  box-shadow: var(--md-sys-elevation-level2);
  transform: translateY(-2px);
}

.md-card-header {
  display: flex;
  align-items: flex-start;
  margin-bottom: 8px;
}

.md-card-title {
  font-family: var(--md-sys-typescale-title-medium-font-family);
  font-weight: var(--md-sys-typescale-title-medium-font-weight);
  font-size: var(--md-sys-typescale-title-medium-font-size);
  line-height: var(--md-sys-typescale-title-medium-line-height);
  letter-spacing: var(--md-sys-typescale-title-medium-letter-spacing);
  color: var(--md-sys-color-on-surface);
  flex-grow: 1;
  margin-right: 8px;
  word-break: break-word;
}

.md-card-content {
  font-family: var(--md-sys-typescale-body-medium-font-family);
  font-weight: var(--md-sys-typescale-body-medium-font-weight);
  font-size: var(--md-sys-typescale-body-medium-font-size);
  line-height: var(--md-sys-typescale-body-medium-line-height);
  letter-spacing: var(--md-sys-typescale-body-medium-letter-spacing);
  color: var(--md-sys-color-on-surface-variant);
  margin-bottom: 16px;
}

.md-card-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Card body small adjustments */
.md-card-body { padding: 8px 12px; }
.md-card-desc { margin-top:8px; color: var(--md-sys-color-on-surface-variant); }
.md-card-due { margin-top:8px; font-size: 13px; color: var(--md-sys-color-on-surface-variant); }

/* Action icons on card (right) */
.md-card-actions { gap:8px; }
.md-button { background: transparent; border: none; cursor: pointer; padding:6px; border-radius:6px; }
.md-button:hover { background: rgba(0,0,0,0.04); }
.task-edit { color: var(--md-sys-color-primary); }
.task-delete { color: var(--md-sys-color-error); }

/* Chips */
.md-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.md-chip {
  font-family: var(--md-sys-typescale-label-large-font-family);
  font-weight: var(--md-sys-typescale-label-large-font-weight);
  font-size: var(--md-sys-typescale-label-large-font-size);
  line-height: var(--md-sys-typescale-label-large-line-height);
  letter-spacing: var(--md-sys-typescale-label-large-letter-spacing);
  padding: 6px 12px;
  border-radius: var(--md-sys-shape-corner-small);
  background-color: var(--md-sys-color-surface-variant);
  color: var(--md-sys-color-on-surface-variant);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.md-chip.priority-high {
  background-color: #ffcdd2; /* Light red */
  color: #c62828;
}

.md-chip.priority-medium {
  background-color: #ffecb3; /* Light amber */
  color: #ff8f00;
}

.md-chip.priority-low {
  background-color: #c8e6c9; /* Light green */
  color: #2e7d32;
}

.md-chip.due-date {
  background-color: #bbdefb; /* Light blue */
  color: #1565c0;
}

/* Checkbox */
.md-checkbox {
  display: inline-block;
  position: relative;
  width: 20px;
  height: 20px;
  margin-right: 12px;
}

.md-checkbox input {
  position: absolute;
  opacity: 0;
  cursor: pointer;
  height: 0;
  width: 0;
}

.md-checkbox-mark {
  position: absolute;
  top: 0;
  left: 0;
  height: 20px;
  width: 20px;
  background-color: transparent;
  border: 2px solid var(--md-sys-color-outline);
  border-radius: 2px;
  transition: all 0.2s ease;
}

.md-checkbox input:checked ~ .md-checkbox-mark {
  background-color: var(--md-sys-color-primary);
  border-color: var(--md-sys-color-primary);
}

.md-checkbox-mark:after {
  content: "";
  position: absolute;
  display: none;
  left: 6px;
  top: 2px;
  width: 5px;
  height: 10px;
  border: solid var(--md-sys-color-on-primary);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.md-checkbox input:checked ~ .md-checkbox-mark:after {
  display: block;
}

/* Button Styles */
.md-fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  border: none;
  box-shadow: var(--md-sys-elevation-level3);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: box-shadow 0.3s, background-color 0.3s;
  z-index: 3;
}

.md-fab:hover {
  box-shadow: var(--md-sys-elevation-level4);
  background-color: var(--md-sys-color-primary);
}

.md-fab:active {
  box-shadow: var(--md-sys-elevation-level2);
}

.md-fab .md-icon {
  font-size: 24px;
}

.md-button {
  font-family: var(--md-sys-typescale-label-large-font-family);
  font-weight: var(--md-sys-typescale-label-large-font-weight);
  font-size: var(--md-sys-typescale-label-large-font-size);
  line-height: var(--md-sys-typescale-label-large-line-height);
  letter-spacing: var(--md-sys-typescale-label-large-letter-spacing);
  text-transform: uppercase;
  padding: 10px 24px;
  border-radius: var(--md-sys-shape-corner-full);
  border: none;
  cursor: pointer;
  transition: all 0.2s;
}

.md-button-filled {
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
}

.md-button-filled:hover {
  box-shadow: var(--md-sys-elevation-level1);
}

.md-button-text {
  background-color: transparent;
  color: var(--md-sys-color-primary);
}

.md-button-text:hover {
  background-color: rgba(103, 80, 164, 0.08); /* Primary with hover opacity */
}

.md-icon-button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: transparent;
  color: var(--md-sys-color-on-surface-variant);
  border: none;
  cursor: pointer;
  transition: background-color 0.2s;
}

.md-icon-button:hover {
  background-color: rgba(0, 0, 0, 0.08);
}

/* Modal */
.md-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.6);
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}

.md-modal-backdrop.open {
  opacity: 1;
  visibility: visible;
}

.md-modal {
  background-color: var(--md-sys-color-surface);
  border-radius: var(--md-sys-shape-corner-large);
  box-shadow: var(--md-sys-elevation-level3);
  width: 100%;
  max-width: 560px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
}

.md-modal-header {
  padding: 24px 24px 16px;
  border-bottom: 1px solid var(--md-sys-color-outline);
}

.md-modal-title {
  font-family: var(--md-sys-typescale-headline-small-font-family);
  font-weight: var(--md-sys-typescale-headline-small-font-weight);
  font-size: var(--md-sys-typescale-headline-small-font-size);
  line-height: var(--md-sys-typescale-headline-small-line-height);
  letter-spacing: var(--md-sys-typescale-headline-small-letter-spacing);
  color: var(--md-sys-color-on-surface);
}

.md-modal-content {
  padding: 24px;
}

.md-modal-footer {
  padding: 16px 24px 24px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Form Fields */
.md-form-field {
  margin-bottom: 20px;
  position: relative;
}

.md-form-field label {
  font-family: var(--md-sys-typescale-body-medium-font-family);
  font-size: var(--md-sys-typescale-body-medium-font-size);
  color: var(--md-sys-color-on-surface-variant);
  margin-bottom: 8px;
  display: block;
}

.md-input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--md-sys-color-outline);
  border-radius: var(--md-sys-shape-corner-small);
  background-color: transparent;
  color: var(--md-sys-color-on-surface);
  font-family: var(--md-sys-typescale-body-large-font-family);
  font-size: var(--md-sys-typescale-body-large-font-size);
  line-height: var(--md-sys-typescale-body-large-line-height);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.md-input:focus {
  outline: none;
  border-color: var(--md-sys-color-primary);
  box-shadow: 0 0 0 2px rgba(103, 80, 164, 0.2);
}

.md-input::placeholder {
  color: var(--md-sys-color-on-surface-variant);
  opacity: 0.5;
}

.md-textarea {
  min-height: 100px;
  resize: vertical;
}

/* Empty state */
.md-empty-state {
  text-align: center;
  padding: 40px 0;
}

.md-empty-state-icon {
  font-size: 64px;
  color: var(--md-sys-color-on-surface-variant);
  margin-bottom: 16px;
}

.md-empty-state-title {
  font-family: var(--md-sys-typescale-headline-medium-font-family);
  font-weight: var(--md-sys-typescale-headline-medium-font-weight);
  font-size: var(--md-sys-typescale-headline-medium-font-size);
  line-height: var(--md-sys-typescale-headline-medium-line-height);
  letter-spacing: var(--md-sys-typescale-headline-medium-letter-spacing);
  color: var(--md-sys-color-on-surface);
  margin-bottom: 8px;
}

.md-empty-state-description {
  font-family: var(--md-sys-typescale-body-medium-font-family);
  font-weight: var(--md-sys-typescale-body-medium-font-weight);
  font-size: var(--md-sys-typescale-body-medium-font-size);
  line-height: var(--md-sys-typescale-body-medium-line-height);
  letter-spacing: var(--md-sys-typescale-body-medium-letter-spacing);
  color: var(--md-sys-color-on-surface-variant);
}

/* Helper/error text */
.md-helper-text {
  font-family: var(--md-sys-typescale-body-small-font-family);
  font-size: var(--md-sys-typescale-body-small-font-size);
  line-height: var(--md-sys-typescale-body-small-line-height);
  letter-spacing: var(--md-sys-typescale-body-small-letter-spacing);
  color: var(--md-sys-color-on-surface-variant);
  margin-top: 4px;
}

.md-error-text {
  font-family: var(--md-sys-typescale-body-small-font-family);
  font-size: var(--md-sys-typescale-body-small-font-size);
  line-height: var(--md-sys-typescale-body-small-line-height);
  letter-spacing: var(--md-sys-typescale-body-small-letter-spacing);
  color: var(--md-sys-color-error);
  margin-top: 4px;
}

/* Completed task style */
.md-task-completed .md-card-title {
  text-decoration: line-through;
  color: var(--md-sys-color-on-surface-variant);
}

/* Responsive Styles */
@media (max-width: 768px) {
  .md-cards-grid {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  }
  
  .md-app-bar-header {
    flex-wrap: wrap;
  }
  
  .md-app-bar-title {
    margin-bottom: 8px;
    width: 100%;
  }
  
  .md-search {
    width: 100%;
    max-width: none;
  }
  
  .md-app-bar-actions {
    width: 100%;
    justify-content: space-between;
    margin-top: 8px;
  }
  
  .md-modal {
    width: calc(100% - 32px);
    max-width: none;
  }
}

@media (max-width: 480px) {
  .md-cards-grid {
    grid-template-columns: 1fr;
  }
  
  .md-fab {
    right: 16px;
    bottom: 16px;
  }
  
  .md-chips {
    margin-bottom: 12px;
  }
}
