* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

:root {
    --bg-color: #121212;
    --text-color: #ffffff;
    --primary-color: #ffffff;
    --secondary-color: #202020;
    --border-color: #333333;
    --message-ai-bg: #202020;
    --message-user-bg: #ffffff;
    --input-bg: #202020;
    --ollama-color: #3a86ff;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    display: fixed;
    flex-direction: column;
}

.container {
    max-width: 100%;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    height: 100vh;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 20px;
}

.logo {
    display: flex;
    justify-content: center;
    align-items: center;
}

.logo img {
    height: 50px;
    width: auto;
    max-width: 100%;
}

#reset-button {
    background-color: transparent;
    border: none;
    color: var(--text-color);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s ease;
}

#reset-button:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

#reset-button:active {
    background-color: rgba(255, 255, 255, 0.2);
}

.ai-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}

.status-indicator {
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background-color: #4CAF50;
    display: inline-block;
    box-shadow: 0 0 5px rgba(76, 175, 80, 0.5);
}

.status-indicator.thinking {
    background-color: #FFC107;
    box-shadow: 0 0 5px rgba(255, 193, 7, 0.5);
}

.status-indicator.error {
    background-color: #F44336;
    box-shadow: 0 0 5px rgba(244, 67, 54, 0.5);
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 10px 0;
    margin-bottom: 20px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.chat-container::-webkit-scrollbar {
    display: none;
}

.messages {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.message {
    display: flex;
    margin-bottom: 10px;
}

.ai-message {
    justify-content: flex-start;
}

.user-message {
    justify-content: flex-end;
}

.message-content {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 18px;
    line-height: 1.5;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: pre-wrap;
}

.ai-message .message-content {
    background-color: var(--message-ai-bg);
    border-bottom-left-radius: 4px;
}


.first-message .message-content {
    padding: 6px 16px;
    line-height: 0.5;
}

.first-message .message-content p {
    margin: 0;
}

.user-message .message-content {
    background-color: var(--message-user-bg);
    border-bottom-right-radius: 4px;
    color: var(--bg-color);
}


.input-wrapper {
    position: relative;
    margin-top: auto;
}

.input-container {
    display: flex;
    gap: 10px;
    padding: 15px;
    background-color: var(--secondary-color);
    border-radius: 12px;
}

#user-input {
    flex: 1;
    background-color: var(--input-bg);
    border: none;
    border-radius: 8px;
    padding: 12px 15px;
    color: var(--text-color);
    resize: none;
    outline: none;
    max-height: 150px;
    overflow-y: auto;
}

#send-button {
    background-color: var(--primary-color);
    color: var(--bg-color);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s;
}

#send-button:hover {
    background-color: #e6e6e6;
}

#send-button:disabled {
    background-color: #666;
    cursor: not-allowed;
}


.typing-indicator {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    position: relative;
}

.typing-bubble {
    position: relative;
    background-color: var(--message-ai-bg);
    border-radius: 18px;
    padding: 12px 16px;
    min-width: 60px;
    min-height: 24px;
    display: flex;
    align-items: center;
}

.typing-bubble::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: -6px;
    width: 12px;
    height: 12px;
    background-color: var(--message-ai-bg);
    border-radius: 50%;
    transform: translateY(50%);
}

.typing-dots {
    display: flex;
    align-items: center;
    gap: 4px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background-color: #aaa;
    border-radius: 50%;
    display: inline-block;
    animation: typingBounce 1.4s infinite ease-in-out both;
}

.typing-dots span:nth-child(1) {
    animation-delay: 0s;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingBounce {
    0%, 100% {
        transform: translateY(0);
        opacity: 0.5;
    }
    50% {
        transform: translateY(-5px);
        opacity: 1;
    }
}


footer {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
    text-align: center;
    font-size: 0.85rem;
    color: #888;
}

footer a {
    color: #ffffff;
    text-decoration: none;
    transition: all 0.2s ease;
}

footer a:hover {
    text-decoration: underline;
}

.model-name {
    color: var(--ollama-color);
    font-weight: 500;
}


pre {
    background-color: #2a2a2a;
    border-radius: 8px;
    padding: 12px;
    margin: 10px 0;
    overflow-x: auto;
    max-width: 100%;
    white-space: pre-wrap;
}

code {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9em;
    background-color: #2a2a2a;
    border-radius: 4px;
    padding: 2px 4px;
    word-break: break-all;
    white-space: pre-wrap;
}


.message-content a {
    color: #ffffff;
    text-decoration: none;
    font-weight: 600;
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.5);
    transition: all 0.2s ease;
}

.message-content a:hover {
    text-decoration: underline;
    text-shadow: 0 0 12px rgba(255, 255, 255, 0.8);
}


.scroll-to-bottom {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-10px);
    width: auto;
    height: 40px;
    padding: 0 20px;
    background-color: var(--primary-color);
    color: var(--bg-color);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: default;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s, transform 0.3s, background-color 0.2s;
    z-index: 100;
    font-weight: 600;
    gap: 8px;
    margin-bottom: 10px;
}

.scroll-to-bottom.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(-10px);
    animation: pulse 2s infinite ease-in-out;
    pointer-events: auto;
    cursor: pointer;
}

.scroll-to-bottom.visible:hover {
    background-color: #e6e6e6;
    box-shadow: 0 6px 20px rgba(255, 255, 255, 0.4);
    transform: translateX(-50%) translateY(-13px);
}

.scroll-to-bottom.visible:active {
    transform: translateX(-50%) translateY(-10px);
    box-shadow: 0 3px 10px rgba(255, 255, 255, 0.3);
}


@keyframes pulse {
    0% { box-shadow: 0 4px 15px rgba(255, 255, 255, 0.4); }
    50% { box-shadow: 0 4px 20px rgba(255, 255, 255, 0.6); }
    100% { box-shadow: 0 4px 15px rgba(255, 255, 255, 0.4); }
}


@media (min-width: 1200px) {
    .container {
        max-width: 900px;
        margin: 0 auto;
    }
    
    .message-content {
        max-width: 700px;
    }
}

@media (min-width: 992px) and (max-width: 1199px) {
    .container {
        max-width: 800px;
        margin: 0 auto;
    }
    
    .message-content {
        max-width: 650px;
    }
}

@media (min-width: 768px) and (max-width: 991px) {
    .container {
        max-width: 700px;
        margin: 0 auto;
    }
    
    .message-content {
        max-width: 600px;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    header h1 {
        font-size: 1.5rem;
    }
    
    .message-content {
        max-width: 90%;
    }
}

@media (max-width: 480px) {
    header {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: flex-start;
        align-items: center;
        gap: 10px;
        position: relative;
        padding-right: 50px;
    }
    
    #reset-button {
    order: 2;
    margin-left: auto;
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-75%);
}
    
    .message-content {
        max-width: 95%;
    }
    
    .input-container {
        padding: 10px;
    }
    
    #user-input {
        padding: 10px;
    }
    
    #send-button {
        width: 36px;
        height: 36px;
    }
    
    .scroll-to-bottom {
        padding: 0 15px;
        height: 36px;
        font-size: 0.9rem;
    }
    
    .scroll-to-bottom span {
        display: none;
    }
    
    .scroll-to-bottom i {
        margin-right: 5px;
    }
    
    .scroll-to-bottom:after {
        content: "Nuovi";
        display: inline;
    }
}
