/* ========== MY AI PAGE STYLES ========== */
/* Extracted from BonzaUI my-ai.html */

/* ========== CONTENT AREA ========== */
.content-area {
  display: flex;
  gap: 16px;
  padding: 0 16px 16px;
  flex: 1;
  position: relative;
}

.main-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

/* ========== CHARACTERS HEADER ========== */
.chars-header {
  display: flex;
  align-items: center;
  gap: 16px;
}

.chars-header-left {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
}

.chars-count {
  font-size: 18px;
  font-weight: 500;
  line-height: 24px;
  white-space: nowrap;
}

.btn-create {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  color: #000;
  font-size: 12px;
  font-weight: 600;
  line-height: 16px;
  padding: 6px 16px 6px 10px;
  border-radius: 8px;
  border: none;
  box-shadow: 0 2px 20px rgba(255,255,255,0.56);
  cursor: pointer;
  white-space: nowrap;
  font-family: 'Heebo', sans-serif;
}

.btn-create img {
  width: 20px;
  height: 20px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--neutral-800);
  border: 1px solid var(--neutral-700);
  border-radius: 8px;
  padding: 8px 16px 8px 8px;
  width: 330px;
}

.search-box img {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.search-box input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: #fff;
  font-family: 'Heebo', sans-serif;
  font-size: 12px;
  line-height: 16px;
}

.search-box input::placeholder {
  color: var(--neutral-500);
}

.mobile-filter-btn {
  display: none;
  background: var(--neutral-800);
  border: 1px solid var(--neutral-700);
  border-radius: 8px;
  padding: 8px 16px;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  align-items: center;
  gap: 6px;
  font-family: 'Heebo', sans-serif;
}

.mobile-filter-btn img {
  width: 16px;
  height: 16px;
}

/* ========== CHARACTER CARDS GRID ========== */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.char-card {
  background: var(--neutral-800);
  border: 1px solid var(--neutral-700);
  border-radius: 16px;
  padding: 4px;
  display: flex;
  flex-direction: column;
  min-width: 0;
  cursor: pointer;
  transition: all 0.2s ease;
}

.char-card.active {
  background: #000;
  border-color: var(--purple-400);
  box-shadow: 0 0 28px 0 rgba(204,149,255,0.7);
}

.char-card.expandable {
  grid-column: span 1;
}

.char-card-img {
  aspect-ratio: 213.5/248;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  background: var(--neutral-800);
}

/* Skeleton shimmer placeholder (visible until image loads) */
.char-card-skeleton {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  background: linear-gradient(
    110deg,
    var(--neutral-800) 30%,
    var(--neutral-700) 50%,
    var(--neutral-800) 70%
  );
  background-size: 200% 100%;
  animation: charCardShimmer 1.5s linear infinite;
  z-index: 1;
}

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

.char-card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 12px;
  position: relative;
  z-index: 2;
  opacity: 1;
  transition: opacity 0.3s ease;
}

/* Fade in image once loaded, hide skeleton */
.char-card-img img.loaded {
  opacity: 1;
}
.char-card-img:has(img.loaded) .char-card-skeleton {
  display: none;
}

.char-card-badges {
  position: absolute;
  bottom: 12px;
  left: 12px;
  display: flex;
  gap: 2px;
}

.char-badge {
  background: #000;
  color: #fff;
  font-size: 12px;
  line-height: 16px;
  padding: 2px 6px;
  border-radius: 4px;
}

.char-card-info {
  padding: 8px 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.char-card-name {
  font-size: 18px;
  font-weight: 500;
  line-height: 24px;
  margin: 0;
}

.char-card-hobbies {
  font-size: 12px;
  line-height: 16px;
  color: var(--neutral-400);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  height: 32px;
  margin: 0;
}

/* ========== ACTIVE CARD ACTIONS ========== */
.char-card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px 16px;
  gap: 6px;
  flex-wrap: wrap;
}

