/**
 * Attention Time Widget Styles
 * Slide-out focus timer tray component
 */

/* ─── Widget Container ─── */
#attentionTimeWidget {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.4;
  color: #1f2937;
}

/* ─── Collapsed Tab ─── */
.att-tab {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  min-height: 80px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 12px 0 0 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  z-index: 9001;
  box-shadow: -2px 0 12px rgba(0, 0, 0, 0.15);
  transition: transform 0.3s ease, opacity 0.3s ease;
  padding: 8px 4px;
}

.att-tab:hover {
  transform: translateY(-50%) translateX(-4px);
}

.att-tab.hidden {
  transform: translateY(-50%) translateX(100%);
  opacity: 0;
  pointer-events: none;
}

.att-tab-icon {
  font-size: 20px;
  filter: grayscale(1) brightness(10);
}

.att-tab-text {
  font-size: 12px;
  font-weight: 700;
  color: white;
  text-align: center;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  letter-spacing: 0.5px;
}

/* Tab state variations */
.att-tab-measuring {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  animation: att-tab-pulse 2s infinite;
}

.att-tab-focusing {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
}

.att-tab-break {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

@keyframes att-tab-pulse {
  0%, 100% { box-shadow: -2px 0 12px rgba(16, 185, 129, 0.3); }
  50% { box-shadow: -2px 0 20px rgba(16, 185, 129, 0.6); }
}

/* ─── Slide-out Tray ─── */
.att-tray {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%) translateX(100%);
  width: 300px;
  max-height: 80vh;
  background: white;
  border-radius: 16px 0 0 16px;
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
  z-index: 9002;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.3s ease;
}

.att-tray.open {
  transform: translateY(-50%) translateX(0);
}

/* ─── Tray Header ─── */
.att-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.att-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.att-close {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.att-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* ─── Tray Body ─── */
.att-body {
  padding: 16px;
  overflow-y: auto;
  flex: 1;
}

.att-section {
  margin-bottom: 16px;
}

.att-section:last-child {
  margin-bottom: 0;
}

/* ─── Instructions ─── */
.att-instructions {
  font-size: 14px;
  color: #6b7280;
  line-height: 1.5;
  margin-bottom: 16px;
}

.att-hint {
  font-size: 12px;
  color: #9ca3af;
  text-align: center;
  margin-top: 12px;
}

/* ─── Buttons ─── */
.att-btn {
  display: block;
  width: 100%;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 48px;
  margin-bottom: 8px;
}

.att-btn:last-child {
  margin-bottom: 0;
}

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

.att-btn-large {
  padding: 16px 20px;
  font-size: 17px;
  min-height: 56px;
}

.att-btn-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.att-btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.att-btn-stop {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: white;
}

.att-btn-stop:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

.att-btn-secondary {
  background: #f3f4f6;
  color: #4b5563;
}

.att-btn-secondary:hover:not(:disabled) {
  background: #e5e7eb;
}

/* ─── Timer Display ─── */
.att-timer-display {
  font-size: 48px;
  font-weight: 700;
  text-align: center;
  font-variant-numeric: tabular-nums;
  letter-spacing: -1px;
  color: #1f2937;
  margin: 8px 0;
}

.att-break-timer {
  color: #d97706;
}

.att-timer-label {
  font-size: 13px;
  color: #9ca3af;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 0 0 16px 0;
}

/* ─── Status Indicator ─── */
.att-status-indicator {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #10b981;
  margin: 0 auto 8px;
}

.att-pulse {
  animation: att-pulse 1.5s infinite;
}

.att-focus-pulse {
  background: #3b82f6;
}

@keyframes att-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(1.2); }
}

/* ─── Progress Bar ─── */
.att-progress-bar {
  height: 8px;
  background: #e5e7eb;
  border-radius: 4px;
  overflow: hidden;
  margin: 12px 0;
}

.att-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
  border-radius: 4px;
  transition: width 0.3s ease;
}

/* ─── Break Info ─── */
.att-break-info {
  background: #fef3c7;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}

.att-break-info h4 {
  margin: 0 0 12px 0;
  font-size: 18px;
  color: #92400e;
}

.att-stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: 14px;
}

.att-stat-row span {
  color: #78350f;
}

.att-stat-row strong {
  color: #92400e;
  font-size: 16px;
}

.att-break-countdown {
  text-align: center;
  margin-bottom: 16px;
}

.att-ready-msg {
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  color: #059669;
  margin-bottom: 16px;
}

/* ─── Stats Panel ─── */
.att-stats {
  display: flex;
  justify-content: space-around;
  background: #f9fafb;
  border-radius: 12px;
  padding: 14px 8px;
  margin-top: 16px;
}

.att-stat {
  text-align: center;
  flex: 1;
}

.att-stat-value {
  display: block;
  font-size: 18px;
  font-weight: 700;
  color: #1f2937;
}

.att-stat-label {
  display: block;
  font-size: 11px;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

/* ─── Completed State ─── */
.att-completed h4 {
  text-align: center;
  font-size: 20px;
  margin: 0 0 16px 0;
  color: #059669;
}

/* ─── Measuring State ─── */
.att-measuring {
  text-align: center;
}

/* ─── Break Overlay (Full Screen) ─── */
.att-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  z-index: 99999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow-y: auto;
}

.att-overlay-content {
  max-width: 420px;
  width: 100%;
  text-align: center;
}

.att-overlay h2 {
  font-size: 36px;
  color: #92400e;
  margin: 0 0 16px 0;
}

.att-overlay-focus-info {
  margin-bottom: 16px;
}

.att-overlay-focus-info p {
  font-size: 18px;
  color: #78350f;
  margin: 4px 0;
}

