/* ═════════════════════════════════════════════════════════════════════════════ */
/*                      API CLIENT — LOADING STATES                             */
/*            Estados visuais para requisições HTTP e feedback                   */
/* ═════════════════════════════════════════════════════════════════════════════ */

/* ═════════════════════════════════════════════════════════════════════════════ */
/*                          BUTTON LOADING STATE                                */
/* ═════════════════════════════════════════════════════════════════════════════ */

button.loading {
  position: relative;
  color: transparent;
}

button.loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  top: 50%;
  left: 50%;
  margin-left: -8px;
  margin-top: -8px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

button.loading:disabled {
  opacity: 0.8;
  cursor: wait;
}

/* ═════════════════════════════════════════════════════════════════════════════ */
/*                          REQUEST SKELETON (Shimmer effect)                   */
/* ═════════════════════════════════════════════════════════════════════════════ */

.skeleton {
  background: linear-gradient(
    90deg,
    #f3f4f6 0%,
    #e5e7eb 50%,
    #f3f4f6 100%
  );
  background-size: 200% 100%;
  animation: shimmer 2s infinite;
  border-radius: 4px;
  font-family: Verdana, sans-serif;
  letter-spacing: 1pt;
}

.skeleton-text {
  height: 1rem;
  width: 100%;
  margin-bottom: 0.5rem;
}

.skeleton-title {
  height: 1.5rem;
  width: 60%;
  margin-bottom: 1rem;
}

.skeleton-image {
  height: 200px;
  width: 100%;
  margin-bottom: 1rem;
}

.skeleton-card {
  padding: 1rem;
  border-radius: 6px;
}

@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

/* ═════════════════════════════════════════════════════════════════════════════ */
/*                          REQUEST OVERLAY (Bloqueio durante requisição)       */
/* ═════════════════════════════════════════════════════════════════════════════ */

.request-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(2px);
  font-family: Verdana, sans-serif;
  letter-spacing: 1pt;
}

.request-overlay.hidden {
  display: none;
}

.request-loading {
  background: white;
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  text-align: center;
  font-family: Verdana, sans-serif;
  letter-spacing: 1pt;
}

.request-loading-spinner {
  width: 48px;
  height: 48px;
  margin: 0 auto 1rem;
  border: 4px solid #e5e7eb;
  border-top-color: #3caa6e;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.request-loading-text {
  margin: 0;
  color: #6b7280;
  font-size: 0.95rem;
  font-family: Verdana, sans-serif;
  letter-spacing: 1pt;
}

/* ═════════════════════════════════════════════════════════════════════════════ */
/*                          ERROR STATE                                         */
/* ═════════════════════════════════════════════════════════════════════════════ */

.error-state {
  padding: 2rem;
  text-align: center;
  border-radius: 8px;
  background: #fef2f2;
  border: 1px solid #fca5a5;
  font-family: Verdana, sans-serif;
  letter-spacing: 1pt;
}

.error-state-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.error-state-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: #991b1b;
  margin: 0 0 0.5rem 0;
  font-family: Verdana, sans-serif;
  letter-spacing: 1pt;
}

.error-state-message {
  color: #dc2626;
  margin: 0 0 1.5rem 0;
  line-height: 1.5;
  font-family: Verdana, sans-serif;
  letter-spacing: 1pt;
}

.error-state-action {
  display: inline-block;
}

.error-state-action .btn {
  margin: 0 0.5rem;
  font-family: Verdana, sans-serif;
  letter-spacing: 1pt;
}

/* ═════════════════════════════════════════════════════════════════════════════ */
/*                          EMPTY STATE                                         */
/* ═════════════════════════════════════════════════════════════════════════════ */

.empty-state {
  padding: 3rem 2rem;
  text-align: center;
  color: #6b7280;
  font-family: Verdana, sans-serif;
  letter-spacing: 1pt;
}

.empty-state-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.empty-state-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: #1f2937;
  margin: 0 0 0.5rem 0;
  font-family: Verdana, sans-serif;
  letter-spacing: 1pt;
}

.empty-state-message {
  margin: 0 0 1.5rem 0;
  line-height: 1.5;
  font-family: Verdana, sans-serif;
  letter-spacing: 1pt;
}

.empty-state-action {
  display: inline-block;
}

.empty-state-action .btn {
  font-family: Verdana, sans-serif;
  letter-spacing: 1pt;
}

/* ═════════════════════════════════════════════════════════════════════════════ */
/*                          DARK MODE                                           */
/* ═════════════════════════════════════════════════════════════════════════════ */

:root[data-theme="dark"] .skeleton {
  background: linear-gradient(
    90deg,
    #1a2548 0%,
    #111b3c 50%,
    #1a2548 100%
  );
}

:root[data-theme="dark"] .request-loading {
  background: #111b3c;
  color: #e8ecf1;
}

:root[data-theme="dark"] .request-loading-text {
  color: #a0aec0;
}

:root[data-theme="dark"] .error-state {
  background: #2f0f0f;
  border-color: rgba(239, 68, 68, 0.2);
}

:root[data-theme="dark"] .error-state-title {
  color: #f87171;
}

:root[data-theme="dark"] .error-state-message {
  color: #fecaca;
}

:root[data-theme="dark"] .empty-state {
  color: #64748b;
}

:root[data-theme="dark"] .empty-state-title {
  color: #e8ecf1;
}

/* ═════════════════════════════════════════════════════════════════════════════ */
/*                          CONTENT TRANSITIONS                                 */
/* ═════════════════════════════════════════════════════════════════════════════ */

.content-fade-in {
  animation: fadeIn 0.3s ease-in-out;
}

.content-fade-out {
  animation: fadeOut 0.3s ease-in-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

/* ═════════════════════════════════════════════════════════════════════════════ */
/*                          REQUEST PROGRESS INDICATOR                          */
/* ═════════════════════════════════════════════════════════════════════════════ */

.request-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: linear-gradient(90deg, #3caa6e, #0693e3, #9b51e0);
  animation: progressBar 2s ease-in-out infinite;
  z-index: 9998;
}

.request-progress.hidden {
  display: none;
}

@keyframes progressBar {
  0% {
    width: 0;
  }
  50% {
    width: 70%;
  }
  100% {
    width: 100%;
  }
}

/* ═════════════════════════════════════════════════════════════════════════════ */
/*                          ACCESSIBLE FOCUS                                    */
/* ═════════════════════════════════════════════════════════════════════════════ */

button.loading:focus {
  outline: 2px solid #3caa6e;
  outline-offset: 2px;
}

/* ═════════════════════════════════════════════════════════════════════════════ */
/*                          RESPONSIVE                                          */
/* ═════════════════════════════════════════════════════════════════════════════ */

@media (max-width: 640px) {
  .request-loading {
    margin: 1rem;
    width: calc(100% - 2rem);
  }

  .error-state,
  .empty-state {
    padding: 2rem 1rem;
  }

  .error-state-icon,
  .empty-state-icon {
    font-size: 2.5rem;
  }

  .error-state-title,
  .empty-state-title {
    font-size: 1.1rem;
  }
}

/* ═════════════════════════════════════════════════════════════════════════════ */
/*                          REDUCE MOTION                                       */
/* ═════════════════════════════════════════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {
  .skeleton,
  .request-loading-spinner,
  .request-progress,
  .content-fade-in,
  .content-fade-out {
    animation: none;
  }
}
