/* ============================================================
   Character Creator — Premium Dark Theme
   ============================================================ */

.cc-main {
    display: grid;
    grid-template-columns: 420px 1fr;
    min-height: 100vh;
    padding-top: var(--nav-height);
}

/* ── Left Panel (Controls) ── */
.cc-panel.cc-controls {
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-subtle);
    padding: 24px;
    overflow-y: auto;
    max-height: calc(100vh - var(--nav-height));
    position: sticky;
    top: var(--nav-height);
}

.cc-panel-header {
    margin-bottom: 24px;
}

.cc-title {
    font-size: 1.5rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 10px;
    letter-spacing: -0.5px;
}

.cc-title-icon {
    font-size: 1.6rem;
}

.cc-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ── Tabs ── */
.cc-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    padding: 4px;
    margin-bottom: 20px;
    overflow-x: auto;
}

.cc-tab {
    flex: 1;
    min-width: 0;
    padding: 8px 6px;
    font-size: 0.72rem;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    color: var(--text-muted);
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    white-space: nowrap;
}

.cc-tab:hover {
    color: var(--text-secondary);
    background: rgba(139, 92, 246, 0.06);
}

.cc-tab.active {
    color: #fff;
    background: var(--accent-primary);
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.3);
}

.cc-tab-icon {
    font-size: 1rem;
}

/* ── Tab Content ── */
.cc-tab-content {
    display: none;
}

.cc-tab-content.active {
    display: block;
    animation: ccFadeIn 0.25s ease-out;
}

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

/* ── Form Elements ── */
.cc-form-group {
    margin-bottom: 16px;
}

.cc-form-row {
    display: flex;
    gap: 12px;
}

.cc-form-half {
    flex: 1;
}

.cc-label {
    display: flex;
    align-items: baseline;
    gap: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cc-label-hint {
    font-size: 0.7rem;
    font-weight: 400;
    color: var(--text-muted);
    text-transform: none;
    letter-spacing: 0;
}

.cc-select,
.cc-input {
    width: 100%;
    padding: 10px 14px;
    font-size: 0.9rem;
    font-family: 'Inter', sans-serif;
    color: var(--text-primary);
    background: var(--bg-primary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    -webkit-appearance: none;
}

.cc-select {
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 5l3 3 3-3' stroke='%23666680' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

.cc-select:focus,
.cc-input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.12);
}

.cc-input::placeholder {
    color: var(--text-muted);
}

.cc-textarea {
    width: 100%;
    padding: 10px 14px;
    font-size: 0.85rem;
    font-family: 'Inter', sans-serif;
    color: var(--text-primary);
    background: var(--bg-primary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    outline: none;
    resize: none;
    min-height: 60px;
    overflow-y: auto;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

/* Visual prompt auto-expands to show full description */
#cc-visual-prompt {
    min-height: 180px;
    overflow: hidden;
}

.cc-textarea:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.12);
}

/* ── Generate Button ── */
.cc-btn-generate,
.cc-btn-remix {
    width: 100%;
    padding: 14px 24px;
    font-size: 1rem;
    font-weight: 700;
    font-family: 'Inter', sans-serif;
    color: #fff;
    background: var(--gradient-accent);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.cc-btn-generate:hover,
.cc-btn-remix:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(139, 92, 246, 0.4);
}

.cc-btn-generate:active,
.cc-btn-remix:active {
    transform: translateY(0);
}

.cc-btn-generate.loading,
.cc-btn-remix.loading {
    pointer-events: none;
    opacity: 0.85;
}

.cc-btn-generate.loading .cc-btn-text,
.cc-btn-remix.loading .cc-btn-text,
.cc-btn-generate.loading .cc-btn-icon,
.cc-btn-remix.loading .cc-btn-icon {
    display: none;
}

.cc-btn-generate.loading .cc-btn-loader,
.cc-btn-remix.loading .cc-btn-loader {
    display: flex !important;
    align-items: center;
    gap: 8px;
}

.cc-btn-remix {
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-primary));
    margin-top: 4px;
}

.cc-btn-remix.pulse {
    animation: ccPulse 1.5s ease-in-out infinite;
}

@keyframes ccPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(6, 182, 212, 0.4); }
    50% { box-shadow: 0 0 0 10px rgba(6, 182, 212, 0); }
}

/* ── Spinner ── */
.cc-spinner {
    width: 20px;
    height: 20px;
    border: 2.5px solid rgba(255,255,255,0.25);
    border-top-color: #fff;
    border-radius: 50%;
    animation: ccSpin 0.7s linear infinite;
}

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

/* ── Result Top (name, tagline, traits — above image) ── */
.cc-result-top {
    margin-bottom: 16px;
    animation: ccFadeIn 0.35s ease-out;
}

