/* Reset e base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f8f9fa;
}

/* Demo content styles */
.demo-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

.demo-content header {
    text-align: center;
    margin-bottom: 3rem;
    padding: 2rem 0;
    background: linear-gradient(135deg, #ff6b35, #f7931e);
    color: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(255, 107, 53, 0.3);
}

.demo-content h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.demo-content p {
    font-size: 1.1rem;
    opacity: 0.9;
}

.content-blocks {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.block {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.block:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.block h3 {
    color: #ff6b35;
    font-size: 1.5rem;
    margin-bottom: 1rem;
    font-weight: 600;
}

/* Widget styles */
.cucchiaio-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    font-family: 'Inter', sans-serif;
}

/* Balloon styles */
.widget-balloon {
    position: relative;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: float 3s ease-in-out infinite;
}

.widget-balloon:hover {
    transform: scale(1.05);
}

.balloon-content {
    background: linear-gradient(135deg, #ff6b35, #f7931e);
    color: white;
    padding: 16px 20px;
    border-radius: 25px;
    box-shadow: 0 8px 25px rgba(255, 107, 53, 0.4);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 200px;
    position: relative;
    z-index: 2;
}

.balloon-logo {
    width: 30px;
    height: 30px;
    object-fit: contain;
    animation: pulse 2s infinite;
}

.balloon-text {
    font-weight: 500;
    font-size: 0.95rem;
}

.balloon-pulse {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #ff6b35, #f7931e);
    border-radius: 25px;
    opacity: 0.3;
    animation: pulse-ring 2s infinite;
    z-index: 1;
}

/* Panel styles */
.widget-panel {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 400px;
    height: 500px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    display: none;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(20px) scale(0.95);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.widget-panel.open {
    display: flex;
    transform: translateY(0) scale(1);
    opacity: 1;
}

/* Panel header */
.panel-header {
    background: linear-gradient(135deg, #DD774C, #f7931e);
    color: white;
    padding: 11px 13px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-logo {
    width: 50px;
    height: 50px;
    object-fit: contain;
}

.header-text h4 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 2px;
}

.status {
    font-size: 0.85rem;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 6px;
}

.status::before {
    content: '';
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.header-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

.sponsor-logo {
    width: 65px;
    height: 55px;
    object-fit: contain;
    transition: all 0.2s ease;
}

/*.sponsor-logo:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}*/

.fullscreen-btn, .close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background-color 0.2s ease;
}

.fullscreen-btn:hover, .close-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

/* Chat container */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 13px;
    background: #f8f9fa;
}

.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.message {
    display: flex;
    gap: 12px;
    animation: messageSlide 0.3s ease-out;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.bot-message .message-avatar {
    background: linear-gradient(135deg, #ff6b35, #f7931e);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
}

.avatar-logo {
    width: 35px;
    height: 35px;
    object-fit: contain;
}

.user-message .message-avatar {
    background: #e5e7eb;
    color: #6b7280;
}

.message-content {
    flex: 1;
    background: white;
    padding: 12px 16px;
    border-radius: 18px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    position: relative;
}

.user-message .message-content {
    background: linear-gradient(135deg, #ff6b35, #f7931e);
    color: white;
}

.message-content p {
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.4;
    white-space: pre-wrap; /* preserva i ritorni a capo dell'API */
}

.message-content h4, h3 {
    margin: 12px 0 8px 0;
    font-size: 1rem;
    font-weight: 600;
    color: #ff6b35;
    line-height: 1.3;
}

.message-content h4:first-child {
    margin-top: 0;
}

.message-content ul, .message-content ol {
    margin: 8px 0;
    padding-left: 20px;
    list-style-type: disc;
}

.message-content ul ul {
    margin: 4px 0;
    padding-left: 20px;
    list-style-type: circle;
}

.message-content li {
    margin: 4px 0;
    line-height: 1.5;
}

.message-content li strong {
    font-weight: 600;
    color: #333;
}

/* Blocchi di codice Mermaid */
.mermaid-block {
    margin: 16px 0;
    padding: 16px;
    background: #f8f9fa;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    text-align: center;
}

.mermaid-block .mermaid {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 200px;
}

.mermaid-block svg {
    max-width: 100%;
    height: auto;
}

.mermaid-code {
    margin: 0;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    color: #333;
    white-space: pre;
    line-height: 1.4;
    text-align: left;
}

.message-time {
    font-size: 0.75rem;
    opacity: 0.7;
    margin-top: 4px;
    display: block;
}

/* Message footer con feedback */
.message-footer {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

.message-footer .message-time {
    margin-top: 0;
}

/* Feedback con stelle */
.message-feedback {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.feedback-stars {
    display: flex;
    align-items: center;
    gap: 4px;
}

.feedback-star {
    background: none;
    border: none;
    padding: 2px;
    cursor: pointer;
    color: #d1d5db;
    font-size: 1rem;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.feedback-star:hover:not(:disabled) {
    transform: scale(1.15);
}

.feedback-star.highlighted,
.feedback-star.selected {
    color: #f59e0b;
}

.feedback-star.selected {
    cursor: default;
}

.feedback-star:disabled {
    cursor: default;
}

/* Form commento feedback */
.feedback-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 4px;
    animation: fadeIn 0.2s ease;
}

.feedback-comment {
    width: 100%;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 8px 10px;
    font-family: inherit;
    font-size: 0.85rem;
    resize: none;
    outline: none;
    transition: border-color 0.2s ease;
    min-height: 50px;
}

.feedback-comment:focus {
    border-color: #ff6b35;
}

.feedback-comment::placeholder {
    color: #9ca3af;
}

.feedback-form-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.feedback-submit-btn,
.feedback-cancel-btn {
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.feedback-submit-btn {
    background: linear-gradient(135deg, #ff6b35, #f7931e);
    color: white;
    border: none;
}

.feedback-submit-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(255, 107, 53, 0.3);
}

.feedback-cancel-btn {
    background: white;
    color: #6b7280;
    border: 1px solid #e5e7eb;
}

.feedback-cancel-btn:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
}

.feedback-thanks {
    font-size: 0.75rem;
    color: #22c55e;
    font-weight: 500;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Sponsor message */
.sponsor-message {
    /*background: #fef3e7; color variant*/
    background: #F6F6F6;
    /*border: 1px solid #f7931e; color variant*/
    border: 2px solid #E6B332;
    border-radius: 12px;
    padding: 16px;
    margin: 16px 0;
    position: relative;
    animation: messageSlide 0.3s ease-out;
}

.sponsor-header {
    margin-bottom: 8px;
}

.sponsor-label {
    font-size: 0.80rem;
    color: #F28E24;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sponsor-body {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 16px;
    align-items: center;
}

.sponsor-content h4 {
    font-size: 1rem;
    font-weight: 600;
    color: #4D4D4D;
    margin: 0 0 8px 0;
    line-height: 1.3;
}

.sponsor-content p {
    font-size: 0.85rem;
    color: #4D4D4D;
    margin: 0;
    line-height: 1.4;
}

.sponsor-footer {
    display: flex;
    justify-content: center;
    align-items: center;
}

.sponsor-logo-inline {
    width: 100px;
    height: 100px;
    object-fit: contain;
}

/* Input container */
.chat-input-container {
    padding: 13px;
    background: white;
    border-top: 1px solid #e5e7eb;
}

.input-wrapper {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

#message-input {
    flex: 1;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    padding: 12px 16px;
    font-family: inherit;
    font-size: 0.95rem;
    resize: none;
    outline: none;
    transition: border-color 0.2s ease;
    min-height: 60px;
    max-height: 120px;
}

#message-input:focus {
    border-color: #ff6b35;
}

#message-input::placeholder {
    color: #9ca3af;
}

.send-btn {
    background: linear-gradient(135deg, #ff6b35, #f7931e);
    color: white;
    border: none;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.send-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 107, 53, 0.4);
}

.send-btn:disabled {
    background: #d1d5db;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.input-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 8px;
}

.char-count {
    font-size: 0.75rem;
    color: #9ca3af;
}

/* Animations */
@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
}

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

@keyframes pulse-ring {
    0% {
        transform: scale(1);
        opacity: 0.3;
    }
    100% {
        transform: scale(1.2);
        opacity: 0;
    }
}

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

/* Fullscreen mode */
.widget-panel.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw !important;
    height: 100vh !important;
    border-radius: 0;
    z-index: 10000;
    transform: none !important;
    opacity: 1 !important;
}

.widget-panel.fullscreen .fullscreen-btn i:before {
    content: "\f066"; /* fas fa-compress */
}

/* Responsive design */
@media (max-width: 768px) {
    .widget-panel {
        width: calc(100vw - 40px);
        height: calc(100vh - 120px);
        bottom: 100px;
        right: 20px;
        left: 20px;
    }
    
    .balloon-content {
        min-width: 160px;
        padding: 12px 16px;
    }
    
    .balloon-text {
        font-size: 0.85rem;
    }
}

@media (max-width: 480px) {
    .cucchiaio-widget {
        bottom: 15px;
        right: 15px;
    }
    
    .widget-panel {
        width: calc(100vw - 30px);
        height: calc(100vh - 100px);
        bottom: 80px;
        right: 15px;
        left: 15px;
    }
}

/* Typing indicator */
.typing-message {
    opacity: 0.8;
}

.typing-dots {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-right: 8px;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    background: #ff6b35;
    border-radius: 50%;
    animation: typingDot 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

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

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

.typing-text {
    font-size: 0.85rem;
    color: #666;
    font-style: italic;
}

@keyframes typingDot {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Scrollbar styling */
.chat-container::-webkit-scrollbar {
    width: 6px;
}

.chat-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.chat-container::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.chat-container::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}