.btn-card-icon {
  background: var(--neutral-700);
  border: none;
  border-radius: 8px;
  padding: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.btn-card-icon:hover {
  background: var(--neutral-600);
}

.btn-card-icon img {
  width: 20px;
  height: 20px;
}

.card-actions-right {
  display: flex;
  gap: 8px;
  align-items: center;
}

.btn-chat {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  color: #000;
  font-size: 12px;
  font-weight: 600;
  line-height: 16px;
  padding: 6px 10px 6px 16px;
  border-radius: 8px;
  border: none;
  box-shadow: 0 2px 20px rgba(255,255,255,0.56);
  cursor: pointer;
  font-family: 'Heebo', sans-serif;
}

.btn-chat img {
  width: 20px;
  height: 20px;
}

/* ========== CREATE NEW PLACEHOLDER CARD ========== */
.char-card.create-card {
  background: var(--purple-900);
  border: 1px dashed var(--purple-700);
  cursor: default;
}

/* Order: Third on desktop (order: 3) */
.create-card-order {
  order: 3;
}

.create-card-img {
  aspect-ratio: 213.5/248;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  background: radial-gradient(ellipse at center, #432362 30%, #311a47 65%, #1F102D 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.create-card-ghost {
  position: relative;
  width: 120px;
  height: 170px;
}

.create-card-ghost .ghost-body {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.create-card-ghost .ghost-body img {
  width: 60%;
  height: auto;
  opacity: 0.6;
}

.create-card-ghost .ghost-top {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 60%;
}

.create-card-ghost .ghost-top img {
  width: 100%;
}

.create-card-ghost .ghost-bottom {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 55%;
}

.create-card-ghost .ghost-bottom img {
  width: 100%;
}

.create-card-body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 12px;
}

.btn-create-new {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--purple-400);
  color: var(--purple-900);
  font-size: 14px;
  font-weight: 600;
  line-height: 20px;
  padding: 4px 4px 4px 20px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  font-family: 'Heebo', sans-serif;
}

.btn-create-new:hover {
  background: var(--purple-300);
}

.btn-create-new-credits {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--purple-300);
  border-radius: 8px;
  padding: 6px 8px 6px 6px;
}

.btn-create-new-credits img {
  width: 20px;
  height: 20px;
}

.btn-create-new-credits span {
  font-size: 12px;
  font-weight: 600;
  color: var(--purple-700);
}

/* ========== FILTERS PANEL (RIGHT SIDEBAR) ========== */
.filters-panel {
  width: 221px;
  min-width: 221px;
  background: var(--neutral-800);
  border: 1px solid var(--neutral-700);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  position: sticky;
  top: 0;
}

.filters-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.filters-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Mobile-only close button inside the filters panel. Hidden on desktop. */
.filters-close-mobile {
  display: none;
  background: var(--neutral-700);
  border: 1px solid var(--neutral-600);
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
}
.filters-close-mobile:hover { background: var(--neutral-600); }
@media (max-width: 768px) {
  .filters-close-mobile { display: inline-flex; }
}

.filters-title {
  font-size: 18px;
  font-weight: 500;
  line-height: 24px;
  color: var(--neutral-400);
}

.btn-reset {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--neutral-700);
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  color: #fff;
  font-family: 'Heebo', sans-serif;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.btn-reset:hover {
  background: var(--neutral-600);
}

.btn-reset img {
  width: 16px;
  height: 16px;
}

.filter-divider {
  height: 1px;
  background: var(--neutral-700);
}

.filter-section-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--neutral-400);
}

.filter-section-title img {
  width: 20px;
  height: 20px;
}

/* ========== AGE SLIDER ========== */
.age-range-labels {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--neutral-500);
}

.range-slider {
  position: relative;
  width: 100%;
  height: 16px;
}

.range-slider input[type="range"] {
  -webkit-appearance: none;
  position: absolute;
  width: 100%;
  height: 6px;
  background: none;
  pointer-events: none;
  top: 5px;
  margin: 0;
  padding: 0;
}

.range-slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--purple-900);
  border: 1px solid var(--purple-400);
  cursor: pointer;
  pointer-events: all;
  position: relative;
  z-index: 2;
}

.range-slider input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--purple-900);
  border: 1px solid var(--purple-400);
  cursor: pointer;
  pointer-events: all;
}

.range-track {
  position: absolute;
  height: 6px;
  top: 5px;
  background: var(--neutral-700);
  border-radius: 999px;
  width: 100%;
}

.range-fill {
  position: absolute;
  height: 6px;
  top: 5px;
  background: var(--purple-400);
  border-radius: 999px;
}

.age-inputs {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
}

.age-input {
  background: var(--neutral-700);
  border: 1px solid var(--neutral-600);
  border-radius: 8px;
  padding: 8px 12px;
  color: #fff;
  font-size: 12px;
  text-align: center;
  width: 72px;
  font-family: 'Heebo', sans-serif;
}

.age-input:focus {
  outline: none;
  border-color: var(--purple-400);
}

.age-to {
  font-size: 12px;
  color: var(--neutral-600);
}

/* ========== CHECKBOXES ========== */
.filter-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 4px;
  font-size: 12px;
  color: var(--neutral-400);
  cursor: pointer;
  user-select: none;
}

