/* Museum Persona Generator CSS */
:root {
    --green: #004225;      /* Primary actions */
    --amber: #CC7A00;      /* Active states, toggles */
    --bronze: #8B6914;     /* Secondary buttons */
    --gold: #D4AF37;       /* Accents, highlights */
    --card-bg: #F0EEE6;
    --text-dark: #333;
    --text-medium: #666;
    --text-light: #999;
}

.terminal-section {
    min-height: auto;
    padding: 80px 40px;
    background: var(--bg-color);
    position: relative;
}

.avatar-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    max-width: 1200px;
    margin: 0 auto;
    align-items: stretch;
    height: 600px;
}

/* Unified Card Styling */
.trait-selector-card, .avatar-card {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(51, 51, 51, 0.2);
    border-radius: 0;
    padding: 0;
    position: relative;
    display: flex;
    flex-direction: column;
    font-family: 'Roboto Mono', monospace;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    height: 100%; /* Fill container height */
}

.trait-selector-card:hover, .avatar-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
}

/* Unified Header Styling */
.trait-card-header, .avatar-card-header {
    background: #e0e0e0;
    color: #333;
    padding: 12px 15px;
    font-size: 0.9rem;
    font-weight: 600;
    border-bottom: 1px solid #333;
    line-height: 1;
    min-height: 45px;
    flex-shrink: 0; /* Prevent header from shrinking */
}


.toggle-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

/* Left Panel Content */
.trait-card-content {
    padding: 8px 15px 12px; /* Reduced padding for tighter layout */
    color: var(--text-dark);
    display: flex;
    flex-direction: column;
    gap: 0px; /* Removed gap for tighter spacing */
    flex-grow: 1; /* Allow content to fill space */
    overflow-y: auto;
    min-height: 0; /* Allow flex item to shrink below content size */
}

/* Right Panel Content */
.avatar-display {
    background: var(--bg-color);
    border-radius: 0;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: stretch;
    justify-content: center;
    padding: 0;
    height: 100%;
}

.avatar-card {
    width: 100%;
    cursor: pointer;
}

.card-header {
    display: flex;
    border-bottom: 1px solid rgba(51, 51, 51, 0.2);
}

.image-container {
    width: calc(100% - 50px); /* Responsive width with 25px padding on each side */
    aspect-ratio: 16/9; /* Maintain 16:9 cinematic aspect ratio */
    max-width: calc(100% - 50px); /* Ensure it doesn't exceed card width on mobile */
    overflow: visible; /* Changed from hidden to allow loading overlay to show */
    background: #333;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
    font-weight: 600;
    position: relative;
    margin: 0 auto; /* Center in card */
}

/* Ensure images inside the container are properly sized */
.image-container .generated-avatar {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Better space utilization for 1:1 images */
    object-position: center top; /* Focus on character's upper body */
}

.image-container .avatar-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Radar Charts Section - New Position Above Sliders */
.radar-charts-section {
    padding: 12px 8px;
}

.header-radars {
    display: flex;
    flex-direction: row;
    justify-content: center;
    gap: 24px;
    width: 100%;
}

.header-radar-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 12px;
}

.header-chart-title {
    font-size: 0.7rem;
    font-weight: 600;
    margin: 0 0 8px 0;
    color: var(--text-dark);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: center;
}

.header-radar-chart {
    width: 60px;
    height: 60px;
}

.card-content {
    padding: 15px 25px; /* Reduced padding for better space utilization */
    display: flex;
    flex-direction: column;
    justify-content: space-between; /* Distribute content evenly */
}

.artwork-title {
    font-size: 2.2rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: -1px;
    margin: 0 0 8px 0;
    line-height: 1;
    color: var(--text-dark);
}

.artwork-subtitle {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0 0 20px 0;
    color: var(--text-dark);
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(51, 51, 51, 0.2);
}

.artwork-details {
    font-size: 0.8rem;
    line-height: 1.6;
    margin: 0 0 15px 0;
    font-weight: 400;
    color: var(--text-dark);
}

.collection-info {
    font-size: 0.75rem;
    line-height: 1.5;
    margin: 0; /* Removed large margin */
    padding: 0; /* Removed large padding */
    font-weight: 400;
    opacity: 0.9;
    color: var(--text-dark);
}


/* Trait Toggles and Grid */
.trait-toggle-section {
    margin-bottom: 8px;
}

.toggle-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-dark);
}

.trait-counter {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--amber);
}

.trait-toggles {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 8px;
}

.trait-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.trait-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    font-weight: 400;
    color: var(--text-dark);
}

.trait-emoji {
    font-size: 0.9rem;
    width: 14px;
    text-align: center;
}

