@import url('https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100..900;1,100..900&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: #f5f5f5;
    padding: 20px;
    font-family: "Montserrat", sans-serif;
}

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

.header {
    margin-bottom: 2rem;
    text-align: center;
}

h1 {
    font-size: 2.3rem;
}

p{
    line-height: 1.4em;
}

.align-center{
    text-align: center;
}

.card-title{
    display: flex;
    flex-direction: row-reverse;
    justify-content: space-between;
}

.card-grid{
    display: flex;
    flex-direction: row;
    gap: 1rem;
}

.card {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 1rem;
}

.card-grid .card:first-child{width: calc(40% - 0.5rem);}
.card-grid .card:last-child{width: calc(60% - 0.5rem);}

.card-header {
    padding: 1.5rem;
}

.card-header h1{
    margin-bottom: 0.5rem;
}

.card-content {
    padding: 1.5rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    text-align: center;
    gap: 1rem;
}

.input-group p{
    color: #8b8b8b;
    font-size: 12px;
    position: relative;
}

.input-group p span{
    background-color: #fff;
    position: relative;
    z-index: 1;
    padding:0 10px;
}

.input-group p:after {
    content: "";
    position: absolute;
    top: 6px;
    left: 0;
    height: 1px;
    background: #e9e9e9;
    width: 100%;
}

.address-wrapper {
    position: relative;
    flex: 1;
}

input[type="text"] {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

.btn-primary {
    padding: 0.75rem 1.5rem;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
    text-transform: uppercase;
}

.btn-primary:hover {
    background: #2563eb;
}

.suggestions-list {
    position: absolute;
    width: 100%;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-top: 4px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    z-index: 1000;
    display: none;
    max-height: 300px;
    overflow: scroll;
}

.suggestion-item {
    padding: 0.75rem;
    text-align: left;
    cursor: pointer;
}

.suggestion-item:hover {
    background: #f5f5f5;
}

.loyalty-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

/* .loyalty-select {
    width: 100%;
    min-height: 120px;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: white;
    font-size: 1rem;
} */

/* Aggiungi questi stili in style.css */
.custom-select {
    position: relative;
    width: 100%;
    user-select: none;
}

.select-trigger {
    padding: 12px 16px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: border-color 0.2s;
}

.select-trigger:hover {
    border-color: #3b82f6;
}

.trigger-text {
    color: #000;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: calc(100% - 24px); /* Spazio per la freccia */
}

.trigger-arrow {
    font-size: 0.8rem;
    transition: transform 0.2s;
}

.custom-select.open .trigger-arrow {
    transform: rotate(180deg);
}

.select-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    display: none;
    max-height: 250px;
    overflow-y: auto;
}

.custom-select.open .select-dropdown {
    display: block;
}

.checkbox-list {
    padding: 8px 0;
}

.checkbox-item {
    padding: 8px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: background-color 0.2s;
}

.checkbox-item:hover {
    background-color: #f5f5f5;
}

.checkbox-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.checkbox-item label {
    cursor: pointer;
    flex: 1;
    font-size: 0.95rem;
}

.select-trigger {
    padding: 12px 16px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: border-color 0.2s;
    gap: 8px; /* Spazio tra il testo e la freccia */
}

.select-trigger:hover .trigger-text {
    overflow: visible;
    white-space: normal;
    position: relative;
    z-index: 1001;
    background: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    border-radius: 4px;
    padding: 4px;
}

/* Stili per il focus e l'accessibilità */
.select-trigger:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

/* Stili per la scrollbar personalizzata */
.select-dropdown::-webkit-scrollbar {
    width: 8px;
}

.select-dropdown::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.select-dropdown::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.select-dropdown::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Rimuovi gli stili vecchi */
.loyalty-cards,
.loyalty-card-btn {
    display: none;
}


.search-container {
    position: relative;
}

.search-results {
    position: absolute;
    width: 100%;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-top: 4px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    z-index: 1000;
    display: none;
    max-height: 300px;
    overflow: scroll;
}

