/**
 * EUMA Search Tables v2 - CSS
 * Layout card come prima immagine con filtro Members
 */

/* Base InstantSearch Styles */

/* EUMA App Container */
#euma-app {
    max-width: 1280px;
    margin: 0 auto;
    padding: 2rem 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

/* Database Search Menu */
.database-search-menu {
    margin-bottom: 2rem;
    text-align: center;
}

.database-search-menu h1 {
    font-size: 2rem;
    margin-bottom: 1rem;
    color: #333;
    font-weight: 600;
}

.database-search-menu ul.bullet-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    justify-content: center;
    gap: 0;
    flex-wrap: wrap;
}

.database-search-menu ul.bullet-list li {
    margin: 5px;
}

.database-search-menu ul.bullet-list a {
    display: inline-block;
    padding: 12px 24px;
    background-color: #e8e8e8;
    color: #666;
    text-decoration: none;
    font-weight: 600;
    font-size: 16px;
    border: none;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.database-search-menu ul.bullet-list a:hover {
    background-color: #d0d0d0;
    color: #333;
}

.database-search-menu a.nav-link.li-active {
    background-color: #00713D !important;
    color: #fff !important;
}

/* Search Panel Layout */
.search-panel {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 2rem;
    margin-top: 2rem;
    align-items: start;
}

/* Search Sidebar */
.search-sidebar {
    background: #f9f9f9;
    border-radius: 8px;
    padding: 1.5rem;
    border: 1px solid #e0e0e0;
    position: sticky;
    top: 2rem;
    align-self: flex-start;
    /* max-height: calc(100vh - 4rem); */
    overflow-y: auto;
}

.search-sidebar > div {
    margin-bottom: 1.5rem;
}

.search-sidebar h3 {
    font-size: 1rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #3a4570;
    margin-bottom: 0.8rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #c4c8d8;
}

/* Members Filter - nuovo componente */
/* Members Filter - layout come seconda immagine */
.members-filter {
    background: #fff;
    border-radius: 6px;
    padding: 0.5rem;
    border: 1px solid #ddd;
    margin-bottom: 1.5rem;
}

.members-filter h3 {
    margin: 0 0 1rem 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: #333;
    text-transform: uppercase;
}

.members-radios {
    /* max-height: 300px; */
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.member-radio {
    display: flex;
    align-items: center;
    padding: 0.30rem;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
    border: 1px solid #eee;
}

.member-radio:hover {
    background-color: #f8f9fa;
    border-color: #007cba;
}

.member-radio input[type="radio"] {
    margin-right: 0.75rem;
    width: 18px;
    height: 18px;
    accent-color: #007cba;
}

.member-radio input[type="radio"]:checked + .member-name {
    font-weight: 600;
    color: #007cba;
}

.member-radio input[type="radio"]:checked ~ .member-count {
    /* color: #007cba; */
    font-weight: 600;
}

/* Keep backward compatibility for existing checkboxes */
.members-checkboxes {
    max-height: 300px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.member-checkbox {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
    border: 1px solid #eee;
}

.member-checkbox:hover {
    background-color: #f8f9fa;
    border-color: #007cba;
}

.member-checkbox input[type="checkbox"] {
    margin-right: 0.75rem;
    width: 18px;
    height: 18px;
    accent-color: #007cba;
}

.member-checkbox input[type="checkbox"]:checked + .member-name {
    font-weight: 600;
    color: #007cba;
}

.member-name {
    flex: 1;
    font-size: 0.9rem;
    color: #333;
    line-height: 1.3;
}

.member-count {
    font-size: 0.8rem;
    color: black;
    background: #DFE2EE;
    padding: 3px 8px;
    border-radius: 12px;
    /* min-width: 24px; */
    text-align: center;
    font-weight: 400;
}

.member-checkbox input[type="checkbox"]:checked ~ .member-count {
    background: #007cba;
}

/* Search Results */
.search-results {
    min-height: 400px;
}

/* Card Grid Layout - 3 colonne su desktop */
.euma-card-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    margin: 0;
    padding: 0;
    list-style: none;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.euma-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 0;
    margin: 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    width: 100%;
    max-width: 100%;
    min-width: 250px;
    height: auto;
    box-sizing: border-box;
}

.euma-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

.card-content {
    padding: 1.5rem;
    height: 100%;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    overflow: hidden;
}

.card-title {
    margin: 0 0 0.8rem 0;
    font-size: 1.1rem;
    font-weight: 600;
    line-height: 1.3;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    max-width: 100%;
    overflow: hidden;
}

.card-info {
    font-size: 0.95rem;
    font-weight: 500;
    color: #666;
    margin: 0 0 0.5rem 0;
    padding: 0.25rem 0;
}

.card-title a {
    color: #0066cc;
    text-decoration: none;
    transition: color 0.2s ease;
    display: block;
    width: 100%;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.card-title a:hover {
    color: #0052a3;
    text-decoration: underline;
}

/* Member badge - more prominent as in the second image */
.member-badge {
    /* display: inline-block; */
    display: none;
    background: #00713D;
    color: white;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: bold;
    margin: 8px 0;
    text-transform: uppercase;
}

.member-info {
    display: inline-block;
    background: #55c0ef;
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    margin-bottom: 0.8rem;
}

.ref-info {
    color: #666;
    font-size: 0.9rem;
    font-weight: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

.card-excerpt {
    color: #666;
    font-size: 0.9rem;
    line-height: 1.4;
    margin: 0 0 1rem 0;
    flex: 1;
}

.card-meta {
    margin: 0.8rem 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.card-meta span {
    display: inline-block;
    background: #f8f9fa;
    color: #495057;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    border: 1px solid #e9ecef;
}

.meta-difficulty {
    background: #dc3545 !important;
    color: white !important;
    border-color: #dc3545 !important;
}

.card-actions {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid #f0f0f0;
}

.card-link {
    display: inline-block;
    background: #00713D;
    color: white !important;
    padding: 8px 16px;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    transition: background-color 0.2s ease;
}

.card-link:hover {
    background: #005a2b;
    text-decoration: none;
}

/* View More Button */
.view-more-container {
    grid-column: 1 / -1;
    display: flex;
    justify-content: center;
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid #f0f0f0;
}

.view-more-btn {
    display: inline-block;
    background: #00713D;
    color: white;
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.view-more-btn:hover:not(:disabled) {
    background: #005a2b;
}

.view-more-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Current Refinements - styling per filtri members */
.ais-CurrentRefinements {
    margin-bottom: 1rem;
}

.ais-CurrentRefinements-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.ais-CurrentRefinements-item {
    background: #55c0ef;
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ais-CurrentRefinements-delete {
    background: rgba(255, 255, 255, 0.3);
    border: none;
    color: white;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 12px;
    transition: background-color 0.2s ease;
}

.ais-CurrentRefinements-delete:hover {
    background: rgba(255, 255, 255, 0.5);
}

/* Search Box */
.ais-SearchBox {
    margin-bottom: 1.5rem;
}

.ais-SearchBox-form {
    position: relative;
    display: flex;
    align-items: center;
}

.ais-SearchBox-input {
    width: 100%;
    padding: 12px 40px 12px 40px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 1rem;
    background: white;
    transition: border-color 0.2s ease;
}

.ais-SearchBox-input:focus {
    outline: none;
    border-color: #55c0ef;
    box-shadow: 0 0 0 3px rgba(85, 192, 239, 0.1);
}

.ais-SearchBox-submit,
.ais-SearchBox-reset {
    position: absolute;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    color: #666;
    transition: color 0.2s ease;
}

.ais-SearchBox-submit {
    right: 8px;
}

.ais-SearchBox-reset {
    right: 8px;
}

/* Hide submit button when input has content */
.ais-SearchBox-input:not(:placeholder-shown) + .ais-SearchBox-submit {
    display: none;
}

/* Show reset button only when input has content */
.ais-SearchBox-reset {
    display: none;
}

.ais-SearchBox-input:not(:placeholder-shown) ~ .ais-SearchBox-reset {
    display: block;
}

.ais-SearchBox-submit:hover,
.ais-SearchBox-reset:hover {
    color: #55c0ef;
}

/* Make search icon white */
.ais-SearchBox-submit svg,
.ais-SearchBox-submit svg path {
    fill: white;
    color: white;
}

/* Stats */
.ais-Stats {
    margin-bottom: 1rem;
    font-style: italic;
    color: #666;
    font-size: 0.9rem;
}

/* Loading Indicator */
#loading-indicator {
    text-align: center;
    padding: 3rem;
    color: #666;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #55c0ef;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

/* No Results */
.no-results,
.error-message {
    text-align: center;
    padding: 3rem 1rem;
    color: #666;
    grid-column: 1 / -1;
}

.error-message {
    background-color: #fff5f5;
    border: 1px solid #fed7d7;
    border-radius: 8px;
    color: #c53030;
}

/* Responsive Design */
/* Mobile e Tablet - 1 colonna */
@media screen and (max-width: 1199px) {
    .euma-card-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .search-panel {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .database-search-menu ul.bullet-list {
        flex-direction: column;
        gap: 0;
    }
    
    .database-search-menu ul.bullet-list a {
        border-radius: 8px;
        border-bottom: none;
        margin-bottom: 8px;
    }
    
    .database-search-menu ul.bullet-list a:last-child {
        margin-bottom: 0;
    }
    
    .euma-card-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .search-sidebar {
        padding: 1rem;
        position: static;
        max-height: none;
        overflow-y: visible;
    }
    
    .members-checkboxes {
        max-height: 150px;
    }
}

@media screen and (max-width: 480px) {
    #euma-app {
        padding: 1rem 0;
    }
    
    .database-search-menu h1 {
        font-size: 1.5rem;
    }
    
    .card-content {
        padding: 1rem;
    }
    
    .card-meta {
        flex-direction: column;
        gap: 0.3rem;
    }
}

/* Print Styles */
@media print {
    .search-sidebar,
    .database-search-menu {
        display: none;
    }
    
    .search-panel {
        grid-template-columns: 1fr;
    }
    
    .euma-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
    }
    
    .card-link {
        display: none;
    }
}