.cc-result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.cc-result-name {
    font-size: 1.5rem;
    font-weight: 800;
    background: var(--gradient-accent);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.cc-result-badge {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 100px;
    background: rgba(139, 92, 246, 0.15);
    color: var(--accent-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cc-result-oneline {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
    line-height: 1.5;
}

.cc-result-traits {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.cc-trait-tag {
    font-size: 0.75rem;
    font-weight: 500;
    padding: 4px 14px;
    border-radius: 100px;
    background: rgba(6, 182, 212, 0.1);
    color: var(--accent-cyan);
    border: 1px solid rgba(6, 182, 212, 0.2);
}

/* ── Result Bottom (description + remix — below image) ── */
.cc-result-bottom {
    margin-top: 16px;
    margin-bottom: 24px;
    padding: 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    animation: ccFadeIn 0.35s ease-out;
}

/* ── Upload Zone (Cartoon, Identity, Reference tabs) ── */
.cc-upload-zone {
    position: relative;
    border: 2px dashed var(--border-subtle);
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    cursor: pointer;
    transition: all 0.25s ease;
    overflow: hidden;
    min-height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cc-upload-zone:hover,
.cc-upload-zone.drag-over {
    border-color: var(--accent-primary);
    background: rgba(139, 92, 246, 0.06);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.08);
}

.cc-upload-placeholder {
    text-align: center;
    padding: 24px;
    color: var(--text-muted);
}

.cc-upload-icon {
    font-size: 2.5rem;
    display: block;
    margin-bottom: 8px;
    opacity: 0.5;
}

.cc-upload-placeholder p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.cc-upload-hint {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.cc-upload-preview-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
}

/* ══════════════════════════════════ */
/* Right Panel (Preview & Gallery)   */
/* ══════════════════════════════════ */

.cc-panel.cc-preview {
    padding: 24px;
    background: var(--bg-primary);
    overflow-y: auto;
    max-height: calc(100vh - var(--nav-height));
}

.cc-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.cc-preview-title {
    font-size: 1.1rem;
    font-weight: 700;
}

.cc-preview-status {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ── Preview Image ── */
.cc-preview-image {
    position: relative;
    width: 100%;
    max-width: 600px;
    aspect-ratio: 1;
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
}

.cc-preview-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 0.4s ease;
}

.cc-preview-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 32px;
}

.cc-preview-empty-icon {
    font-size: 4rem;
    display: block;
    margin-bottom: 12px;
    opacity: 0.4;
}

.cc-preview-empty p {
    font-size: 0.9rem;
}

.cc-preview-empty-hint {
    font-size: 0.75rem !important;
    margin-top: 4px;
    opacity: 0.6;
}

/* ── Preview Loading ── */
.cc-preview-loading {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(10, 10, 15, 0.85);
    backdrop-filter: blur(8px);
    z-index: 5;
    gap: 12px;
}

.cc-preview-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(139, 92, 246, 0.2);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: ccSpin 0.8s linear infinite;
}

.cc-preview-loading p {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.cc-preview-loading-model {
    font-size: 0.75rem !important;
    color: var(--text-muted) !important;
    font-family: 'Space Mono', monospace;
}

/* ── Gallery ── */
.cc-gallery-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.cc-gallery-title {
    font-size: 0.95rem;
    font-weight: 700;
}

.cc-gallery-count {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.cc-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 8px;
}

.cc-gallery-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s ease;
}

.cc-gallery-item:hover {
    border-color: var(--accent-primary);
    transform: scale(1.03);
    box-shadow: var(--shadow-glow);
}

.cc-gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cc-gallery-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 24px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ── Toast Notification ── */
.cc-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 12px 20px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 500;
    z-index: 9999;
    animation: ccToastIn 0.3s ease-out, ccToastOut 0.3s ease-in 3s forwards;
    box-shadow: var(--shadow-lg);
    max-width: 360px;
}

.cc-toast.success { border-left: 3px solid var(--accent-green); }
.cc-toast.error   { border-left: 3px solid #ef4444; }
.cc-toast.info    { border-left: 3px solid var(--accent-cyan); }

.cc-toast-title {
    font-weight: 700;
    margin-bottom: 2px;
}

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

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

/* ── Responsive ── */
@media (max-width: 900px) {
    .cc-main {
        grid-template-columns: 1fr;
    }

    .cc-panel.cc-controls {
        position: static;
        max-height: none;
        border-right: none;
        border-bottom: 1px solid var(--border-subtle);
    }

    .cc-panel.cc-preview {
        max-height: none;
    }

    .cc-preview-image {
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    .cc-panel.cc-controls,
    .cc-panel.cc-preview {
        padding: 16px;
    }

    .cc-tabs {
        gap: 2px;
    }

    .cc-tab {
        padding: 6px 4px;
        font-size: 0.65rem;
    }

    .cc-form-row {
        flex-direction: column;
        gap: 0;
    }
}
