/* ============================================
   Gruppo Len Search Widget Styles
   ============================================ */

/* Container principale */
.glsw-search-container {
    position: relative;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* Form di ricerca */
.glsw-search-form {
    position: relative;
    margin-bottom: 20px;
}

/* Input field */
.glsw-search-input {
    width: 100%;
    padding: 15px 50px 15px 20px;
    font-size: 16px;
    border: 2px solid #e0e0e0;
    border-radius: 50px;
    outline: none;
    transition: all 0.3s ease;
    box-sizing: border-box;
}

.glsw-search-input:focus {
    border-color: #0066cc;
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

/* Search button */
.glsw-search-button {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    background: #0066cc;
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.glsw-search-button:hover {
    background: #0052a3;
    transform: translateY(-50%) scale(1.05);
}

.glsw-search-button:active {
    transform: translateY(-50%) scale(0.95);
}

.glsw-search-button svg {
    width: 20px;
    height: 20px;
}

/* Filtri tipo contenuto */
.glsw-content-filters {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 12px;
}

.glsw-filter-button {
    padding: 8px 16px;
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.glsw-filter-button:hover {
    border-color: #0066cc;
    color: #0066cc;
}

.glsw-filter-button.active {
    background: #0066cc;
    color: white;
    border-color: #0066cc;
}

/* Loading state */
.glsw-loading {
    display: none;
    text-align: center;
    padding: 30px;
    color: #666;
}

.glsw-loading.active {
    display: block;
}

.glsw-loading-spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #0066cc;
    border-radius: 50%;
    animation: glsw-spin 1s linear infinite;
    margin-bottom: 10px;
}

@keyframes glsw-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Risultati */
.glsw-results {
    margin-top: 20px;
}

.glsw-results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e0e0e0;
}

.glsw-results-count {
    font-size: 14px;
    color: #666;
}

.glsw-results-count strong {
    color: #0066cc;
    font-weight: 600;
}

/* Lista risultati */
.glsw-results-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

/* Singolo risultato */
.glsw-result-item {
    display: flex;
    gap: 15px;
    padding: 20px;
    margin-bottom: 15px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    transition: all 0.3s ease;
    text-decoration: none;
    color: inherit;
}

.glsw-result-item:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-color: #0066cc;
    transform: translateY(-2px);
}

/* Thumbnail */
.glsw-result-thumbnail {
    flex-shrink: 0;
    width: 80px;
    height: 80px;
    border-radius: 8px;
    overflow: hidden;
    background: #f0f0f0;
}

.glsw-result-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.glsw-result-thumbnail.no-image {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 24px;
}

/* Contenuto risultato */
.glsw-result-content {
    flex: 1;
    min-width: 0;
}

.glsw-result-meta {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 8px;
}

.glsw-result-type {
    display: inline-block;
    padding: 4px 10px;
    background: #e7f3ff;
    color: #0066cc;
    font-size: 12px;
    font-weight: 600;
    border-radius: 12px;
    text-transform: uppercase;
}

.glsw-result-date {
    font-size: 12px;
    color: #999;
}

.glsw-result-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 8px 0;
    color: #333;
    line-height: 1.4;
}

.glsw-result-item:hover .glsw-result-title {
    color: #0066cc;
}

.glsw-result-excerpt {
    font-size: 14px;
    color: #666;
    line-height: 1.6;
    margin: 0;
}

.glsw-result-excerpt mark {
    background: #fff3cd;
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: 600;
}