.search-result-item {
    padding: 0.75rem;
    cursor: pointer;
}

.search-result-item:hover {
    background: #f5f5f5;
}

.shopping-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
}

.shopping-table th,
.shopping-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
    border-right: 1px solid #e2e8f0;
}

.shopping-table th {
    white-space: normal;
    vertical-align: top;
    font-weight: 600;
}

.shopping-table tr td,
.shopping-table tr th{
    text-align: center;
    min-width: 160px;
    line-height: 1.4em;
}

.shopping-table tr td:first-child, 
.shopping-table tr th:first-child {
    min-width: 110px;
    width: 110px;
    background-color: #f5f5f5;
}

.shopping-table tr td:nth-child(2), 
.shopping-table tr th:nth-child(2) {
    text-align: left;
    min-width: 300px;
}

.shopping-table tr td:nth-child(3), 
.shopping-table tr th:nth-child(3) {
    min-width: 80px;
}

#favoritesList .shopping-table tr td:first-child, 
#favoritesList .shopping-table tr th:first-child {
    min-width: 80px;
    width: 80px;
}

#favoritesList .shopping-table tr td:nth-child(2), 
#favoritesList .shopping-table tr th:nth-child(2) {
    min-width: 200px;
}

#favoritesList .shopping-table tr td:nth-child(3), 
#favoritesList .shopping-table tr th:nth-child(3) {
    min-width: 160px;
}

.shopping-table thead{
    background-color: #f5f5f5;
    text-transform: uppercase;
}

.shopping-table thead th{
    border-right: 1px solid #d6d6d6;
}

.shopping-table-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
}


.price-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin: 1rem 0;
}

.price-card {
    padding: 1rem;
    border-radius: 4px;
    background: #f5f5f5;
}

.price-card.best {
    background: #dcfce7;
    color: #166534;
}

.promo-price {
    color: #dc2626;
    font-weight: bold;
}

.original-price {
    text-decoration: line-through;
    color: #666;
    margin-right: 0.5rem;
}

.remove-btn {
    color: #ef4444;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.25rem;
    padding: 0 2px;
}

.remove-btn:hover {
    color: #dc2626;
}

.empty-message {
    text-align: center;
    color: #666;
    padding: 2rem;
}

.favorite-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0 2px;
    font-size: 1.2em;
}

.quick-todo-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2em;
    padding: 0 2px;
}

.price-card {
    cursor: pointer;
    transition: all 0.3s ease;
}

.price-card.selected {
    border: 2px solid #007bff;
    transform: scale(1.05);
}

.list-actions {
    margin-top: 20px;
    text-align: center;
}

.saved-lists {
    margin-top: 40px;
}

.saved-list {
    border: 1px solid #ddd;
    padding: 15px;
    margin: 10px 0;
    border-radius: 5px;
}

.saved-list-total {
    font-weight: bold;
    text-align: center;
    margin: 10px 0;
}

.complete-list-btn {
    background-color: #28a745;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 3px;
    cursor: pointer;
}

.complete-list-btn:hover {
    background-color: #218838;
}


.checklist {
    list-style: none;
    padding: 0;
}

.checklist-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    cursor: pointer;
    justify-content: space-between; /* Allinea gli elementi internamente */
}

.checklist-item-content {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.checklist-remove-btn {
    color: #ef4444;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.25rem;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
}

.checklist-remove-btn:hover {
    background-color: #fee2e2;
    color: #dc2626;
}

.checklist-item input[type="checkbox"] {
    cursor: pointer;
}

.product-name.checked {
    text-decoration: line-through;
    color: #666;
}

.saved-list-container {
    margin-top: 2rem;
    padding: 1.5rem;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background-color: #f8fafc;
}

.saved-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e2e8f0;
}

