:root {
    --bg-color: #f2f2f7;
    --text-color: #000000;
    --subtitle-color: #8e8e93;
    --glass-bg: rgba(255, 255, 255, 0.75);
    --glass-border: rgba(255, 255, 255, 0.4);
    --accent-color: #007AFF;
    --bot-msg-bg: rgba(233, 233, 235, 0.8);
    --bot-msg-text: #000;
    --user-msg-bg: #007AFF;
    --user-msg-text: #fff;
    --input-bg: rgba(118, 118, 128, 0.12);
    --input-border: rgba(0,0,0,0);
    --shadow-color: rgba(0,0,0,0.1);
    --blob-color-1: #ff9a9e;
    --blob-color-2: #fad0c4;
    --dot-color: #8e8e93;
    
    /* Formatare avansată */
    --quote-bg: rgba(0, 122, 255, 0.08);
    --quote-border: #007AFF;
    --code-bg: #282c34;
    --code-header-bg: #21252b;
    --code-text: #abb2bf;
    --inline-code-bg: rgba(0, 122, 255, 0.1);
    --inline-code-text: #007AFF;
    --table-border: rgba(0, 0, 0, 0.1);
    --table-header-bg: rgba(0, 122, 255, 0.08);
}

[data-theme="dark"] {
    --bg-color: #000000;
    --text-color: #ffffff;
    --subtitle-color: #98989d;
    --glass-bg: rgba(30, 30, 30, 0.70);
    --glass-border: rgba(255, 255, 255, 0.1);
    --accent-color: #0A84FF;
    --bot-msg-bg: rgba(58, 58, 60, 0.8);
    --bot-msg-text: #fff;
    --user-msg-bg: #0A84FF;
    --user-msg-text: #fff;
    --input-bg: rgba(118, 118, 128, 0.24);
    --input-border: rgba(255,255,255,0.05);
    --shadow-color: rgba(0,0,0,0.3);
    --blob-color-1: #0f2027;
    --blob-color-2: #203a43;
    --dot-color: #d1d1d6;
    
    --quote-bg: rgba(10, 132, 255, 0.12);
    --quote-border: #0A84FF;
    --code-bg: #282c34;
    --code-header-bg: #21252b;
    --code-text: #abb2bf;
    --inline-code-bg: rgba(10, 132, 255, 0.15);
    --inline-code-text: #0A84FF;
    --table-border: rgba(255, 255, 255, 0.1);
    --table-header-bg: rgba(10, 132, 255, 0.12);
}

html, body {
    height: 100%; margin: 0; padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-color); color: var(--text-color);
    overflow: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.background-blobs { 
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: -1; overflow: hidden; 
}
.blob { 
    position: absolute; border-radius: 50%; filter: blur(80px); opacity: 0.4; 
    transition: background 0.5s ease; 
}
.blob-1 { 
    top: -10%; left: -10%; width: 50%; height: 50%; background: var(--blob-color-1); 
    animation: move 15s infinite alternate; 
}
.blob-2 { 
    bottom: -10%; right: -10%; width: 60%; height: 60%; background: var(--blob-color-2); 
    animation: move 12s infinite alternate-reverse; 
}
@keyframes move { 
    from { transform: translate(0, 0); } 
    to { transform: translate(100px, 50px); } 
}

.main-container {
    display: flex; flex-direction: column; height: 100%; max-width: 800px; margin: 0 auto;
    background: var(--glass-bg); backdrop-filter: blur(25px) saturate(180%); 
    -webkit-backdrop-filter: blur(25px) saturate(180%);
    border: 1px solid var(--glass-border);
}
@media (min-width: 801px) { 
    .main-container { 
        height: 90vh; margin-top: 5vh; border-radius: 32px; 
        box-shadow: 0 20px 40px var(--shadow-color); 
    } 
}

