/* Root Variables */
:root {
  /* Dark Theme (default) */
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  --surface-light: #222;
  --border: #333;
  --border-light: #444;
  --text: #fff;
  --text-secondary: #aaa;
  --primary: #29a8e0;
  --primary-dark: #1e87b3;
  --low: #4CAF50;
  --medium: #FFC107;
  --high: #F44336;
  --gray: #888;
  --font: 'Inter', sans-serif;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  --transition: all 0.2s ease;
}

[data-theme="light"] {
  /* Light Theme */
  --bg: #f5f5f5;
  --surface: #ffffff;
  --surface-light: #f8f8f8;
  --border: #e0e0e0;
  --border-light: #d0d0d0;
  --text: #333333;
  --text-secondary: #666;
  --primary: #1a73e8;
  --primary-dark: #0d5bba;
  --low: #34a853;
  --medium: #f9ab00;
  --high: #d93025;
}

/* Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: var(--font);
}

html {
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 2rem;
  min-height: 100vh;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* App Container */
.app-container {
  background: var(--surface);
  border-radius: 12px;
  padding: 24px;
  max-width: 800px;
  width: 100%;
  box-shadow: var(--shadow);
}

/* Header */
.app-header {
  margin-bottom: 1.5rem;
}

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

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-header h1 {
  font-size: 1.75rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-header h1 .material-icons-round {
  color: var(--primary);
}

/* Theme Toggle */
.theme-toggle {
  position: relative;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--primary);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.theme-toggle:hover {
  transform: scale(1.05);
}

.theme-toggle:active {
  transform: scale(0.95);
}

.theme-toggle .material-icons-round {
  position: absolute;
  font-size: 20px;
  color: white;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.theme-toggle .dark-icon {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

.theme-toggle .light-icon {
  opacity: 0;
  transform: rotate(90deg) scale(0.5);
}

[data-theme="light"] .theme-toggle .dark-icon {
  opacity: 0;
  transform: rotate(-90deg) scale(0.5);
}

[data-theme="light"] .theme-toggle .light-icon {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

/* Filters */
.filters {
  display: flex;
  flex-direction: row;
  gap: 1rem;
  margin-bottom: 1rem;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--surface-light);
  padding: 12px;
  border-radius: 8px;
  flex: 1;
}

.filter-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
  width: 100%;
}

.filter-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-btn {
  background: transparent;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  transition: var(--transition);
  white-space: nowrap;
}

.filter-btn.active {
  background: var(--primary);
  color: white;
}

.filter-btn:not(.active):hover {
  background: var(--border);
}

/* Buttons */
.btn {
  padding: 10px 18px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition);
}

.btn.primary {
  background: var(--primary);
  color: var(--text);
}

.btn.primary:hover {
  background: var(--primary-dark);
}

.btn.secondary {
  background: var(--surface-light);
  color: var(--text);
}

.btn.secondary:hover {
  background: var(--border);
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text);
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: var(--transition);
}

.icon-btn:hover {
  background: var(--border);
}

/* New Task Button */
.new-task-btn {
  background: var(--primary);
  color: var(--text);
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.new-task-btn:hover {
  background: var(--primary-dark);
}

.new-task-btn .icon-add {
  display: flex;
}

.new-task-btn .btn-text {
  transition: opacity 0.2s ease;
}

/* Task List */
.task-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.task-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  background: var(--surface-light);
  border-radius: 8px;
  transition: var(--transition);
  border-left: 4px solid transparent;
  -webkit-tap-highlight-color: transparent;
  tap-highlight-color: transparent;
}

.task-item:hover {
  background: var(--border);
}

.task-item.completed {
  opacity: 0.8;
}

.task-item.high { border-left-color: var(--high); }
.task-item.medium { border-left-color: var(--medium); }
.task-item.low { border-left-color: var(--low); }

.task-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.task-checkbox {
  appearance: none;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-light);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.task-checkbox:checked {
  background: var(--primary);
  border-color: var(--primary);
}

.task-checkbox:checked::after {
  content: "✓";
  color: white;
  font-size: 12px;
}

.task-text {
  flex: 1;
  cursor: pointer;
  position: relative;
}

