/**
 * Products Page - Modern Design
 * PN-Construction Ltd
 */

:root {
    --primary: #070642;
    --primary-light: #1a1a6e;
    --secondary: #1a5f7a;
    --accent: #2d6a4f;
    --success: #28a745;
    --warning: #ffc107;
    --danger: #dc3545;
    --light: #f8f9fa;
    --dark: #212529;
    --gray: #6c757d;
    --border: #e9ecef;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.12);
    --radius: 16px;
    --radius-sm: 10px;
    --transition: all 0.2s ease;
}

* {
    box-sizing: border-box;
}

/* Performance: Reduce animations on mobile */
@media (max-width: 768px) {
    :root {
        --transition: none;
    }
}

/* Page Header */
.page-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 50%, var(--secondary) 100%);
    padding: 60px 0 40px;
    margin-bottom: 0;
    position: relative;
    overflow: hidden;
}

.page-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    pointer-events: none;
}

.page-header h1 {
    color: white;
    font-weight: 700;
    font-size: 2.5rem;
    margin-bottom: 8px;
    position: relative;
}

.page-header p {
    color: rgba(255, 255, 255, 0.85);
    font-size: 1.1rem;
    position: relative;
}

/* Search Box */
.search-container {
    background: white;
    border-radius: var(--radius);
    padding: 8px;
    box-shadow: var(--shadow-lg);
    max-width: 500px;
}

.search-input-wrapper {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
}

.search-container .form-control {
    border: none;
    padding: 12px 40px 12px 20px;
    font-size: 1rem;
    background: transparent;
    width: 100%;
}

.search-container .form-control:focus {
    box-shadow: none;
}

.btn-clear-search {
    position: absolute;
    right: 8px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: var(--gray);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, background 0.2s ease;
}

.btn-clear-search.visible {
    opacity: 1;
    visibility: visible;
}

.btn-clear-search:hover {
    background: var(--danger);
}

.search-container .btn {
    border-radius: var(--radius-sm);
    padding: 12px 24px;
    font-weight: 500;
}

/* Stats Bar */
.stats-bar {
    background: white;
    border-radius: var(--radius);
    padding: 25px 40px;
    box-shadow: var(--shadow);
    margin: 30px 0;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    max-height: 200px;
    opacity: 1;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease, margin 0.3s ease, padding 0.3s ease;
}

.stats-bar.hidden {
    max-height: 0;
    opacity: 0;
    margin: 0;
    padding: 0 40px;
}

.stats-bar .stat-item {
    text-align: center;
    padding: 10px;
    border-right: 1px solid var(--border);
}

.stats-bar .stat-item:last-child {
    border-right: none;
}

.stats-bar .stat-number {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
}

.stats-bar .stat-label {
    font-size: 0.85rem;
    color: var(--gray);
    margin-top: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

@media (max-width: 768px) {
    .stats-bar {
        grid-template-columns: repeat(2, 1fr);
        padding: 20px;
    }

    .stats-bar .stat-item {
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .stats-bar .stat-item:nth-child(3),
    .stats-bar .stat-item:nth-child(4) {
        border-bottom: none;
    }
}

/* Category Filter Section */
.category-filter-wrapper {
    background: white;
    border-radius: var(--radius);
    padding: 25px;
    box-shadow: var(--shadow);
    margin-bottom: 30px;
    max-height: 500px;
    opacity: 1;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease, margin 0.3s ease, padding 0.3s ease;
}

.category-filter-wrapper.hidden {
    max-height: 0;
    opacity: 0;
    margin: 0;
    padding: 0 25px;
}

.category-filter-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border);
}

.category-filter-header h6 {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--gray);
    text-transform: uppercase;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.category-filter-header h6 i {
    font-size: 1rem;
    color: var(--primary);
}

.filter-reset {
    font-size: 0.8rem;
    color: var(--primary);
    text-decoration: none;
    cursor: pointer;
    border: none;
    background: none;
    padding: 5px 10px;
    border-radius: 5px;
    transition: var(--transition);
}

.filter-reset:hover {
    background: var(--light);
}

.category-filter {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}

.filter-pill {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    background: var(--light);
    border: 2px solid transparent;
    color: var(--dark);
    font-weight: 500;
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
}

.filter-pill i {
    width: 32px;
    height: 32px;
    background: white;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: var(--primary);
    flex-shrink: 0;
}