.glass-header {
    padding: 20px 25px; display: flex; justify-content: space-between; align-items: center;
    border-bottom: 1px solid var(--glass-border); background: var(--glass-bg);
    backdrop-filter: blur(25px); -webkit-backdrop-filter: blur(25px); 
    border-radius: 32px 32px 0 0; z-index: 10;
}
.header-left { display: flex; align-items: center; gap: 12px; }
.status-indicator { 
    width: 10px; height: 10px; border-radius: 50%; transition: background 0.3s; 
}
.status-indicator.online { background: #34C759; box-shadow: 0 0 10px #34C759; }
.status-indicator.offline { background: #FF3B30; }
.header-titles h1 { 
    margin: 0; 
    font-size: 1.3rem; 
    font-weight: 700;
    color: #001a4d;
    text-shadow: 
        0 0 3px #0066ff,
        0 0 6px #0066ff,
        0 0 9px #0066ff;
    -webkit-text-stroke: 1px;
    -webkit-text-stroke-color: #003d99;
    animation: glowPulseSubtle 2s ease-in-out infinite;
}

@keyframes glowPulseSubtle {
    0%, 100% {
        text-shadow: 
            0 0 3px #0066ff,
            0 0 6px #0066ff,
            0 0 9px #0066ff,
            0 0 12px #0066ff;
    }
    50% {
        text-shadow: 
            0 0 1.5px #0066ff,
            0 0 3px #0066ff,
            0 0 4.5px #0066ff,
            0 0 7.5px #0066ff;
    }
}
.subtitle { margin: 0; font-size: 0.8rem; color: var(--subtitle-color); }
.header-actions { display: flex; gap: 15px; align-items: center; }

.model-selector-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.model-selector {
    height: 36px;
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    background: var(--input-bg);
    color: var(--text-color);
    font: inherit;
    font-size: 0.86rem;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    width: 165px;
    max-width: 30vw;
    padding: 0 10px;
    cursor: pointer;
}

.model-selector:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.12);
}

.theme-selector-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.theme-selector-dropdown {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 10px;
    display: flex;
    gap: 10px;
    padding: 12px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    box-shadow: 0 4px 16px var(--shadow-color);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    z-index: 1000;
}

.theme-selector-wrapper:hover .theme-selector-dropdown {
    opacity: 1;
    visibility: visible;
}

.color-dot {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border: 2px solid transparent;
}
.color-dot:hover {
    transform: scale(1.15);
}

.color-dot.theme-1 { background: #007AFF; }
.color-dot.theme-2 { background: #FF3B30; }
.color-dot.theme-3 { background: #34C759; }
.color-dot.theme-4 { background: #FF9500; }
.color-dot.theme-5 { background: #AF52DE; }
.color-dot.theme-6 { background: #00C7FD; }

.color-dot.active {
    border-color: var(--text-color);
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.4);
}

.icon-btn {
    background: none; border: none; cursor: pointer; color: var(--accent-color); padding: 8px;
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    transition: background 0.2s ease, transform 0.2s ease;
}
.icon-btn:hover { background: var(--input-bg); transform: scale(1.1); }
.icon-btn:active { transform: scale(0.95); }

.new-chat-icon {
    background: var(--accent-color);
    color: white;
    padding: 10px;
    border-radius: 50%;
}
.new-chat-icon:hover {
    background: var(--accent-color);
    opacity: 0.85;
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.4);
}

[data-theme="light"] .sun-icon { display: none; }
[data-theme="dark"] .moon-icon { display: none; }

@media (max-width: 600px) {
    .glass-header {
        align-items: flex-start;
        flex-wrap: wrap;
        gap: 12px;
        padding: 16px;
    }

    .header-left {
        min-width: 0;
    }

    .header-actions {
        width: 100%;
        justify-content: flex-end;
        flex-wrap: wrap;
        gap: 8px;
    }

    .model-selector-wrapper {
        width: 100%;
        justify-content: stretch;
    }

    .model-selector {
        width: 100%;
        max-width: none;
    }
}

.chat-content { 
    flex: 1; padding: 20px; overflow-y: auto; display: flex; 
    flex-direction: column; gap: 12px; scrollbar-width: thin;
    opacity: 1;
    transition: opacity 0.6s ease-out;
}
.chat-content::-webkit-scrollbar { width: 6px; }
.chat-content::-webkit-scrollbar-track { background: transparent; }
.chat-content::-webkit-scrollbar-thumb { 
    background: var(--subtitle-color); border-radius: 10px; 
}

/* ============================================
   WELCOME SCREEN
   ============================================ */
#welcome-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    min-height: 400px;
    padding: 40px 20px;
    transition: opacity 0.6s ease-out, visibility 0.6s ease-out, display 0s 0.6s;
    opacity: 1;
    visibility: visible;
    flex: 1;
}

#welcome-screen.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    display: none;
}

.welcome-content {
    text-align: center;
    animation: welcomeFadeIn 0.8s ease-out;
    padding-top: 2rem;
}

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

.welcome-title {
    font-size: 3.5em;
    font-weight: 700;
    color: #001a4d;
    margin: 0 0 0.5em 0;
    letter-spacing: -1px;
    text-shadow: 
        0 0 10px #0066ff,
        0 0 20px #0066ff,
        0 0 30px #0066ff;
    -webkit-text-stroke: 1.5px;
    -webkit-text-stroke-color: #003d99;
    animation: glowPulse 2s ease-in-out infinite;
}

@keyframes glowPulse {
    0%, 100% {
        text-shadow: 
            0 0 10px #0066ff,
            0 0 20px #0066ff,
            0 0 30px #0066ff,
            0 0 40px #0066ff;
    }
    50% {
        text-shadow: 
            0 0 5px #0066ff,
            0 0 10px #0066ff,
            0 0 15px #0066ff,
            0 0 25px #0066ff;
    }
}

.welcome-subtitle {
    font-size: 0.9em;
    font-weight: 600;
    color: var(--subtitle-color);
    letter-spacing: 2px;
    text-transform: uppercase;
    margin: 0 0 1.5em 0;
}

.prompt-suggestions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.2em;
    margin-bottom: 1.5em;
    max-width: 600px;
}

.prompt-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.8em;
    padding: 1.5em;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--text-color);
    text-align: center;
}

