/**
 * Characters page - matches homepage dark cinematic + purple/pink gradient style.
 * Hero glass panel, builder (preview + settings), character grid.
 */

/* Page container */
.characters-page {
    padding: 0 0 48px;
    max-width: 1200px;
    margin: 0 auto;
}

/* Hero: content only; background is on page wrapper (top-hero-container) so one continuous layer */
.characters-hero {
    position: relative;
    margin: 0 -24px 32px -24px;
    padding: 48px 24px 56px;
    background: transparent;
    background-color: transparent;
    border-radius: 0 0 24px 24px;
}

.characters-hero-glass {
    max-width: 720px;
    margin: 0 auto;
    padding: 32px 28px 36px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(168, 85, 247, 0.25);
    border-radius: 28px;
    box-shadow: 0 0 40px rgba(168, 85, 247, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.characters-hero-title {
    font-size: clamp(24px, 3.5vw, 32px);
    font-weight: 700;
    color: #fff;
    margin: 0 0 8px;
    letter-spacing: -0.02em;
}

.characters-hero-subtitle {
    font-size: 15px;
    color: rgba(255, 255, 255, 0.8);
    margin: 0 0 24px;
    line-height: 1.5;
}

.characters-hero-input-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.characters-hero-input-wrap {
    position: relative;
    flex: 1;
    min-width: 200px;
}

.characters-hero-input-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255, 255, 255, 0.5);
    font-size: 14px;
    pointer-events: none;
}

.characters-hero-input {
    width: 100%;
    padding: 14px 18px 14px 44px;
    font-size: 15px;
    font-family: 'Inter', sans-serif;
    background: rgba(15, 15, 35, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    color: #fff;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.characters-hero-input::placeholder {
    color: rgba(255, 255, 255, 0.45);
}

.characters-hero-input:focus {
    border-color: rgba(168, 85, 247, 0.6);
    box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.15);
}

.characters-hero-cta {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 24px;
    font-size: 15px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    color: #fff;
    background: linear-gradient(135deg, #8b5cf6, #ec4899);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    white-space: nowrap;
}

.characters-hero-cta:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.45);
}

.characters-hero-cta i {
    font-size: 16px;
}

.characters-hero-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.characters-pill {
    padding: 8px 16px;
    font-size: 13px;
    font-family: 'Inter', sans-serif;
    color: rgba(255, 255, 255, 0.9);
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 20px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.characters-pill:hover,
.characters-pill.active {
    background: rgba(168, 85, 247, 0.25);
    border-color: rgba(168, 85, 247, 0.5);
}

.characters-pill-trait {
    cursor: default;
    margin-right: 6px;
    margin-bottom: 4px;
}

/* Builder section: two columns */
.characters-builder {
    margin-bottom: 40px;
}

.characters-builder-inner {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    align-items: start;
}

@media (max-width: 900px) {
    .characters-builder-inner {
        grid-template-columns: 1fr;
    }
}

.characters-preview-card,
.characters-settings-card {
    margin-top: 32px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    padding: 24px;
}

.characters-card-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary, #fff);
    margin: 0 0 20px;
}

/* Preview: portrait + trait pills + buttons */
.characters-preview-portrait-wrap {
    margin-bottom: 16px;
}

