/* European Project Chatbot Styles - v3.0 */

/* Il colore tema scelto in admin viene iniettato come variabile CSS
   (--eupc-primary / --eupc-primary-dark) via wp_add_inline_style */
:root {
    --eupc-primary: #667eea;
    --eupc-primary-dark: #4c5fb8;
}

/* Chatbot Container */
#eupc-chatbot-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* Chat Button */
#eupc-chat-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--eupc-primary) 0%, var(--eupc-primary-dark) 100%);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

#eupc-chat-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

#eupc-chat-button:focus-visible {
    outline: 3px solid var(--eupc-primary);
    outline-offset: 3px;
}

#eupc-chat-button svg {
    width: 30px;
    height: 30px;
    fill: white;
}

/* Chat Window */
#eupc-chat-window {
    display: none;
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 600px;
    max-height: 80vh;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    flex-direction: column;
    overflow: hidden;
}

#eupc-chat-window.active {
    display: flex;
    animation: eupcSlideUp 0.3s ease;
}

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

/* Chat Header */
#eupc-chat-header {
    background: linear-gradient(135deg, var(--eupc-primary) 0%, var(--eupc-primary-dark) 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#eupc-chat-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: white;
}

.eupc-header-actions {
    display: flex;
    gap: 4px;
    align-items: center;
}

#eupc-close-button,
#eupc-clear-button {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
}

#eupc-close-button {
    font-size: 24px;
}

#eupc-clear-button svg {
    width: 18px;
    height: 18px;
    fill: white;
}

#eupc-close-button:hover,
#eupc-clear-button:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* Chat Messages */
#eupc-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f7f9fc;
}

.eupc-message {
    margin-bottom: 16px;
    display: flex;
    gap: 10px;
    animation: eupcFadeIn 0.3s ease;
}

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

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

.eupc-message.eupc-user .eupc-message-avatar {
    background: #e0e7ff;
}

.eupc-message.eupc-bot .eupc-message-avatar {
    background: linear-gradient(135deg, var(--eupc-primary) 0%, var(--eupc-primary-dark) 100%);
    color: white;
}

.eupc-message-content {
    flex: 1;
    min-width: 0;
    background: white;
    padding: 12px 16px;
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    word-wrap: break-word;
    overflow-wrap: break-word;
    color: #2d3748;
    font-size: 14px;
}

.eupc-message.eupc-user .eupc-message-content {
    background: var(--eupc-primary);
    color: white;
}

.eupc-message.eupc-bot .eupc-message-content {
    background: #f7fafc;
    color: #2d3748;
    border: 1px solid #e2e8f0;
}

.eupc-message-content p {
    margin: 0;
    line-height: 1.5;
}

.eupc-message-content p:not(:last-child) {
    margin-bottom: 12px;
}

/* Formattazione HTML nel contenuto */
.eupc-message-content strong,
.eupc-message-content b {
    font-weight: 600;
    color: inherit;
}

.eupc-message-content em,
.eupc-message-content i {
    font-style: italic;
}

.eupc-message-content ul,
.eupc-message-content ol {
    margin: 8px 0;
    padding-left: 24px;
}

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

.eupc-message-content h1,
.eupc-message-content h2,
.eupc-message-content h3,
.eupc-message-content h4 {
    margin: 12px 0 8px 0;
    font-weight: 600;
    line-height: 1.3;
}

.eupc-message-content h1 { font-size: 1.3em; }
.eupc-message-content h2 { font-size: 1.2em; }
.eupc-message-content h3 { font-size: 1.1em; }
.eupc-message-content h4 { font-size: 1.05em; }