.filter-pill .filter-text {
    flex: 1;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.filter-pill:hover {
    border-color: var(--primary);
    background: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.filter-pill.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.filter-pill.active i {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.filter-pill .count {
    background: rgba(0, 0, 0, 0.08);
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    flex-shrink: 0;
}

.filter-pill.active .count {
    background: rgba(255, 255, 255, 0.2);
}

@media (max-width: 768px) {
    .category-filter {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .filter-pill {
        padding: 10px 12px;
        font-size: 0.8rem;
    }

    .filter-pill i {
        width: 28px;
        height: 28px;
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .category-filter {
        grid-template-columns: 1fr;
    }
}

/* Category Section */
.category-section {
    margin-bottom: 40px;
}

.category-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--border);
}

.category-icon {
    width: 50px;
    height: 50px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
}

.category-header h3 {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--dark);
}

.category-header .badge {
    font-weight: 500;
    padding: 6px 12px;
}

/* Product Cards Grid */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

/* Product Card */
.product-card {
    background: white;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: var(--transition);
    cursor: pointer;
    position: relative;
    border: 1px solid transparent;
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
}

.product-card-header {
    padding: 20px 20px 0;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.product-code {
    font-size: 0.7rem;
    font-weight: 700;
    color: white;
    background: var(--primary);
    padding: 4px 10px;
    border-radius: 20px;
    letter-spacing: 0.5px;
}

.product-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    opacity: 0.8;
}

.product-card-body {
    padding: 15px 20px;
}

.product-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 8px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-unit {
    font-size: 0.8rem;
    color: var(--gray);
    display: flex;
    align-items: center;
    gap: 5px;
}

.product-card-footer {
    padding: 15px 20px;
    background: var(--light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border);
    position: relative;
    z-index: 5;
    border-radius: 0 0 var(--radius) var(--radius);
}

.product-actions {
    display: flex;
    gap: 8px;
}

.product-price {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary);
}

.product-price small {
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--gray);
}

.btn-add-cart,
.btn-buy-now {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: none;
    color: white;
    font-size: 1.1rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-add-cart {
    background: var(--primary);
}

.btn-buy-now {
    background: var(--success);
}

.btn-add-cart:hover {
    background: var(--primary-light);
    transform: scale(1.1);
}

.btn-buy-now:hover {
    background: #218838;
    transform: scale(1.1);
}

.btn-add-cart.added {
    background: var(--secondary);
}

.btn-add-cart.adding {
    animation: pulse 0.3s ease;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

/* View Details Overlay - Only covers top section, not footer */
.product-card .view-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 70px; /* Leave space for footer with buttons */
    background: rgba(7, 6, 66, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: var(--transition);
    border-radius: var(--radius) var(--radius) 0 0;
    pointer-events: none;
}

.product-card:hover .view-overlay {
    opacity: 1;
    pointer-events: auto;
}

.view-overlay .btn {
    background: white;
    color: var(--primary);
    border: none;
    padding: 10px 20px;
    border-radius: 50px;
    font-weight: 600;
    transform: translateY(15px);
    transition: var(--transition);
    font-size: 0.85rem;
}

.product-card:hover .view-overlay .btn {
    transform: translateY(0);
}

.view-overlay .btn:hover {
    background: var(--light);
    transform: scale(1.05);
}

/* Product Modal */
.product-modal .modal-content {
    border: none;
    border-radius: var(--radius);
    overflow: hidden;
}

.product-modal .modal-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    border: none;
    padding: 25px 30px;
}

.product-modal .modal-header .btn-close {
    filter: brightness(0) invert(1);
    opacity: 0.8;
}

.product-modal .modal-body {
    padding: 30px;
}

.product-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.detail-item {
    padding: 15px;
    background: var(--light);
    border-radius: var(--radius-sm);
}

.detail-item label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--gray);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: block;
    margin-bottom: 5px;
}

.detail-item p {
    margin: 0;
    font-weight: 500;
    color: var(--dark);
}

.product-modal .price-display {
    background: var(--primary);
    color: white;
    padding: 20px;
    border-radius: var(--radius-sm);
    text-align: center;
}

.product-modal .price-display .price {
    font-size: 2rem;
    font-weight: 700;
}

.product-modal .modal-footer {
    border: none;
    padding: 20px 30px 30px;
    gap: 10px;
}

/* Quantity Selector in Modal */
.quantity-selector {
    display: flex;
    align-items: center;
    gap: 15px;
    background: var(--light);
    padding: 10px 15px;
    border-radius: var(--radius-sm);
}

.quantity-selector button {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: white;
    font-size: 1.2rem;
    cursor: pointer;
    transition: var(--transition);
}

.quantity-selector button:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.quantity-selector input {
    width: 50px;
    text-align: center;
    border: none;
    background: transparent;
    font-size: 1.1rem;
    font-weight: 600;
}

