/* Pomodoro Timer Styles */

:root {
  /* Pomodoro Colors */
  --pomodoro-work: #EF4444;
  --pomodoro-work-bg: #FEF2F2;
  --pomodoro-break: #22C55E;
  --pomodoro-break-bg: #F0FDF4;
  --pomodoro-long-break: #3B82F6;
  --pomodoro-long-break-bg: #EFF6FF;
  --pomodoro-paused: #EAB308;
  --pomodoro-paused-bg: #FEFCE8;

  /* Timer dimensions */
  --pomodoro-timer-size: 120px;
  --pomodoro-ring-width: 6px;
  --pomodoro-timer-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);

  /* Tomato indicator */
  --pomodoro-tomato-size: 14px;
  --pomodoro-tomato-gap: 2px;
}

/* ==================== TARJETA CON POMODORO ACTIVO ==================== */

.kanban-card.has-active-pomodoro {
  border: 2px solid var(--pomodoro-work);
  box-shadow:
    0 0 0 3px rgba(239, 68, 68, 0.1),
    var(--shadow-card);
  animation: pomodoro-card-pulse 2s ease-in-out infinite;
  position: relative;
}

.kanban-card.has-active-pomodoro::before {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  border-radius: var(--radius-base);
  background: linear-gradient(135deg, var(--pomodoro-work), var(--color-orange));
  opacity: 0.15;
  z-index: -1;
  animation: pomodoro-border-rotate 3s linear infinite;
}

.kanban-card.has-active-pomodoro .card-title {
  font-weight: var(--font-weight-semibold);
}

@keyframes pomodoro-card-pulse {
  0%, 100% {
    box-shadow:
      0 0 0 3px rgba(239, 68, 68, 0.1),
      var(--shadow-card);
  }
  50% {
    box-shadow:
      0 0 0 5px rgba(239, 68, 68, 0.15),
      var(--shadow-card-hover);
  }
}

@keyframes pomodoro-border-rotate {
  0% {
    filter: hue-rotate(0deg);
  }
  100% {
    filter: hue-rotate(360deg);
  }
}

/* Badge de estado activo (REMOVED - now handled in JS via .pomodoro-active-badge) */
.kanban-card.has-active-pomodoro::after {
  content: none;
}

.pomodoro-active-badge {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  margin-bottom: var(--spacing-2);
  margin-top: var(--spacing-1);
}

.pomodoro-active-badge::before {
  content: '🍅';
  font-size: 20px;
  animation: tomato-spin 2s linear infinite;
  display: block;
}

@keyframes tomato-spin {
  0% {
    transform: rotate(0deg) scale(1);
  }
  25% {
    transform: rotate(-5deg) scale(1.1);
  }
  50% {
    transform: rotate(0deg) scale(1);
  }
  75% {
    transform: rotate(5deg) scale(1.1);
  }
  100% {
    transform: rotate(0deg) scale(1);
  }
}

@keyframes badge-fade-in {
  from {
    opacity: 0;
    transform: scale(0.8) translateY(-4px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* ==================== INDICADOR DE TOMATE EN CARDS ==================== */

.pomodoro-indicator {
  display: flex;
  align-items: center;
  gap: var(--pomodoro-tomato-gap);
  margin-top: var(--spacing-2);
  padding-top: var(--spacing-2);
  border-top: 1px solid var(--color-border-subtle);
}

.pomodoro-tomato {
  width: var(--pomodoro-tomato-size);
  height: var(--pomodoro-tomato-size);
  color: var(--pomodoro-work);
  opacity: 0.9;
  transition: transform var(--transition-fast), opacity var(--transition-fast);
}

.pomodoro-tomato svg {
  width: 100%;
  height: 100%;
}

.pomodoro-indicator.is-active .pomodoro-tomato:last-of-type {
  animation: pomodoro-pulse 2s ease-in-out infinite;
}

.pomodoro-count {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-secondary);
  margin-left: var(--spacing-1);
}

@keyframes pomodoro-pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 0.9;
  }
  50% {
    transform: scale(1.15);
    opacity: 1;
  }
}

/* ==================== TIMER WIDGET FLOTANTE ==================== */

