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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
header {
    background: rgba(255, 255, 255, 0.95);
    padding: 2rem 0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
}

header h1 {
    font-size: 2.5rem;
    color: #667eea;
    text-align: center;
    margin-bottom: 0.5rem;
}

.subtitle {
    text-align: center;
    font-size: 1.2rem;
    color: #666;
}

/* Sezione introduttiva */
.search-section {
    margin-bottom: 2rem;
}

.search-bar {
    display: flex;
    gap: 0.5rem;
    max-width: 600px;
    margin: 0 auto 1rem auto;
    background: white;
    padding: 0.5rem;
    border-radius: 50px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.sort-section {
    text-align: center;
    margin-top: 1rem;
}

.sort-section label {
    color: white;
    font-weight: 500;
    margin-right: 0.5rem;
}

#sort-select {
    padding: 0.5rem 1rem;
    border-radius: 20px;
    border: 2px solid white;
    background: white;
    color: #667eea;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

#sort-select:hover {
    background: rgba(255, 255, 255, 0.9);
}

#sort-select:focus {
    outline: 3px solid #764ba2;
    outline-offset: 2px;
}

.project-link {
    color: white;
    text-decoration: none;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 0.5rem 1.5rem;
    border-radius: 20px;
    display: inline-block;
    margin-left: 1rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.project-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.project-link:focus {
    outline: 3px solid #764ba2;
    outline-offset: 2px;
}

.project-actions {
    text-align: center;
    margin-top: 1rem;
}

.btn-secondary {
    background: white;
    color: #667eea;
    text-decoration: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    border: 2px solid #667eea;
    display: inline-block;
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    background: #667eea;
    color: white;
}

#search-input {
    flex: 1;
    border: none;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    outline: none;
    background: transparent;
    color: #333;
}

#search-input::placeholder {
    color: #999;
}

#search-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s ease;
    color: white;
}

#search-button:hover {
    transform: scale(1.05);
}

#search-button:active {
    transform: scale(0.95);
}

.intro {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    margin-bottom: 2rem;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.intro h2 {
    color: #667eea;
    margin-bottom: 1rem;
}

/* Il Progetto - FAQ Section */
.project-section {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    margin-bottom: 2rem;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.project-section h2 {
    color: #667eea;
    margin-bottom: 1.5rem;
    text-align: center;
    font-size: 2rem;
}

.faq-container {
    max-width: 800px;
    margin: 0 auto;
}

.faq-item {
    border-bottom: 1px solid #e0e0e0;
    margin-bottom: 0.5rem;
}

.faq-item:last-child {
    border-bottom: none;
}

.faq-question {
    width: 100%;
    background: none;
    border: none;
    padding: 1.5rem 0;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: left;
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
    transition: color 0.3s ease;
}

.faq-question:hover {
    color: #667eea;
}

.faq-question:focus {
    outline: 2px solid #667eea;
    outline-offset: 4px;
    border-radius: 4px;
}

.faq-icon {
    font-size: 1.5rem;
    color: #667eea;
    transition: transform 0.3s ease;
    font-weight: 300;
    line-height: 1;
}

.faq-question[aria-expanded="true"] .faq-icon {
    transform: rotate(45deg);
}

.faq-answer {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
    padding: 0 0;
}

.faq-answer.active {
    max-height: 500px;
    padding: 0 0 1.5rem 0;
}

.faq-answer p {
    color: #666;
    line-height: 1.8;
    margin: 0;
}

/* Griglia degli albi */
.albums-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.album-card {
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
}

.album-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.album-card:focus {
    outline: 3px solid #667eea;
    outline-offset: 2px;
}

.album-cover {
    width: 100%;
    height: 350px;
    object-fit: cover;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

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

.cover-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 1.5rem;
    font-weight: bold;
    text-align: center;
    padding: 2rem;
}

.cover-placeholder p {
    margin: 0;
}

.album-info {
    padding: 1.5rem;
}

.album-info h3 {
    color: #333;
    margin-bottom: 0.5rem;
    font-size: 1.3rem;
}

.album-info .author {
    color: #667eea;
    font-style: italic;
    margin-bottom: 0.3rem;
    font-size: 0.95rem;
}

.album-info .publisher {
    color: #999;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.album-info .description {
    color: #666;
    font-size: 0.9rem;
    line-height: 1.5;
}

.album-author {
    color: #667eea;
    font-style: italic;
    margin-bottom: 0.3rem;
    font-size: 0.95rem;
}

.album-publisher {
    color: #999;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.album-year {
    color: #999;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.album-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.tag {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 0.3rem 0.8rem;
    border-radius: 15px;
    font-size: 0.75rem;
    font-weight: 500;
}

.no-results {
    text-align: center;
    color: white;
    font-size: 1.2rem;
    padding: 3rem;
    grid-column: 1 / -1;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.8);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 2rem;
    border-radius: 10px;
    width: 90%;
    max-width: 800px;
    position: relative;
    animation: slideDown 0.3s ease;
}

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

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 20px;
}