.prompt-box:hover {
    background: rgba(10, 132, 255, 0.1);
    border-color: var(--accent-color);
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(10, 132, 255, 0.2);
}

.prompt-box svg {
    width: 28px;
    height: 28px;
    color: var(--accent-color);
    transition: transform 0.3s ease;
}

.prompt-box:hover svg {
    transform: scale(1.2);
}

.prompt-box p {
    margin: 0;
    font-size: 0.95em;
    font-weight: 500;
}

@media (max-width: 600px) {
    .prompt-suggestions {
        grid-template-columns: 1fr;
    }
}

.welcome-email {
    display: inline-flex;
    align-items: center;
    gap: 0.8em;
    padding: 12px 24px;
    margin-bottom: 1.5em;
    background: var(--input-bg);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
    cursor: pointer;
}

.welcome-email:hover {
    background: rgba(0, 122, 255, 0.1);
    border-color: var(--accent-color);
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.2);
    transform: translateY(-2px);
}

.welcome-email svg {
    width: 20px;
    height: 20px;
}

.message {
    max-width: 88%;
    padding: 12px 18px; border-radius: 20px; line-height: 1.6; font-size: 1rem;
    position: relative; word-wrap: break-word; animation: popIn 0.3s;
}
@keyframes popIn { 
    from { opacity: 0; transform: translateY(20px) scale(0.95); } 
    to { opacity: 1; transform: translateY(0) scale(1); } 
}

.message.user { 
    align-self: flex-end; background-color: var(--accent-color); 
    color: white; border-bottom-right-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.25);
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}
.message.bot { 
    align-self: flex-start; background-color: var(--bot-msg-bg); 
    color: var(--bot-msg-text); border-bottom-left-radius: 4px; 
    backdrop-filter: blur(10px);
    box-shadow: 0 0 20px rgba(0, 122, 255, 0.15);
    transition: box-shadow 0.3s ease;
}

/* ============================================
   FORMATARE AVANSATĂ - MARKDOWN
   ============================================ */

/* Paragrafe și spațiere */
.message.bot p {
    margin: 0.6em 0;
    line-height: 1.6;
}

.message.bot p:first-child {
    margin-top: 0;
}

.message.bot p:last-child {
    margin-bottom: 0;
}

/* Text bold și italic */
.message.bot strong {
    font-weight: 700;
    color: var(--text-color);
}

.message.bot em {
    font-style: italic;
    color: var(--text-color);
}

/* Titluri */
.message.bot h1, 
.message.bot h2, 
.message.bot h3, 
.message.bot h4 {
    margin: 1.2em 0 0.6em 0;
    font-weight: 700;
    line-height: 1.3;
    color: var(--text-color);
}