.pomodoro-timer {
  position: fixed;
  bottom: var(--spacing-6);
  right: var(--spacing-6);
  z-index: var(--z-dropdown);

  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing-3);

  padding: var(--spacing-4);
  background: var(--color-bg-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--pomodoro-timer-shadow);
  border: 1px solid var(--color-border);

  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition:
    opacity var(--transition-base),
    transform var(--transition-spring);
}

.pomodoro-timer.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Anillo circular del timer */
.pomodoro-timer-ring {
  position: relative;
  width: var(--pomodoro-timer-size);
  height: var(--pomodoro-timer-size);
}

.pomodoro-timer-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.pomodoro-ring-bg {
  fill: none;
  stroke: var(--color-bg-tertiary);
  stroke-width: var(--pomodoro-ring-width);
}

.pomodoro-ring-progress {
  fill: none;
  stroke: var(--pomodoro-work);
  stroke-width: var(--pomodoro-ring-width);
  stroke-linecap: round;
  stroke-dasharray: 283; /* 2 * PI * 45 */
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 1s linear, stroke var(--transition-base);
}

/* Estados del timer */
.pomodoro-timer.is-work .pomodoro-ring-progress {
  stroke: var(--pomodoro-work);
}

.pomodoro-timer.is-break .pomodoro-ring-progress {
  stroke: var(--pomodoro-break);
}

.pomodoro-timer.is-long-break .pomodoro-ring-progress {
  stroke: var(--pomodoro-long-break);
}

.pomodoro-timer.is-paused .pomodoro-ring-progress {
  stroke: var(--pomodoro-paused);
}

.pomodoro-timer.is-paused .pomodoro-time {
  animation: blink-subtle 1.5s ease-in-out infinite;
}

@keyframes blink-subtle {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Estado de procesamiento - deshabilita clicks y muestra feedback */
.pomodoro-timer.is-processing {
  pointer-events: none;
}

.pomodoro-timer.is-processing .pomodoro-btn {
  opacity: 0.5;
  cursor: wait;
}

.pomodoro-timer.is-processing .pomodoro-btn-pause {
  animation: processing-pulse 0.6s ease-in-out infinite;
}

@keyframes processing-pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 0.5;
  }
  50% {
    transform: scale(0.95);
    opacity: 0.7;
  }
}

/* Contenido central del timer */
.pomodoro-timer-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.pomodoro-time {
  display: block;
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-semibold);
  font-variant-numeric: tabular-nums;
  color: var(--color-text-primary);
  line-height: 1;
}

.pomodoro-label {
  display: block;
  font-size: var(--font-size-xs);
  color: var(--color-text-tertiary);
  margin-top: var(--spacing-1);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Botones de acción */
.pomodoro-timer-actions {
  display: flex;
  gap: var(--spacing-2);
}

.pomodoro-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--radius-base);
  background: var(--color-bg-secondary);
  color: var(--color-text-secondary);
  cursor: pointer;
  transition:
    background var(--transition-fast),
    color var(--transition-fast),
    transform var(--transition-fast);
  /* Asegurar que el botón reciba todos los clicks */
  position: relative;
  z-index: 1;
}

/* Los SVG dentro de los botones no deben capturar eventos */
.pomodoro-btn svg,
.pomodoro-btn svg * {
  pointer-events: none;
}

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

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

.pomodoro-btn-complete:hover {
  background: rgba(34, 197, 94, 0.1);
  color: var(--pomodoro-break);
}

.pomodoro-btn-cancel:hover {
  background: var(--color-red-bg);
  color: var(--pomodoro-work);
}

/* Info de la tarjeta */
.pomodoro-timer-card {
  max-width: 180px;
  text-align: center;
  position: relative;
}

.pomodoro-project-name {
  display: block;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-secondary);
  margin-bottom: 4px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pomodoro-card-title {
  font-size: var(--font-size-xs);
  color: var(--color-text-tertiary);
  /* Permitir múltiples líneas (mínimo 3) */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
  min-height: calc(var(--font-size-xs) * 1.4 * 3); /* Espacio para 3 líneas */
  word-wrap: break-word;
  cursor: help;
}

/* Tooltip para mostrar nombre completo */
.pomodoro-card-title:hover::after {
  content: attr(data-full-title);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-bottom: 8px;
  padding: 8px 12px;
  background: var(--color-text-primary);
  color: var(--color-text-inverse);
  font-size: var(--font-size-xs);
  border-radius: var(--radius-base);
  white-space: normal;
  max-width: 250px;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  pointer-events: none;
  opacity: 0;
  animation: tooltip-fade-in 0.2s ease-out forwards;
  line-height: 1.4;
}

