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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #f9fafb;
    min-height: 100vh;
    line-height: 1.5;
    color: #111827;
}

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

.main-layout {
    display: grid;
    grid-template-columns: 250px 1fr;
    grid-column-gap: 20px;
    padding: 0 20px;
}

/* Sidebar */
.sidebar-column {
    position: sticky;
    top: 20px;
    height: fit-content;
}

.sidebar {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 20px;
}

.sidebar-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
    color: #111827;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 12px;
}

.sidebar-dataset {
    list-style: none;
    padding: 12px 16px;
    margin-bottom: 4px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    color: #4b5563;
}

.sidebar-dataset:hover {
    background: #f9fafb;
    color: #111827;
}

.sidebar-dataset.active {
    background: linear-gradient(135deg, #6e8efb, #8a75f5);
    color: white;
    font-weight: 500;
}

.total-products {
    margin-top: 12px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 20px;
    font-size: 18px;
    font-weight: 600;
    color: #111827;
    padding-bottom: 12px;
}

.content-area {
    grid-column: 2;
    flex: 1;
}

/* Header */
.header {
    background: white;
    border-bottom: 1px solid #e5e7eb;
    padding: 40px 0;
}

.header-content {
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.header-center {
    max-width: 600px;
}

.brand-name {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 2px;
    color: #4b5563;
    margin-bottom: 8px;
    text-transform: uppercase;
}

.main-title {
    font-size: 36px;
    font-weight: 700;
    color: #111827;
    margin-bottom: 12px;
    line-height: 1.2;
}

.subtitle {
    font-size: 16px;
    color: #4b5563;
    line-height: 1.5;
    margin-bottom: 40px;
}

/* Main content */
.main-content {
    padding: 32px 0;
}

/* Navigation Arrows */
.navigation-arrows {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-top: 60px;
}

.navigation-arrows.hidden {
    display: none !important;
}

.nav-arrow {
    width: 40px;
    height: 40px;
    border: 1px solid #e5e7eb;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #4b5563;
}

.nav-arrow:hover:not(:disabled) {
    background: #111827;
    color: white;
    border-color: #111827;
}

.nav-arrow:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.pagination-dots {
    display: flex;
    gap: 8px;
    align-items: center;
}

.pagination-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #e5e7eb;
    cursor: pointer;
    transition: all 0.3s ease;
}

.pagination-dot.active {
    background: #111827;
    transform: scale(1.2);
}

/* Product Popup */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.popup-overlay.active {
    display: flex;
}

.popup-content {
    background: white;
    border-radius: 8px;
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.popup-header {
    padding: 20px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.popup-title {
    font-size: 20px;
    font-weight: 600;
    color: #111827;
}

.popup-close {
    width: 32px;
    height: 32px;
    border: none;
    background: none;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #4b5563;
    transition: all 0.3s ease;
}

.popup-close:hover {
    background: #f9fafb;
    color: #111827;
}

.popup-body {
    padding: 20px;
    display: flex;
    gap: 30px;
}

.popup-image {
    flex: 1;
    max-width: 350px;
}

.popup-image img {
    width: 100%;
    height: auto;
    max-height: 400px;
    padding: 40px;
    border-radius: 6px;
    object-fit: contain;
}

.popup-details {
    flex: 1;
}

.popup-product-name {
    font-size: 18px;
    font-weight: 600;
    color: rgb(45, 76, 179);
    margin-bottom: 10px;
    line-height: 1.4;
}

.popup-product-price {
    font-size: 18px;
    font-weight: 700;
    color: #4068ec;
    margin-bottom: 16px;
}

.popup-product-description {
    color: #4b5563;
    line-height: 1.6;
    margin-bottom: 14px;
    white-space: pre-line;
}

.popup-product-note {
    font-size: 12px;
    color: #4b5563;
    margin-bottom: 10px;
    line-height: 1.2;
    display: inline-block;
    padding: 4px 12px;
    border: 1px solid #4b5563;
    border-radius: 9999px;
    background: #ffffff;
}

@media (max-width: 768px) {
    .popup-body {
        flex-direction: column;
        gap: 20px;
    }

    .popup-image {
        max-width: 100%;
    }
}

/* Viewpoint Buttons */
.viewpoint-section {
    background: transparent;
    border: none;
    border-radius: 0;
    margin-bottom: 24px;
    overflow: visible;
}

.viewpoint-buttons-container {
    padding: 0;
}

.viewpoint-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: flex-start;
    align-items: flex-start;
}

.viewpoint-button {
    padding: 5px 10px;
    border: 2px solid #e5e7eb;
    background: white;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    color: #4b5563;
    border-radius: 24px;
    transition: all 0.3s ease;
    white-space: nowrap;
    text-align: center;
    position: relative;
    min-width: 120px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.viewpoint-button:hover {
    background: #f9fafb;
    color: #111827;
    border-color: #9ca3af;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.viewpoint-button.active {
    color: white;
    border-color: #6e8efb;
    background: linear-gradient(135deg, #7f9bf7, #9481f3);
    font-weight: 600;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(110, 142, 251, 0.3);
}

.viewpoint-button.active:hover {
    background: linear-gradient(135deg, #6182f1, #8172ee);
    transform: translateY(-3px);
    box-shadow: 0 8px 16px rgba(110, 142, 251, 0.4);
}

@media (max-width: 768px) {
    .viewpoint-buttons {
        gap: 8px;
    }

    .viewpoint-button {
        padding: 10px 16px;
        font-size: 13px;
        min-width: 100px;
    }

    .viewpoint-buttons-container {
        padding: 16px;
    }
}

@media (max-width: 480px) {
    .viewpoint-buttons {
        justify-content: center;
        gap: 6px;
    }

    .viewpoint-button {
        padding: 8px 14px;
        font-size: 12px;
        min-width: 80px;
    }
}


/* Products grid */
.products-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
    animation: fadeInUp 0.6s ease-out;
    align-items: stretch;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInCard {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Note: base is 2 columns; larger breakpoints override below */

@media (min-width: 1024px) {
    .products-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 1280px) {
    .products-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}


/* Product card */
.product-card {
    animation: slideInCard 0.4s ease-out;
    animation-fill-mode: both;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.product-card .ribbon {
    position: absolute;
    top: 12px;
    left: -30px;
    width: 120px;
    padding: 4px 0;
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: white;
    transform: rotate(-45deg);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    z-index: 10;
}

.ribbon-1 {
    background: #cf0000;
}

.ribbon-2 {
    background: #ff6600ec;
}

.ribbon-3 {
    background: #ffa600;
}


.product-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.15),
        0 10px 10px -5px rgba(0, 0, 0, 0.1);
    border-color: #6e8efb;
}

.product-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #6e8efb, #8a75f5);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.product-card:hover::before {
    opacity: 1;
}

.product-image-container {
    aspect-ratio: 1;
    background: white;
    position: relative;
    overflow: hidden;
}

.product-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 15px;
    transition: transform 0.3s ease;
}

.product-card:hover .product-image {
    transform: scale(1.05);
}

.product-content {
    padding: 12px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.product-info {
    flex-grow: 1;
    text-align: center;
}

.product-mall-product-id {
    color: #6b7280;
    font-size: 12px;
    margin-bottom: 6px;
    background: #f1f5f9;
    padding: 1px 4px;
    border-radius: 2px;
    display: inline-block;
    font-family: monospace;
}

.product-name {
    font-size: 13px;
    font-weight: 500;
    line-height: 1.4;
    margin-bottom: 12px;
    min-height: 36px;
    color: #374151;
    transition: all 0.3s ease;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: 0.2px;
}

.product-card:hover .product-name {
    color: #1f2937;
    font-weight: 600;
}

.product-footer {
    padding-top: 8px;
    flex-shrink: 0;
    text-align: center;
}

.product-price {
    color: #577dfc;
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 0;
    letter-spacing: 0.3px;
    transition: all 0.3s ease;
}

.product-card:hover .product-price {
    color: #3361f8;
    font-weight: 700;
}

.product-price-suffix {
    font-size: 14px;
    color: #6b7280;
}

.product-card[draggable="true"] {
    cursor: move;
}

.product-card[draggable="true"]:active {
    opacity: 0.7;
}

.error-message {
    text-align: center;
    display: inline-block;
    padding: 20px;
    font-size: 16px;
    color: #6b7280;
    white-space: nowrap;
}

/* Layout: mobile-first adjustments */
@media (max-width: 1023px) {
    .main-layout {
        grid-template-columns: 1fr;
        grid-column-gap: 0;
    }

    .sidebar-column {
        position: static;
        top: auto;
        height: auto;
        margin-bottom: 16px;
    }

    /* Ensure content area stays in the single column */
    .content-area {
        grid-column: 1;
    }
}

/* Mobile Filters - Hidden on desktop */
.mobile-filters {
    display: none;
}

.mobile-filter-row {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.mobile-filter {
    flex: 1;
}

.mobile-select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    background: white;
    font-size: 14px;
    color: #374151;
    transition: all 0.3s ease;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
    background-position: right 12px center;
    background-repeat: no-repeat;
    background-size: 16px;
    padding-right: 40px;
}

.mobile-select:focus {
    outline: none;
    border-color: #6e8efb;
    box-shadow: 0 0 0 3px rgba(110, 142, 251, 0.1);
}

.mobile-select:disabled {
    background-color: #f9fafb;
    color: #9ca3af;
    cursor: not-allowed;
}

.mobile-total-products {
    font-size: 14px;
    font-weight: 600;
    color: #4b5563;
    text-align: center;
    padding: 8px;
    background: #f8fafc;
    border-radius: 6px;
}

@media (max-width: 768px) {
    .header {
        padding: 24px 0;
    }

    .main-title {
        font-size: 28px;
    }

    .subtitle {
        font-size: 14px;
        margin-bottom: 24px;
    }

    /* Hide desktop sidebar on mobile */
    .sidebar-column {
        display: none;
    }

    /* Show mobile filters */
    .mobile-filters {
        display: block;
        margin-bottom: 24px;
        padding: 0 4px;
    }

    /* Hide desktop viewpoint buttons on mobile */
    .viewpoint-section {
        display: none !important;
    }

    /* Card tweaks cho mobile */
    .product-content {
        padding: 10px;
    }

    .product-name {
        font-size: 12px;
        min-height: auto;
    }

    .product-price {
        font-size: 16px;
    }

    /* Popup image smaller */
    .popup-image img {
        padding: 16px;
        max-height: 280px;
    }

    /* Navigation arrows smaller */
    .navigation-arrows {
        gap: 12px;
        margin-top: 32px;
    }

    /* Products grid tweaks on mobile */
    .products-grid {
        gap: 16px;
    }

    /* Adjust ribbon for mobile tablet */
    .product-card .ribbon {
        font-size: 11px;
        padding: 3px 0;
        width: 110px;
        left: -28px;
        top: 10px;
    }
}

@media (max-width: 480px) {

    /* Adjust ribbon for mobile */
    .product-card .ribbon {
        font-size: 10px;
        padding: 2px 0;
        width: 100px;
        left: -25px;
        top: 8px;
    }

    /* Reduce card size to avoid ribbon overlap */
    .product-image {
        padding: 10px;
    }
}

/* Tablet layout refinements: 769px-1023px */
@media (min-width: 769px) and (max-width: 1023px) {

    /* Use a compact two-column layout with a slimmer sidebar */
    .main-layout {
        grid-template-columns: 220px 1fr;
        grid-column-gap: 16px;
        padding: 0 16px;
    }

    /* Ensure the content area sits in the second column on tablets */
    .content-area {
        grid-column: 2;
    }

    /* Keep sidebar sticky for easier navigation on tablets */
    .sidebar-column {
        position: sticky;
        top: 16px;
        height: fit-content;
        margin-bottom: 0;
    }

    /* Slightly denser product grid for better use of space */
    .products-grid {
        gap: 20px;
    }

    /* Tighter spacing and sizing for viewpoint controls */
    .viewpoint-buttons {
        gap: 10px;
    }

    .viewpoint-button {
        min-width: 110px;
        padding: 8px 12px;
        font-size: 12px;
    }

    /* Reduce top spacing around pagination on tablets */
    .navigation-arrows {
        margin-top: 40px;
    }

    /* Subtle ribbon size tweak to avoid overlap on smaller tablets */
    .product-card .ribbon {
        font-size: 11px;
        padding: 3px 0;
        width: 110px;
        left: -28px;
        top: 10px;
    }

    /* Slightly tighter header */
    .header {
        padding: 32px 0;
    }

    .main-title {
        font-size: 32px;
    }
}

/* Promote 3 columns for wider tablets without affecting desktops */
@media (min-width: 900px) and (max-width: 1023px) {
    .products-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}