/* CSS Design System for Claude Infinite Playground */

:root {
    /* Color Palette */
    --bg-app: #070a13;
    --bg-sidebar: rgba(13, 19, 33, 0.85);
    --bg-chat-container: #090e1a;
    --bg-card: rgba(22, 30, 49, 0.6);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-color-active: rgba(255, 255, 255, 0.15);
    
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    
    /* Model Themes (Default: Fable Theme) */
    --theme-primary: #f59e0b;
    --theme-primary-hover: #d97706;
    --theme-glow: rgba(245, 158, 11, 0.15);
    --theme-gradient: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    
    /* Model Colors mapping */
    --color-fable: #f59e0b;
    --color-sonnet: #8b5cf6;
    --color-opus: #ef4444;
    --color-haiku: #10b981;
    
    /* System variables */
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
    --font-heading: 'Outfit', sans-serif;
    --font-mono: 'Fira Code', monospace;
    
    --sidebar-width: 320px;
    --chat-bubble-user: #2563eb;
    --chat-bubble-assistant: rgba(22, 30, 49, 0.9);
}

/* Reset and Core Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body, html {
    height: 100%;
    background-color: var(--bg-app);
    color: var(--text-primary);
    font-family: var(--font-sans);
    overflow: hidden;
    line-height: 1.5;
}

/* Layout Structure */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    position: relative;
    background-image: 
        radial-gradient(at 0% 0%, rgba(22, 38, 70, 0.25) 0px, transparent 50%),
        radial-gradient(at 100% 100%, var(--theme-glow) 0px, transparent 50%);
    transition: background-image 0.5s ease;
}

/* Sidebar Styles */
.sidebar {
    width: var(--sidebar-width);
    height: 100%;
    background-color: var(--bg-sidebar);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 10;
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.logo-icon {
    font-size: 24px;
    background: var(--theme-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: pulse-glow 3s infinite ease-in-out;
}

.logo-text {
    font-family: var(--font-heading);
    font-size: 22px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.logo-text span {
    font-weight: 400;
    background: var(--theme-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-subtext {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.config-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.section-title {
    font-family: var(--font-heading);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.75px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

/* Control Elements */
.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.control-group label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

.control-group.row-group {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
}

select {
    width: 100%;
    padding: 12px;
    background-color: rgba(9, 14, 26, 0.6);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 500;
    outline: none;
    cursor: pointer;
    transition: all 0.2s ease;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%239ca3af'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 36px;
}

select:focus {
    border-color: var(--theme-primary);
    box-shadow: 0 0 0 2px var(--theme-glow);
}

.model-description {
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.4;
    padding: 4px 2px;
}

/* Switch Toggle Component */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.1);
    transition: .3s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 4px;
    bottom: 4px;
    background-color: var(--text-primary);
    transition: .3s;
}

input:checked + .slider {
    background-color: var(--theme-primary);
}

input:focus + .slider {
    box-shadow: 0 0 1px var(--theme-primary);
}

input:checked + .slider:before {
    transform: translateX(20px);
}

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

/* Slider Controls */
.slider-header {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
}

.slider-header span {
    font-family: var(--font-mono);
    color: var(--theme-primary);
    font-weight: 600;
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--theme-primary);
    cursor: pointer;
    transition: transform 0.1s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

/* Textareas and Inputs */
textarea {
    width: 100%;
    padding: 12px;
    background-color: rgba(9, 14, 26, 0.6);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 13px;
    resize: none;
    outline: none;
    transition: all 0.2s ease;
}

textarea:focus {
    border-color: var(--theme-primary);
    box-shadow: 0 0 0 2px var(--theme-glow);
}

#system-prompt {
    height: 80px;
    font-size: 12px;
}

/* Stats Section */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.stat-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 10px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-label {
    font-size: 10px;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
}

.stat-value {
    font-size: 13px;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--text-primary);
}

/* Quick templates list */
.templates-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.template-btn {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 10px 12px;
    border-radius: 8px;
    text-align: left;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.template-btn:hover {
    border-color: var(--theme-primary);
    color: var(--text-primary);
    background-color: rgba(255, 255, 255, 0.03);
}

/* Buttons in Sidebar */
.sidebar-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
}

.secondary-btn {
    width: 100%;
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.secondary-btn:hover {
    border-color: rgba(239, 68, 68, 0.4);
    color: #ef4444;
    background-color: rgba(239, 68, 68, 0.05);
}

/* Chat Main Area */
.chat-area {
    flex: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-chat-container);
}

/* Chat Header */
.chat-header {
    height: 72px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 32px;
    background-color: rgba(9, 14, 26, 0.4);
    backdrop-filter: blur(8px);
    z-index: 5;
}

.active-model-display {
    display: flex;
    align-items: center;
    gap: 12px;
}

.model-badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    font-family: var(--font-heading);
    letter-spacing: 0.5px;
    text-transform: lowercase;
    border: 1px solid transparent;
}

.model-badge.fable {
    background-color: rgba(245, 158, 11, 0.1);
    color: var(--color-fable);
    border-color: rgba(245, 158, 11, 0.2);
}

.model-badge.sonnet {
    background-color: rgba(139, 92, 246, 0.1);
    color: var(--color-sonnet);
    border-color: rgba(139, 92, 246, 0.2);
}

.model-badge.opus {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--color-opus);
    border-color: rgba(239, 68, 68, 0.2);
}

.model-badge.haiku {
    background-color: rgba(16, 185, 129, 0.1);
    color: var(--color-haiku);
    border-color: rgba(16, 185, 129, 0.2);
}

.status-indicator-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--text-muted);
}