/* Toggle switch styles removed - replaced with OCEAN sliders */

.trait-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 4px;
    margin-bottom: 12px;
    width: 100%;
}

.trait-option {
    background: rgba(240, 238, 230, 0.9);
    border: 1px solid rgba(51, 51, 51, 0.2);
    color: var(--text-dark);
    padding: 4px;
    text-align: center;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 0;
    height: 24px; /* Increased height for better clickability */
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.trait-option:hover {
    background: rgba(240, 238, 230, 1);
    border-color: var(--amber);
    transform: scale(1.1);
}

.trait-option:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 4px 6px;
    border-radius: 2px;
    font-size: 10px;
    white-space: nowrap;
    z-index: 1000;
    margin-bottom: 4px;
    pointer-events: none;
}

.trait-option.selected {
    background: var(--amber);
    color: white;
    border-color: var(--gold);
    box-shadow: 0 2px 8px rgba(204, 122, 0, 0.3);
}

/* Sound Bar Visualization */
.soundbar-container {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1px;
    height: 40px;
    margin: 12px 0;
    padding: 0 8px;
    border: 1px solid rgba(51, 51, 51, 0.2);
    border-radius: 2px;
    background: #f9f9f9;
}

.soundbar {
    flex: 1;
    background: rgba(51, 51, 51, 0.2);
    border-radius: 1px;
    height: 6px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.soundbar.active {
    background: var(--amber);
    height: 25px;
}

/* Advanced Section Styling */
.advanced-section {
}

.advanced-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    user-select: none;
}

.advanced-toggle {
    font-size: 0.8rem;
    color: var(--text-medium);
    transition: transform 0.2s ease;
}

.advanced-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-dark);
}

.advanced-content {
    margin-left: 8px; /* Reduced margin for tighter layout */
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    padding-bottom: 8px; /* Extra padding for button visibility */
    opacity: 0;
    transition: max-height 0.3s ease, opacity 0.3s ease;
}

.advanced-section.expanded .advanced-content {
    max-height: 140px; /* Increased height to ensure button is fully visible */
    opacity: 1;
}

.advanced-section.expanded .advanced-toggle {
    transform: rotate(90deg);
}

.advanced-description {
    font-size: 0.8rem;
    color: var(--text-medium);
    margin: 0;
    line-height: 1.4;
}

.terminal-mode-btn {
    background: var(--green);
    color: white;
    border: none;
    padding: 10px 16px;
    font-size: 0.8rem;
    font-weight: 600;
    font-family: 'Roboto Mono', monospace;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px; /* Reduced space from description text */
    margin-bottom: 4px; /* Bottom margin for visibility */
}

.terminal-mode-btn:hover {
    background: var(--amber);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 66, 37, 0.3);
}

.terminal-mode-btn:active {
    transform: translateY(0);
}

/* Terminal Interface Styling - GitHub Style */
.terminal-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #0d1117;
    border: 1px solid #21262d;
    display: flex;
    flex-direction: column;
    z-index: 100;
    font-family: 'Roboto Mono', monospace;
}

.terminal-header {
    background: #21262d;
    height: 32px;
    display: flex;
    align-items: center;
    padding: 0 12px;
    border-bottom: 1px solid #30363d;
    user-select: none;
}

.terminal-controls {
    display: flex;
    gap: 8px;
    margin-right: 12px;
}

.control-btn {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
}

.control-btn.close { 
    background: #ff5f56; 
}

.control-btn.minimize { 
    background: #ffbd2e; 
}

.control-btn.maximize { 
    background: #27ca3f; 
}

.terminal-title {
    font-size: 13px;
    color: #ffffff;
    font-weight: 400;
}

.terminal-body {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    background: #0d1117;
    line-height: 1.4;
    font-size: 12px;
    color: #ffffff;
    text-align: left; /* Ensure left alignment */
}

#terminal-output {
    text-align: left; /* Left align all terminal output */
}

#terminal-output div {
    text-align: left; /* Left align each line */
    margin: 0;
    padding: 0;
}