.message.bot h1 { font-size: 1.6em; border-bottom: 2px solid var(--accent-color); padding-bottom: 0.3em; }
.message.bot h2 { font-size: 1.4em; }
.message.bot h3 { font-size: 1.2em; color: var(--accent-color); }
.message.bot h4 { font-size: 1.1em; }

/* Liste */
.message.bot ul, 
.message.bot ol {
    margin: 0.8em 0;
    padding-left: 1.8em;
    line-height: 1.7;
}

.message.bot ul {
    list-style-type: disc;
}

.message.bot ol {
    list-style-type: decimal;
}

.message.bot li {
    margin-bottom: 0.8em;
    padding: 12px 14px;
    padding-left: 0.3em;
    background: var(--input-bg);
    border-radius: 8px;
    border-left: 3px solid var(--accent-color);
    transition: all 0.2s ease;
}

.message.bot li:hover {
    background: var(--glass-bg);
    box-shadow: 0 2px 8px var(--shadow-color);
}

.message.bot li::marker {
    color: var(--accent-color);
    font-weight: 700;
    font-size: 1.1em;
}

/* Sub-liste */
.message.bot li > ul,
.message.bot li > ol {
    margin-top: 0.4em;
    margin-bottom: 0.2em;
}

/* ============================================
   POEZIE
   ============================================ */
.poem {
    font-family: 'Georgia', 'Garamond', serif;
    margin: 1.5em 0;
    padding: 1.8em 2.5em;
    background: linear-gradient(90deg, rgba(0, 122, 255, 0.1) 0%, transparent 20%);
    border-left: 4px solid var(--accent-color);
    border-radius: 8px;
    text-align: left;
    line-height: 2.2;
    color: var(--text-color);
}

.poem .stanza {
    margin-bottom: 2em;
    padding-bottom: 1.5em;
    border-bottom: 1px solid rgba(0, 122, 255, 0.2);
}

.poem .stanza:last-child {
    border-bottom: none;
}

.poem .verse {
    margin: 0.6em 0;
    font-style: italic;
    letter-spacing: 0.3px;
    font-size: 1.05em;
    color: var(--text-color);
}

.poem .stanza-separator {
    text-align: center;
    margin: 1.2em 0;
    opacity: 0.5;
    font-size: 0.9em;
}

/* ============================================
   POVESTE
   ============================================ */
.story {
    font-family: 'Palatino', 'Palatino Linotype', 'Book Antiqua', 'Georgia', serif;
    margin: 1.5em 0;
    padding: 2.2em 2.8em;
    background: linear-gradient(135deg, rgba(0, 122, 255, 0.05) 0%, rgba(0, 122, 255, 0.02) 100%);
    border: 1px solid rgba(0, 122, 255, 0.15);
    border-radius: 12px;
    line-height: 2;
    text-align: justify;
    color: var(--text-color);
    font-size: 1.05em;
    font-style: italic;
    position: relative;
    box-shadow: inset 0 2px 8px rgba(0, 122, 255, 0.05);
}

.story::before {
    content: '✦';
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1.2em;
    color: var(--accent-color);
    opacity: 0.4;
}

.story p {
    margin: 1.2em 0;
    text-indent: 1.5em;
}

.story p:first-of-type {
    text-indent: 0;
}

.story p:first-of-type::first-letter {
    font-size: 2em;
    font-weight: bold;
    color: var(--accent-color);
    margin-right: 0.05em;
    float: left;
    line-height: 0.8;
    padding-right: 0.1em;
}

/* ============================================
   LABEL CU TIPUL DE CONȚINUT
   ============================================ */
.content-type-label {
    display: inline-block;
    margin: 0 0 1em 0;
    padding: 6px 14px;
    font-size: 0.75em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-radius: 20px;
    background: var(--accent-color);
    color: white;
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.3);
    animation: labelFadeIn 0.4s ease-out;
}

