:root {
    /* Premium Dark Palette */
    --bg-dark: #0a0a0c;
    --bg-panel: #131316;
    --bg-element: #1c1c21;
    --primary-gradient: linear-gradient(135deg, #7c3aed 0%, #db2777 100%);
    --primary-color: #a855f7;
    --secondary-color: #ec4899;
    --text-main: #ffffff;
    --text-muted: #9ca3af;
    --border-color: #2e2e36;
    --success: #10b981;
    --error: #ef4444;

    /* Glassmorphism */
    --glass-bg: rgba(28, 28, 33, 0.7);
    --glass-border: rgba(255, 255, 255, 0.08);
    --blur-amount: 12px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar Styling */
.sidebar {
    width: 340px;
    background-color: var(--bg-panel);
    border-right: 1px solid var(--border-color);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    overflow-y: auto;
    transition: transform 0.3s ease;
    z-index: 10;
}

.brand h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.gradient-text {
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Sidebar Tabs */
.sidebar-tabs {
    display: flex;
    background: var(--bg-element);
    padding: 4px;
    border-radius: 8px;
    gap: 4px;
}

.tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    padding: 8px;
    color: var(--text-muted);
    font-size: 0.9rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.tab-btn.active {
    background: var(--bg-panel);
    color: var(--text-main);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.tab-content {
    display: none;
    flex-direction: column;
    gap: 1.5rem;
}

.tab-content.active {
    display: flex;
}

/* Settings Groups */
.settings-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.settings-group label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.info-tooltip {
    background: var(--bg-element);
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    cursor: help;
    border: 1px solid var(--border-color);
}

input[type="password"],
input[type="text"],
select,
textarea {
    background: var(--bg-element);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.75rem;
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.9rem;
    width: 100%;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(168, 85, 247, 0.2);
}

.hidden {
    display: none !important;
}

/* Range Slider Styling */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: var(--bg-element);
    border-radius: 3px;
    outline: none;
    border: 1px solid var(--border-color);
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: var(--primary-gradient);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(168, 85, 247, 0.4);
    transition: transform 0.2s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--primary-gradient);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 6px rgba(168, 85, 247, 0.4);
}

.range-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 4px;
}

#reply-length-value {
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 600;
}

/* Buttons */
.primary-btn {
    background: var(--primary-gradient);
    border: none;
    color: white;
    padding: 0.8rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: opacity 0.2s;
    width: 100%;
}

.primary-btn:hover {
    opacity: 0.9;
}

.secondary-btn {
    background: var(--bg-element);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 0.6rem;
    border-radius: 8px;
    cursor: pointer;
}

.secondary-btn:hover {
    border-color: var(--primary-color);
    color: var(--text-main);
}

.small-btn {
    padding: 0.4rem;
    font-size: 0.8rem;
}

/* Character Mini Card (Active) */
.character-mini-card {
    background: var(--bg-element);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.character-mini-card.empty {
    border-style: dashed;
    opacity: 0.7;
}

.mini-avatar {
    width: 40px;
    height: 40px;
    background: var(--bg-panel);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.mini-info {
    display: flex;
    flex-direction: column;
}

.mini-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.mini-role {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.model-badge {
    display: inline-block;
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--primary-color);
    color: white;
    margin-top: 4px;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.model-badge.default {
    background: var(--bg-element);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
}

/* My Characters List */
.character-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.character-item {
    background: var(--bg-element);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.character-item:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.character-item.active {
    border-color: var(--primary-color);
    background: rgba(168, 85, 247, 0.1);
}

.character-actions {
    margin-left: auto;
    display: flex;
    gap: 5px;
}

.action-icon {
    opacity: 0.5;
    cursor: pointer;
    padding: 4px;
}

.action-icon:hover {
    opacity: 1;
    color: var(--error);
}



.credits {
    margin-top: auto;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
}

.credits a {
    color: var(--primary-color);
    text-decoration: none;
}

/* Main Chat Styling */
.chat-interface {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-dark);
    position: relative;
}

.chat-header {
    height: 60px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    background: rgba(10, 10, 12, 0.8);
    backdrop-filter: blur(var(--blur-amount));
}

.current-model-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--border-color);
}

.status-dot.online {
    background-color: var(--success);
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.4);
}

#mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-main);
    cursor: pointer;
}

/* Chat History */
.chat-history {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    scroll-behavior: smooth;
}

.welcome-message {
    text-align: center;
    margin-top: 5vh;
    animation: fadeIn 0.5s ease-out;
}

.welcome-message h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.features {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 2rem;
    flex-wrap: wrap;
}

.feature-item {
    background: var(--bg-element);
    border: 1px solid var(--border-color);
    padding: 0.8rem 1.2rem;
    border-radius: 12px;
    font-size: 0.9rem;
}