.filter-option.active {
  color: #fff;
}

.filter-checkbox {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: var(--neutral-700);
  border: 1px solid var(--neutral-500);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
}

.filter-checkbox.checked {
  background: var(--purple-400);
  border-color: var(--purple-400);
}

.filter-checkbox.checked::after {
  content: '';
  width: 10px;
  height: 7px;
  border-left: 2px solid #000;
  border-bottom: 2px solid #000;
  transform: rotate(-45deg);
  margin-top: -2px;
}

/* ========== LOADING STATE ========== */
.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  gap: 16px;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--neutral-700);
  border-top-color: var(--purple-400);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

.loading-text {
  font-size: 14px;
  color: var(--neutral-400);
}

/* ========== RESPONSIVE DESIGN ========== */
@media (max-width: 1024px) {
  .cards-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .filters-panel {
    width: 200px;
    min-width: 200px;
  }
  
  .search-box {
    width: 220px;
  }
}

@media (max-width: 768px) {
  .content-area {
    flex-direction: column;
    padding: 0 12px 12px;
  }
  
  .chars-header {
    flex-direction: column;
    gap: 8px;
    align-items: stretch;
  }
  
  .chars-header-left {
    flex-wrap: wrap;
    gap: 8px;
  }
  
  .search-box {
    width: 100%;
  }
  
  /* Filters button takes its own full-width row so it's easy to tap and
     doesn't get orphaned next to the count/create button. */
  .mobile-filter-btn {
    width: 100%;
    justify-content: center;
    padding: 10px 16px;
    font-size: 13px;
    /* Force a line break before it when wrapped inside chars-header-left. */
    flex-basis: 100%;
  }
  
  .cards-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  /* Order: First on mobile (order: -1) */
  .create-card-order {
    order: -1;
  }
  
  /* Filters — hidden on mobile; toggled open as a plain block that
     expands inline inside .content-area. Panel is a sibling of
     .main-col; `order: -1` floats it to the top of the column layout
     so it appears right under the app topbar instead of below the
     entire cards list. */
  .filters-panel {
    display: none !important;
    width: 100% !important;
    min-width: 0 !important;
    position: static !important;
    max-height: none !important;
    right: auto !important;
    top: auto !important;
    box-shadow: none !important;
    order: -1;
  }
  .filters-panel.show {
    display: flex !important;
    flex-direction: column !important;
  }
  
  .mobile-filter-btn {
    display: flex;
  }
  
  .btn-create {
    font-size: 11px;
    padding: 6px 12px 6px 8px;
  }
  
  .btn-chat {
    padding: 6px 8px 6px 12px;
    font-size: 11px;
  }
}

@media (max-width: 480px) {
  /* Keep 2 character cards per row on small phones (previous 1-col made
     the My-AI grid scroll forever on long libraries). */
  .cards-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  /* Shrink card internals so a pair fits nicely at ~360px-wide viewports. */
  .char-card-badges {
    bottom: 8px;
    left: 8px;
    flex-wrap: wrap;
    max-width: calc(100% - 16px);
  }
  .char-badge {
    font-size: 10px;
    line-height: 14px;
    padding: 2px 5px;
  }
  .char-card-info {
    padding: 6px 10px 10px;
    gap: 4px;
  }
  .char-card-name {
    font-size: 15px;
    line-height: 20px;
  }
  .char-card-hobbies {
    font-size: 11px;
    line-height: 14px;
    height: 28px;
  }
  .char-card-actions {
    flex-wrap: nowrap;
    padding: 0 10px 10px;
    gap: 4px;
  }

  /* Keep order: First on mobile */
  .create-card-order {
    order: -1;
  }
}

/* ========== EYE BUTTON ON CARDS ========== */
.btn-card-eye {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(0, 0, 0, 0.6);
  border: none;
  border-radius: 8px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 5;
  opacity: 1;
  transition: background 0.2s;
}

.btn-card-eye:hover {
  background: rgba(0, 0, 0, 0.8);
}

.btn-card-eye img {
  width: 18px;
  height: 18px;
  filter: invert(1);
}

/* ========== CHARACTER INFO MODAL ========== */
.ai-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 16px;
  /* If the modal is taller than the viewport, scroll the overlay
     instead of clipping the top/bottom of the modal. */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.ai-overlay.show {
  display: flex;
}