/* Messaggio nessun risultato */
.glsw-no-results {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

.glsw-no-results-icon {
    font-size: 64px;
    color: #ddd;
    margin-bottom: 20px;
}

.glsw-no-results h3 {
    font-size: 20px;
    margin: 0 0 10px 0;
    color: #333;
}

.glsw-no-results p {
    margin: 0;
    font-size: 14px;
}

/* Messaggio di errore */
.glsw-error {
    padding: 20px;
    background: #fee;
    border: 1px solid #fcc;
    border-radius: 8px;
    color: #c33;
    text-align: center;
}

/* Responsive */
@media (max-width: 768px) {
    .glsw-search-container {
        padding: 0 15px;
    }
    
    .glsw-result-item {
        flex-direction: column;
    }
    
    .glsw-result-thumbnail {
        width: 100%;
        height: 200px;
    }
    
    .glsw-content-filters {
        gap: 8px;
    }
    
    .glsw-filter-button {
        padding: 6px 12px;
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .glsw-search-input {
        padding: 12px 45px 12px 15px;
        font-size: 15px;
    }
    
    .glsw-search-button {
        width: 35px;
        height: 35px;
    }
    
    .glsw-result-title {
        font-size: 16px;
    }
    
    .glsw-result-excerpt {
        font-size: 13px;
    }
}

/* Animazioni */
@keyframes glsw-fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.glsw-result-item {
    animation: glsw-fadeIn 0.3s ease;
}

/* Accessibilità */
.glsw-search-button:focus,
.glsw-filter-button:focus {
    outline: 2px solid #0066cc;
    outline-offset: 2px;
}

/* Widget specifico */
.widget .glsw-search-container {
    max-width: 100%;
}

.widget .glsw-search-input {
    font-size: 14px;
    padding: 12px 45px 12px 15px;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .glsw-search-input {
        background: #2d2d2d;
        color: #fff;
        border-color: #444;
    }
    
    .glsw-result-item {
        background: #2d2d2d;
        border-color: #444;
        color: #fff;
    }
    
    .glsw-result-title {
        color: #fff;
    }
    
    .glsw-content-filters {
        background: #2d2d2d;
    }
    
    .glsw-filter-button {
        background: #1a1a1a;
        border-color: #444;
        color: #fff;
    }
}

/* ============================================
   Chat Modal Styles
   ============================================ */

/* Widget completo */
.glsw-widget-complete {
    max-width: 800px;
    margin: 0 auto;
}

/* Search Bar con stile chat-like */
.glsw-search-bar {
    position: relative;
    margin-bottom: 15px;
}

.glsw-search-input {
    width: 100%;
    padding: 15px 60px 15px 20px;
    font-size: 16px;
    border: 2px solid #e0e0e0;
    border-radius: 25px;
    outline: none;
    transition: all 0.3s ease;
}

.glsw-search-input:focus {
    border-color: #0066cc;
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

.glsw-search-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: #0066cc;
    color: white;
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.glsw-search-btn:hover {
    background: #0052a3;
    transform: translateY(-50%) scale(1.05);
}

.glsw-search-btn svg {
    width: 20px;
    height: 20px;
}

/* Quick Buttons */
.glsw-quick-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-bottom: 20px;
}

.quick-label {
    font-size: 13px;
    color: #666;
    font-weight: 500;
}

.quick-btn {
    padding: 8px 16px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.quick-btn:hover {
    border-color: #0066cc;
    color: #0066cc;
    background: #f0f7ff;
}

/* Chat Modal */
.glsw-chat-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 999999;
}

.glsw-chat-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.chat-container {
    position: relative;
    width: 90%;
    max-width: 600px;
    height: 80vh;
    max-height: 700px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

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

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

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

.chat-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.chat-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chat-avatar svg {
    width: 22px;
    height: 22px;
}

.chat-title strong {
    display: block;
    font-size: 15px;
}

.chat-title small {
    display: block;
    font-size: 12px;
    opacity: 0.9;
}

.chat-close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.chat-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.chat-close-btn svg {
    width: 18px;
    height: 18px;
}

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

.chat-message {
    margin-bottom: 16px;
    animation: fadeInMessage 0.3s ease;
}

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

.chat-message.assistant {
    display: flex;
    gap: 10px;
}

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

.message-avatar {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 16px;
    flex-shrink: 0;
    overflow: hidden;
}

.message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.message-content {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 16px;
    line-height: 1.5;
}

.chat-message.assistant .message-content {
    background: white;
    border: 1px solid #e0e0e0;
    border-top-left-radius: 4px;
}

.chat-message.user .message-content {
    background: #0066cc;
    color: white;
    border-top-right-radius: 4px;
}

.message-citations {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #e0e0e0;
    font-size: 13px;
}

.citation-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: #f0f7ff;
    color: #0066cc;
    border-radius: 4px;
    text-decoration: none;
    font-size: 12px;
    margin-right: 6px;
    margin-bottom: 6px;
}

.citation-link:hover {
    background: #e0edff;
}

/* Chat Input */
.chat-input-area {
    display: flex;
    gap: 10px;
    padding: 16px;
    background: white;
    border-top: 1px solid #e0e0e0;
}

.chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 20px;
    outline: none;
    resize: none;
    max-height: 120px;
    font-family: inherit;
    font-size: 14px;
    transition: all 0.2s ease;
}

.chat-input:focus {
    border-color: #0066cc;
}

.chat-send-btn {
    width: 44px;
    height: 44px;
    background: #0066cc;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.chat-send-btn:hover {
    background: #0052a3;
    transform: scale(1.05);
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.chat-send-btn svg {
    width: 20px;
    height: 20px;
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 16px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    animation: typingDot 1.4s infinite;
}

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

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

@keyframes typingDot {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-10px);
    }
}

/* Responsive */
@media (max-width: 768px) {
    .chat-container {
        width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }
    
    .message-content {
        max-width: 85%;
    }
    
    .glsw-quick-buttons {
        flex-wrap: wrap;
    }
    
    .quick-btn {
        font-size: 12px;
        padding: 6px 12px;
    }
}

/* Quick Questions in Chat */
.quick-questions {
    margin: 15px 0;
    padding: 15px;
    background: white;
    border-radius: 12px;
    border: 1px solid #e0e0e0;
}

.quick-question-btn {
    display: block;
    width: 100%;
    padding: 12px 16px;
    margin-bottom: 8px;
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
    color: #333;
}

.quick-question-btn:last-child {
    margin-bottom: 0;
}

.quick-question-btn:hover {
    border-color: #0066cc;
    background: #f0f7ff;
    color: #0066cc;
}

.quick-question-btn:active {
    transform: scale(0.98);
}
