/**
 * Focus Helper - Minimalist Styles
 * Mobile-first responsive design
 */

/* CSS Variables for theming */
:root {
  --primary-color: #4A90E2;
  --secondary-color: #6C757D;
  --success-color: #28A745;
  --danger-color: #DC3545;
  --text-color: #333;
  --text-light: #666;
  --bg-color: #FFFFFF;
  --bg-secondary: #F8F9FA;
  --border-color: #DEE2E6;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.15);
  --border-radius: 8px;
  --transition: all 0.3s ease;
}

/* Reset and base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  line-height: 1.6;
  color: var(--text-color);
  background-color: var(--bg-secondary);
  min-height: 100vh;
  /* Support for notched phones */
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* Container - mobile-first */
.container {
  max-width: 100%;
  min-height: 100vh;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

/* Header */
header {
  text-align: center;
  margin-bottom: 2rem;
}

h1 {
  font-size: 2rem;
  color: var(--primary-color);
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.subtitle {
  color: var(--text-light);
  font-size: 0.9rem;
}

/* Main content area */
main {
  width: 100%;
  max-width: 500px;
  background: var(--bg-color);
  border-radius: var(--border-radius);
  padding: 2rem;
  box-shadow: var(--shadow);
}

/* Timer Display */
.timer-display {
  text-align: center;
  margin-bottom: 2rem;
  padding: 2rem 1rem;
  background: var(--bg-secondary);
  border-radius: var(--border-radius);
}

.timer-value {
  font-size: 3rem;
  font-weight: 700;
  color: var(--primary-color);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.05em;
}

.timer-status {
  margin-top: 0.5rem;
  font-size: 1rem;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.85rem;
}

.timer-status.running {
  color: var(--success-color);
}

.timer-status.stopped {
  color: var(--secondary-color);
}

/* Controls */
.controls {
  display: flex;
  gap: 1rem;
  margin-bottom: 2rem;
}

/* Buttons */
.btn {
  flex: 1;
  padding: 1rem;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: var(--transition);
  /* Touch-friendly minimum size */
  min-height: 44px;
  font-family: inherit;
}

.btn:active {
  transform: scale(0.98);
}

.btn:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

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

.btn-primary:hover:not(:disabled) {
  background: #3A7BC8;
}

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

.btn-secondary:hover:not(:disabled) {
  background: #5A6268;
}

.btn-tertiary {
  background: var(--bg-secondary);
  color: var(--text-color);
  border: 1px solid var(--border-color);
}

.btn-tertiary:hover:not(:disabled) {
  background: var(--border-color);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-small {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  min-height: auto;
}

/* Settings */
.settings {
  border-top: 1px solid var(--border-color);
  padding-top: 1.5rem;
}

.settings h2 {
  font-size: 1.1rem;
  margin-bottom: 1rem;
  color: var(--text-color);
  font-weight: 600;
}

.settings-group {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
}

.input-group {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.input-group label {
  font-size: 0.875rem;
  color: var(--text-light);
  margin-bottom: 0.25rem;
  font-weight: 500;
}

.input-group input {
  padding: 0.75rem;
  font-size: 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  font-family: inherit;
  transition: var(--transition);
  min-height: 44px;
}

.input-group input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

/* Notification Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  padding: 1rem;
  backdrop-filter: blur(4px);
}

.modal.show {
  display: flex;
}

.modal-content {
  background: var(--bg-color);
  padding: 2rem;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-lg);
  text-align: center;
  max-width: 400px;
  width: 100%;
  animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-content h3 {
  font-size: 1.5rem;
  color: var(--primary-color);
  margin-bottom: 1rem;
}

.modal-content p {
  color: var(--text-light);
  margin-bottom: 1.5rem;
  font-size: 1.1rem;
}

/* Install Prompt */
.install-prompt {
  position: fixed;
  bottom: 1rem;
  left: 1rem;
  right: 1rem;
  background: var(--primary-color);
  color: white;
  padding: 1rem;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 1rem;
  z-index: 900;
  animation: slideUp 0.3s ease;
}

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

.install-prompt p {
  flex: 1;
  margin: 0;
  font-size: 0.9rem;
}

.btn-close {
  background: none;
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: var(--transition);
}

.btn-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Footer */
footer {
  margin-top: 2rem;
  text-align: center;
  color: var(--text-light);
  font-size: 0.85rem;
}

/* Tablet and Desktop styles */
@media (min-width: 768px) {
  .container {
    padding: 2rem;
  }

  main {
    max-width: 600px;
    padding: 3rem;
  }

  h1 {
    font-size: 2.5rem;
  }

  .timer-value {
    font-size: 4rem;
  }

  .install-prompt {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    max-width: 500px;
  }
}

/* Landscape mobile adjustments */
@media (max-height: 600px) and (orientation: landscape) {
  .container {
    min-height: auto;
    padding: 0.5rem;
  }

  header {
    margin-bottom: 1rem;
  }

  main {
    padding: 1.5rem;
  }

  .timer-display {
    padding: 1rem;
    margin-bottom: 1rem;
  }

  .timer-value {
    font-size: 2rem;
  }
}

/* Loading state for timer */
.timer-display.loading .timer-value {
  opacity: 0.5;
  animation: pulse 1.5s ease-in-out infinite;
}

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

/* Active/Running state animation */
.timer-display.running {
  box-shadow: 0 0 0 4px rgba(74, 144, 226, 0.1);
  animation: pulseGlow 2s ease-in-out infinite;
}

@keyframes pulseGlow {
  0%, 100% {
    box-shadow: 0 0 0 4px rgba(74, 144, 226, 0.1);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(74, 144, 226, 0.15);
  }
}

/* Accessibility: Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Print styles */
@media print {
  .install-prompt,
  .controls,
  footer {
    display: none;
  }
}

/* ========== ENHANCED UI: Settings Icon Bar & Panels ========== */

/* Settings Icon Bar */
.settings-icons {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color);
  flex-wrap: wrap;
}

.settings-icon-btn {
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 0.75rem;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  min-width: 70px;
  position: relative;
}

.settings-icon-btn .icon {
  font-size: 1.5rem;
}

.settings-icon-btn .label {
  font-size: 0.7rem;
  color: var(--text-light);
  font-weight: 500;
}

.settings-icon-btn:hover {
  background: var(--bg-color);
  border-color: var(--primary-color);
  transform: translateY(-2px);
}

.settings-icon-btn:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

.settings-icon-btn.active {
  background: var(--primary-color);
  border-color: var(--primary-color);
  color: white;
}

.settings-icon-btn.active .label {
  color: white;
}

/* Settings Panels */
.settings-panels {
  margin-top: 1rem;
}

.settings-panel {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 1.5rem;
  margin-bottom: 1rem;
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.settings-panel h3 {
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
  color: var(--primary-color);
  font-weight: 600;
}

.panel-description {
  font-size: 0.85rem;
  color: var(--text-light);
  margin-bottom: 1rem;
}

.settings-panel .btn-apply {
  width: 100%;
  margin-top: 1rem;
}

/* Radio Groups */
.radio-group {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.radio-label {
  display: flex;
  align-items: flex-start;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: var(--transition);
  background: var(--bg-color);
}

.radio-label:hover {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(74, 144, 226, 0.05);
}

.radio-label input[type="radio"] {
  margin-top: 0.25rem;
  margin-right: 0.75rem;
  cursor: pointer;
  flex-shrink: 0;
}

.radio-label input[type="radio"]:disabled {
  cursor: not-allowed;
}

.radio-label:has(input:disabled) {
  opacity: 0.5;
  cursor: not-allowed;
}

.radio-label:has(input:disabled):hover {
  border-color: var(--border-color);
  box-shadow: none;
}

.radio-label:has(input:checked) {
  background: rgba(74, 144, 226, 0.05);
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(74, 144, 226, 0.1);
}

.radio-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.radio-text strong {
  color: var(--text-color);
  font-size: 0.95rem;
}

.radio-text small {
  color: var(--text-light);
  font-size: 0.8rem;
  line-height: 1.4;
}

/* Rest Countdown Display */
.rest-countdown {
  font-size: 4rem;
  font-weight: 700;
  color: var(--primary-color);
  margin: 1rem 0;
  animation: pulse 1s ease-in-out infinite;
  font-variant-numeric: tabular-nums;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.8;
    transform: scale(1.05);
  }
}

/* Button Variants */
.btn-warning {
  background: #FFC107;
  color: #333;
}

.btn-warning:hover:not(:disabled) {
  background: #FFB300;
}

.btn-warning:active:not(:disabled) {
  background: #FFA000;
}

/* Session Duration Conditional Visibility */
#sessionDurationGroup {
  display: none;
  margin-top: 1rem;
}

#sessionDurationGroup.visible {
  display: flex;
}

/* Enhanced Input Group Styles */
.input-group small {
  display: block;
  margin-top: 0.25rem;
  color: var(--text-light);
  font-size: 0.75rem;
}

/* Modal Enhancements for New Modals */
.modal .modal-content h3 {
  margin-bottom: 1rem;
}

.modal .modal-content p {
  margin-bottom: 1.5rem;
}

/* Status Classes for Different States */
.timer-status.resting_waiting,
.timer-status.resting_active,
.timer-status.resting_confirm {
  color: #FF9800;
}

/* Mobile Optimizations for Settings */
@media (max-width: 480px) {
  .settings-icon-btn {
    min-width: 60px;
    padding: 0.5rem;
  }

  .settings-icon-btn .icon {
    font-size: 1.25rem;
  }

  .settings-icon-btn .label {
    font-size: 0.65rem;
  }

  .settings-panel {
    padding: 1rem;
  }

  .rest-countdown {
    font-size: 3rem;
  }
}

/* Accessibility: Focus visible improvements */
.settings-icon-btn:focus-visible,
.radio-label:focus-within {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* Dark state for timer when paused */
.timer-display.paused {
  opacity: 0.7;
  box-shadow: none;
  animation: none;
}