@keyframes labelFadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.content-type-label.story-label {
    background: linear-gradient(135deg, var(--accent-color) 0%, #0066ff 100%);
}

.content-type-label.quote-label {
    background: linear-gradient(135deg, #34C759 0%, #17C979 100%);
}

.dialogue {
    margin: 1.2em 1.5em;
    padding: 1em 1.5em;
    background: var(--input-bg);
    border-left: 4px solid var(--accent-color);
    border-radius: 8px;
    font-style: italic;
    color: var(--text-color);
    position: relative;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.dialogue::before {
    content: '❝';
    position: absolute;
    left: 8px;
    top: -8px;
    font-size: 2.5em;
    color: var(--accent-color);
    opacity: 0.2;
    font-weight: bold;
}

.dialogue::after {
    content: '❞';
    position: absolute;
    right: 12px;
    bottom: -12px;
    font-size: 2.5em;
    color: var(--accent-color);
    opacity: 0.2;
    font-weight: bold;
}

.dialogue-speaker {
    font-weight: 700;
    color: var(--accent-color);
    margin-right: 0.8em;
    font-style: normal;
    text-transform: capitalize;
    letter-spacing: 0.5px;
}

.dialogue-text {
    font-style: italic;
}

.dialogue-text {
    font-style: italic;
}

/* Linii orizontale */
.message.bot hr {
    border: none;
    border-top: 2px solid var(--glass-border);
    margin: 1.5em 0;
    opacity: 0.6;
}

/* ============================================
   CITATE (BLOCKQUOTE)
   ============================================ */
.message.bot blockquote {
    margin: 1em 0;
    padding: 12px 18px;
    background: var(--quote-bg);
    border-left: 4px solid var(--quote-border);
    border-radius: 0 8px 8px 0;
    font-style: italic;
    color: var(--text-color);
    position: relative;
}

.message.bot blockquote::before {
    content: '"';
    font-size: 2.5em;
    color: var(--quote-border);
    opacity: 0.3;
    position: absolute;
    left: 8px;
    top: -10px;
    font-family: Georgia, serif;
}

.message.bot blockquote p {
    margin: 0.3em 0;
}

/* ============================================
   CITATE INLINE - TRATARE SPECIALĂ
   ============================================ */
.quote-element {
    margin: 1em 0;
    padding: 16px 18px;
    background: var(--quote-bg);
    border-left: 4px solid var(--quote-border);
    border-radius: 0 8px 8px 0;
    font-style: italic;
    color: var(--text-color);
    position: relative;
}

.quote-element::before {
    content: '"';
    font-size: 2.5em;
    color: var(--quote-border);
    opacity: 0.3;
    position: absolute;
    left: 8px;
    top: -10px;
    font-family: Georgia, serif;
}

.quote-attribution {
    display: block;
    margin-top: 0.8em;
    font-weight: 500;
    font-style: normal;
    color: var(--quote-border);
    font-size: 0.95em;
}

.quote-element .quote-attribution {
    text-align: right;
}

/* ============================================
   BLOCURI DE COD (PRE + CODE)
   ============================================ */
.code-block-wrapper {
    margin: 1.2em 0;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(128, 128, 128, 0.2);
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 14px;
    background: var(--code-header-bg);
    border-bottom: 1px solid rgba(128, 128, 128, 0.2);
}

.code-language {
    font-size: 0.75em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #61afef;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, monospace;
}

.copy-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    padding: 6px 10px;
    cursor: pointer;
    color: #abb2bf;
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.8em;
    transition: all 0.2s ease;
}

.copy-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
    color: #fff;
}

.copy-btn.copied {
    background: rgba(52, 199, 89, 0.2);
    border-color: #34C759;
    color: #34C759;
}

.message.bot pre {
    margin: 0;
    padding: 0;
    background: var(--code-bg);
    overflow-x: auto;
    font-size: 0.9em;
}

.message.bot pre code {
    display: block;
    padding: 16px !important;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    font-size: 0.95em;
    line-height: 1.6;
    color: var(--code-text);
    background: var(--code-bg);
    border-radius: 0;
    overflow-x: auto;
    white-space: pre;
    word-wrap: normal;
}

/* Scroll pentru cod lung */
.message.bot pre::-webkit-scrollbar {
    height: 8px;
}

.message.bot pre::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 0 0 10px 10px;
}

.message.bot pre::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 10px;
}

.message.bot pre::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.4);
}

/* ============================================
   COD INLINE
   ============================================ */
.message.bot p code,
.message.bot li code {
    background: var(--inline-code-bg);
    color: var(--inline-code-text);
    padding: 2px 8px;
    border-radius: 5px;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, monospace;
    font-size: 0.9em;
    font-weight: 500;
    border: 1px solid rgba(0, 122, 255, 0.2);
}

