/* ==============================================================================
   AniList Integration Styles (anime.4umovies.site)
   Features: Header Widget, Profile Modal, Completed Stats, Anime Grid
   ============================================================================== */

:root {
  --al-blue: #02a9ff;
  --al-blue-hover: #0093e0;
  --al-blue-glow: rgba(2, 169, 255, 0.35);
  --al-bg: #151922;
  --al-card-bg: #11161d;
  --al-border: rgba(255, 255, 255, 0.08);
}

/* Header Nav Button & Pill */
.anilist-header-widget {
  display: flex;
  align-items: center;
  margin-left: 6px;
}

.anilist-login-nav-btn {
  background: rgba(2, 169, 255, 0.12);
  border: 1px solid rgba(2, 169, 255, 0.35);
  color: #02a9ff;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.anilist-login-nav-btn:hover {
  background: #02a9ff;
  color: #000;
  box-shadow: 0 0 16px var(--al-blue-glow);
  transform: translateY(-1px);
}

.anilist-login-nav-btn svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.anilist-profile-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid rgba(2, 169, 255, 0.3);
  padding: 4px 12px 4px 5px;
  border-radius: 30px;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.anilist-profile-pill:hover {
  border-color: #02a9ff;
  background: rgba(2, 169, 255, 0.1);
  box-shadow: 0 0 16px rgba(2, 169, 255, 0.2);
  transform: translateY(-1px);
}

.al-pill-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid #02a9ff;
  background: #000;
}

.al-pill-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.al-pill-name {
  font-size: 0.8rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.al-pill-completed {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Modal Overlay */
.anilist-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 2500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.anilist-modal-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.anilist-modal-card {
  background: #0f1318;
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
  max-width: 840px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.9);
  position: relative;
  transform: scale(0.96);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.anilist-modal-overlay.show .anilist-modal-card {
  transform: scale(1);
}

.anilist-modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 1.3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 100;
  transition: all 0.2s;
}

.anilist-modal-close:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: rotate(90deg);
}

.anilist-modal-body {
  overflow-y: auto;
  flex: 1;
  padding: 0;
}

/* Login View in Modal */
.al-login-view {
  padding: 40px 32px;
  max-width: 520px;
  margin: 0 auto;
  text-align: center;
}

.al-brand-banner {
  margin-bottom: 28px;
}

.al-logo-circle {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  background: rgba(2, 169, 255, 0.12);
  border: 1.5px solid rgba(2, 169, 255, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  box-shadow: 0 0 24px rgba(2, 169, 255, 0.25);
}

.al-brand-banner h2 {
  font-size: 1.6rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 8px;
}

.al-brand-banner p {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.al-login-tabs {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px;
  margin-bottom: 24px;
  gap: 4px;
}

.al-tab-btn {
  flex: 1;
  padding: 8px 14px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 700;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.al-tab-btn.active {
  background: #02a9ff;
  color: #000;
}

.al-input-group {
  text-align: left;
  margin-bottom: 20px;
}

.al-input-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 8px;
}

.al-input-wrap {
  position: relative;
  width: 100%;
}

.al-input-wrap i {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  font-size: 0.9rem;
}

.al-input-wrap input {
  width: 100%;
  height: 44px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 16px 0 42px;
  color: #fff;
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}

.al-input-wrap input:focus {
  border-color: #02a9ff;
  box-shadow: 0 0 0 3px rgba(2, 169, 255, 0.2);
}

.al-hint {
  display: block;
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.4;
}

.al-hint a {
  color: #02a9ff;
  text-decoration: underline;
}

.al-submit-btn {
  width: 100%;
  height: 44px;
  background: linear-gradient(135deg, #02a9ff 0%, #0077b6 100%);
  border: none;
  border-radius: 8px;
  color: #fff;
  font-size: 0.92rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 20px rgba(2, 169, 255, 0.35);
  transition: all 0.2s;
}

.al-submit-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(2, 169, 255, 0.5);
}

.al-submit-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.al-error-box {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #f87171;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 0.8rem;
  margin-top: 16px;
  text-align: left;
}

/* Logged-In Profile View */
.al-profile-hero {
  position: relative;
  min-height: 160px;
  background-size: cover;
  background-position: center;
  background-color: #1a202c;
  padding: 24px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
}

.al-hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(15, 19, 24, 0.3) 0%, rgba(15, 19, 24, 0.95) 100%);
}

.al-hero-info {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 16px;
}

.al-avatar-lg {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 3px solid #02a9ff;
  object-fit: cover;
  background: #000;
  box-shadow: 0 0 20px rgba(2, 169, 255, 0.4);
}

.al-user-text h3 {
  font-size: 1.35rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 4px;
}

