/* === STILI SEZIONE BATTITI CARDIACI === */

.heart-rate-section {
  margin-bottom: 30px;
}

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

.heart-rate-header h2 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: bold;
  color: #333;
}

.heart-rate-toggle-btn {
  background: var(--color-primary-500);
  color: white;
  border: 1px solid var(--color-primary-500);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.3s ease;
}

.heart-rate-toggle-btn:hover {
  background: var(--color-primary-600);
  border-color: var(--color-primary-600);
  transform: translateY(-1px);
}

.heart-rate-content {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  border-radius: 20px;
  padding: 28px;
  box-shadow:
    0 10px 40px rgba(0, 0, 0, 0.12),
    0 4px 16px rgba(229, 62, 62, 0.08);
  position: relative;
  z-index: var(--z-above);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

/* Bottoni rapidi per accesso diretto ai form */
.heart-rate-quick-btn {
  background: linear-gradient(135deg, var(--color-error), var(--color-error));
  color: white;
  border: none;
  padding: 0.5rem 0.8rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.3s ease;
  white-space: nowrap;
}

.heart-rate-quick-btn:hover {
  background: linear-gradient(
    135deg,
    var(--color-error-dark),
    var(--color-error)
  );
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(229, 62, 62, 0.3);
}

/* Contenitore bottoni rapidi dentro heart-rate-content */
.heart-rate-quick-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid rgba(229, 62, 62, 0.2);
}

.heart-rate-content::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(
    90deg,
    var(--color-error),
    var(--color-error-dark),
    var(--color-error)
  );
  background-size: 200% 100%;
  animation: gradientShift 3s ease infinite;
  border-radius: 20px 20px 0 0;
}

@keyframes gradientShift {
  0%,
  100% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
}

/* Form inserimento */
.heart-rate-input-section {
  padding: 20px;
  background: white;
  border-radius: 12px;
  margin-bottom: 30px;
  position: relative;
  z-index: var(--z-raised);
}

.heart-rate-input-section h3 {
  margin: 0 0 20px 0;
  color: var(--color-gray-900);
  font-size: 1.2rem;
}

.heart-rate-input-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
  align-items: end;
}

.heart-rate-input-form .form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.heart-rate-input-form label {
  font-weight: 600;
  color: var(--color-gray-700);
  font-size: 14px;
}

.heart-rate-input-form .form-input {
  padding: 14px 16px;
  border: 2px solid var(--color-gray-200);
  border-radius: 12px;
  font-size: 16px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  background: var(--color-gray-50);
  font-weight: 500;
}

.heart-rate-input-form .form-input:hover {
  border-color: var(--color-gray-300);
  background: #fff;
}

.heart-rate-input-form .form-input:focus {
  outline: none;
  border-color: var(--color-error);
  background: #fff;
  box-shadow:
    0 0 0 4px rgba(229, 62, 62, 0.1),
    0 4px 12px rgba(229, 62, 62, 0.15);
  transform: translateY(-1px);
}

.heart-rate-input-form .save-btn {
  padding: 14px 28px;
  background: linear-gradient(
    135deg,
    var(--color-error) 0%,
    var(--color-error-dark) 100%
  );
  color: white;
  border: none;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 14px rgba(229, 62, 62, 0.4);
  position: relative;
  overflow: hidden;
}

.heart-rate-input-form .save-btn::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.3),
    transparent
  );
  transition: left 0.5s;
}

.heart-rate-input-form .save-btn:hover::before {
  left: 100%;
}