.task-text .timestamp {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

.task-text.completed {
  color: var(--text-secondary);
  text-decoration: line-through;
}

.task-actions {
  display: flex;
  gap: 8px;
}

.task-actions .material-icons-round {
  cursor: pointer;
  font-size: 20px;
  color: var(--text-secondary);
  transition: var(--transition);
  padding: 4px;
  border-radius: 4px;
}

.task-actions .material-icons-round:hover {
  color: var(--text);
  background: var(--border);
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.modal-content {
  background: var(--surface);
  border-radius: 12px;
  width: 100%;
  max-width: 450px;
  z-index: 1001;
  box-shadow: var(--shadow);
  overflow: hidden;
}

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

.modal-header h2 {
  font-size: 1.5rem;
  font-weight: 600;
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  font-size: 0.95rem;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  background: var(--surface-light);
  color: var(--text);
  font-size: 1rem;
  transition: var(--transition);
}

.form-group input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(41, 168, 224, 0.2);
}

.priority-options {
  display: flex;
  gap: 8px;
}

.priority-option {
  flex: 1;
  padding: 10px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  text-align: center;
  transition: var(--transition);
  background: var(--surface-light);
  color: var(--text);
}

.priority-option.high {
  border: 1px solid var(--high);
}

.priority-option.medium {
  border: 1px solid var(--medium);
}

.priority-option.low {
  border: 1px solid var(--low);
}

.priority-option.selected {
  color: white;
}

.priority-option.high.selected {
  background: var(--high);
}

.priority-option.medium.selected {
  background: var(--medium);
  color: #000;
}

.priority-option.low.selected {
  background: var(--low);
}

.hidden {
  display: none;
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
  color: var(--text-secondary);
}

.empty-state .material-icons-round {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

/* Floating Action Button */
.fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  border: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 90;
  transition: transform 0.2s, box-shadow 0.2s;
}

.fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.3);
}

.fab:active {
  transform: translateY(0);
}

/* Pomodoro Drawer */
.pomodoro-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: flex-end;
  z-index: 1000;
  pointer-events: none;
  transition: opacity 0.3s ease;
  opacity: 0;
}

.pomodoro-drawer.visible {
  pointer-events: auto;
  opacity: 1;
}

.drawer-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.pomodoro-drawer.visible .drawer-backdrop {
  opacity: 1;
}

.drawer-content {
  background: var(--surface);
  height: 100%;
  width: 100%;
  max-width: 420px;
  box-shadow: -4px 0 12px rgba(0, 0, 0, 0.3);
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.pomodoro-drawer.visible .drawer-content {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 10;
}

.drawer-header h2 {
  font-size: 1.5rem;
  font-weight: 600;
}

.pomodoro-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 24px;
  flex-grow: 1;
}

.phase-selector {
  display: flex;
  justify-content: center;
  background: var(--surface-light);
  padding: 6px;
  border-radius: 50px;
  width: 100%;
  max-width: 300px;
}

.phase-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 8px 16px;
  border-radius: 50px;
  cursor: pointer;
  font-weight: 500;
  font-size: 0.9rem;
  flex: 1;
  transition: var(--transition);
  text-align: center;
}

.phase-btn.active {
  color: white;
  background: var(--primary);
  box-shadow: 0 2px 8px rgba(41, 168, 224, 0.3);
}

.pomodoro-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 10px 0;
}

.progress-ring {
  position: relative;
  width: 220px;
  height: 220px;
  margin-bottom: 16px;
}

.progress-ring-circle {
  fill: transparent;
  stroke: var(--primary);
  stroke-width: 8;
  stroke-linecap: round;
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
  transition: stroke-dashoffset 0.5s linear, stroke 0.3s ease;
}

.time-display {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 3rem;
  font-weight: 300;
  font-variant-numeric: tabular-nums;
}

.phase-label {
  font-size: 1.2rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
  margin-top: 12px;
  color: var(--primary);
}

.pomodoro-controls {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin: 10px 0;
}

.pomodoro-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: white;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.pomodoro-btn:hover {
  background: var(--primary-dark);
  transform: scale(1.05);
}

.pomodoro-btn:active {
  transform: scale(0.95);
}

.pomodoro-settings {
  background: var(--surface-light);
  border-radius: 12px;
  padding: 20px;
  width: 100%;
}

.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  tap-highlight-color: transparent;
}

.settings-header h3 {
  font-size: 1rem;
  color: var(--text-secondary);
}

.expand-settings {
  transition: transform 0.3s ease;
  color: var(--text-secondary);
}

.pomodoro-settings.expanded .expand-settings {
  transform: rotate(180deg);
}

.settings-content {
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height 0.3s ease, opacity 0.3s ease;
  padding-top: 0;
  pointer-events: none;
}

.pomodoro-settings.expanded .settings-content {
  max-height: 500px; /* Large enough to fit all content */
  opacity: 1;
  padding-top: 16px;
  pointer-events: auto;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.setting-row:last-child {
  margin-bottom: 0;
}

.setting-row label {
  font-size: 0.95rem;
  color: var(--text);
  width: 120px;
  text-align: left;
}

.setting-row .input-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.setting-row input {
  width: 60px;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  color: var(--text);
  text-align: center;
  font-size: 1rem;
}

.setting-row span {
  font-size: 0.9rem;
  color: var(--text-secondary);
  width: 60px;
  text-align: left;
}

/* Phase-specific styling */
.pomodoro-drawer.short-break-phase .phase-btn.phase-short-break.active {
  background: var(--low);
  box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3);
}