/* Message Bubbles */
.message {
    max-width: 80%;
    padding: 1rem 1.2rem;
    border-radius: 16px;
    line-height: 1.6;
    font-size: 0.95rem;
    position: relative;
    animation: slideIn 0.3s ease-out;
}

.message.user {
    align-self: flex-end;
    background: var(--primary-gradient);
    color: white;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 15px rgba(124, 58, 237, 0.2);
}

.message.ai {
    align-self: flex-start;
    background: var(--bg-element);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 4px;
    color: var(--text-main);
}

.message.system {
    align-self: center;
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
    border: 1px solid rgba(239, 68, 68, 0.2);
    font-size: 0.85rem;
    text-align: center;
    max-width: 90%;
}

/* Markdown Styling inside messages */
.message p {
    margin-bottom: 0.8rem;
}

.message p:last-child {
    margin-bottom: 0;
}

.message code {
    background: rgba(0, 0, 0, 0.2);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.9em;
}

/* Input Area */
.input-area {
    padding: 1.5rem;
    background: rgba(10, 10, 12, 0.9);
    border-top: 1px solid var(--border-color);
    backdrop-filter: blur(var(--blur-amount));
}

.input-container {
    display: flex;
    gap: 0.8rem;
    background: var(--bg-element);
    padding: 0.5rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    transition: all 0.2s;
}

.input-container:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(168, 85, 247, 0.2);
}

#user-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-main);
    padding: 0.8rem;
    resize: none;
    max-height: 120px;
    font-family: inherit;
    outline: none;
}

#send-btn {
    background: var(--bg-panel);
    border: none;
    color: var(--text-muted);
    width: 45px;
    height: 45px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

#send-btn:hover {
    color: var(--primary-color);
    background: rgba(168, 85, 247, 0.1);
}

/* MODALS */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.modal:not(.hidden) {
    opacity: 1;
    pointer-events: all;
}

.modal-content {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    width: 90%;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    max-height: 85vh;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.large-modal {
    max-width: 800px;
    height: 700px;
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.close-modal {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.modal-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    padding: 0 1.5rem;
}

.mode-tab {
    background: none;
    border: none;
    padding: 1rem;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
}

.mode-tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.mode-content {
    display: none;
    flex-direction: column;
    gap: 1rem;
    height: 100%;
}

.mode-content.active {
    display: flex;
}

.mode-desc {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

/* Interview Chat */
.interview-chat-area {
    flex: 1;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.interview-input {
    display: flex;
    gap: 10px;
}

.interview-input input {
    flex: 1;
}

.scrollable-form {
    gap: 1.5rem;
}

.modal-actions {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

/* Loading Animation */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 4px 8px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-dot:nth-child(2) {
    animation-delay: -0.16s;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes bounce {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -340px;
        height: 100%;
        box-shadow: 5px 0 25px rgba(0, 0, 0, 0.5);
    }

    .sidebar.open {
        transform: translateX(340px);
        left: -340px;
    }

    #mobile-menu-btn {
        display: block;
    }

    .message {
        max-width: 90%;
    }
}

/* Creator Model Selector Styles */
.creator-settings {
    flex-wrap: wrap;
}

.creator-settings>div {
    display: flex;
    gap: 1rem;
    align-items: center;
}

#creator-model {
    min-width: 150px;
    background: var(--bg-element);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.5rem;
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

#creator-model:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(168, 85, 247, 0.2);
}

/* Creator Model Chips */
.creator-model-chips {
    padding: 0.5rem 0;
}

.creator-model-chips .model-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.creator-model-chips .chip {
    background: var(--bg-element);
    border: 1px solid var(--border-color);
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

.creator-model-chips .chip:hover {
    background: var(--accent);
    transform: translateY(-1px);
}



/* Pricing display for paid models */
#creator-model option[data-pricing="paid"] {
    color: var(--accent);
}

#creator-model optgroup {
    font-weight: 600;
    color: var(--text-muted);
}

#creator-model optgroup option {
    font-weight: 400;
    color: var(--text-main);
}


/* Debug Container */
.debug-container {
    background: #000;
    border-bottom: 1px solid var(--border-color);
    padding: 0;
    font-family: monospace;
    font-size: 0.8rem;
    display: flex;
    flex-direction: column;
}

.debug-header {
    background: rgba(255, 255, 255, 0.05);
    padding: 0.5rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.debug-title {
    color: var(--primary-color);
    font-weight: 600;
}

#creator-debug-content {
    padding: 1rem 1.5rem;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 200px;
    overflow-y: auto;
    color: #00ff00;
    /* Hacker terminal green */
    margin: 0;
}

.debug-container.hidden {
    display: none;
}