.eupc-message-content code {
    background: rgba(0, 0, 0, 0.05);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.eupc-message-content pre {
    background: rgba(0, 0, 0, 0.05);
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 8px 0;
}

.eupc-message-content pre code {
    background: none;
    padding: 0;
}

.eupc-message-content a {
    color: var(--eupc-primary);
    text-decoration: underline;
}

.eupc-message-content a:hover {
    color: var(--eupc-primary-dark);
}

/* Colori specifici per messaggi utente */
.eupc-message.eupc-user .eupc-message-content strong,
.eupc-message.eupc-user .eupc-message-content code,
.eupc-message.eupc-user .eupc-message-content a {
    color: white;
}

.eupc-message.eupc-user .eupc-message-content code {
    background: rgba(255, 255, 255, 0.2);
}

/* ===================== VIDEO NELLE RISPOSTE ===================== */

.eupc-video {
    margin: 12px 0;
    border-radius: 10px;
    overflow: hidden;
    background: #000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

/* Wrapper responsive 16:9 per gli iframe (YouTube/Vimeo) */
.eupc-video-frame {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%;
    height: 0;
}

.eupc-video-frame iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

.eupc-video video {
    display: block;
    width: 100%;
    height: auto;
    background: #000;
}

.eupc-video-title {
    background: #1a202c;
    color: #e2e8f0;
    font-size: 12px;
    padding: 8px 12px;
    line-height: 1.4;
}

.eupc-video-link {
    margin: 8px 0;
}

/* ===================== DOMANDE SUGGERITE ===================== */

#eupc-suggestions {
    padding: 0 16px 10px;
    background: #f7f9fc;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.eupc-suggestion-chip {
    background: white;
    border: 1px solid var(--eupc-primary);
    color: var(--eupc-primary);
    border-radius: 16px;
    padding: 7px 14px;
    font-size: 13px;
    line-height: 1.3;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    text-align: left;
}

.eupc-suggestion-chip:hover {
    background: var(--eupc-primary);
    color: white;
}

.eupc-suggestion-chip:focus-visible {
    outline: 2px solid var(--eupc-primary-dark);
    outline-offset: 2px;
}

/* ===================== TYPING INDICATOR ===================== */

.eupc-typing-content {
    padding: 8px 16px !important;
    min-height: 40px;
    display: flex;
    align-items: center;
}

.eupc-typing-dots {
    display: flex;
    gap: 4px;
    align-items: center;
}

.eupc-typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #cbd5e0;
    animation: eupcTyping 1.4s infinite;
}

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

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

@keyframes eupcTyping {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.5;
    }
    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

/* ===================== INPUT ===================== */

#eupc-chat-input-container {
    padding: 16px 20px;
    background: white;
    border-top: 1px solid #e2e8f0;
}

#eupc-chat-input-form {
    display: flex;
    gap: 10px;
}

#eupc-message-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

#eupc-message-input:focus {
    border-color: var(--eupc-primary);
}

#eupc-send-button {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--eupc-primary) 0%, var(--eupc-primary-dark) 100%);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

#eupc-send-button:hover:not(:disabled) {
    transform: scale(1.05);
}

#eupc-send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#eupc-send-button svg {
    width: 20px;
    height: 20px;
    fill: white;
}

/* Scrollbar Styles */
#eupc-chat-messages::-webkit-scrollbar {
    width: 6px;
}

#eupc-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

#eupc-chat-messages::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

#eupc-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    #eupc-chatbot-container {
        bottom: 10px;
        right: 10px;
        left: 10px;
    }

    #eupc-chat-window {
        width: 100%;
        height: 500px;
        max-height: calc(100vh - 100px);
        right: auto;
    }
}

/* Error Message */
.eupc-error-message {
    background: #fee;
    color: #c33;
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
}

/* Rispetta la preferenza "riduci movimento" */
@media (prefers-reduced-motion: reduce) {
    #eupc-chat-window.active,
    .eupc-message,
    .eupc-typing-dots span,
    #eupc-chat-button,
    #eupc-send-button {
        animation: none !important;
        transition: none !important;
    }
}

/* ===================== SELETTORE LINGUA ===================== */

.eupc-lang-title {
    font-weight: 600;
    margin-bottom: 10px !important;
}

.eupc-lang-buttons {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.eupc-lang-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 14px 10px;
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    cursor: pointer;
    transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
}

.eupc-lang-btn:hover {
    border-color: var(--eupc-primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}

.eupc-lang-btn:focus-visible {
    outline: 2px solid var(--eupc-primary);
    outline-offset: 2px;
}

.eupc-lang-flag {
    display: block;
    width: 48px;
    height: 32px;
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    line-height: 0;
}

.eupc-lang-flag svg {
    width: 100%;
    height: 100%;
    display: block;
}

.eupc-lang-label {
    font-size: 13px;
    font-weight: 600;
    color: #2d3748;
}

#eupc-message-input:disabled {
    background: #f1f5f9;
    cursor: not-allowed;
}