/* Flecha del tooltip */
.pomodoro-card-title:hover::before {
  content: '';
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-bottom: 2px;
  border: 6px solid transparent;
  border-top-color: var(--color-text-primary);
  z-index: 1001;
  pointer-events: none;
  opacity: 0;
  animation: tooltip-fade-in 0.2s ease-out forwards;
}

@keyframes tooltip-fade-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* ==================== PANEL EN MODAL ==================== */

.pomodoro-panel {
  margin-top: 0;
  padding-top: 0;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-3);
}

.pomodoro-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--spacing-3);
}

.pomodoro-panel-title {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.pomodoro-count-display {
  display: flex;
  align-items: center;
  gap: var(--spacing-2);
  font-size: var(--font-size-base);
  color: var(--color-text-secondary);
}

.pomodoro-count-display .pomodoro-tomato {
  width: 16px;
  height: 16px;
}

.pomodoro-panel-content {
  display: flex;
  flex-direction: row;
  gap: var(--spacing-3);
}

.pomodoro-start-btn {
  flex: 1;
  padding: var(--spacing-3);
  border: none;
  border-radius: var(--radius-base);
  background: var(--pomodoro-work);
  color: white;
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-2);
}

.pomodoro-start-btn:hover {
  background: #DC2626;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
}

.pomodoro-start-btn:active {
  transform: translateY(0);
}

.pomodoro-start-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.pomodoro-start-btn svg {
  width: 16px;
  height: 16px;
}

/* Botón de descanso */
.pomodoro-break-btn {
  flex: 1;
  padding: var(--spacing-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-base);
  background: var(--color-bg-primary);
  color: var(--color-text-primary);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.pomodoro-break-btn:hover {
  background: var(--color-bg-hover);
  border-color: var(--color-text-tertiary);
}

/* Botón de descanso largo - variante con color azul */
.pomodoro-long-break-btn {
  border-color: var(--pomodoro-long-break);
  color: var(--pomodoro-long-break);
}

.pomodoro-long-break-btn:hover {
  background: var(--pomodoro-long-break-bg);
  border-color: var(--pomodoro-long-break);
}

/* Botón para completar sesión */
.pomodoro-complete-btn {
  flex: 1;
  padding: var(--spacing-3);
  border: 1px solid var(--pomodoro-break);
  border-radius: var(--radius-base);
  background: var(--color-bg-primary);
  color: var(--pomodoro-break);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.pomodoro-complete-btn:hover {
  background: var(--pomodoro-break-bg);
  border-color: var(--pomodoro-break);
}

/* Estados del panel */
.pomodoro-state {
  padding: var(--spacing-3);
  border-radius: var(--radius-base);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  text-align: center;
}

.pomodoro-state--active {
  background: var(--pomodoro-work-bg);
  color: var(--pomodoro-work);
}

.pomodoro-state--paused {
  background: var(--pomodoro-paused-bg);
  color: var(--pomodoro-paused);
  border: 1px solid var(--pomodoro-paused);
}

.pomodoro-state--warning {
  background: var(--color-orange-bg);
  color: var(--color-orange);
  border: 1px solid var(--color-orange);
}

.pomodoro-state--error {
  background: var(--color-red-bg);
  color: var(--pomodoro-work);
}

/* Historial */
.pomodoro-history {
  margin-top: var(--spacing-3);
}

.pomodoro-history-title {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--spacing-2);
}

.pomodoro-history-list {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-2);
}

.pomodoro-history-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-2);
  padding: var(--spacing-2);
  border-radius: var(--radius-sm);
  background: var(--color-bg-secondary);
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
}

.pomodoro-history-item .pomodoro-tomato {
  width: 12px;
  height: 12px;
}

/* ==================== RESPONSIVE ==================== */

/* ==================== PANEL DE TAREAS PAUSADAS ==================== */

/* Badge en botón del header */
#btnPausedTasks {
  position: relative;
}

.paused-tasks-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: var(--radius-full, 9999px);
  background: var(--pomodoro-paused);
  color: #000;
  font-size: 10px;
  font-weight: var(--font-weight-bold);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  pointer-events: none;
}