.characters-preview-portrait {
    width: 100%;
    aspect-ratio: 1;
    max-height: 320px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.characters-preview-portrait-placeholder {
    background: linear-gradient(135deg, rgba(30, 20, 50, 0.9), rgba(50, 25, 60, 0.9));
    border: 1px dashed rgba(255, 255, 255, 0.2);
}

.characters-preview-portrait.generated {
    background: linear-gradient(135deg, #4c1d95 0%, #7c3aed 50%, #a855f7 100%);
    border: 1px solid rgba(168, 85, 247, 0.4);
}

.characters-preview-placeholder-text {
    color: rgba(255, 255, 255, 0.5);
    font-size: 15px;
}

.characters-reference-thumbnails {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.characters-reference-thumbnails img {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.characters-trait-pills {
    margin-bottom: 20px;
    flex-wrap: wrap;
    display: flex;
    gap: 8px;
}

.characters-preview-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.characters-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.characters-btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.characters-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.25);
}

.characters-btn-primary {
    background: linear-gradient(135deg, #8b5cf6, #ec4899);
    color: #fff;
}

.characters-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(139, 92, 246, 0.4);
}

/* Settings: sections + toggles */
.characters-settings-section {
    margin-bottom: 24px;
}

.characters-settings-section:last-child {
    margin-bottom: 0;
}

.characters-settings-heading {
    font-size: 14px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    margin: 0 0 12px;
}

.characters-settings-fields {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.characters-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.characters-field-label {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
}

.characters-input,
.characters-select,
.characters-textarea {
    padding: 10px 14px;
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    color: #fff;
    outline: none;
    transition: border-color 0.2s;
}

.characters-input::placeholder,
.characters-textarea::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.characters-input:focus,
.characters-select:focus,
.characters-textarea:focus {
    border-color: rgba(168, 85, 247, 0.5);
}

.characters-textarea {
    resize: vertical;
    min-height: 72px;
}

.characters-select {
    cursor: pointer;
}

.characters-select option {
    background: #1a1a2e;
    color: #fff;
}

/* Identity Lock toggles */
.characters-toggle-group {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.characters-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.characters-toggle-input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.characters-toggle-slider {
    position: relative;
    width: 44px;
    height: 24px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    transition: background 0.2s;
    flex-shrink: 0;
}

.characters-toggle-slider::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    left: 2px;
    top: 2px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.characters-toggle-input:checked + .characters-toggle-slider {
    background: linear-gradient(135deg, #8b5cf6, #a855f7);
}

.characters-toggle-input:checked + .characters-toggle-slider::after {
    transform: translateX(20px);
}

.characters-toggle-label {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.9);
}

/* Your Characters grid */
.characters-grid-section {
    margin-top: 40px;
}

.characters-grid-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary, #fff);
    margin: 0 0 20px;
}

.characters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
}

.character-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    overflow: hidden;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.character-card:hover {
    border-color: rgba(168, 85, 247, 0.3);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.character-card-portrait {
    width: 100%;
    aspect-ratio: 1;
    background: linear-gradient(135deg, rgba(40, 25, 60, 0.8), rgba(60, 35, 80, 0.8));
}

.character-card-portrait-placeholder {
    background: linear-gradient(135deg, rgba(30, 20, 50, 0.9), rgba(50, 25, 60, 0.9));
}

.character-card-info {
    padding: 14px 16px;
}

.character-card-name {
    display: block;
    font-size: 15px;
    font-weight: 600;
    color: #fff;
    margin-bottom: 4px;
}

.character-card-meta {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.55);
}

.character-card-actions {
    display: flex;
    padding: 0 12px 12px;
    gap: 8px;
    flex-wrap: wrap;
    opacity: 0.85;
}

.character-card:hover .character-card-actions {
    opacity: 1;
}

.character-card-action {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.9);
    cursor: pointer;
    transition: background 0.2s;
}

.character-card-action:hover {
    background: rgba(168, 85, 247, 0.35);
    color: #fff;
}

.character-card-action i {
    font-size: 14px;
}

/* Responsive */
@media (max-width: 768px) {
    .characters-page {
        padding: 0 0 32px;
    }
    
    .characters-hero {
        margin: 0 -16px 24px -16px;
        padding: 32px 16px 40px;
        border-radius: 0 0 20px 20px;
    }
    
    .characters-hero-glass {
        padding: 24px 20px 28px;
        border-radius: 20px;
    }
    
    .characters-hero-input-row {
        flex-direction: column;
        align-items: stretch;
    }
    
    .characters-hero-cta {
        width: 100%;
        justify-content: center;
    }
    
    .characters-preview-actions {
        flex-direction: column;
    }
    
    .characters-preview-actions .characters-btn {
        width: 100%;
        justify-content: center;
    }
    
    .characters-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 16px;
    }
}
