/* Modern SaaS Glassmorphism & Utilities */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --bg-main: #ffffff;
    --bg-surface: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --accent: #3b82f6;
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(0, 0, 0, 0.06);
}

.dark {
    --bg-main: #171717;
    --bg-surface: #1c1c1c;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: #2a2a2a;
    --accent: #3b82f6;
    --glass-bg: rgba(23, 23, 23, 0.7);
    --glass-border: rgba(255, 255, 255, 0.08);
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-main) !important;
    color: var(--text-main);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Glassmorphism Classes */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

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

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Markdown Content Styling for Chat */
.prose pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 1rem;
    border-radius: 0.5rem;
    overflow-x: auto;
}

.typing-indicator span {
    animation: blink 1.4s infinite both;
    height: 6px;
    width: 6px;
    background: var(--text-muted);
    border-radius: 50%;
    display: inline-block;
    margin: 0 1px;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes blink {
    0% {
        opacity: 0.2;
    }

    20% {
        opacity: 1;
    }

    100% {
        opacity: 0.2;
    }
}

/* Toast */
#toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 50;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* --- ChatGPT Redesign Layout & Transitions --- */
#chat-workspace {
    position: relative;
    height: 100%;
    width: 100%;
}

#chat-history-scroll {
    display: none;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

.state-active #chat-history-scroll {
    display: block;
    flex-grow: 1;
    opacity: 1;
    pointer-events: auto;
}

/* Center group transitions */
#center-group {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: all 0.6s cubic-bezier(0.25, 1, 0.5, 1);
    z-index: 10;
}

.state-initial #center-group {
    margin-top: auto;
    margin-bottom: auto;
    transform: translateY(-8vh);
}

.state-active #center-group {
    margin-top: 0;
    margin-bottom: 0;
    width: 100%;
}

#empty-state {
    opacity: 1;
    max-height: 400px;
    transition: all 0.6s cubic-bezier(0.25, 1, 0.5, 1);
}

.state-active #empty-state {
    opacity: 0;
    max-height: 0;
    margin-bottom: 0;
    padding-top: 0;
    padding-bottom: 0;
    overflow: hidden;
    pointer-events: none;
}

/* Message styling: User on right, Assistant on left */
.message-row {
    display: flex;
    width: 100%;
    margin-bottom: 1.5rem;
    gap: 1.5rem;
}

.message-row.user {
    justify-content: flex-end;
}

.message-row.assistant {
    justify-content: flex-start;
}

.message-avatar {
    flex-shrink: 0;
    width: 2rem;
    height: 2rem;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.875rem;
}

.message-row.user .message-avatar {
    background-color: var(--accent);
    color: white;
}

.message-row.assistant .message-avatar {
    background-color: #10b981;
    color: white;
}

.message-bubble {
    max-width: 80%;
    padding: 0.875rem 1.25rem;
    border-radius: 1.25rem;
    font-size: 0.975rem;
    line-height: 1.6;
    word-break: break-word;
}

/* User Message Bubble */
.message-row.user .message-bubble {
    background-color: #f4f4f4;
    color: #0d0d0d;
    border-top-right-radius: 0.25rem;
}
.dark .message-row.user .message-bubble {
    background-color: #2f2f2f;
    color: #ececec;
}

/* Assistant Message Bubble */
.message-row.assistant .message-bubble {
    background-color: transparent;
    color: var(--text-main);
    padding-left: 0;
    padding-right: 0;
    max-width: calc(100% - 3.5rem);
    width: 100%;
}

/* Code Blocks Styling */
.prose pre {
    position: relative !important;
    background: #0d0d0d !important;
    color: #ececec !important;
    padding: 2.5rem 1rem 1rem 1rem !important;
    border-radius: 0.75rem !important;
    font-family: monospace;
    font-size: 0.875rem;
    margin: 1.25rem 0;
    overflow-x: auto;
}

.code-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2.25rem;
    background: #2f2f2f;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1rem;
    font-size: 0.75rem;
    color: #b4b4b4;
    border-top-left-radius: 0.75rem;
    border-top-right-radius: 0.75rem;
}

.copy-btn {
    background: transparent;
    border: none;
    color: #b4b4b4;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    transition: color 0.2s;
}

.copy-btn:hover {
    color: #ffffff;
}

/* Mic animation states */
.mic-listening {
    color: #ef4444 !important;
    animation: mic-pulse 1.5s infinite;
}

@keyframes mic-pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

/* Sidebar sessions list styles */
.session-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.625rem 0.875rem;
    border-radius: 0.75rem;
    font-size: 0.875rem;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.session-item:hover {
    background-color: rgba(0, 0, 0, 0.04);
}

.dark .session-item:hover {
    background-color: rgba(255, 255, 255, 0.04);
}

.session-item.active {
    background-color: rgba(59, 130, 246, 0.1);
    color: var(--accent);
    font-weight: 500;
}

.dark .session-item.active {
    background-color: rgba(59, 130, 246, 0.15);
}

.session-actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.session-item:hover .session-actions {
    opacity: 1;
}

.session-action-btn {
    padding: 0.25rem;
    border-radius: 0.375rem;
    color: var(--text-muted);
    transition: all 0.15s ease;
}

.session-action-btn:hover {
    color: #ef4444;
    background-color: rgba(239, 68, 68, 0.1);
}

/* Sidebar toggle visibility classes */
#sidebar.collapsed {
    transform: translateX(-100%);
}

@media (min-width: 768px) {
    #sidebar.collapsed {
        display: none !important;
    }
}