.terminal-content {
    color: #ffffff;
    font-family: 'Roboto Mono', monospace;
    font-weight: 400;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.loading-line {
    opacity: 0;
    animation: fadeIn 0.1s ease-in forwards;
}

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

.typewriter {
    overflow: hidden;
    white-space: nowrap;
    animation: typing 0.05s steps(1) forwards;
}

.prompt-line {
    margin-top: 20px;
    display: flex;
    align-items: center;
    font-size: 12px;
}


.prompt {
    color: #ffffff;
    font-weight: 400;
}

.input-container {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
}

/* Native caret styling for terminal input */
.terminal-input {
    color: #ffffff;
    background: transparent;
    border: none;
    outline: none;
    font-family: 'Roboto Mono', monospace;
    font-size: 12px;
    width: 100%;
    caret-color: #ffffff;
    caret-shape: block;
    position: relative;
    z-index: 1;
}

.input-line {
    color: #ffffff;
    background: transparent;
    border: none;
    outline: none;
    font-family: 'Roboto Mono', monospace;
    font-size: 12px;
    width: 100%;
    caret-color: transparent;
    position: relative;
    z-index: 1;
}

.input-text-overlay {
    position: absolute;
    left: 0;
    top: 0;
    color: #ffffff;
    font-family: 'Roboto Mono', monospace;
    font-size: 12px;
    pointer-events: none;
    z-index: 5;
    white-space: nowrap;
}

/* Scrollbar styling */
.terminal-body::-webkit-scrollbar {
    width: 8px;
}

.terminal-body::-webkit-scrollbar-track {
    background: #0d1117;
}

.terminal-body::-webkit-scrollbar-thumb {
    background: #30363d;
    border-radius: 4px;
}

.terminal-body::-webkit-scrollbar-thumb:hover {
    background: #484f58;
}

/* Card Flip Animation */
.trait-selector-card {
    transition: transform 0.6s ease-in-out;
    transform-style: preserve-3d;
    position: relative;
}

.trait-selector-card.flipped .trait-card-content {
    opacity: 0;
    pointer-events: none;
}

.trait-selector-card.flipped .terminal-container {
    display: flex !important;
    animation: terminalFadeIn 0.3s ease-in-out 0.3s both;
}

@keyframes terminalFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}



/* Card Accents */
.trait-panel-accent, .blue-accent {
    position: absolute;
    top: 0;
    right: 0;
    width: 6px;
    height: 100%;
    background: var(--green);
    opacity: 0.8;
    z-index: 20;
}

/* Responsive */
@media (max-width: 768px) {
    .avatar-container {
        grid-template-columns: 1fr;
        gap: 20px;
        height: auto; /* Allow flexible height on mobile */
        width: 100vw !important;
        max-width: 100vw !important;
        padding: 0 20px;
        box-sizing: border-box;
    }

    /* Fix card order - BUILD card first, CHARACTER card second */
    .trait-panel {
        order: 1;
        width: 100%;
        box-sizing: border-box;
    }

    .avatar-display {
        order: 2;
        width: 100%;
        box-sizing: border-box;
    }

    .trait-selector-card, .avatar-card {
        height: auto !important; /* Keep auto height as requested */
        min-height: 500px; /* Minimum height for mobile usability */
        width: calc(100vw - 40px) !important; /* Viewport-based width */
        max-width: calc(100vw - 40px) !important;
        min-width: calc(100vw - 40px) !important;
        margin: 0 auto;
        padding: 0 !important; /* Reset any padding differences */
        box-sizing: border-box;
        flex-shrink: 0; /* Prevent cards from shrinking differently */
    }
    
    /* Add padding back to card content */
    .trait-card-content, .card-content {
        padding: 15px !important;
    }

    .trait-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .artwork-title {
        font-size: 1.8rem;
    }

    /* Terminal mobile adjustments */
    .terminal-body {
        padding: 12px;
        font-size: 12px;
    }

    /* Hide advanced section on mobile for cleaner UX */
    .advanced-section {
        display: none;
    }
}

/* Loading Overlay Styles */

.loading-overlay {
    display: inline-block;
    opacity: 1;
    visibility: visible;
    transition: all 0.3s ease;
    z-index: 9999;
    pointer-events: none;
}


.loading-content {
    background-color: transparent;
    color: #333;
    font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
    border: none;
    padding: 0;
    box-shadow: none;
    backdrop-filter: none;
    min-width: auto;
    border-radius: 0;
}

.status-line {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 0;
}

.spinner {
    width: 12px;
    height: 12px;
    border: 1px solid #ccc;
    border-top: 1px solid #ff6b35;
    border-radius: 50%;
}

.spinner.active {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.status-text {
    color: #ff6b35;
    font-weight: bold;
    font-size: 12px;
    min-width: auto;
}

.meta-info {
    color: #888;
    font-size: 11px;
}

/* Mobile adjustments for loading overlay */
@media (max-width: 768px) {
    .loading-overlay {
        bottom: 10px;
        right: 10px;
        left: 10px;
    }
    
    .loading-content {
        min-width: auto;
        padding: 12px 16px;
    }
    
    .status-text {
        min-width: auto;
        font-size: 13px;
    }
    
    .meta-info {
        font-size: 12px;
    }
}
