@use '../../../shared/styles/settings-shared' as settings;

.main-container {
  width: 100%;
  padding: 1rem;
  height: calc(100dvh - 10.5rem);
  overflow-y: auto;

  @media (min-width: 768px) {
    height: calc(100dvh - 11.65rem);
  }
}

@include settings.settings-page-header;

.settings-header {
  .header-content {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 2rem;

    @media (max-width: 768px) {
      flex-direction: column;
      gap: 1rem;
    }
  }

  .header-text {
    flex: 1;
  }
}

.settings-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--p-text-color);
  margin: 0 0 0.75rem 0;

  .pi {
    color: var(--p-primary-color);
    font-size: 1.25rem;
  }
}

.settings-description {
  color: var(--p-text-muted-color);
  font-size: 0.875rem;
  line-height: 1.5;
  margin-bottom: 0;
}

.settings-content {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

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

.section-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--p-text-color);
  margin: 0 0 0.5rem 0;

  .pi {
    color: var(--p-primary-color);
  }

  .font-count {
    color: var(--p-text-muted-color);
    font-size: 1rem;
    font-weight: 500;
  }
}

.section-description {
  color: var(--p-text-muted-color);
  font-size: 0.875rem;
  line-height: 1.5;
  margin: 0;
}

.settings-card {
  border: 1px solid var(--p-content-border-color);
  border-radius: 8px;
  background: var(--p-content-background);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

// ==================== Empty State ====================
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 3rem 1.5rem;
  min-height: 300px;

  .empty-icon-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 80px;
    background: color-mix(in srgb, var(--p-primary-color) 10%, transparent);
    border-radius: 50%;
    margin-bottom: 1.5rem;
    border: 3px dashed var(--p-primary-color);

    .empty-icon {
      font-size: 2.5rem;
      color: var(--p-primary-color);
      opacity: 0.7;
    }
  }

  .empty-title {
    margin: 0 0 0.75rem 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--p-text-color);
  }

  .empty-description {
    margin: 0 0 1rem 0;
    font-size: 0.9375rem;
    color: var(--p-text-muted-color);
    max-width: 500px;
    line-height: 1.6;
  }

  .empty-hint {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin: 0;
    padding: 0.75rem 1.25rem;
    background: color-mix(in srgb, var(--p-primary-color) 5%, transparent);
    border: 1px solid color-mix(in srgb, var(--p-primary-color) 20%, transparent);
    border-radius: 6px;
    font-size: 0.875rem;
    color: var(--p-text-muted-color);
    max-width: 500px;

    i {
      color: var(--p-primary-color);
      font-size: 0.875rem;
      flex-shrink: 0;
    }

    strong {
      color: var(--p-text-color);
      font-weight: 600;
    }
  }

  @media (max-width: 768px) {
    padding: 2rem 1rem;
    min-height: 250px;

    .empty-icon-wrapper {
      width: 70px;
      height: 70px;
      margin-bottom: 1rem;

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

    .empty-title {
      font-size: 1.125rem;
    }

    .empty-description {
      font-size: 0.875rem;
      max-width: 100%;
    }

    .empty-hint {
      font-size: 0.75rem;
      padding: 0.625rem 1rem;
      max-width: 100%;
      flex-direction: column;
      text-align: center;
      gap: 0.375rem;
    }
  }
}

// ==================== Fonts Grid ====================
.fonts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 1.5rem;

  @media (max-width: 768px) {
    grid-template-columns: 1fr;
  }
}

// ==================== Font Card ====================
.font-card {
  padding: 0;
  gap: 0;

  .font-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem 1rem 0.75rem;
    border-bottom: 1px solid var(--p-content-border-color);

    .font-title-group {
      flex: 1;
      display: flex;
      align-items: center;
      gap: 0.75rem;
      flex-wrap: wrap;

      .font-name {
        margin: 0;
        font-size: 1rem;
        font-weight: 600;
        color: var(--p-text-color);
      }

      .format-tag {
        display: inline-block;
        padding: 0.1875rem 0.5rem;
        border-radius: 4px;
        background: transparent;
        border: 1px solid var(--p-primary-color);
        color: var(--p-primary-color);
        font-size: 0.6875rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.025em;
      }
    }
  }

  .font-preview-area {
    padding: 1rem;
    border-bottom: 1px solid var(--p-content-border-color);

    .preview-label {
      display: flex;
      align-items: center;
      gap: 0.375rem;
      font-size: 0.75rem;
      font-weight: 600;
      color: var(--p-text-muted-color);
      text-transform: uppercase;
      letter-spacing: 0.025em;
      margin-bottom: 0.75rem;

      i {
        font-size: 0.75rem;
      }
    }

    .font-preview {
      padding: 1rem;
      border: 1px solid var(--p-content-border-color);
      border-radius: 6px;
      background: color-mix(in srgb, var(--p-surface-ground) 30%, var(--p-content-background));
      display: flex;
      flex-direction: column;
      gap: 0.75rem;

      .preview-paragraph {
        color: var(--p-text-color);
        font-size: 0.9375rem;
        line-height: 1.7;
        margin: 0;
        text-align: justify;
        font-weight: 400;
      }

      .preview-paragraph-small {
        color: var(--p-text-color);
        font-size: 0.875rem;
        line-height: 1.6;
        margin: 0;
        text-align: justify;
        font-weight: 400;
      }

      .preview-characters {
        display: flex;
        flex-direction: column;
        gap: 0.25rem;
        padding-top: 0.5rem;
        margin-top: 0.25rem;
        border-top: 1px solid var(--p-content-border-color);

        span {
          font-size: 0.6875rem;
          color: var(--p-text-muted-color);
          letter-spacing: 0.025em;
          font-weight: 400;
        }
      }
    }

    .font-preview-skeleton {
      padding: 1rem;
      border: 1px solid var(--p-content-border-color);
      border-radius: 6px;
      background: color-mix(in srgb, var(--p-surface-ground) 30%, var(--p-content-background));
      display: flex;
      flex-direction: column;
      gap: 0.75rem;
    }
  }

  .font-metadata {
    padding: 1rem;
    background: color-mix(in srgb, var(--p-surface-ground) 20%, var(--p-content-background));

    .metadata-row {
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 1rem;
      padding: 0.375rem 0;

      &:not(:last-child) {
        border-bottom: 1px solid var(--p-content-border-color);
      }

      .meta-label {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        font-size: 0.875rem;
        color: var(--p-text-muted-color);
        font-weight: 500;

        i {
          color: var(--p-primary-color);
          font-size: 0.75rem;
        }
      }

      .meta-value {
        font-size: 0.875rem;
        color: var(--p-text-color);
        font-weight: 500;
        text-align: right;
        word-break: break-word;
      }
    }
  }
}

.float-top-right {
  position: absolute;
  top: -0.5rem;
  right: -0.5rem;
  z-index: 10;
}