/* Estado activo del botón cuando el panel está abierto */
#btnPausedTasks.panel-open {
  background: var(--color-bg-active);
  color: var(--pomodoro-paused);
}

/* Panel flotante */
.paused-tasks-panel {
  position: fixed;
  top: calc(var(--header-height, 64px) + 4px);
  right: var(--spacing-4);
  width: 380px;
  max-height: 480px;
  background: var(--color-bg-primary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-dropdown);
  z-index: var(--z-dropdown);
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all var(--transition-base);
}

.paused-tasks-panel.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* Cabecera del panel */
.paused-tasks-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-3) var(--spacing-4);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.paused-tasks-panel-title {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
}

.paused-tasks-panel-count {
  font-size: var(--font-size-xs);
  color: var(--color-text-tertiary);
  background: var(--color-bg-tertiary);
  padding: 2px 8px;
  border-radius: var(--radius-full, 9999px);
}

/* Lista con scroll */
.paused-tasks-list {
  flex: 1;
  overflow-y: auto;
  padding: var(--spacing-2);
}

.paused-tasks-list::-webkit-scrollbar {
  width: 6px;
}

.paused-tasks-list::-webkit-scrollbar-track {
  background: transparent;
}

.paused-tasks-list::-webkit-scrollbar-thumb {
  background: var(--color-bg-active);
  border-radius: 3px;
}

/* Item de sesión pausada */
.paused-task-item {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-2);
  padding: var(--spacing-3);
  border-radius: var(--radius-base);
  border: 1px solid var(--color-border-subtle);
  margin-bottom: var(--spacing-2);
  transition: all var(--transition-fast);
  background: var(--color-bg-primary);
}

.paused-task-item:hover {
  border-color: var(--color-border);
  background: var(--color-bg-secondary);
}

.paused-task-item:last-child {
  margin-bottom: 0;
}

/* Nombre del proyecto */
.paused-task-project {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Título de la tarea */
.paused-task-title {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-primary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Sección de progreso */
.paused-task-progress {
  display: flex;
  align-items: center;
  gap: var(--spacing-2);
}

.paused-task-progress-bar {
  flex: 1;
  height: 4px;
  background: var(--color-bg-tertiary);
  border-radius: 2px;
  overflow: hidden;
}

.paused-task-progress-fill {
  height: 100%;
  background: var(--pomodoro-paused);
  border-radius: 2px;
  transition: width var(--transition-base);
}

.paused-task-time {
  font-size: var(--font-size-xs);
  font-variant-numeric: tabular-nums;
  color: var(--color-text-tertiary);
  white-space: nowrap;
}

/* Fila de botones de acción */
.paused-task-actions {
  display: flex;
  gap: var(--spacing-2);
  justify-content: flex-end;
}

.paused-task-btn {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-bg-primary);
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.paused-task-btn svg {
  pointer-events: none;
}

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

/* Botón reanudar */
.paused-task-btn-resume:hover {
  background: rgba(34, 197, 94, 0.1);
  border-color: var(--pomodoro-break);
  color: var(--pomodoro-break);
}

/* Botón completar */
.paused-task-btn-complete:hover {
  background: var(--color-blue-bg);
  border-color: var(--color-blue);
  color: var(--color-blue);
}

/* Botón descartar */
.paused-task-btn-discard:hover {
  background: var(--color-red-bg);
  border-color: var(--color-red);
  color: var(--color-red);
}

/* Estado vacío */
.paused-tasks-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-8) var(--spacing-4);
  color: var(--color-text-tertiary);
  text-align: center;
}

.paused-tasks-empty svg {
  margin-bottom: var(--spacing-3);
  opacity: 0.4;
}

.paused-tasks-empty-text {
  font-size: var(--font-size-sm);
}

/* ==================== RESPONSIVE ==================== */

@media (max-width: 768px) {
  .pomodoro-timer {
    bottom: var(--spacing-4);
    right: var(--spacing-4);
  }

  .pomodoro-timer-ring {
    --pomodoro-timer-size: 100px;
  }

  .pomodoro-time {
    font-size: var(--font-size-lg);
  }

  .paused-tasks-panel {
    width: calc(100vw - var(--spacing-4) * 2);
    right: var(--spacing-2);
  }
}
