/* Layout components */

/* Category layout */
.category {
    margin: 25px auto;
    padding: 4px;
    background-color: #333;
    border-radius: 8px;
    max-width: 1200px;
    border: 1px solid #444;
}

.category h3 {
    font-size: 1.5em;
    font-weight: bold;
    color: #ffffff;
    margin-bottom: 20px;
    padding-bottom: 8px;
    text-transform: uppercase;
    border-bottom: 2px solid #6f42c1;
}

/* Controls sections */
.controls-section {
    margin: 25px auto;
    padding: 4px;
    background-color: #404040;
    border-radius: 8px;
    max-width: 1200px;
    border: 1px solid #484848;
}

.controls-group {
    margin: 15px;
    padding: 15px;
    background: #484848;
    border-radius: 6px;
    display: flex !important;
    flex-direction: row !important;
    gap: 20px !important;
    align-items: center !important;
    flex-wrap: wrap !important;
    justify-content: flex-start !important;
}

.control-item {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 5px !important;
    color: white !important;
    margin: 0 !important;
    min-width: fit-content !important;
    flex: 0 0 auto !important;
}

.control-item input[type="checkbox"] {
    margin: 0 !important;
    width: 16px !important;
    height: 16px !important;
    cursor: pointer !important;
}

.control-item label {
    margin: 0 !important;
    cursor: pointer !important;
    white-space: nowrap !important;
}

/* Input containers */
.input-group {
    position: relative;
    margin: 15px auto;
    width: 100%;
    max-width: 300px;
}

/* Input styling */
#product-barcode,
#search-product,
#note {
    background-color: #505050;
    color: #ffffff;
    border: 2px solid #6f42c1;
    padding: 10px 35px;
    border-radius: 6px;
    width: 100%;
    height: 42px;
    font-size: 14px;
    transition: all 0.3s ease;
    text-align: center;
}

/* Icon styling */
.input-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #ffffff;
    font-size: 18px;
    pointer-events: none;
}

/* Focus and hover effects */
#product-barcode:focus,
#search-product:focus,
#note:focus {
    outline: none;
    border-color: #8250df;
    box-shadow: 0 0 0 2px rgba(111, 66, 193, 0.3);
}

#product-barcode:hover,
#search-product:hover,
#note:hover {
    border-color: #8250df;
}

/* Container styling */
.search-section,
.note-container {
    width: 100%;
    max-width: 300px;
    margin: 0 auto;
}

/* Placeholder color */
input::placeholder {
    color: #bbb;
}

/* Responsive adjustments */
@media (max-width: 600px) {
    .search-section,
    .note-container {
        padding: 0 15px;
        max-width: 300px;
    }
}

/* Vendor Modal Styling */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal.show {
    display: block;
}

.modal-content {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #2d2d2d;
    padding: 20px;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    border: 1px solid #3d3d3d;
}

.modal-content h2 {
    color: #fff;
    margin-bottom: 15px;
    font-size: 1.4em;
    border-bottom: 2px solid #6f42c1;
    padding-bottom: 8px;
}

#vendor-list {
    max-height: 300px;
    overflow-y: auto;
    margin: 15px 0;
    background: #404040;
    border-radius: 8px;
    padding: 10px;
}

#vendor-list label {
    display: block;
    padding: 8px 12px;
    color: #fff;
    cursor: pointer;
    transition: background-color 0.2s;
    border-radius: 4px;
    margin: 2px 0;
}

#vendor-list label:hover {
    background-color: #484848;
}

#vendor-list input[type="radio"] {
    margin-right: 10px;
}

.modal .close-button {
    position: absolute;
    right: 12px;
    top: 12px;
    background: #dc3545;
    border: none;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
    transition: all 0.3s ease;
    border-radius: 4px;
}

.modal .close-button:hover {
    background: #c82333;
}

.modal .action-button {
    background: #6f42c1;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    min-width: 110px;
    text-align: center;
    display: block;
    margin: 15px auto 5px;
}

.modal .action-button:hover {
    background: #8250df;
}

/* SweetAlert2 Custom Styling */
.swal2-popup {
    background: #2d2d2d !important;
    border: 1px solid #3d3d3d !important;
    border-radius: 12px !important;
    padding: 20px !important;
    width: 360px !important;
}

