/* File: /webapp/style.css */
/* PWA Styles for MindTrack - Enhanced with Recovery Features */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #0066cc;
  --primary-dark: #0052a3;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --bg-dark: #0f0f0f;
  --bg-light: #1a1a1a;
  --surface: #262626;
  --surface-hover: #2d2d2d;
  --text: #f3f4f6;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;
  --border: #374151;
  --radius: 12px;
  --radius-sm: 8px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body.light-theme {
  --bg-dark: #ffffff;
  --bg-light: #f9fafb;
  --surface: #ffffff;
  --surface-hover: #f3f4f6;
  --text: #111827;
  --text-muted: #6b7280;
  --text-dim: #9ca3af;
  --border: #e5e7eb;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-dark);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  user-select: none;
  -webkit-user-select: none;
  transition: var(--transition);
}

/* NEW: Crash Mode */
body.crash-mode {
  background: #0a0a0a;
}

body.crash-mode .app-container {
  opacity: 0.7;
}

body.crash-mode .session-badge {
  background: var(--warning);
  animation: gentlePulse 3s ease-in-out infinite;
}

@keyframes gentlePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* Install Banner */
.install-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: var(--primary);
  color: white;
  padding: 0.75rem 1rem;
  z-index: 1000;
  transform: translateY(-100%);
  transition: transform 0.3s ease;
}

.install-banner.show { transform: translateY(0); }
.install-banner.hidden { display: none; }

.install-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.btn-small {
  padding: 0.375rem 1rem;
  background: white;
  color: var(--primary);
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 500;
  cursor: pointer;
}

.btn-text {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.9);
  cursor: pointer;
  text-decoration: underline;
}

/* App Container */
.app-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
  padding: 0 1rem;
}

/* Header */
.app-header {
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2rem;
}

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

.back-btn {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 1.25rem;
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  border: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
}

.back-btn:hover {
  color: var(--text);
  background: var(--surface-hover);
  border-color: var(--primary);
  transform: scale(1.05);
}

.app-title {
  font-size: 1.5rem;
  font-weight: 600;
  background: linear-gradient(135deg, var(--primary), var(--success));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.header-actions {
  display: flex;
  gap: 0.75rem;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.icon-btn:hover {
  background: var(--surface-hover);
  transform: scale(1.05);
}

/* NEW: Energy Status Section */
.energy-status {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 1.5rem;
  margin-bottom: 2rem;
}

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

.energy-header h2 {
  font-size: 1.125rem;
  font-weight: 600;
  margin: 0;
}

.energy-percentage {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--success);
}

.energy-battery {
  height: 1.5rem;
  background: var(--bg-light);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
}

.battery-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--success), #059669);
  transition: width 0.5s ease, background 0.5s ease;
  border-radius: var(--radius-sm);
}

.energy-message {
  font-size: 0.9375rem;
  color: var(--text-muted);
  text-align: center;
  margin: 0;
}

/* Timer Section */
.timer-section {
  text-align: center;
  padding: 2rem;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 2rem;
  position: relative;
}

.session-badge {
  display: inline-block;
  padding: 0.375rem 1rem;
  background: var(--primary);
  color: white;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 1px;
  margin-bottom: 1.5rem;
  text-transform: uppercase;
}

.session-badge.break { background: var(--success); }
.session-badge.recovery { background: var(--warning); }

.timer-display {
  font-size: 5rem;
  font-weight: 200;
  letter-spacing: -2px;
  font-variant-numeric: tabular-nums;
  margin-bottom: 1.5rem;
  color: var(--text);
}

.timer-display.pulse {
  animation: pulse 2s ease-in-out infinite;
}

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

.timer-progress {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin-bottom: 1.5rem;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--success));
  width: 0%;
  transition: width 1s linear;
  border-radius: 2px;
}

.session-info {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.info-item {
  text-align: center;
}

.info-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--text);
}

.info-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* NEW: Recovery Section */
.recovery-section {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 1.5rem;
  margin-bottom: 2rem;
  text-align: center;
}

.recovery-section h2 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.recovery-display {
  margin-bottom: 1rem;
}

.recovery-time {
  font-size: 2.5rem;
  font-weight: 600;
  color: var(--warning);
  margin-bottom: 0.25rem;
}

