/* ===== CSS Variables ===== */
:root {
  --primary-color: #6200ee;
  --primary-dark: #3700b3;
  --secondary-color: #03dac6;
  --error-color: #b00020;
  --warning-color: #ff9800;
  --success-color: #4caf50;
  --background: #ffffff;
  --surface: #ffffff;
  --on-primary: #ffffff;
  --on-surface: #000000;
  --border-color: #e0e0e0;
  --text-primary: #212121;
  --text-secondary: #757575;
  --shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  --shadow-elevated: 0 4px 8px rgba(0, 0, 0, 0.15);
}

@media (prefers-color-scheme: dark) {
  :root {
    --background: #121212;
    --surface: #1e1e1e;
    --on-primary: #ffffff;
    --on-surface: #ffffff;
    --border-color: #2c2c2c;
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    --shadow-elevated: 0 4px 8px rgba(0, 0, 0, 0.4);
  }
}

/* ===== Global Styles ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background-color: var(--background);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===== App Container ===== */
.app-container {
  max-width: 800px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===== Header ===== */
.app-header {
  background-color: var(--primary-color);
  color: var(--on-primary);
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-header h1 {
  font-size: 1.25rem;
  font-weight: 500;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--on-primary);
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s;
}

.icon-btn:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

/* ===== Main Content ===== */
.main-content {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
}

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

.empty-state svg {
  margin-bottom: 24px;
  opacity: 0.5;
}

.empty-state h2 {
  font-size: 1.5rem;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.empty-state p {
  font-size: 1rem;
}

/* ===== Timers List ===== */
.timers-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ===== Timer Card ===== */
/* Expired timer banner - compact red alert */
.timer-card-expired {
  background-color: #d32f2f;
  color: white;
  border-radius: 8px;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 8px rgba(211, 47, 47, 0.3);
  animation: pulse 1.5s infinite;
}

.expired-name {
  font-size: 2.5rem;
  font-weight: 700;
  line-height: 1.1;
  flex: 1;
}

.overdue-time {
  font-size: 1.2rem;
  font-weight: 600;
  opacity: 0.9;
  margin-left: 12px;
  flex-shrink: 0;
}

.expired-dismiss {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
  margin-left: 12px;
}

.expired-dismiss:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Active timer cards */
.timer-card {
  background-color: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 8px 12px;
  box-shadow: var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s;
}

.timer-card:hover {
  box-shadow: var(--shadow-elevated);
  transform: translateY(-2px);
}

.timer-card.expired {
  border-left: 4px solid var(--error-color);
}

.timer-card.warning {
  border-left: 4px solid var(--warning-color);
}

.timer-card.active {
  border-left: 4px solid var(--success-color);
}

.timer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.timer-info h3 {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 2px;
  line-height: 1.1;
}

.timer-info .duration-text {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

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

.timer-actions button {
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.timer-actions button:hover {
  background-color: var(--border-color);
}

.timer-actions .delete-btn:hover {
  background-color: var(--error-color);
  color: white;
  border-color: var(--error-color);
}

.timer-display {
  text-align: center;
  margin-bottom: 4px;
}

.time-remaining {
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.timer-display.expired .time-remaining {
  color: var(--error-color);
}

.timer-display.warning .time-remaining {
  color: var(--warning-color);
}

.time-label {
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin-top: 0;
}

.progress-bar {
  height: 4px;
  background-color: var(--border-color);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background-color: var(--success-color);
  transition: width 1s linear, background-color 0.3s;
  border-radius: 4px;
}

.progress-fill.warning {
  background-color: var(--warning-color);
}

.progress-fill.expired {
  background-color: var(--error-color);
}

.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  margin-top: 4px;
}

.status-badge.paused {
  background-color: rgba(158, 158, 158, 0.2);
  color: var(--text-secondary);
}

.status-badge.expired {
  background-color: rgba(176, 0, 32, 0.1);
  color: var(--error-color);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}

/* ===== Floating Action Buttons ===== */
.fab-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: row-reverse;
  gap: 16px;
  z-index: 50;
}

.fab {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background-color: var(--primary-color);
  color: var(--on-primary);
  border: none;
  box-shadow: var(--shadow-elevated);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s;
}

.fab-voice {
  background-color: #ff5722;
}

.fab:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
}

.fab:active {
  transform: scale(0.95);
}

.fab.listening {
  background-color: var(--error-color);
  animation: pulse 1s infinite;
}

/* ===== Dialog ===== */
.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: 1000;
  padding: 20px;
}

.dialog {
  background-color: var(--surface);
  border-radius: 16px;
  padding: 24px;
  max-width: 500px;
  width: 100%;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
  max-height: 90vh;
  overflow-y: auto;
}

.dialog h2 {
  font-size: 1.5rem;
  margin-bottom: 20px;
  color: var(--text-primary);
}

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

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  color: var(--text-primary);
}

.form-group input[type="text"],
.form-group input[type="number"] {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 1rem;
  background-color: var(--surface);
  color: var(--text-primary);
  transition: border-color 0.2s;
}

.form-group input:focus {
  outline: none;
  border-color: var(--primary-color);
}

.duration-chips {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.duration-chip {
  padding: 8px 16px;
  border: 2px solid var(--border-color);
  border-radius: 20px;
  background-color: var(--surface);
  color: var(--text-primary);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s;
}

.duration-chip:hover {
  background-color: var(--border-color);
}

.duration-chip.selected {
  background-color: var(--primary-color);
  color: var(--on-primary);
  border-color: var(--primary-color);
}

.dialog-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
}

.btn-primary,
.btn-secondary {
  padding: 10px 24px;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
}

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

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

.btn-secondary {
  background-color: transparent;
  color: var(--primary-color);
  border: 1px solid var(--border-color);
}

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

.duration-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  margin-bottom: 8px;
  background-color: var(--surface);
  color: var(--text-primary);
}

.form-group label input[type="checkbox"] {
  margin-right: 8px;
}

/* ===== Install Prompt ===== */
.install-prompt {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: var(--surface);
  border-top: 1px solid var(--border-color);
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
  z-index: 100;
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

.install-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  gap: 16px;
}

.install-content span {
  flex: 1;
  font-size: 0.875rem;
}

/* ===== Responsive ===== */
@media (max-width: 600px) {
  .app-header h1 {
    font-size: 1.125rem;
  }

  .time-remaining {
    font-size: 2.5rem;
  }

  .fab {
    bottom: 16px;
    right: 16px;
  }

  .dialog {
    padding: 20px;
  }

  .duration-chips {
    justify-content: center;
  }
}

/* ===== Accessibility ===== */
@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}

/* ===== Print Styles ===== */
@media print {
  .app-header,
  .fab,
  .timer-actions,
  .install-prompt {
    display: none;
  }
}