.heart-rate-input-form .save-btn:hover {
  background: linear-gradient(135deg, var(--color-error-dark) 0%, #9b2c2c 100%);
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(229, 62, 62, 0.5);
}

.heart-rate-input-form .save-btn:active {
  transform: translateY(-1px);
}

.heart-rate-note {
  margin-top: 15px;
  padding: 12px;
  background: var(--color-gray-100);
  border-left: 3px solid var(--color-primary-500);
  border-radius: 4px;
  font-size: 14px;
  color: var(--color-gray-700);
}

/* Controllo Granularità */
.granularity-control {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 25px auto 30px auto;
  padding: 14px 20px;
  background: linear-gradient(
    135deg,
    var(--color-error-light) 0%,
    var(--color-error-light) 100%
  );
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  position: relative;
  z-index: var(--z-raised);
  clear: both;
  width: fit-content;
  display: flex;
}

.granularity-control label {
  font-weight: 700;
  color: var(--color-error-dark);
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.granularity-select {
  padding: 10px 16px;
  border: 2px solid var(--color-error);
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  background: white;
  color: var(--color-error-dark);
  cursor: pointer;
  transition: all 0.3s;
  min-width: 180px;
}

.granularity-select:hover {
  border-color: var(--color-error-dark);
  box-shadow: 0 2px 8px rgba(229, 62, 62, 0.2);
}

.granularity-select:focus {
  outline: none;
  border-color: var(--color-error-dark);
  box-shadow: 0 0 0 3px rgba(229, 62, 62, 0.15);
}

/* Grafici */
.heart-rate-charts-section {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 30px;
  position: relative;
  z-index: var(--z-above);
  clear: both;
}

.chart-container-full {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  width: 100%;
  position: relative;
  z-index: var(--z-above);
  border: 2px solid rgba(226, 232, 240, 0.5);
}

.chart-header {
  margin-bottom: 15px;
}

.chart-header h3 {
  margin: 0;
  color: var(--color-gray-900);
  font-size: 1.1rem;
}

/* Statistiche */
.heart-rate-stats-section {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 15px;
  margin-bottom: 30px;
  position: relative;
  z-index: var(--z-raised);
  clear: both;
}

.heart-rate-stats-section .stat-card {
  background: linear-gradient(
    135deg,
    rgba(255, 245, 245, 0.95),
    rgba(254, 215, 215, 0.95)
  );
  backdrop-filter: blur(10px);
  border-radius: 16px;
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 15px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  min-height: 120px;
  border: 2px solid rgba(229, 62, 62, 0.1);
}

.heart-rate-stats-section .stat-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(229, 62, 62, 0.2);
  border-color: rgba(229, 62, 62, 0.3);
}

.heart-rate-stats-section .stat-icon {
  font-size: 2rem;
  flex-shrink: 0;
}

.heart-rate-stats-section .stat-content {
  flex: 1;
  min-width: 0;
}

.heart-rate-stats-section .stat-label {
  font-size: 0.75rem;
  color: var(--color-error-dark);
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 12px;
  letter-spacing: 1px;
}

.heart-rate-stats-section .stat-value {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--color-error-dark);
  line-height: 1;
}

.heart-rate-stats-section .stat-unit {
  font-size: 0.9rem;
  color: #9b2c2c;
  font-weight: 500;
  margin-top: 4px;
}

/* Stat card per min/max */
.heart-rate-stats-section .stat-minmax {
  display: flex;
  gap: 15px;
  align-items: center;
  justify-content: center;
  margin-top: 8px;
}

.heart-rate-stats-section .stat-min,
.heart-rate-stats-section .stat-max {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.heart-rate-stats-section .stat-min-label,
.heart-rate-stats-section .stat-max-label {
  font-size: 0.65rem;
  color: var(--color-error-dark) !important;
  font-weight: 600;
  text-transform: uppercase;
}

.heart-rate-stats-section .stat-min-value,
.heart-rate-stats-section .stat-max-value {
  font-size: 1.3rem;
  font-weight: bold;
  color: var(--color-error-dark) !important;
}

/* Storico */
.heart-rate-history-section {
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px solid var(--color-gray-200);
  position: relative;
  z-index: var(--z-above);
  clear: both;
}

.heart-rate-history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.heart-rate-history-header h4 {
  margin: 0;
  color: var(--color-gray-900);
  font-size: 1.3rem;
  font-weight: 700;
}

.history-buttons {
  display: flex;
  gap: 10px;
}

.export-btn {
  padding: 8px 16px;
  background: var(--color-success);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.3s;
}

.export-btn:hover {
  background: var(--color-success-dark);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(72, 187, 120, 0.3);
}

.heart-rate-history-toggle-btn {
  padding: 8px 16px;
  background: var(--color-primary-500);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.3s;
}

.heart-rate-history-toggle-btn:hover {
  background: var(--color-primary-600);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px var(--color-primary-200);
}

.heart-rate-history-list {
  max-height: 400px;
  overflow-y: auto;
}

.heart-rate-history-item {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr auto;
  gap: 15px;
  align-items: center;
  padding: 18px 20px;
  margin-bottom: 10px;
  border-radius: 14px;
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.9),
    rgba(247, 250, 252, 0.9)
  );
  backdrop-filter: blur(10px);
  border: 2px solid rgba(226, 232, 240, 0.5);
  border-left: 5px solid var(--color-error);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  position: relative;
  overflow: hidden;
}