/* Override SweetAlert2 select styling */
div:where(.swal2-container) .swal2-select {
    min-width: 50% !important;
    max-width: 80% !important;
    padding: .375em .625em !important;
    background: rgba(0, 0, 0, 0) !important;
    color: inherit !important;
    font-size: 1.125em !important;
}

/* Additional select styling */
.swal2-select {
    background-color: #404040 !important;
    border: 1px solid #484848 !important;
    border-radius: 6px !important;
    color: #fff !important;
    margin: 10px auto !important;
    display: block !important;
}

.swal2-select option {
    background-color: #404040 !important;
    color: #fff !important;
    padding: 8px !important;
}

.swal2-title {
    color: #fff !important;
    font-size: 1.4em !important;
    padding-bottom: 8px !important;
    border-bottom: 2px solid #6f42c1 !important;
}

.swal2-html-container {
    color: #fff !important;
    margin: 10px 0 !important;
}

.swal2-radio {
    display: flex !important;
    flex-direction: column !important;
    gap: 5px !important;
    background: #404040 !important;
    padding: 10px !important;
    border-radius: 8px !important;
    margin: 10px 0 !important;
    max-height: 200px !important;
    overflow-y: auto !important;
}

.swal2-radio label {
    display: flex !important;
    align-items: center !important;
    color: #fff !important;
    padding: 8px 12px !important;
    border-radius: 4px !important;
    cursor: pointer !important;
    transition: background-color 0.2s !important;
    margin: 0 !important;
}

.swal2-radio label:hover {
    background-color: #484848 !important;
}

.swal2-radio input {
    margin: 0 10px 0 0 !important;
}

.swal2-confirm {
    background: #6f42c1 !important;
    color: white !important;
    border-radius: 6px !important;
    padding: 8px 20px !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    box-shadow: none !important;
}

.swal2-confirm:hover {
    background: #8250df !important;
}

.swal2-cancel {
    background: #dc3545 !important;
    color: white !important;
    border-radius: 6px !important;
    padding: 8px 20px !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    box-shadow: none !important;
}

.swal2-cancel:hover {
    background: #c82333 !important;
}

/* Mobile adjustments */
@media (max-width: 600px) {
    .controls-section {
        margin: 15px 10px;
        padding: 4px;
    }

    .controls-group {
        margin: 10px;
        padding: 10px;
    }

    .control-item {
        padding: 6px;
    }

    #management-container {
        width: 92%;
        padding: 15px;
    }

    .flex-item {
        padding: 12px;
    }

    .flex-item input[type="text"] {
        width: 65%;
        font-size: 14px;
    }

    .flex-item button {
        width: 30%;
        font-size: 14px;
    }
}

/* Product management section */
.product-management-section {
    margin-top: 20px;
    padding: 20px;
    background-color: #444;
    border-radius: 8px;
}

.product-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-width: 500px;
    margin: 0 auto;
}

.product-name-container {
    position: relative;
}

/* Existing barcodes display */
.existing-barcodes {
    font-size: 14px;
    color: #aaa;
    margin-top: 5px;
    text-align: left;
    padding: 5px 0;
}

/* Top options layout */
#top-options {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    margin: 20px auto;
    max-width: 800px;
}

/* Product list layout */
.product-list-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
    padding: 15px;
    margin: 0 auto;
    max-width: 1200px;
    margin-bottom: 200px;
}

.product {
    display: inline-block;
    margin: 5px;
    flex: 0 1 calc(50% - 10px); /* Due prodotti per riga su mobile */
}

/* Desktop view */
@media screen and (min-width: 768px) {
    .product {
        flex: 0 1 auto; /* Auto-fit su desktop */
    }
}