[data-theme="dark"] .message.bot p code,
[data-theme="dark"] .message.bot li code {
    border-color: rgba(10, 132, 255, 0.3);
}

/* ============================================
   TABELE
   ============================================ */
.table-wrapper {
    overflow-x: auto;
    margin: 1.2em 0;
    border-radius: 12px;
    box-shadow: 0 4px 16px var(--shadow-color);
    border: 1px solid var(--glass-border);
    position: relative;
    background: var(--glass-bg);
}

.table-wrapper:hover {
    box-shadow: 0 6px 20px var(--shadow-color);
}

.copy-table-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    border-radius: 6px;
    padding: 8px 14px;
    cursor: pointer;
    font-size: 0.75em;
    opacity: 0;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: 600;
    z-index: 20;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.table-wrapper:hover .copy-table-btn {
    opacity: 1;
}

.copy-table-btn:hover {
    background: var(--accent-color);
    border-color: var(--accent-color);
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.3);
}

.copy-table-btn.copied {
    background: #34C759;
    border-color: #34C759;
    box-shadow: 0 4px 12px rgba(52, 199, 89, 0.3);
}

.formatted-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
    background: transparent;
}

.formatted-table thead {
    background: linear-gradient(135deg, rgba(0, 122, 255, 0.15) 0%, rgba(0, 122, 255, 0.08) 100%);
    border-bottom: 3px solid var(--accent-color);
    position: sticky;
    top: 0;
}

.formatted-table th {
    padding: 14px 16px;
    text-align: left;
    font-weight: 700;
    color: var(--text-color);
    text-transform: uppercase;
    font-size: 0.8em;
    letter-spacing: 1px;
}

.formatted-table tbody tr {
    transition: all 0.2s ease;
}

.formatted-table tbody tr:nth-child(even) {
    background: rgba(0, 122, 255, 0.04);
}

.formatted-table tbody tr:nth-child(odd) {
    background: transparent;
}

.formatted-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--glass-border);
    color: var(--text-color);
}

.formatted-table tbody tr:hover {
    background: rgba(0, 122, 255, 0.12);
    box-shadow: inset 0 0 8px rgba(0, 122, 255, 0.1);
}

.formatted-table tbody tr:last-child td {
    border-bottom: none;
}

/* ============================================
   FORMULE MATEMATICE (KaTeX)
   ============================================ */
.katex-display {
    overflow-x: auto;
    overflow-y: hidden;
    padding: 1.2em 1.4em;
    margin: 1.2em 0;
    background: linear-gradient(135deg, rgba(0, 122, 255, 0.08) 0%, rgba(0, 122, 255, 0.03) 100%);
    border-radius: 12px;
    border: 2px solid var(--accent-color);
    border-left: 4px solid var(--accent-color);
    text-align: center;
    position: relative;
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.1);
    transition: all 0.3s ease;
}
.katex-display:hover {
    box-shadow: 0 6px 16px rgba(0, 122, 255, 0.2);
}

.katex-display-wrapper {
    position: relative;
    display: inline-block;
    width: 100%;
}

.copy-formula-btn {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    border-radius: 6px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 0.75em;
    opacity: 0;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: 600;
}
.katex-display:hover .copy-formula-btn {
    opacity: 1;
}
.copy-formula-btn:hover {
    background: var(--accent-color);
    border-color: var(--accent-color);
}
.copy-formula-btn.copied {
    background: #34C759;
    border-color: #34C759;
}

.katex {
    font-size: 1.15em;
    color: var(--text-color);
    font-weight: 500;
}

.message.bot .katex-display > .katex {
    text-align: center;
}

/* Scroll pentru formule lungi */
.katex-display::-webkit-scrollbar {
    height: 6px;
}

.katex-display::-webkit-scrollbar-track {
    background: transparent;
}

.katex-display::-webkit-scrollbar-thumb {
    background: var(--accent-color);
    border-radius: 10px;
}

/* ============================================
   LINKURI
   ============================================ */
.message.bot a {
    color: var(--accent-color);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s ease;
    font-weight: 500;
}

.message.bot a:hover {
    border-bottom-color: var(--accent-color);
}

/* ============================================
   INDICATOR TASTARE
   ============================================ */