.heart-rate-history-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 5px;
  background: linear-gradient(
    135deg,
    var(--color-error),
    var(--color-error-dark)
  );
  opacity: 0;
  transition: opacity 0.3s ease;
}

.heart-rate-history-item:hover {
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 1),
    rgba(247, 250, 252, 1)
  );
  transform: translateX(6px) translateY(-2px);
  box-shadow: 0 6px 20px rgba(229, 62, 62, 0.15);
  border-color: rgba(229, 62, 62, 0.3);
}

.heart-rate-history-item:hover::before {
  opacity: 1;
}

.heart-rate-history-date {
  font-weight: 500;
  color: var(--color-gray-900);
}

.heart-rate-history-time {
  color: var(--color-gray-700);
  font-size: 0.9rem;
}

.heart-rate-history-value {
  font-weight: bold;
  color: var(--color-error);
  font-size: 1.1rem;
}

.heart-rate-history-type {
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  text-align: center;
  background: var(--color-gray-100);
  color: var(--color-gray-700);
}

.heart-rate-history-actions {
  display: flex;
  gap: 8px;
}

.edit-heart-rate-btn {
  background: rgba(226, 232, 240, 0.5);
  border: 2px solid rgba(203, 213, 224, 0.5);
  color: var(--color-info);
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 16px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(5px);
}

.edit-heart-rate-btn:hover {
  background: linear-gradient(
    135deg,
    rgba(59, 130, 246, 0.15),
    rgba(37, 99, 235, 0.15)
  );
  border-color: #3b82f6;
  transform: scale(1.15) rotate(-5deg);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.delete-heart-rate-btn {
  background: rgba(226, 232, 240, 0.5);
  border: 2px solid rgba(203, 213, 224, 0.5);
  color: var(--color-error);
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 16px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(5px);
}

.delete-heart-rate-btn:hover {
  background: linear-gradient(
    135deg,
    rgba(239, 68, 68, 0.15),
    rgba(220, 38, 38, 0.15)
  );
  border-color: var(--color-error);
  transform: scale(1.15) rotate(5deg);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.no-data {
  text-align: center;
  padding: 40px;
  color: var(--color-gray-400);
  font-style: italic;
}

/* Responsive */
@media (max-width: 768px) {
  .heart-rate-header {
    flex-direction: column;
    gap: 15px;
    text-align: center;
  }

  .heart-rate-input-form {
    grid-template-columns: 1fr;
  }

  .granularity-control {
    flex-direction: column;
    align-items: flex-start;
  }

  .granularity-select {
    width: 100%;
  }

  .heart-rate-stats-section {
    grid-template-columns: repeat(2, 1fr);
  }

  .stat-minmax {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .heart-rate-history-item {
    grid-template-columns: 1fr;
    gap: 8px;
    text-align: center;
  }

  .heart-rate-history-actions {
    justify-content: center;
  }

  .history-buttons {
    flex-direction: column;
    width: 100%;
  }

  .export-btn,
  .heart-rate-history-toggle-btn {
    width: 100%;
  }
}
