/**
 * Product Grid & List View Styles
 * 
 * Extracted from inline styles in index.php and category.php
 * Common styles for product display across both pages
 * 
 * @version 1.0
 * @date 2026-01-14
 */

/* ==========================================
   PRODUCT CARD STYLES
   ========================================== */

/* Product title - show full title without truncation */
.product-title {
    margin-bottom: 0.5rem;
    line-height: 1.5em;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

/* Enhanced tooltip styling */
.product-title:hover {
    color: var(--primary-color);
}

/* Product card size - auto height to accommodate full titles */
.product-card {
    height: auto !important;
    min-height: 400px;
}

.product-img {
    height: 160px; /* Reduced image height for compact layout */
}

.product-img img {
    max-height: 100%;
    object-fit: contain;
}

/* ==========================================
   QUANTITY INPUT & CONTROLS
   ========================================== */

/* Updated the quantity input field to remove up/down arrows and added -/+ buttons */
.quantity-input {
    -moz-appearance: textfield; /* Remove arrows in Firefox */
    -webkit-appearance: none; /* Remove arrows in Chrome/Safari */
    appearance: none; /* Remove arrows in modern browsers */
    width: 60px;
    text-align: center;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.25rem;
    margin: 0 0.5rem; /* Adjust margin for buttons */
}

.quantity-wrapper {
    display: flex;
    align-items: center;
    margin-right: 5px; /* Add some spacing between quantity wrapper and add-to-cart button */
}

.quantity-wrapper button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    border-radius: 4px;
}

.quantity-wrapper button:disabled {
    background-color: var(--disabled-color);
    cursor: not-allowed;
}

/* Make product actions row align items properly */
.product-actions {
    display: flex;
    align-items: center;
    padding: 2px 3px; /* Add padding to the product actions section */
}

/* Ensure up/down arrows are removed for all browsers */
input[type=number]::-webkit-inner-spin-button, 
input[type=number]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type=number] {
    -moz-appearance: textfield; /* Firefox */
    appearance: textfield; /* Modern browsers */
}

/* ==========================================
   TOAST NOTIFICATIONS
   ========================================== */

/* Enhanced Toast Notifications */
.toast {
    min-width: 300px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    font-weight: 500;
}

.toast.text-bg-success {
    background-color: #28a745 !important;
    color: white !important;
}

.toast.text-bg-danger {
    background-color: #dc3545 !important;
    color: white !important;
}

.toast.text-bg-warning {
    background-color: #ffc107 !important;
    color: #000 !important;
}

.toast.text-bg-info {
    background-color: #17a2b8 !important;
    color: white !important;
}

.toast-body {
    font-size: 1rem;
    padding: 0.75rem;
}

/* ==========================================
   GRID/LIST VIEW TOGGLE
   ========================================== */

/* Grid/List View Styles */
.view-toggle .btn {
    padding: 0.25rem 0.75rem;
}

.view-toggle .btn.active {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Grid View (default) - Keep product cards as they are */
#productsContainer.grid-view .product-description {
    display: none;
}

/* ==========================================
   LIST VIEW LAYOUT
   ========================================== */

/* List View - Horizontal Layout */
#productsContainer.list-view > div {
    flex: 0 0 100% !important;
    max-width: 100% !important;
    margin-bottom: 1.5rem !important;
}

#productsContainer.list-view .product-card {
    display: flex !important;
    flex-direction: row !important;
    min-height: 180px !important;
    height: auto !important;
    width: 100%;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    padding: 0 !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: box-shadow 0.3s ease;
}

#productsContainer.list-view .product-card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

#productsContainer.list-view .product-card > a {
    display: flex !important;
    flex-direction: row !important;
    flex: 1;
    text-decoration: none;
}

#productsContainer.list-view .product-img {
    width: 250px !important;
    min-width: 250px !important;
    height: 200px !important;
    flex-shrink: 0;
    margin-right: 0 !important;
    padding: 15px;
    background: #f8f9fa;
    position: relative;
}

#productsContainer.list-view .product-img img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

#productsContainer.list-view .product-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1;
}

#productsContainer.list-view .product-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1.25rem 1.5rem;
    position: relative;
}

#productsContainer.list-view .product-stock {
    margin-bottom: 0.75rem !important;
}

#productsContainer.list-view .product-title {
    font-size: 1.25rem !important;
    margin-bottom: 0.5rem !important;
    font-weight: 600;
    color: #333;
}