.close:hover,
.close:focus {
    color: #667eea;
}

.modal-album-cover {
    width: 100%;
    max-height: 400px;
    object-fit: cover;
    border-radius: 5px;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    min-height: 300px;
}

.modal-album-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#modal-body h2 {
    color: #667eea;
    margin-bottom: 0.5rem;
}

#modal-body .author {
    color: #764ba2;
    font-style: italic;
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.album-meta {
    background: #f5f5f5;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.album-meta p {
    margin: 0.5rem 0;
    color: #555;
}

.rating {
    margin-top: 0.5rem;
}

.rating-number {
    color: #667eea;
    font-weight: bold;
    margin-left: 0.5rem;
}

.purchase-links {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 2px solid #eee;
}

.purchase-links h3 {
    color: #667eea;
    margin-bottom: 1rem;
}

.buy-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.buy-button {
    flex: 1;
    min-width: 120px;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    text-decoration: none;
    text-align: center;
    font-weight: 600;
    transition: all 0.3s ease;
    color: white;
}

.buy-button.amazon {
    background: #FF9900;
}

.buy-button.amazon:hover:not(.disabled) {
    background: #e88800;
}

.buy-button.feltrinelli {
    background: #E31E24;
}

.buy-button.feltrinelli:hover:not(.disabled) {
    background: #c71a1f;
}

.buy-button.mondadori {
    background: #003DA5;
}

.buy-button.mondadori:hover:not(.disabled) {
    background: #002f7f;
}

.buy-button.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #999;
}

.affiliate-notice {
    font-size: 0.85rem;
    color: #666;
    font-style: italic;
    text-align: center;
}

.modal-album-details {
    display: flex;
    flex-direction: column;
}

.modal-album-info {
    margin-top: 1rem;
}

.modal-album-info h2 {
    color: #667eea;
    margin-bottom: 0.5rem;
}

.modal-album-info p {
    margin: 0.5rem 0;
    line-height: 1.6;
}

.modal-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 1rem 0;
}

.modal-description {
    margin: 1.5rem 0;
}

.modal-description h3 {
    color: #667eea;
    margin-bottom: 0.5rem;
}

.modal-description p {
    line-height: 1.8;
    color: #333;
}

.modal-purchase-links {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 2px solid #eee;
}

.modal-purchase-links h3 {
    color: #667eea;
    margin-bottom: 1rem;
}

.purchase-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.purchase-link {
    flex: 1;
    min-width: 120px;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    text-decoration: none;
    text-align: center;
    font-weight: 600;
    transition: all 0.3s ease;
    color: white;
    display: inline-block;
}

.purchase-link.amazon {
    background: #FF9900;
}

.purchase-link.amazon:hover {
    background: #e88800;
}

.purchase-link.feltrinelli {
    background: #E31E24;
}

.purchase-link.feltrinelli:hover {
    background: #c71a1f;
}

.purchase-link.mondadori {
    background: #003DA5;
}

.purchase-link.mondadori:hover {
    background: #002f7f;
}

#modal-body p {
    line-height: 1.8;
    color: #333;
    margin-bottom: 1rem;
}

/* Footer */
footer {
    background: rgba(255, 255, 255, 0.95);
    padding: 1.5rem 0;
    margin-top: 2rem;
    text-align: center;
    color: #666;
}