.status-indicator-dot.online {
    background-color: #10b981;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
}

.status-indicator-dot.busy {
    background-color: var(--theme-primary);
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.5);
    animation: flash 1.5s infinite alternate;
}

.status-text {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.info-label {
    font-size: 11px;
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    padding: 4px 8px;
    border-radius: 6px;
    font-weight: 600;
}

/* Welcome Screen */
.welcome-screen {
    max-width: 680px;
    margin: auto;
    padding: 40px 20px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.welcome-icon {
    font-size: 48px;
    width: 80px;
    height: 80px;
    border-radius: 24px;
    background: var(--theme-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    margin-bottom: 8px;
    box-shadow: 0 10px 25px var(--theme-glow);
}

.welcome-screen h2 {
    font-family: var(--font-heading);
    font-size: 32px;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.welcome-screen p {
    color: var(--text-secondary);
    font-size: 15px;
    max-width: 500px;
    margin-bottom: 24px;
}

.welcome-steps {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    width: 100%;
}

.step-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.step-num {
    font-size: 11px;
    font-weight: 800;
    color: var(--theme-primary);
    background-color: var(--theme-glow);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.step-card h4 {
    font-family: var(--font-heading);
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
}

.step-card p {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-bottom: 0;
}

/* Chat Messages Area */
.chat-messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 32px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Chat Bubbles */
.message-wrapper {
    display: flex;
    gap: 16px;
    max-width: 80%;
    animation: slide-in 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.message-wrapper.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-wrapper.assistant {
    align-self: flex-start;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-family: var(--font-heading);
    font-size: 14px;
    flex-shrink: 0;
}

.message-wrapper.user .avatar {
    background-color: var(--chat-bubble-user);
    color: #fff;
}

.message-wrapper.assistant .avatar {
    background-color: var(--theme-glow);
    color: var(--theme-primary);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.message-bubble {
    padding: 14px 18px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.6;
    word-break: break-word;
}

.message-wrapper.user .message-bubble {
    background-color: var(--chat-bubble-user);
    color: #fff;
    border-top-right-radius: 4px;
}

.message-wrapper.assistant .message-bubble {
    background-color: var(--chat-bubble-assistant);
    color: var(--text-primary);
    border-top-left-radius: 4px;
    border: 1px solid var(--border-color);
}

/* Markdown styling inside bubbles */
.message-bubble p {
    margin-bottom: 12px;
}
.message-bubble p:last-child {
    margin-bottom: 0;
}

.message-bubble h1, 
.message-bubble h2, 
.message-bubble h3, 
.message-bubble h4 {
    font-family: var(--font-heading);
    font-weight: 700;
    margin: 16px 0 8px 0;
}
.message-bubble h1 { font-size: 20px; }
.message-bubble h2 { font-size: 18px; }
.message-bubble h3 { font-size: 16px; }

.message-bubble ul, 
.message-bubble ol {
    margin: 8px 0 16px 20px;
}

.message-bubble li {
    margin-bottom: 6px;
}

.message-bubble blockquote {
    border-left: 3px solid var(--theme-primary);
    padding-left: 12px;
    color: var(--text-secondary);
    margin: 12px 0;
    font-style: italic;
}

/* Code Syntax Styling */
.message-bubble code {
    font-family: var(--font-mono);
    font-size: 12.5px;
    background-color: rgba(0, 0, 0, 0.3);
    padding: 2px 6px;
    border-radius: 4px;
    color: #f43f5e;
}

.message-bubble pre {
    margin: 16px 0;
    border-radius: 8px;
    overflow-x: auto;
    background-color: rgba(0, 0, 0, 0.4) !important;
    border: 1px solid var(--border-color);
}

.message-bubble pre code {
    background-color: transparent;
    padding: 0;
    border-radius: 0;
    color: inherit;
    display: block;
}

.code-block-header {
    background-color: rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid var(--border-color);
    padding: 6px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
    font-size: 11px;
    font-family: var(--font-mono);
    color: var(--text-secondary);
}

.copy-code-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.copy-code-btn:hover {
    color: var(--text-primary);
    background-color: rgba(255, 255, 255, 0.05);
}

/* Tables inside chat */
.message-bubble table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
}

.message-bubble th, 
.message-bubble td {
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    text-align: left;
    font-size: 13px;
}

.message-bubble th {
    background-color: rgba(255, 255, 255, 0.03);
    font-weight: 600;
}

/* Typing cursor animation for streams */
.typing-cursor {
    display: inline-block;
    width: 6px;
    height: 14px;
    background-color: var(--theme-primary);
    margin-left: 2px;
    animation: blink 0.8s infinite;
    vertical-align: middle;
}

/* Input Area at Bottom */
.chat-input-area {
    padding: 24px 32px 32px 32px;
    background-color: var(--bg-chat-container);
    border-top: 1px solid var(--border-color);
}

.input-container {
    max-width: 800px;
    margin: 0 auto;
    background-color: rgba(9, 14, 26, 0.6);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.input-container:focus-within {
    border-color: var(--theme-primary);
    box-shadow: 0 10px 30px var(--theme-glow);
}

#user-input {
    background: transparent;
    border: none;
    padding: 0;
    border-radius: 0;
    max-height: 200px;
    min-height: 24px;
    font-size: 14.5px;
    line-height: 1.5;
}

#user-input:focus {
    box-shadow: none;
}

.input-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.shortcut-hint {
    font-size: 11px;
    color: var(--text-muted);
}

.button-group {
    display: flex;
    gap: 10px;
}

.send-btn, .stop-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.send-btn {
    background: var(--theme-gradient);
    color: #fff;
    box-shadow: 0 4px 12px var(--theme-glow);
}

.send-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px var(--theme-glow);
}

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

.stop-btn {
    background-color: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.stop-btn:hover {
    background-color: rgba(239, 68, 68, 0.2);
}

.hidden {
    display: none !important;
}

/* Animations */
@keyframes slide-in {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse-glow {
    0%, 100% {
        filter: drop-shadow(0 0 2px var(--theme-primary));
        opacity: 0.8;
    }
    50% {
        filter: drop-shadow(0 0 8px var(--theme-primary));
        opacity: 1;
    }
}

@keyframes blink {
    0%, 100% { opacity: 0; }
    50% { opacity: 1; }
}

@keyframes flash {
    0% { opacity: 0.4; }
    100% { opacity: 1; }
}

/* Custom Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Responsive adjustments */
@media (max-width: 900px) {
    .app-container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        max-height: 350px;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    
    .chat-area {
        height: calc(100vh - 350px);
    }
    
    .message-wrapper {
        max-width: 95%;
    }
}