.att-overlay-focus-info strong {
  color: #92400e;
  font-size: 20px;
}

.att-overlay-timer {
  font-size: 80px;
  font-weight: 700;
  color: #d97706;
  font-variant-numeric: tabular-nums;
  margin: 8px 0;
  line-height: 1;
  transition: color 0.3s ease;
}

.att-overlay-timer.att-warning {
  color: #dc2626;
  animation: att-warning-pulse 1s infinite;
}

.att-overlay-timer.att-complete {
  color: #059669;
}

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

.att-overlay-timer-label {
  font-size: 14px;
  color: #92400e;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 0 0 16px 0;
}

.att-overlay-warning {
  background: #fef2f2;
  border: 2px solid #dc2626;
  color: #dc2626;
  padding: 10px 16px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 15px;
  margin: 12px 0;
  animation: att-warning-pulse 1s infinite;
}

.att-overlay-stats {
  background: rgba(255, 255, 255, 0.9);
  border-radius: 16px;
  padding: 16px 20px;
  margin: 16px 0;
  text-align: left;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.att-overlay-stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  font-size: 15px;
  border-bottom: 1px solid #fde68a;
}

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

.att-overlay-stat-row span {
  color: #78350f;
}

.att-overlay-stat-row strong {
  color: #92400e;
  font-size: 17px;
}

.att-overlay-motivation {
  font-size: 20px;
  color: #92400e;
  font-weight: 600;
  margin: 20px 0 12px;
}

.att-overlay-tip {
  font-size: 16px;
  color: #78350f;
  margin: 8px 0 20px;
  font-style: italic;
}

.att-overlay-buttons {
  margin-top: 20px;
}

.att-overlay-buttons .att-btn {
  margin-bottom: 12px;
}

.att-overlay-resume {
  font-size: 18px;
  padding: 18px 24px;
  min-height: 60px;
}

.att-overlay-resume:disabled {
  background: linear-gradient(135deg, #9ca3af 0%, #6b7280 100%);
}

/* ─── Mobile Adjustments ─── */
@media (max-width: 768px) {
  .att-tray {
    width: 100%;
    max-width: 320px;
    max-height: 70vh;
    border-radius: 16px 0 0 16px;
  }

  .att-tab {
    width: 40px;
    min-height: 70px;
  }

  .att-timer-display {
    font-size: 40px;
  }

  .att-btn-large {
    padding: 14px 16px;
    font-size: 16px;
  }
}

/* ─── Landscape Phone ─── */
@media (max-height: 500px) {
  .att-tray {
    top: 10px;
    bottom: 10px;
    transform: translateX(100%);
    max-height: none;
  }

  .att-tray.open {
    transform: translateX(0);
  }

  .att-tab {
    top: 50%;
    transform: translateY(-50%);
  }
}

/* ─── Print: Hide Widget ─── */
@media print {
  #attentionTimeWidget {
    display: none !important;
  }
}

/* ─── Accessibility & Polish ─── */

/* Focus visible outlines for keyboard navigation */
.att-btn:focus-visible,
.att-tab:focus-visible,
.att-close:focus-visible {
  outline: 3px solid #667eea;
  outline-offset: 2px;
}

/* Entrance animation for tab on first load */
@keyframes att-slide-in {
  from {
    transform: translateY(-50%) translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateY(-50%) translateX(0);
    opacity: 1;
  }
}

.att-tab {
  animation: att-slide-in 0.5s ease 0.3s both;
}

/* Ensure timer uses tabular/monospace numbers for stable width */
.att-timer-display,
.att-overlay-timer,
#attTabText {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  .att-tab,
  .att-tray,
  .att-btn,
  .att-progress-fill,
  .att-overlay-timer {
    animation: none !important;
    transition: none !important;
  }

  .att-pulse,
  .att-warning {
    animation: none !important;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .att-btn {
    border: 2px solid currentColor;
  }

  .att-overlay-warning {
    border-width: 3px;
  }
}

/* Dark mode support (if system prefers) */
@media (prefers-color-scheme: dark) {
  .att-tray {
    background: #1f2937;
    color: #f9fafb;
  }

  .att-body {
    background: #1f2937;
  }

  .att-instructions,
  .att-hint {
    color: #9ca3af;
  }

  .att-timer-display {
    color: #f9fafb;
  }

  .att-stats {
    background: #374151;
  }

  .att-stat-value {
    color: #f9fafb;
  }

  .att-stat-label {
    color: #9ca3af;
  }
}

/* ─── Calibrated Duration Display ─── */
.att-calibrated-info {
  text-align: center;
  background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
  border: 2px solid #10b981;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}

.att-calibrated-icon {
  display: block;
  font-size: 24px;
  color: #059669;
  margin-bottom: 4px;
}

.att-calibrated-info p {
  font-size: 13px;
  color: #047857;
  margin: 0 0 4px 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.att-calibrated-duration {
  font-size: 36px;
  font-weight: 700;
  color: #059669;
  font-variant-numeric: tabular-nums;
}

/* Small button variant */
.att-btn-small {
  padding: 10px 16px;
  font-size: 13px;
  min-height: 40px;
  margin-top: 8px;
}

/* Dark mode for calibrated info */
@media (prefers-color-scheme: dark) {
  .att-calibrated-info {
    background: linear-gradient(135deg, #064e3b 0%, #065f46 100%);
    border-color: #34d399;
  }

  .att-calibrated-icon {
    color: #34d399;
  }

  .att-calibrated-info p {
    color: #a7f3d0;
  }

  .att-calibrated-duration {
    color: #6ee7b7;
  }
}
