/* Base styles and reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: #f0f2f5;
    color: #333;
    line-height: 1.6;
}

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

/* Header */
header {
    text-align: center;
    margin-bottom: 30px;
}

h1 {
    font-size: 2.5rem;
    color: #1c3d5a;
}

/* Search and Filters */
.search-container {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

#searchInput, #categoryFilter, #subcategoryFilter {
    padding: 10px;
    font-size: 1rem;
    border: 1px solid #ccc;
    border-radius: 5px;
    min-width: 200px;
}

#resetFilters {
    padding: 10px 15px;
    font-size: 1rem;
    border: none;
    border-radius: 5px;
    background-color: #6c757d;
    color: white;
    cursor: pointer;
    transition: background-color 0.3s;
}

#resetFilters:hover {
    background-color: #5a6268;
}

.info-bar {
    text-align: center;
    margin-bottom: 20px;
    font-size: 1.1rem;
    color: #555;
}

/* Pagination Controls - Layout actualizat */
.pagination-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 20px 0;
    padding: 15px 20px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    gap: 20px;
}

.pagination-left {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
}

.pagination-center {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
}

.pagination-right {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
}

.pagination-btn {
    padding: 10px 20px;
    font-size: 1rem;
    border: none;
    border-radius: 5px;
    background-color: #007bff;
    color: white;
    cursor: pointer;
    transition: background-color 0.3s;
    font-weight: bold;
}

.pagination-btn:hover:not(:disabled) {
    background-color: #0056b3;
}

.pagination-btn:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

.pagination-info {
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
    white-space: nowrap;
}

/* Total Stock Value */
.total-stock-value {
    display: flex;
    align-items: center;
    gap: 8px;
}

.total-stock-value .total-label {
    color: #000;
    font-size: 1rem;
    font-weight: normal;
}

.total-stock-value .total-amount {
    color: #000;
    font-size: 1.2rem;
    font-weight: bold;
}

/* Filter Options - Sortare și ascundere stoc 0 */
.filter-options {
    display: flex;
    align-items: center;
    gap: 15px;
}

.hide-stock-label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 0.95rem;
    user-select: none;
}

.hide-stock-label input[type="checkbox"] {
    cursor: pointer;
    width: 18px;
    height: 18px;
}

#sortDropdown {
    padding: 8px 12px;
    font-size: 0.95rem;
    border: 1px solid #ccc;
    border-radius: 5px;
    background-color: white;
    cursor: pointer;
    min-width: 180px;
}

/* Product Grid */
#productGrid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 20px;
}

.product-card {
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

.product-image-container {
    position: relative;
    width: 100%;
    padding-top: 100%;
    overflow: hidden;
}

.product-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: #007bff;
    color: white;
    padding: 5px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: bold;
}

.product-info {
    padding: 15px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.product-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 10px;
    flex-grow: 1;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Product Quantity Display */
.product-quantity {
    font-size: 0.9rem;
    font-weight: 600;
    padding: 6px 10px;
    border-radius: 5px;
    margin-bottom: 10px;
    text-align: center;
}

.product-quantity.in-stock {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.product-quantity.out-of-stock {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    font-weight: bold;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.pricerow {
    display: flex;
    justify-content: space-between;
    font-size: 0.95rem;
    margin-bottom: 5px;
}

.pricelabel {
    color: #666;
}

.pricevalue {
    font-weight: bold;
    color: #333;
}

.pricerow.rrp .pricevalue {
    color: #888;
}

.pricerow.discount .pricevalue {
    color: #28a745;
    font-weight: bold;
}

.pricerow.resale .pricevalue {
    color: #007bff;
    font-weight: bold;
}

.buttons-row {
    display: flex;
    gap: 10px;
    margin-top: auto;
    padding-top: 15px;
}

.btn {
    flex: 1;
    padding: 10px;
    text-align: center;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: bold;
    text-decoration: none;
    transition: background-color 0.3s;
}

.btn-details {
    background-color: #17a2b8;
    color: white;
}

.btn-details:hover {
    background-color: #138496;
}

.btn-link {
    background-color: #28a745;
    color: white;
}

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

/* Similar Products - Stil actualizat */
.similar-product-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    margin-bottom: 10px;
    background-color: #e8e8e8;
    border: none;
    border-radius: 5px;
    color: #333;
    text-decoration: none;
    font-size: 0.9rem;
    transition: background-color 0.3s;
    cursor: pointer;
}

.similar-product-link:hover {
    background-color: #d0d0d0;
}

.similar-product-image {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
}

.similar-product-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.similar-product-title {
    font-size: 0.85rem;
    font-weight: 500;
    line-height: 1.3;
    color: #333;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.similar-product-price {
    font-size: 0.9rem;
    font-weight: bold;
    color: #007bff;
}

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

.modal-content {
    background-color: #fff;
    margin: 5% auto;
    padding: 30px;
    border-radius: 8px;
    max-width: 900px;
    width: 90%;
    position: relative;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.close-button {
    color: #aaa;
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close-button:hover,
.close-button:focus {
    color: #333;
}

.modal-body {
    display: flex;
    gap: 30px;
}

.modal-image-gallery {
    flex: 1;
}

.modal-main-image {
    width: 100%;
    border-radius: 8px;
    margin-bottom: 10px;
}

.modal-thumbnails {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.modal-thumbnail {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 4px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color 0.2s;
}

.modal-thumbnail.active {
    border-color: #007bff;
}

.modal-details {
    flex: 1;
}

#modalTitle {
    font-size: 1.3rem;
    margin-bottom: 15px;
}

.product-meta {
    background-color: #f8f9fa;
    padding: 12px;
    border-radius: 5px;
    margin-bottom: 15px;
}

.meta-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    margin-bottom: 5px;
}

.meta-row:last-child {
    margin-bottom: 0;
}

.meta-label {
    color: #666;
    font-weight: 500;
}

.meta-value {
    color: #333;
    font-weight: 600;
}

#modalDescription {
    margin-top: 20px;
    font-size: 1rem;
    color: #555;
}

body.modal-open {
    overflow: hidden;
}

/* Responsive Design */
@media (max-width: 1600px) {
    #productGrid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 1200px) {
    #productGrid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 900px) {
    #productGrid {
        grid-template-columns: repeat(2, 1fr);
    }

    .pagination-controls {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }

    .pagination-left,
    .pagination-center,
    .pagination-right {
        width: 100%;
        justify-content: center;
    }

    .pagination-center {
        order: 1;
    }

    .pagination-left {
        order: 2;
    }

    .pagination-right {
        order: 3;
    }

    .filter-options {
        flex-direction: column;
        gap: 10px;
    }

    #sortDropdown {
        width: 100%;
    }
}

@media (max-width: 768px) {
    #productGrid {
        grid-template-columns: 1fr;
    }

    .modal-body {
        flex-direction: column;
    }

    .search-container {
        flex-direction: column;
        align-items: stretch;
    }

    .pagination-center {
        flex-direction: column;
        gap: 10px;
    }

    .pagination-btn {
        width: 100%;
    }
}

footer {
    text-align: center;
    margin-top: 40px;
    padding: 20px;
    background-color: #1c3d5a;
    color: #f0f2f5;
}