:root {
    --primary: #0056b3;
    --bg-color: #f4f7f6;
    --card-bg: #ffffff;
    --text-dark: #333;
    --text-muted: #666;
    --border: #e0e0e0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    margin: 0;
    padding: 0;
    padding-bottom: 100px; /* NEW: Prevents the floating tray from hiding products */
    color: var(--text-dark);
}

/* Header */
.app-header {
    background: var(--primary);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.search-bar input {
    padding: 8px;
    border: none;
    border-radius: 4px 0 0 4px;
    outline: none;
}
.search-bar button {
    padding: 8px 12px;
    border: none;
    background: #e9ecef;
    cursor: pointer;
    border-radius: 0 4px 4px 0;
}

/* Layout */
.app-container {
    max-width: 1200px;
    margin: 20px auto;
    padding: 0 15px;
}

/* Product Grid */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
}
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 10px;
    margin-bottom: 15px;
}
.product-card {
    background: var(--card-bg);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    position: relative;
    transition: transform 0.2s;
}
.product-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}
.card-img-container {
    width: 100%;
    height: 200px;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid var(--border);
}
.card-img-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}
.card-details {
    padding: 15px;
}
.sku-badge {
    font-size: 11px;
    background: #eee;
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--text-muted);
}
.card-title {
    font-size: 14px;
    font-weight: bold;
    margin: 10px 0;
    line-height: 1.4;
}

/* Floating Tray */
.selection-tray {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: #212529;
    color: white;
    padding: 15px 0;
    box-shadow: 0 -4px 10px rgba(0,0,0,0.2);
    z-index: 1000;
    transition: transform 0.3s ease-in-out;
}
.selection-tray.hidden {
    transform: translateY(100%);
}
.tray-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.tray-actions button {
    margin-left: 10px;
    padding: 8px 15px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
}
.btn-primary { background: var(--primary); color: white; }
.btn-secondary { background: #ffc107; color: #333; }
.btn-danger { background: #dc3545; color: white; }

/* --- Modal Styles --- */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
}
.modal.hidden {
    display: none;
}
.modal-content {
    background: white;
    padding: 25px;
    border-radius: 8px;
    width: 320px;
    text-align: center;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}
.modal-content h3 {
    margin-top: 0;
}
.modal-content input {
    width: 90%;
    padding: 10px;
    margin: 15px 0;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 14px;
}
.modal-actions {
    display: flex;
    justify-content: space-between;
    gap: 10px;
}
.modal-actions button {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
}

/* --- Product Detail Modal Styles --- */
.modal-large {
    width: 90%;
    max-width: 1000px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 25px;
    background: #f8f9fa;
    border-bottom: 1px solid var(--border);
}
.modal-header h2 {
    margin: 0;
    font-size: 1.2rem;
    color: var(--primary);
}
.btn-icon {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
}
.btn-icon:hover {
    color: #dc3545;
}
.modal-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
    padding: 25px;
    overflow-y: auto;
}
@media (max-width: 768px) {
    .modal-body {
        grid-template-columns: 1fr;
    }
}
.detail-gallery {
    display: flex;
    flex-direction: column;
    gap: 15px;
}
#detailMainImage {
    width: 100%;
    max-height: 400px;
    object-fit: contain;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 10px;
}
.thumbnail-row {
    display: flex;
    gap: 10px;
    overflow-x: auto;
}
.thumbnail-row img {
    width: 60px;
    height: 60px;
    object-fit: contain;
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
}
.thumbnail-row img:hover {
    border-color: var(--primary);
}
.rich-text-content h3 {
    margin-top: 0;
    color: var(--primary);
    border-bottom: 1px solid var(--border);
    padding-bottom: 5px;
}
.rich-text-content table {
    width: 100% !important;
    font-size: 0.9rem;
}
.detail-tags {
    margin-bottom: 15px;
}

/* =========================================
   MOBILE RESPONSIVENESS OVERRIDES
========================================= */
@media (max-width: 768px) {
    .app-header { flex-direction: column; gap: 10px; text-align: center; }
    .search-bar { width: 100%; display: flex; }
    .search-bar input { flex: 1; }
    
    .product-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
    .card-img-container { height: 160px; }
    .card-details { padding: 12px; }
    .card-title { font-size: 13px; }
    
    .product-card-actions { flex-direction: column; gap: 6px; }
    .action-btn { width: 100%; background: #f8f9fa; border: 1px solid #eee; padding: 8px; }
    
    .tray-content { flex-direction: column; gap: 10px; }
    .tray-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 5px; width: 100%; }
    .tray-actions button { margin: 0; flex: 1 1 40%; font-size: 12px; padding: 10px; }
    
    .modal-large { width: 95%; max-height: 95vh; }
    .modal-content { width: 90%; padding: 15px; }
    .modal-header, .modal-body { padding: 15px; }
    
    .lightbox-prev, .lightbox-next { font-size: 30px; padding: 10px; }
}