/**
 * personality-gallery.css
 * Personality Gallery Window — Historische Denker & Persönlichkeiten
 *
 * Accent: Dark-Green  #22c55e / rgba(34,197,94,...)
 */

/* ── WINDOW ──────────────────────────────────────────────────── */
#personality-gallery-window {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 380px;
    min-height: 500px;
}
.pg-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    min-height: 0;             /* ← allows flex child to shrink & scroll */
}

/* ── SEARCH ──────────────────────────────────────────────────── */
.pg-search-bar {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(255,255,255,0.07);
}
.pg-search-wrap {
    position: relative;
    flex: 1;
}
.pg-search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    opacity: 0.4;
    color: var(--text-secondary, #94a3b8);
}
.pg-search-input {
    width: 100%;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    padding: 7px 10px 7px 32px;
    font-size: 13px;
    color: var(--text-primary, #e2e8f0);
    outline: none;
    transition: border-color .2s, background .2s;
    box-sizing: border-box;
}
.pg-search-input:focus {
    border-color: #22c55e;
    background: rgba(255,255,255,0.09);
}
.pg-search-input::placeholder { color: rgba(148,163,184,0.5); }

/* ── CATEGORY DROPDOWN ──────────────────────────────────────────── */
.pg-cat-select {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(34,197,94,0.25);
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 12px;
    color: var(--text-primary, #e2e8f0);
    outline: none;
    cursor: pointer;
    transition: border-color .2s;
    min-width: 90px;
}
.pg-cat-select:focus { border-color: #22c55e; }
.pg-cat-select option { background: #1e293b; }

.pg-voice-filter-select {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(249,115,22,0.24);
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 12px;
    color: var(--text-primary, #e2e8f0);
    outline: none;
    cursor: pointer;
    transition: border-color .2s;
    min-width: 118px;
    flex-shrink: 0;
}
.pg-voice-filter-select:focus { border-color: #fb923c; }
.pg-voice-filter-select option { background: #1e293b; }

/* Favorites toggle */
.pg-fav-toggle {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 6px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    cursor: pointer;
    color: var(--text-secondary, #94a3b8);
    transition: all .15s;
    padding: 0;
    flex-shrink: 0;
}
.pg-fav-toggle:hover {
    background: rgba(239,68,68,0.15);
    border-color: rgba(239,68,68,0.3);
    color: #f87171;
}
.pg-fav-toggle.active {
    background: rgba(239,68,68,0.2);
    border-color: rgba(239,68,68,0.5);
    color: #ef4444;
}

/* ── SORT + VIEW CONTROLS ────────────────────────────────────── */
.pg-controls-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.07);
    flex-shrink: 0;
}
.pg-sort-wrap { flex: 1; }
.pg-sort-select {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 12px;
    color: var(--text-primary, #e2e8f0);
    outline: none;
    cursor: pointer;
    transition: border-color .2s;
}
.pg-sort-select:focus { border-color: #22c55e; }
.pg-sort-select option { background: #1e293b; }

.pg-view-toggle { display: flex; gap: 2px; }
.pg-view-btn {
    background: none;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 6px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary, #94a3b8);
    transition: all .15s;
}
.pg-view-btn:hover { background: rgba(255,255,255,0.08); color: var(--text-primary, #e2e8f0); }
.pg-view-btn.active {
    background: rgba(34,197,94,0.18);
    border-color: #22c55e;
    color: #86efac;
}

/* ── LIST CONTAINER ──────────────────────────────────────────── */
.pg-list {
    flex: 1 1 0;
    min-height: 0;             /* ← critical for overflow scroll */
    overflow-y: auto;
    padding: 10px;
    scrollbar-width: thin;
    scrollbar-color: rgba(34,197,94,0.25) transparent;
}
.pg-list::-webkit-scrollbar { width: 4px; }
.pg-list::-webkit-scrollbar-thumb { background: rgba(34,197,94,0.3); border-radius: 4px; }

/* GRID */
.pg-list.view-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
    align-content: start;
}
/* LIST */
.pg-list.view-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.pg-empty {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--text-secondary, #94a3b8);
    font-size: 13px;
    padding: 40px 20px;
    opacity: .6;
}
.pg-error { color: var(--color-error, #ef4444); opacity: 1; }

/* ── KARTE (GRID) ────────────────────────────────────────────── */
.pg-card {
    background: rgba(34,197,94,0.06);
    border: 1px solid rgba(34,197,94,0.18);
    border-radius: 12px;
    padding: 14px 12px 10px;
    cursor: pointer;
    transition: background .15s, border-color .15s, transform .15s, box-shadow .15s;
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: relative;
    overflow: hidden;
    min-height: 160px;     /* ensure card expands for avatar + desc + action rows */
}
.pg-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, rgba(34,197,94,0.6), rgba(22,163,74,0.3));
    border-radius: 12px 12px 0 0;
}
.pg-card:hover {
    background: rgba(34,197,94,0.10);
    border-color: rgba(34,197,94,0.35);
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(34,197,94,0.12);
}
.pg-card:focus-visible {
    outline: 2px solid rgba(34,197,94,0.6);
    outline-offset: 2px;
}

/* ── Fav + Audio overlay actions container ────────────────────── */
.pg-card-overlay-actions {
    position: absolute;
    top: 6px;
    right: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 2;
}
.pg-fav-btn {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.5);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 50%;
    font-size: 13px;
    line-height: 1;
    color: rgba(148,163,184,0.55);
    cursor: pointer;
    transition: all .2s;
    padding: 0;
}
.pg-fav-btn:hover {
    background: rgba(239,68,68,0.2);
    border-color: rgba(239,68,68,0.4);
    color: #f87171;
    transform: scale(1.15);
}
.pg-fav-btn.active {
    color: #ef4444;
    background: rgba(239,68,68,0.15);
    border-color: rgba(239,68,68,0.35);
    text-shadow: 0 0 6px rgba(239,68,68,0.5);
}

.pg-audio-btn {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.5);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 50%;
    font-size: 12px;
    line-height: 1;
    color: rgba(148,163,184,0.55);
    cursor: pointer;
    transition: all .2s;
    padding: 0;
}
.pg-audio-btn:hover {
    background: rgba(251,146,60,0.2);
    border-color: rgba(251,146,60,0.4);
    color: #fb923c;
    transform: scale(1.15);
}
.pg-audio-btn.playing {
    color: #fb923c;
    background: rgba(251,146,60,0.18);
    border-color: rgba(251,146,60,0.4);
    animation: pg-audio-pulse 1s ease-in-out infinite;
}
@keyframes pg-audio-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.12); }
}

/* ── Audio Info Button (Kontrollleiste) ──────────────────────── */
.pg-audio-info-btn {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 6px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    cursor: pointer;
    color: var(--text-secondary, #94a3b8);
    transition: all .15s;
}
.pg-audio-info-btn:hover {
    background: rgba(251,146,60,0.15);
    border-color: rgba(251,146,60,0.3);
    color: #fb923c;
}

/* Card Head */
.pg-card-head {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}
.pg-card-avatar {
    font-size: 22px;
    line-height: 1;
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(34,197,94,0.10);
    border-radius: 8px;
    border: 1px solid rgba(34,197,94,0.2);
}
.pg-card-identity { flex: 1; min-width: 0; }
.pg-card-name {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary, #e2e8f0);
    line-height: 1.22;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    white-space: normal;
    overflow-wrap: anywhere;
}
.pg-card-category {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: rgba(34,197,94,0.8);
    margin-top: 3px;
}
.pg-card-role {
    font-size: 10.5px;
    font-weight: 500;
    color: rgba(148,163,184,0.72);
    line-height: 1.3;
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* Badges */
.pg-card-badges {
    display: flex;
    flex-direction: column;
    gap: 3px;
    align-items: flex-end;
    flex-shrink: 0;
}
.pg-badge {
    font-size: 9px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 8px;
    white-space: nowrap;
    letter-spacing: .04em;
}
.pg-badge-soul    { background: rgba(16,185,129,0.18); color: #6ee7b7; border: 1px solid rgba(16,185,129,0.35); }
.pg-badge-no-soul { background: rgba(100,116,139,0.12); color: rgba(148,163,184,0.45); border: 1px solid rgba(100,116,139,0.15); }
.pg-badge-voice   { background: rgba(14,165,233,0.18); color: #38bdf8; border: 1px solid rgba(14,165,233,0.3); }
.pg-badge-voice-clone { background: rgba(249,115,22,0.18); color: #fdba74; border: 1px solid rgba(249,115,22,0.36); }

.pg-badge-icon {
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    border: 1px solid transparent;
}

.pg-badge-voice-icon {
    background: rgba(14,165,233,0.14);
    color: #7dd3fc;
    border-color: rgba(14,165,233,0.24);
}

.pg-badge-voice-clone-icon {
    background: rgba(249,115,22,0.16);
    color: #fdba74;
    border-color: rgba(249,115,22,0.28);
}

.pg-card-has-clone {
    box-shadow: inset 0 0 0 1px rgba(249,115,22,0.26), 0 14px 32px rgba(2,6,23,0.34);
}

.pg-card-has-clone::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    box-shadow: inset 0 0 0 1px rgba(251,146,60,0.18);
}

.pg-audio-btn-has-clone {
    background: linear-gradient(180deg, rgba(249,115,22,0.18), rgba(249,115,22,0.08));
    border-color: rgba(249,115,22,0.38);
    color: #fdba74;
}

/* Badges – Topics */
.pg-badge-topics  { background: rgba(34,197,94,0.12); color: #86efac; border: 1px solid rgba(34,197,94,0.3); }

/* ── Topic Chips on Card ─────────────────────────────────────── */
.pg-card-topics {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    margin: 2px 0;
}
.pg-topic-chip {
    font-size: 9px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 6px;
    background: rgba(34,197,94,0.10);
    border: 1px solid rgba(34,197,94,0.22);
    color: #86efac;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 130px;
    line-height: 1.3;
}
.pg-topic-more {
    font-size: 9px;
    font-weight: 700;
    padding: 2px 5px;
    color: rgba(148,163,184,0.6);
}

/* Description (kept for profile, hidden on overview cards) */
.pg-card-desc {
    font-size: 11px;
    color: var(--text-secondary, #94a3b8);
    line-height: 1.5;
    margin: 0;
    flex: 1;
}

/* ── Action Buttons — 2-Row-Layout ───────────────────────────── */
.pg-card-actions {
    display: flex;
    gap: 5px;
    flex-wrap: nowrap;
}
/* Primary row: Chat + Podcast – equal 50/50 */
.pg-actions-primary {
    margin-top: auto;
}
.pg-actions-primary .pg-action-btn {
    flex: 1 1 0;
}
/* Secondary row: Graph + Compare + Twin – equal 33/33/33 */
.pg-actions-secondary .pg-action-btn {
    flex: 1 1 0;
    font-size: 10px;
    padding: 4px 4px;
}
.pg-action-btn {
    min-width: 0;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 7px;
    padding: 5px 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary, #94a3b8);
    cursor: pointer;
    transition: all .15s;
    white-space: nowrap;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
}
.pg-action-btn:hover { border-color: rgba(34,197,94,0.4); color: #86efac; background: rgba(34,197,94,0.1); }
.pg-action-chat:hover  { border-color: rgba(14,165,233,0.4); color: #38bdf8; background: rgba(14,165,233,0.1); }
.pg-action-podcast:hover { border-color: rgba(251,146,60,0.4); color: #fb923c; background: rgba(251,146,60,0.1); }
.pg-action-graph:hover { border-color: rgba(34,197,94,0.4); color: #4ade80; background: rgba(34,197,94,0.1); }
.pg-action-compare:hover { border-color: rgba(234,179,8,0.4); color: #facc15; background: rgba(234,179,8,0.1); }
.pg-action-twin:hover { border-color: rgba(139,92,246,0.5); color: #c084fc; background: rgba(139,92,246,0.15); }

/* ── LIST VIEW OVERRIDES ──────────────────────────────────────── */
.pg-list.view-list .pg-card {
    flex-direction: row;
    align-items: center;
    padding: 10px 14px;
    gap: 12px;
}
.pg-list.view-list .pg-card::before { display: none; }
.pg-list.view-list .pg-card-head { flex: 1; min-width: 0; }
.pg-list.view-list .pg-card-identity { flex: 1; }
.pg-list.view-list .pg-card-name {
    -webkit-line-clamp: 1;
    line-clamp: 1;
    white-space: nowrap;
    display: block;
}
.pg-list.view-list .pg-card-badges { flex-direction: row; align-items: center; }
.pg-list.view-list .pg-card-desc { display: none; }
.pg-list.view-list .pg-card-topics { display: none; }
.pg-list.view-list .pg-card-actions {
    flex-direction: row;
    margin-top: 0;
    flex-shrink: 0;
    gap: 4px;
}
.pg-list.view-list .pg-actions-secondary { display: none; }
.pg-list.view-list .pg-action-btn { flex: none; padding: 4px 10px; }
.pg-list.view-list .pg-card-overlay-actions { position: static; flex-direction: row; align-items: center; flex-shrink: 0; }
.pg-list.view-list .pg-fav-btn { width: 20px; height: 20px; font-size: 11px; }
.pg-list.view-list .pg-audio-btn { width: 20px; height: 20px; font-size: 10px; }

/* ── FOOTER ──────────────────────────────────────────────────── */
.pg-footer {
    padding: 6px 14px;
    font-size: 11px;
    color: var(--text-secondary, #94a3b8);
    opacity: .6;
    border-top: 1px solid rgba(255,255,255,0.06);
    text-align: right;
}

/* ── SPINNER (reuses roster's) ───────────────────────────────── */
.pg-list .roster-spinner {
    grid-column: 1/-1;
    margin: 40px auto;
}
