/* Dynamic Levels CSS */

/* Header styles override */
.header__title {
  flex: 1;
  text-align: center;
  font-family: var(--font-family-heading);
  font-weight: 700;
  font-size: 16px;
  text-transform: uppercase;
  position: absolute;
  left: 0;
  right: 0;
  margin: 0 auto;
}

.header__nav {
  position: relative;
}

.back-button {
  position: relative;
  z-index: 1;
}

/* User ID display in top right corner */
.user-id-display {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  font-weight: 500;
  color: #333;
  background-color: rgba(0, 177, 49, 0.1);
  padding: 4px 8px;
  border-radius: 4px;
  z-index: 1;
}

#user-id-value {
  font-weight: 600;
  color: #00B131;
}

/* Loading states */
.loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(0, 177, 49, 0.2);
  border-radius: 50%;
  border-top-color: #00B131;
  animation: spin 1s ease-in-out infinite;
  margin: 0 auto;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-badge {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 112px;
  height: 112px;
  background-color: rgba(0, 0, 0, 0.05);
  border-radius: 50%;
}

.loading-bar {
  height: 8px;
  width: 100%;
  background: linear-gradient(90deg, #00B131 30%, rgba(0, 177, 49, 0.2) 30%);
  background-size: 200% 100%;
  animation: loading-bar-animation 1.5s ease-in-out infinite;
  border-radius: 4px;
}

@keyframes loading-bar-animation {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

.loading-benefits {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 0;
  color: #8F8F8F;
  text-align: center;
}

.loading-benefits p {
  margin-top: 16px;
  font-size: 14px;
}

/* Level-specific styling */
body.level-1 {
  --level-color: #00B131;
}

body.level-2 {
  --level-color: #00B131;
}

body.level-3 {
  --level-color: #00B131;
}

body.level-4 {
  --level-color: #00B131;
}

/* Error states */
.error-badge {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 112px;
  height: 112px;
  background-color: rgba(255, 0, 0, 0.1);
  border: 2px solid rgba(255, 0, 0, 0.3);
  border-radius: 50%;
  color: #ff0000;
  font-size: 12px;
  text-align: center;
  padding: 10px;
}

/* Transitions for smooth level changes */
.level-info__value,
.progress-bar__segment,
.level-card {
  transition: all 0.3s ease-in-out;
}

/* Match static page styles */
.benefits-container {
  margin-top: 32px;
}

.benefits-header {
  margin-bottom: 24px;
}

.benefits-header__title {
  font-family: var(--font-family-heading);
  font-weight: 700;
  font-size: 24px;
  color: var(--color-text);
  margin-bottom: 8px;
}

.benefits-header__subtitle {
  color: var(--color-text-secondary);
  font-size: 14px;
}

.level-cards {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Progress bar container and segments */
.progress-bar-container {
  margin: 24px 0;
}

.progress-bar {
  display: flex;
  gap: 4px;
  width: 100%;
}

.progress-bar__segment {
  flex: 1;
  height: 8px;
  background-color: #E0E0E0; /* Default unfilled color */
  border-radius: 4px;
  transition: background-color 0.3s ease;
}

.progress-bar__segment--filled {
  background-color: #00B131; /* Green color for filled segments (paid on time) */
}

.progress-bar__segment--late {
  background-color: #FF4D4D; /* Red color for late payments */
}

.progress-bar__segment--open {
  background-color: #FFFFFF; /* Gray color for open installments */
}

/* Loading animation for progress bar */
.progress-bar--loading .progress-bar__segment {
  animation: pulse 1.5s infinite alternate;
  background-color: rgba(0, 177, 49, 0.2);
}

@keyframes pulse {
  0% { opacity: 0.3; }
  100% { opacity: 0.7; }
}

/* Style for dynamically generated level cards to match static page */
.level-card {
  background-color: var(--color-surface);
  border-radius: 8px;
  padding: 16px;
  border: 1px solid var(--color-border);
}

.level-card__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.level-card__title {
  font-family: var(--font-family-heading);
  font-weight: 700;
  font-size: 18px;
  color: var(--color-text);
}

.level-card__badge {
  background-color: var(--color-primary);
  color: var(--color-text);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  font-family: var(--font-family-heading);
  font-weight: 700;
  font-size: 14px;
}

.level-card__benefits {
  list-style: none;
}

.level-card__benefit {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
  color: var(--color-text-secondary);
  font-size: 14px;
}

.level-card__benefit-icon {
  color: var(--color-primary);
  flex-shrink: 0;
  margin-top: 3px;
}

/* Current level card highlight */
.level-card--current {
  border: 1px solid var(--color-primary);
  position: relative;
}

.level-card--current::before {
  content: "Nível atual";
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--color-primary);
  color: var(--color-text);
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
}

/* Error message */
.error-message {
  text-align: center;
  color: #ff6b6b;
  padding: 24px 0;
}

/* Level status card for max level */
.level-status-card {
  background-color: var(--color-surface);
  border-radius: 8px;
  padding: 16px;
  margin-top: 24px;
  text-align: center;
  border: 1px solid var(--color-primary);
}

.level-status-card__text {
  color: var(--color-text);
  font-size: 16px;
}

.level-status-card__text strong {
  color: var(--color-primary);
}

/* Responsive adjustments */
@media (max-width: 390px) {
  .loading-badge {
    width: 90px;
    height: 90px;
  }
  
  .loading-spinner {
    width: 30px;
    height: 30px;
  }
}