/* Floating Cart */
.floating-cart {
    position: fixed !important;
    bottom: 30px;
    right: 30px;
    z-index: 9990 !important;
}

.floating-cart-btn {
    width: 65px;
    height: 65px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 8px 30px rgba(7, 6, 66, 0.4);
    transition: var(--transition);
    position: relative;
}

.floating-cart-btn:hover {
    transform: scale(1.1) translateY(-3px);
    box-shadow: 0 12px 40px rgba(7, 6, 66, 0.5);
}

/* Disable hover effects on touch devices */
@media (hover: none) {
    .floating-cart-btn:hover {
        transform: none;
        box-shadow: 0 8px 30px rgba(7, 6, 66, 0.4);
    }
}

.floating-cart-btn .badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--danger);
    color: white;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    border: 3px solid white;
}

/* Cart Sidebar */
.cart-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: rgba(0, 0, 0, 0.5) !important;
    backdrop-filter: blur(5px);
    z-index: 9998 !important;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.cart-overlay.open {
    opacity: 1 !important;
    visibility: visible !important;
}

.cart-sidebar {
    position: fixed !important;
    right: -420px;
    top: 0 !important;
    width: 420px;
    max-width: 100%;
    height: 100vh !important;
    background: white !important;
    z-index: 9999 !important;
    transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex !important;
    flex-direction: column;
    box-shadow: -10px 0 50px rgba(0, 0, 0, 0.15);
}

.cart-sidebar.open {
    right: 0 !important;
}

.cart-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    padding: 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cart-header h5 {
    margin: 0;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.cart-header .close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
}

.cart-header .close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.cart-items {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.cart-item {
    display: flex;
    gap: 15px;
    padding: 15px;
    background: var(--light);
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    position: relative;
    transition: var(--transition);
}

.cart-item:hover {
    box-shadow: var(--shadow);
}

.cart-item-info {
    flex: 1;
}

.cart-item-code {
    font-size: 0.7rem;
    color: var(--gray);
    font-weight: 600;
}

.cart-item-name {
    font-weight: 600;
    font-size: 0.9rem;
    margin: 4px 0;
    color: var(--dark);
}

.cart-item-price {
    color: var(--primary);
    font-weight: 700;
}

.cart-item-controls {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
}

.cart-item-qty {
    display: flex;
    align-items: center;
    gap: 8px;
}

.cart-item-qty button {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: white;
    cursor: pointer;
    transition: var(--transition);
}

.cart-item-qty button:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.cart-item-qty span {
    font-weight: 600;
    min-width: 25px;
    text-align: center;
}

.cart-item-remove {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    padding: 5px;
    opacity: 0.7;
    transition: var(--transition);
}

.cart-item-remove:hover {
    opacity: 1;
}

.cart-footer {
    padding: 25px;
    background: var(--light);
    border-top: 1px solid var(--border);
}

.cart-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.cart-total-label {
    font-size: 1rem;
    color: var(--gray);
}

.cart-total-amount {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.cart-footer .btn-checkout {
    width: 100%;
    padding: 15px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
}

/* Empty Cart State */
.empty-cart {
    text-align: center;
    padding: 60px 20px;
}

.empty-cart-icon {
    width: 100px;
    height: 100px;
    margin: 0 auto 20px;
    background: var(--light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    color: var(--gray);
}

.empty-cart h5 {
    color: var(--dark);
    margin-bottom: 10px;
}

.empty-cart p {
    color: var(--gray);
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 110px;
    right: 30px;
    z-index: 1060;
}

.toast {
    background: white;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    padding: 15px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 280px;
    border-left: 4px solid var(--success);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast-icon {
    width: 35px;
    height: 35px;
    background: var(--success);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--dark);
}

.toast-message {
    font-size: 0.8rem;
    color: var(--gray);
}

/* Loading Skeleton */
.skeleton {
    background: linear-gradient(90deg, var(--light) 25%, #e9ecef 50%, var(--light) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Responsive */
@media (max-width: 768px) {
    .page-header {
        padding: 40px 0 30px;
    }

    .page-header h1 {
        font-size: 1.8rem;
    }

    .products-grid {
        grid-template-columns: 1fr;
    }

    .cart-sidebar {
        width: 100%;
        right: -100%;
    }

    .floating-cart {
        bottom: 20px;
        right: 20px;
    }

    .floating-cart-btn {
        width: 55px;
        height: 55px;
    }

    .product-detail-grid {
        grid-template-columns: 1fr;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    /* Can add dark mode styles here if needed */
}

/* Print styles */
@media print {
    .floating-cart,
    .cart-sidebar,
    .cart-overlay {
        display: none !important;
    }
}