.typing-container { 
    display: flex; align-items: center; gap: 4px; padding: 18px 20px; min-width: 40px; 
}
.typing-dot { 
    width: 8px; height: 8px; background-color: var(--dot-color); 
    border-radius: 50%; animation: typingBounce 1.4s infinite; 
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce { 
    0%, 80%, 100% { transform: translateY(0); opacity: 0.6; } 
    40% { transform: translateY(-6px); opacity: 1; } 
}

/* ============================================
   ZONA DE INPUT
   ============================================ */
.glass-input {
    padding: 12px 15px; border-top: 1px solid var(--glass-border); 
    display: flex; gap: 10px; align-items: flex-end;
    background: var(--glass-bg); backdrop-filter: blur(25px); 
    -webkit-backdrop-filter: blur(25px); border-radius: 0 0 32px 32px;
}

.textarea-wrapper {
    flex: 1;
    position: relative;
    display: flex;
    align-items: flex-end;
}

textarea {
    flex: 1; padding: 10px 14px; border: 1px solid var(--input-border); 
    background-color: var(--input-bg);
    color: var(--text-color); border-radius: 20px; resize: none; outline: none; 
    font-family: inherit; font-size: 1rem;
    line-height: 1.4; height: 44px; min-height: 44px; max-height: 150px; 
    box-sizing: border-box; overflow-y: hidden;
    transition: border-color 0.2s ease;
}
textarea:focus { border-color: var(--accent-color); }
.send-button {
    width: 44px; height: 44px; background-color: var(--accent-color); 
    color: white; border: none; border-radius: 50%;
    cursor: pointer; display: flex; align-items: center; justify-content: center; 
    flex-shrink: 0;
    transition: background-color 0.2s, transform 0.1s;
}
.send-button:hover:not(:disabled) { transform: scale(1.05); }
.send-button:active:not(:disabled) { transform: scale(0.95); }
.send-button:disabled { 
    background-color: var(--subtitle-color); opacity: 0.5; cursor: not-allowed; 
}

.response-timer {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0;
    visibility: hidden;
    font-size: 1.25rem;
    font-weight: 600;
    font-style: italic;
    font-family: 'Georgia', 'Garamond', serif;
    color: var(--accent-color);
    transition: opacity 3s ease, visibility 3s ease;
    white-space: nowrap;
    pointer-events: none;
}

.response-timer.active {
    opacity: 0.5;
    visibility: visible;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 600px) {
    .message {
        max-width: 92%;
    }
    
    .code-block-wrapper {
        margin: 1em -5px;
    }
    
    .message.bot pre code {
        font-size: 0.85em;
    }
}

/* --- INFO ICON & TOOLTIP (STATS) --- */
.msg-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 8px;
    padding-top: 4px;
    border-top: 1px solid rgba(0,0,0,0.05);
}

.info-icon-wrapper {
    position: relative;
    display: inline-flex;
    cursor: help;
}

.info-icon {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1.5px solid var(--subtitle-color);
    color: var(--subtitle-color);
    font-size: 11px;
    font-weight: bold;
    font-family: serif; /* Pentru un "i" elegant */
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    opacity: 0.6;
}

.info-icon::before {
    content: 'i';
}

.info-icon-wrapper:hover .info-icon {
    border-color: var(--accent-color);
    color: var(--accent-color);
    opacity: 1;
    transform: scale(1.1);
}

/* TOOLTIP STYLING */
.info-tooltip {
    position: absolute;
    bottom: 140%; /* Apare deasupra iconiței */
    right: -10px;
    width: max-content;
    min-width: 180px;
    background: rgba(30, 30, 35, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: #fff;
    padding: 12px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px) scale(0.95);
    transition: all 0.2s cubic-bezier(0.165, 0.84, 0.44, 1);
    z-index: 100;
    pointer-events: none;
    border: 1px solid rgba(255,255,255,0.1);
}

.info-icon-wrapper:hover .info-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.stat-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.stat-row:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}
.stat-label { opacity: 0.7; font-size: 0.8em; }
.stat-value { font-weight: 600; color: var(--accent-color); font-size: 0.9em; }

/* Săgeată jos pentru tooltip */
.info-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    right: 14px;
    border-width: 6px;
    border-style: solid;
    border-color: rgba(30, 30, 35, 0.95) transparent transparent transparent;
}