.saved-list-info {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.saved-list-total {
    font-weight: bold;
    align-items: center;
}

.saved-list-total span{
    font-size: 20px;
    color: #22c55d;
}

.save-list-btn {
    width: 100%;
    margin-top: 0.5rem;
    padding: 0.5rem;
    background-color: #2563eb;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.save-list-btn:hover {
    background-color: #1d4ed8;
}

.complete-list-btn {
    width: 100%;
    margin-top: 1rem;
    padding: 0.75rem;
    background-color: #22c55e;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.complete-list-btn:hover {
    background-color: #16a34a;
}

.checklist {
    list-style: none;
    padding: 0;
    margin: 1rem 0;
}

.checklist-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0;
    cursor: pointer;
}

.checklist-item input[type="checkbox"] {
    width: 1.2rem;
    height: 1.2rem;
    cursor: pointer;
}

.product-name.checked {
    text-decoration: line-through;
    color: #64748b;
}

.price-card {
    cursor: pointer;
    padding: 1rem;
    border: 2px solid transparent;
    transition: all 0.2s ease;
}

.price-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.price-card.selected {
    border-color: #2563eb;
    background-color: #f0f7ff;
}

.quantity-select {
    padding: 0.25rem;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    width: 100%;
}

.price-card.selected {
    border-color: #2563eb;
    background-color: #f0f7ff;
}

.nearest-store {
    font-size: 0.60rem;
    line-height: 1.5em;
    color: #666;
    text-transform: capitalize;
    font-weight: normal;
    display: block;
    margin-top: 0.25rem;
    white-space: normal;
    font-weight: 500;
}


.saved-list-address {
    font-size: 0.9rem;
    color: #666;
    display: block;
    margin-top: 0.25rem;
}

/* Miglioramenti per l'accessibilità touch */
@media (hover: none) {
    .price-card:hover,
    .loyalty-card-btn:hover,
    .suggestion-item:hover,
    .search-result-item:hover {
        transform: none;
        background: inherit;
    }

    .btn-primary:active,
    .complete-list-btn:active,
    .loyalty-card-btn:active {
        opacity: 0.8;
    }
}

#favoritesList{
    margin-top: .5rem;
}

.remove-favorite-btn {
    color: #ef4444;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.25rem;
    padding: 0 2px;
}

.add-to-list-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2em;
    padding: 0 2px;
    transition: transform 0.2s;
}

.add-to-list-btn:hover {
    transform: scale(1.2);
}

@media screen and (max-width: 768px) {
    .card-title{flex-direction: column; text-align: center;}
    .card-title h1{margin-bottom: 1rem; font-size: 2em;}

    .card-grid{flex-direction: column; margin-bottom: 1rem;}
    .card-grid .card:first-child,
    .card-grid .card:last-child{width: 100%; margin: 0}
    
}

@media screen and (max-width: 768px) {
    .card-option .card-content {
      display: none;
    }
  
    .card-option.open .card-content {
      display: block;
    }
  
    .card-option .card-header {
      cursor: pointer;
      position: relative;
      padding-right: 40px;
    }
  
    .card-option .card-header::after {
      content: '🔽';
      position: absolute;
      right: 20px;
      top: 50%;
      transform: translateY(-50%);
      transition: transform 0.3s ease;
    }
  
    .card-option.open .card-header::after {
      transform: translateY(-50%) rotate(180deg);
    }
  }


@media screen and (max-width: 530px) {
    /* .shopping-table tr td:first-child, .shopping-table tr th:first-child{width: auto; min-width: unset;} */
    .price-grid{grid-template-columns: repeat(2, 1fr); gap: 0.5rem;}

    .saved-list-header{flex-direction: column; align-items: normal;}
    .saved-list-header .saved-list-info{justify-content: space-between;}

    .saved-list-header h2{margin-bottom: .5rem;}

    .shopping-table tr td, .shopping-table tr th{min-width: 120px;}

    .shopping-table tr td:nth-child(2), 
    .shopping-table tr th:nth-child(2) {
        min-width: 200px;
    }
}

.pt0{padding-top: 0;}
.pt05{padding-top: .5rem;}
.pb0{padding-bottom: 0;}
.pb05{padding-bottom: .5rem;}