/* Referral Disclaimer */
.referral-disclaimer {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 999;
    max-width: 400px;
    animation: slideIn 0.5s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(450px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.disclaimer-content {
    background: white;
    padding: 1.5rem;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    border-left: 5px solid #667eea;
    position: relative;
}

.disclaimer-close {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 24px;
    cursor: pointer;
    color: #999;
    line-height: 20px;
}

.disclaimer-close:hover {
    color: #667eea;
}

.disclaimer-content h3 {
    color: #667eea;
    margin-bottom: 1rem;
}

.disclaimer-content p {
    color: #555;
    line-height: 1.6;
    margin-bottom: 1rem;
}

.disclaimer-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 600;
    width: 100%;
    transition: transform 0.2s ease;
}

.disclaimer-button:hover {
    transform: scale(1.02);
}

/* Responsive */
@media (max-width: 768px) {
    header h1 {
        font-size: 2rem;
    }

    .search-bar {
        max-width: 100%;
    }

    #search-input {
        font-size: 0.9rem;
        padding: 0.6rem 1rem;
    }

    .sort-section {
        margin-top: 1rem;
    }

    #sort-select {
        font-size: 0.9rem;
        padding: 0.4rem 0.8rem;
    }

    .albums-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .modal-content {
        width: 95%;
        margin: 10% auto;
        padding: 1.5rem;
    }

    .album-cover {
        height: 250px;
    }

    .buy-buttons {
        flex-direction: column;
    }

    .buy-button {
        width: 100%;
    }

    .referral-disclaimer {
        left: 20px;
        right: 20px;
        max-width: none;
    }
}

/* ===== Chat Widget ===== */
.chat-widget {
    position: fixed;
    bottom: 24px;
    left: 24px;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.chat-toggle {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.chat-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.65);
}

.chat-toggle:focus {
    outline: 3px solid #764ba2;
    outline-offset: 3px;
}

.chat-popup {
    display: none;
    flex-direction: column;
    width: 340px;
    max-width: calc(100vw - 48px);
    height: 460px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.22);
    overflow: hidden;
    margin-bottom: 14px;
    animation: chatSlideUp 0.25s ease;
}

.chat-popup.open {
    display: flex;
}

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

.chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 0.9rem 1.2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 700;
    font-size: 1rem;
    flex-shrink: 0;
}

.chat-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    opacity: 0.85;
    transition: opacity 0.2s;
}

.chat-close:hover {
    opacity: 1;
}

.chat-close:focus {
    outline: 2px solid rgba(255, 255, 255, 0.7);
    border-radius: 3px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.chat-message {
    max-width: 88%;
    padding: 0.65rem 0.9rem;
    border-radius: 14px;
    font-size: 0.88rem;
    line-height: 1.5;
    word-break: break-word;
}

.chat-message.bot {
    background: #f1f0ff;
    color: #333;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
}

.chat-message.user {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 4px;
    align-self: flex-end;
}

.chat-message .album-recommendation {
    margin-top: 0.5rem;
    padding: 0.5rem 0.7rem;
    background: white;
    border-radius: 8px;
    border-left: 3px solid #667eea;
}

.chat-message .album-recommendation strong {
    display: block;
    color: #667eea;
    margin-bottom: 0.2rem;
}

.chat-message .album-recommendation span {
    font-size: 0.82rem;
    color: #555;
}

.chat-input-area {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid #e8e8e8;
    flex-shrink: 0;
}

.chat-input {
    flex: 1;
    border: 1.5px solid #ddd;
    border-radius: 20px;
    padding: 0.55rem 1rem;
    font-size: 0.88rem;
    outline: none;
    transition: border-color 0.2s;
    color: #333;
}

.chat-input:focus {
    border-color: #667eea;
}

.chat-send {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.15s ease;
}

.chat-send:hover {
    transform: scale(1.08);
}

.chat-send:focus {
    outline: 3px solid #764ba2;
    outline-offset: 2px;
}

.chat-typing {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 0.6rem 0.9rem;
}

.chat-typing span {
    width: 7px;
    height: 7px;
    background: #999;
    border-radius: 50%;
    animation: typingBounce 1.2s infinite;
}

.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }

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

@media (max-width: 768px) {
    .chat-widget {
        bottom: 16px;
        left: 16px;
    }

    .chat-popup {
        width: calc(100vw - 32px);
        height: 400px;
        max-width: none;
    }
}