.pomodoro-drawer.long-break-phase .phase-btn.phase-long-break.active {
  background: var(--medium);
  box-shadow: 0 2px 8px rgba(255, 193, 7, 0.3);
}

.pomodoro-drawer.short-break-phase .progress-ring-circle {
  stroke: var(--low);
}

.pomodoro-drawer.long-break-phase .progress-ring-circle {
  stroke: var(--medium);
}

.pomodoro-drawer.short-break-phase .phase-label {
  color: var(--low);
}

.pomodoro-drawer.long-break-phase .phase-label {
  color: var(--medium);
}

/* Responsive Design */
@media (max-width: 768px) {
  body {
    padding: 1rem;
  }

  .app-container {
    padding: 16px;
    border-radius: 8px;
  }

  .header-content {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }

  .header-actions {
    width: 100%;
    justify-content: space-between;
  }

  .filters {
    flex-direction: column;
  }

  .filter-group {
    width: 100%;
  }

  .filter-buttons {
    justify-content: flex-start;
  }

  .task-item {
    padding: 12px;
  }

  .task-left {
    gap: 8px;
  }

  .task-text .timestamp {
    font-size: 0.7rem;
  }

  .modal-content {
    max-width: 90%;
    margin: 0 16px;
  }

  .priority-options {
    flex-direction: column;
  }

  .priority-option {
    padding: 8px;
  }

  /* --- Pomodoro Drawer Responsive Mobile Layout --- */
  .drawer-content {
    max-width: 100%;
    /* No need for scrolling on the main drawer on mobile */
    overflow-y: hidden;
  }

  .drawer-header {
    padding: 16px;
  }

  .pomodoro-body {
    padding: 16px;
    /* Flexbox for clean vertical stacking */
    display: flex;
    flex-direction: column;
    gap: 16px; /* Reduced gap for more compactness */
    justify-content: flex-start;
    align-items: center;
  }

  .phase-selector {
    width: 100%;
    max-width: 320px;
    padding: 8px;
  }

  .pomodoro-display {
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
  }

  .progress-ring {
    width: 160px; /* Reduced size */
    height: 160px; /* Reduced size */
    margin: 0;
  }

  .progress-ring-circle {
    stroke-width: 6; /* Thinner stroke */
  }

  .time-display {
    font-size: 2.2rem; /* Reduced font size */
  }

  .phase-label {
    margin-top: 12px;
    font-size: 1rem;
  }

  .pomodoro-controls {
    width: 100%;
    justify-content: space-around;
  }

  .pomodoro-btn {
    width: 52px;
    height: 52px;
  }

  .pomodoro-settings {
    width: 100%;
    padding: 16px;
    margin-top: 8px;
  }
}

@media (max-width: 480px) {
  .app-header h1 {
    font-size: 1.5rem;
  }

  .theme-toggle {
    width: 40px;
    height: 40px;
    min-width: 40px;
  }

  .new-task-btn {
    padding: 10px;
    width: 40px;
    justify-content: center;
  }

  .new-task-btn .btn-text {
    position: absolute;
    opacity: 0;
    width: 0;
  }

  .new-task-btn::after {
    content: "New Task";
    position: absolute;
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
    white-space: nowrap;
  }

  .new-task-btn:hover::after {
    opacity: 1;
  }

  .filter-group {
    padding: 10px;
  }

  .filter-btn {
    padding: 6px 10px;
    font-size: 0.8rem;
  }

  .task-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .task-left {
    width: 100%;
  }

  .task-actions {
    align-self: flex-end;
  }

  .modal-footer {
    flex-direction: column-reverse;
    gap: 8px;
  }

  .modal-footer .btn {
    width: 100%;
  }

  .fab {
    bottom: 16px;
    right: 16px;
    width: 52px;
    height: 52px;
  }

  /* Pomodoro Drawer adjustments for small phones */
  .pomodoro-body {
    gap: 12px;
  }

  .progress-ring {
    width: 150px;
    height: 150px;
  }

  .time-display {
    font-size: 2rem;
  }
}

/* Tablet landscape optimization */
@media (min-width: 769px) and (max-width: 1024px) {
  .app-container {
    max-width: 90%;
  }

  .filters {
    flex-wrap: wrap;
  }

  .filter-group {
    flex: 1 1 40%;
  }
}