/* Mobile adjustments */
@media (max-width: 600px) {
    .mobile-hide {
        display: none;
    }

    .control-item {
        min-width: 100px;
        padding: 8px 12px;
        font-size: 14px;
    }

    .controls-group {
        gap: 8px;
        padding: 8px;
    }

    .control-item input[type="text"] {
        width: 150px;
    }

    #additional-options {
        padding: 10px;
        margin: 15px auto;
        width: 90%;
    }

    .checkbox-container {
        width: 100%;
        justify-content: flex-start;
        padding: 10px;
    }

    .checkbox-container label {
        font-size: 14px;
    }

    .note-container {
        margin-top: 15px;
    }

    .note-container input[type="text"] {
        padding: 10px;
        font-size: 14px;
    }

    .bottom-section {
        padding: 10px;
    }

    #management-container {
        width: 85%;
        padding: 10px;
        max-width: none;
        max-height: 85vh;
        top: 55%;
    }

    .product-management-section {
        padding: 10px;
        margin-top: 40px;
    }

    .product-list-container {
        margin-bottom: 240px; /* Increased for mobile to ensure visibility */
    }
}

/* Results and Price History Containers */
#results-container,
#price-history-container {
    background: #2d2d2d;
    border-radius: 12px;
    padding: 20px;
    margin: 20px auto;
    max-width: 1200px;
    border: 1px solid #3d3d3d;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

#price-history-container {
    max-width: 900px;
    margin: 20px auto;
    padding: 20px;
    background-color: #2d2d2d;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

#price-history-container h2 {
    color: #fff;
    margin-bottom: 20px;
    font-weight: 500;
}

#price-history-container .styled-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
    font-size: 0.9em;
    border-radius: 8px;
    overflow: hidden;
}

#price-history-table-body tr {
    background-color: #404040;
    border-bottom: 1px solid #484848;
    transition: background-color 0.3s ease;
}

#price-history-table-body tr:hover {
    background-color: #484848;
}

#price-history-table-body td {
    padding: 12px 15px;
    color: #fff;
}

#price-history-table-body td:nth-child(1) {
    text-align: left;
}

#price-history-table-body td:nth-child(2) {
    text-align: right;
    color: #4CAF50;
}

#price-history-table-body td:nth-child(3) {
    text-align: center;
    color: #8250df;
}

#price-history-table-body td:nth-child(4) {
    text-align: right;
    color: #dc3545;
}

#results-container h2,
#price-history-container h2 {
    color: #fff;
    margin-bottom: 15px;
    font-size: 1.4em;
    border-bottom: 2px solid #6f42c1;
    padding-bottom: 8px;
}

/* Convenience List Styling */
#listaConvenienza {
    background: #404040;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
}

#listaConvenienza .vendor-section {
    background: #484848;
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 10px;
}

#listaConvenienza .vendor-name {
    color: #6f42c1;
    font-size: 1.2em;
    font-weight: 500;
    margin-bottom: 8px;
}

#listaConvenienza .product-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px;
    border-bottom: 1px solid #555;
    color: #fff;
}

#listaConvenienza .product-item:last-child {
    border-bottom: none;
}

#listaConvenienza .price {
    color: #4CAF50;
    font-weight: 500;
}

/* Price History Table Styling */
.styled-table {
    width: 100%;
    border-collapse: collapse;
    background: #404040;
    border-radius: 8px;
    overflow: hidden;
}

.styled-table thead {
    background: #484848;
}

.styled-table th {
    color: #fff;
    font-weight: 500;
    text-align: left;
    padding: 12px 15px;
    border-bottom: 2px solid #6f42c1;
}

.styled-table td {
    color: #fff;
    padding: 10px 15px;
    border-bottom: 1px solid #555;
}

.styled-table tr:last-child td {
    border-bottom: none;
}

.styled-table tbody tr:hover {
    background: #484848;
}

/* Print Button Container */
#buttons-container {
    display: flex;
    justify-content: flex-end;
    margin-top: 15px;
}

#printAllOffersButton {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #6f42c1;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
}

#printAllOffersButton:hover {
    background: #8250df;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(111, 66, 193, 0.2);
}

#printAllOffersButton img {
    width: 20px;
    height: 20px;
}

/* Home button styling */
#return-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background-color: #6f42c1;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
}

#return-button:hover {
    background-color: #8250df;
}

#return-button i {
    font-size: 18px;
}

/* Mobile Adjustments */
@media (max-width: 600px) {
    #results-container,
    #price-history-container {
        margin: 15px;
        padding: 15px;
    }

    .styled-table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .styled-table th,
    .styled-table td {
        padding: 8px 12px;
    }

    #listaConvenienza .vendor-section {
        padding: 10px;
    }
}