#productsContainer.list-view .product-description {
    display: block !important;
    margin-bottom: 1rem;
    color: #666;
    font-size: 0.95rem;
    line-height: 1.6;
}

#productsContainer.list-view .product-pricing {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid #eee;
}

#productsContainer.list-view .price-row {
    flex-direction: row !important;
    align-items: center !important;
    gap: 0.5rem !important;
}

#productsContainer.list-view .price-label {
    font-size: 0.9rem;
    color: #666;
}

#productsContainer.list-view .price-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
}

#productsContainer.list-view .product-actions {
    position: absolute;
    bottom: 1.25rem;
    right: 1.5rem;
    display: flex !important;
    gap: 0.5rem;
    align-items: center;
}

/* ==========================================
   SEARCH & FILTER CONTROLS
   ========================================== */

/* Search Filter Styling */
.search-filter-wrapper {
    position: relative;
}

#productSearchFilter {
    padding-right: 2rem;
}

.search-filter-wrapper .search-clear {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    font-size: 1rem;
    padding: 0;
    display: none;
}

.search-filter-wrapper .search-clear:hover {
    color: #333;
}

/* Filter Panel Styling */
#filterPanel .card {
    border: 1px solid #dee2e6;
    background-color: #f8f9fa;
}

/* ==========================================
   LOADING & NO RESULTS STATES
   ========================================== */

/* Loading State */
.loading-overlay {
    position: relative;
}

.loading-overlay::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

/* No Results Message */
.no-results {
    text-align: center;
    padding: 3rem 1rem;
    color: #666;
}

.no-results i {
    font-size: 3rem;
    color: #ccc;
    margin-bottom: 1rem;
}

/* ==========================================
   PAGE-SPECIFIC: INDEX.PHP
   ========================================== */

/* Use 90% width to create margins on both sides - override Bootstrap defaults */
section.py-5.bg-light > .container,
section.bg-light > .container {
    width: 90% !important;
    max-width: 90% !important;
    margin-left: auto !important;
    margin-right: auto !important;
}

/* Mobile optimization - use more space on small screens */
@media (max-width: 576px) {
    section.py-5.bg-light > .container,
    section.bg-light > .container {
        width: 95% !important;
        max-width: 95% !important;
    }
}

/* Tablet optimization */
@media (min-width: 577px) and (max-width: 991px) {
    section.py-5.bg-light > .container,
    section.bg-light > .container {
        width: 92% !important;
        max-width: 92% !important;
    }
}

/* Desktop - keep 90% */
@media (min-width: 992px) {
    section.py-5.bg-light > .container,
    section.bg-light > .container {
        width: 90% !important;
        max-width: 90% !important;
    }
}

/* Custom 5 column grid for extra large screens */
@media (min-width: 1200px) {
    .col-xl-custom-5 {
        flex: 0 0 20%;
        max-width: 20%;
    }
}

/* ==========================================
   PAGE-SPECIFIC: CATEGORY.PHP
   ========================================== */

/* Apply same 90% width layout as index.php for category pages main container */
body .container {
    width: 90% !important;
    max-width: 90% !important;
    margin-left: auto !important;
    margin-right: auto !important;
}

/* Don't apply to header container */
.header .container,
.top-bar .container {
    width: 100% !important;
    max-width: 1320px !important;
}

/* Mobile optimization - use more space on small screens */
@media (max-width: 576px) {
    body .container {
        width: 95% !important;
        max-width: 95% !important;
    }
}

/* Tablet optimization */
@media (min-width: 577px) and (max-width: 991px) {
    body .container {
        width: 92% !important;
        max-width: 92% !important;
    }
}

/* Desktop - keep 90% */
@media (min-width: 992px) {
    body .container {
        width: 90% !important;
        max-width: 90% !important;
    }
}

/* Breadcrumb styling */
.category-breadcrumb {
    background-color: #f8f9fa;
    padding: 5px 0;
    margin-bottom: 0;
}

.breadcrumb {
    margin-bottom: 0;
    padding: 5px 0;
}

/* Filter sidebar */
.filter-card {
    margin-bottom: 20px;
}

.filter-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 10px;
}

.filter-group {
    margin-bottom: 15px;
}

/* Category top info */
.category-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0;
}

.category-description {
    font-size: 1rem;
    margin-bottom: 0;
}

/* Sorting and pagination */
.sort-options {
    margin-bottom: 20px;
}