.ai-modal {
  background: #131313;
  border: 1px solid #2e2e2e;
  border-radius: 24px;
  padding: 24px;
  width: 100%;
  max-width: 960px;
  /* Cap to viewport height so long content scrolls inside the modal
     instead of pushing it off-screen. Use svh/dvh where supported for
     iOS Safari's shrinking viewport. */
  max-height: calc(100vh - 32px);
  max-height: calc(100svh - 32px);
  max-height: calc(100dvh - 32px);
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: relative;
  overflow: hidden; /* outer container stays clipped; inner body scrolls */
}

.ai-head {
  display: flex;
  gap: 8px;
  align-items: center;
  padding-left: 8px;
}

.ai-head h2 {
  flex: 1;
  font-size: 24px;
  font-weight: 500;
  line-height: 32px;
  color: #CC95FF;
  margin: 0;
}

.ai-close {
  background: #2e2e2e;
  border: none;
  border-radius: 8px;
  padding: 6px;
  cursor: pointer;
  transition: background 0.2s;
}

.ai-close:hover {
  background: #4B4B4B;
}

.ai-close img {
  width: 20px;
  height: 20px;
}

.ai-body {
  display: flex;
  gap: 16px;
  align-items: stretch;
  height: 488px;
  /* Enable internal scrolling when content exceeds the capped height
     (desktop: 488px, mobile: whatever remains after header). min-height:0
     is required for a flex child to actually shrink + scroll. */
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.ai-photo {
  aspect-ratio: 153/224;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 24px;
  overflow: hidden;
  flex-shrink: 0;
  position: relative;
  background: #131313;
}

.ai-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ai-photo .badge-socialite {
  position: absolute;
  left: -1px;
  bottom: 24px;
  padding: 6px 24px;
  font-size: 14px;
  font-weight: 600;
  line-height: 20px;
  color: #1F102D;
  background: linear-gradient(219deg, #F4E9FF 18%, #CC95FF 39%, #ECD7FF 55%, #BE78FF 76%);
  box-shadow: 0 2px 2px rgba(0, 0, 0, 0.25);
}

.ai-desc {
  flex: 1;
  min-width: 0;
  background: #000;
  border-radius: 24px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 24px;
  overflow-y: auto;
}

.ai-section h3 {
  font-size: 18px;
  font-weight: 500;
  line-height: 24px;
  color: #fff;
  margin: 0 0 4px 0;
}

.ai-section p.about {
  font-size: 12px;
  line-height: 16px;
  color: #9E9E9E;
  margin: 0;
}

.ai-divider {
  height: 1px;
  background: #2e2e2e;
  margin: 24px 0;
}

.ai-cols {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.ai-col {
  flex: 1;
  min-width: 0;
  padding: 8px 0;
}

.ai-col-divider {
  width: 1px;
  align-self: stretch;
  background: #2e2e2e;
}

.ai-col-head {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 8px;
}

.ai-col-head img {
  width: 16px;
  height: 16px;
}

.ai-col-head span {
  color: #CC95FF;
  font-size: 14px;
  line-height: 20px;
}

.ai-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.ai-grid > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ai-grid label {
  font-size: 12px;
  line-height: 16px;
  color: #9E9E9E;
}

.ai-grid strong {
  font-size: 12px;
  line-height: 16px;
  color: #fff;
  font-weight: 600;
}

.ai-tags {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.ai-tag-block p {
  font-size: 12px;
  line-height: 16px;
  color: #fff;
  margin: 0;
}

.ai-chat-btn {
  align-self: center;
  background: #fff;
  color: #000;
  border: none;
  border-radius: 8px;
  padding: 6px 16px 6px 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  line-height: 16px;
  cursor: pointer;
  box-shadow: 0 2px 20px rgba(255, 255, 255, 0.56);
  margin-top: 24px;
  transition: transform 0.2s;
}

.ai-chat-btn:hover {
  transform: translateY(-1px);
}

.ai-chat-btn img {
  width: 20px;
  height: 20px;
}

/* Modal responsive */
@media (max-width: 768px) {
  .ai-modal {
    padding: 16px;
    gap: 12px;
    /* On mobile let the whole modal scroll as one (header + photo + body)
       instead of keeping the header/photo pinned. Overrides the desktop
       `overflow: hidden`. */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .ai-body {
    flex-direction: column;
    /* Let the body grow to its natural height; the parent modal scrolls. */
    height: auto;
    flex: 0 0 auto;
    min-height: 0;
    overflow: visible;
  }
  
  .ai-photo {
    width: 100%;
    max-width: 280px;
    align-self: center;
  }
  
  .ai-cols {
    flex-direction: column;
  }
  
  .ai-col-divider {
    display: none;
  }
}