.al-user-name-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.al-link-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  font-weight: 700;
  background: rgba(2, 169, 255, 0.15);
  border: 1px solid rgba(2, 169, 255, 0.3);
  color: #02a9ff;
  padding: 2px 8px;
  border-radius: 12px;
  transition: all 0.2s;
}

.al-link-badge:hover {
  background: #02a9ff;
  color: #000;
}

.al-user-bio {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.al-hero-actions {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 8px;
}

.al-btn-icon {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
  transition: all 0.2s;
}

.al-btn-icon:hover {
  background: rgba(255, 255, 255, 0.2);
}

.al-btn-icon.danger {
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.3);
}

.al-btn-icon.danger:hover {
  background: rgba(239, 68, 68, 0.2);
}

/* Stats Cards Grid */
.al-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  padding: 16px 24px;
  background: #12161d;
  border-bottom: 1px solid var(--border);
}

.al-stat-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  text-align: center;
  transition: all 0.2s;
}

.al-stat-box.primary {
  background: rgba(0, 229, 155, 0.08);
  border-color: rgba(0, 229, 155, 0.4);
}

.al-stat-box.primary .al-stat-val {
  color: var(--primary);
  text-shadow: 0 0 14px var(--primary-glow);
}

.al-stat-icon {
  font-size: 1rem;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.al-stat-box.primary .al-stat-icon {
  color: var(--primary);
}

.al-stat-val {
  font-size: 1.35rem;
  font-weight: 800;
  font-family: 'Space Grotesk', sans-serif;
  color: #fff;
  line-height: 1.15;
}

.al-stat-lbl {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 3px;
  font-weight: 500;
}

/* Anime Lists Section */
.al-lists-section {
  padding: 16px 24px 24px;
}

.al-lists-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.al-sub-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.al-sub-tab {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 700;
  font-family: inherit;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.al-sub-tab:hover {
  color: #fff;
}

.al-sub-tab.active {
  background: #02a9ff;
  border-color: #02a9ff;
  color: #000;
  box-shadow: 0 0 10px rgba(2, 169, 255, 0.4);
}

.al-sub-tab[data-status="COMPLETED"].active {
  background: var(--primary);
  border-color: var(--primary);
  color: #000;
  box-shadow: 0 0 10px var(--primary-glow);
}

.al-list-search-wrap {
  position: relative;
  min-width: 180px;
}

.al-list-search-wrap i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  font-size: 0.8rem;
}

.al-list-search-wrap input {
  width: 100%;
  height: 34px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 12px 0 32px;
  color: #fff;
  font-size: 0.8rem;
  font-family: inherit;
  outline: none;
}

.al-list-search-wrap input:focus {
  border-color: #02a9ff;
}

/* Anime Cards Grid in Modal */
.al-entries-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
  max-height: 360px;
  overflow-y: auto;
  padding-right: 4px;
}

.al-anime-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
}

.al-anime-card:hover {
  transform: translateY(-3px);
  border-color: var(--primary);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.7);
}

.al-card-poster {
  position: relative;
  width: 100%;
  padding-top: 140%;
  background: #000;
  overflow: hidden;
}

.al-card-poster img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.al-anime-card:hover .al-card-poster img {
  transform: scale(1.06);
}

.al-card-score {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(0, 0, 0, 0.8);
  border: 1px solid rgba(255, 193, 7, 0.3);
  color: #ffc107;
  font-size: 0.68rem;
  font-weight: 800;
  padding: 2px 5px;
  border-radius: 4px;
}

.al-card-play-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  font-size: 1.5rem;
  opacity: 0;
  transition: opacity 0.2s;
}

.al-anime-card:hover .al-card-play-overlay {
  opacity: 1;
}

.al-card-detail {
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  flex: 1;
}

.al-card-title {
  font-size: 0.76rem;
  font-weight: 600;
  color: #fff;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 4px;
}

.al-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.68rem;
  color: var(--text-muted);
}

.al-badge-status {
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.62rem;
  font-weight: 700;
}

.al-badge-status.completed {
  background: rgba(0, 229, 155, 0.15);
  color: var(--primary);
}

.al-badge-status.current {
  background: rgba(2, 169, 255, 0.15);
  color: #02a9ff;
}

.al-badge-status.planning {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
}

/* Empty State */
.al-empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px 16px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.al-empty-state i {
  font-size: 2rem;
  color: var(--text-dim);
  margin-bottom: 8px;
  display: block;
}

/* Mobile */
@media (max-width: 640px) {
  .anilist-profile-pill .al-pill-name {
    display: none;
  }
  .al-stats-grid {
    grid-template-columns: repeat(3, 1fr);
    padding: 12px 16px;
  }
  .al-stat-val {
    font-size: 1.1rem;
  }
  .al-lists-section {
    padding: 14px 16px;
  }
  .al-entries-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }
}