.recovery-label {
  font-size: 0.875rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.recovery-suggestion {
  font-size: 0.9375rem;
  color: var(--text-muted);
  font-style: italic;
  margin: 0;
}

/* Controls */
.controls-section {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.75rem;
  margin-bottom: 2rem;
}

.btn {
  padding: 0.875rem 1.25rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.btn:hover:not(:disabled) {
  background: var(--surface-hover);
  transform: translateY(-2px);
}

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

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

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

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

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

.btn-icon {
  font-size: 1.125rem;
}

/* Quick Sessions */
.quick-sessions {
  margin-bottom: 2rem;
}

.quick-sessions h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--text-muted);
}

.quick-buttons {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.quick-btn {
  padding: 0.5rem 1rem;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.875rem;
  cursor: pointer;
  transition: var(--transition);
}

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

/* Voice Indicator */
.voice-indicator {
  position: fixed;
  bottom: 2rem;
  left: 2rem;
  padding: 0.75rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  transition: var(--transition);
}

.voice-indicator.listening {
  border-color: var(--primary);
  box-shadow: 0 0 20px rgba(0, 102, 204, 0.3);
}

.voice-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
}

.voice-indicator.listening .voice-dot {
  background: var(--primary);
  animation: voicePulse 1.5s ease-in-out infinite;
}

@keyframes voicePulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.5); opacity: 0.7; }
}

.voice-text {
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* Quote Section */
.quote-section {
  text-align: center;
  padding: 1.5rem;
  margin-bottom: 2rem;
  font-style: italic;
  color: var(--text-muted);
}

/* Modal */
.modal {
  display: none !important;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  z-index: 2000;
  padding: 1rem;
  overflow-y: auto;
}

.modal.active {
  display: flex !important;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: var(--surface);
  border-radius: var(--radius);
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  border: 1px solid var(--border);
}

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

.modal-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-body {
  padding: 1.5rem;
}

.setting-group {
  margin-bottom: 1.5rem;
}

.setting-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  color: var(--text);
}

.setting-group input[type="range"] {
  width: 100%;
  margin-bottom: 0.25rem;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
}

.toggle-label input[type="checkbox"] {
  width: 20px;
  height: 20px;
}

/* NEW: Intensity Modal Styles */
.intensity-buttons {
  display: grid;
  gap: 1rem;
}

.intensity-btn {
  padding: 1.25rem;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.intensity-btn:hover {
  background: var(--surface-hover);
  border-color: var(--primary);
  transform: translateY(-2px);
}

.intensity-icon {
  font-size: 2rem;
}

.intensity-name {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text);
}

.intensity-desc {
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* Stats */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  padding: 1.25rem;
  background: var(--bg-light);
  border-radius: var(--radius-sm);
  text-align: center;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

/* NEW: Energy Stats */
.energy-stats {
  background: var(--bg-light);
  padding: 1.25rem;
  border-radius: var(--radius-sm);
  margin-bottom: 2rem;
}

.energy-stats h3 {
  font-size: 1rem;
  margin-bottom: 1rem;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9375rem;
}

.stat-row:last-child {
  border-bottom: none;
}

.stat-actions {
  display: flex;
  gap: 1rem;
}

/* Voice Help */
.voice-help {
  margin-bottom: 2rem;
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 1rem;
  border: 1px solid var(--border);
}

.voice-help summary {
  cursor: pointer;
  font-weight: 500;
}

.voice-help ul {
  margin-top: 1rem;
  margin-left: 1.5rem;
  color: var(--text-muted);
}

.voice-help li {
  margin-bottom: 0.5rem;
}

/* Footer */
.app-footer {
  padding: 2rem 0;
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  margin-top: auto;
}

.app-footer a {
  color: var(--text-muted);
  text-decoration: none;
}

.app-footer a:hover {
  color: var(--text);
}

.footer-note {
  margin-top: 0.5rem;
  color: var(--text-dim);
}

/* Responsive */
@media (max-width: 640px) {
  .timer-display {
    font-size: 3.5rem;
  }
  
  .controls-section {
    grid-template-columns: 1fr 1fr;
  }
  
  .session-info {
    gap: 0.5rem;
  }
  
  .voice-indicator {
    left: 1rem;
    bottom: 1rem;
    padding: 0.5rem 1rem;
  }
  
  .stat-grid {
    grid-template-columns: 1fr;
  }
}

/* PWA Standalone Mode */
@media (display-mode: standalone) {
  .install-banner {
    display: none !important;
  }
  
  .footer-note {
    display: none;
  }
}

/* Safe Areas for iPhone */
@supports (padding: env(safe-area-inset-top)) {
  .app-header {
    padding-top: calc(1.5rem + env(safe-area-inset-top));
  }
  
  .app-footer {
    padding-bottom: calc(2rem + env(safe-area-inset-bottom));
  }
}