/* Light Mode Base Styling */
:root {
    --bg: #f8fafc; /* Soft white/gray */
    --surface: #ffffff; /* Clean white */
    --surface-hover: #f1f5f9;
    --border: #e2e8f0;
    --primary: #1e3a8a; /* Deep blue to pop */
    --primary-hover: #1e40af;
    --accent: #d4af37; /* Casa Central gold accent */
    --text-main: #0f172a;
    --text-sub: #64748b;
    --radius: 8px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --font: 'Inter', system-ui, sans-serif;
}

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

body {
    background-color: var(--bg);
    color: var(--text-main);
    font-family: var(--font);
    line-height: 1.5;
    overflow-x: hidden;
}

/* Header */
header {
    background: var(--primary);
    color: white;
    padding: 1rem 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    max-width: 1800px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.logo { font-size: 1.5rem; color: #fff; display: flex; align-items: center; gap: 8px; }
.logo span { color: var(--accent); font-weight: 300; }

.search-wrap { flex: 1; max-width: 400px; }
#searchInput {
    width: 100%;
    padding: 0.8rem 1.2rem;
    border-radius: 40px;
    border: none;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
    font-family: var(--font);
}
#searchInput:focus { outline: none; box-shadow: 0 0 0 3px var(--accent); }

/* Cart Toggle Button */
.cart-toggle {
    background: var(--accent);
    color: #111;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 20px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s;
}
.cart-toggle:hover { transform: scale(1.05); }

/* Layout Grid */
.app-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 2rem;
    max-width: 1800px;
    margin: 2rem auto;
    padding: 0 2rem;
}

/* Sidebar */
.sidebar {
    background: var(--surface);
    padding: 1.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    height: fit-content;
    position: sticky;
    top: 90px;
}

.sidebar-block {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}
.sidebar-block h3 {
    font-size: 1rem;
    color: var(--text-main);
    margin-bottom: 0.5rem;
}

.update-note {
    font-size: 0.85rem;
    color: var(--text-sub);
    margin-bottom: 1rem;
}

/* Downloads */
.download-links {
    display: flex;
    gap: 0.5rem;
}
.dl-btn {
    text-decoration: none;
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    flex: 1;
    text-align: center;
    color: white;
    transition: opacity 0.2s;
}
.dl-btn.excel { background-color: #107c41; }
.dl-btn.pdf { background-color: #df2a2a; }
.dl-btn:hover { opacity: 0.8; }

/* Filter UI */
.category-dropdown {
    width: 100%;
    padding: 0.5rem;
    border-radius: 4px;
    border: 1px solid var(--border);
    margin-bottom: 1rem;
    font-family: inherit;
    font-size: 0.9rem;
}

.category-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.parent-cat-wrap {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.btn-parent-cat {
    background: var(--bg);
    border: 1px solid var(--border);
    padding: 0.6rem 0.8rem;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s;
    color: var(--text-main);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.btn-parent-cat.open { background: var(--surface-hover); border-color: var(--primary); }
.btn-parent-cat.active-parent { border-left: 4px solid var(--primary); }

.sub-cat-grid {
    display: none;
    grid-template-columns: 1fr;
    gap: 3px;
    padding-left: 10px;
    margin-bottom: 5px;
}
.sub-cat-grid.open {
    display: grid;
}

.btn-cat {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 0.4rem 0.6rem;
    border-radius: 4px;
    font-size: 0.72rem;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s;
    color: var(--text-sub);
    line-height: 1.3;
}
.btn-cat:hover { background: var(--surface-hover); color: var(--primary); }
.btn-cat.active { background: var(--primary); color: white; border-color: var(--primary); }

.total-count { font-size: 0.9rem; color: var(--text-sub); font-weight: 500; }

/* Inventory Grid Content */
.inventory-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 1.25rem;
}

/* Light Card */
.product-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    position: relative;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    cursor: pointer; /* To indicate they can be added to selection */
}
.product-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    border-color: var(--primary);
}

.card-img-wrap {
    width: 100%;
    aspect-ratio: 1 / 1;
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border-bottom: 1px solid var(--border);
    position: relative;
}
.card-img-wrap img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: transform 0.3s ease;
}

.product-card:hover .card-img-wrap img {
    transform: scale(1.08);
}

.card-img-wrap::after {
    content: "🔍 Click to Enlarge";
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(30, 58, 138, 0.8);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.65rem;
    font-weight: 600;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    white-space: nowrap;
}

.product-card:hover .card-img-wrap::after {
    opacity: 1;
}

.badge {
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 10px;
    color: white;
    background: #10b981;
}
.badge.low-stock { background: #f59e0b; color: #000; }
.badge.out-stock { background: #ef4444; }

.card-body {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}
.card-category { font-size: 0.7rem; text-transform: uppercase; color: var(--text-sub); margin-bottom: 4px; }
.card-title { font-size: 0.95rem; font-weight: 600; margin-bottom: auto; color: var(--text-main); }
.card-price { font-size: 1.2rem; font-weight: 700; color: var(--primary); margin-top: 10px; }
.card-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 5px; }
.card-ref { font-size: 0.75rem; color: var(--text-sub); font-family: monospace; }
.add-btn { background: #f1f5f9; border: 1px solid #cbd5e1; border-radius: 4px; padding: 4px 10px; font-size: 0.8rem; cursor: pointer; transition: 0.2s; }
.add-btn:hover { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Slide-out Cart */
.cart-panel {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    height: 100vh;
    max-width: 100vw;
    background: var(--surface);
    box-shadow: -5px 0 15px rgba(0,0,0,0.1);
    z-index: 1001;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
}
.cart-panel.open { right: 0; }

.cart-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    visibility: hidden;
    opacity: 0;
    transition: all 0.3s ease;
}
.cart-overlay.open { visibility: visible; opacity: 1; }

.cart-header {
    padding: 1.5rem;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.close-cart { background: none; border: none; font-size: 1.5rem; cursor: pointer; }

.cart-body { flex: 1; overflow-y: auto; padding: 1.5rem; }

.cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-bottom: 10px;
    background: var(--bg);
}
.cart-item-info { flex: 1; }
.cart-item-info h4 { font-size: 0.85rem; margin-bottom: 2px; }
.cart-item-info p { font-size: 0.75rem; color: var(--text-sub); }
.cart-qty {
    width: 50px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 4px;
    text-align: center;
}
.remove-item { background: none; border: none; color: red; font-size: 1.2rem; cursor: pointer; margin-left:10px; }

.cart-footer { padding: 1.5rem; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 0.5rem; }
.action-btn { 
    width: 100%; padding: 0.8rem; border-radius: 4px; border: none; 
    font-weight: 600; cursor: pointer; color: white; transition: 0.2s; 
}
.action-btn.email { background: #3b82f6; }
.action-btn.pdf { background: #ef4444; }
.action-btn.excel { background: #107c41; }
.action-btn:hover { filter: brightness(1.1); }

/* Lightbox Modal */
.image-modal {
    display: none;
    position: fixed;
    z-index: 2000;
    padding-top: 50px;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(8px);
    transition: all 0.3s ease;
}

.modal-content {
    margin: auto;
    display: block;
    max-width: 90%;
    max-height: 80vh;
    border-radius: 12px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    background: white;
    padding: 20px;
    object-fit: contain;
    animation: zoom 0.3s;
}

@keyframes zoom {
    from {transform: scale(0.8); opacity: 0;}
    to {transform: scale(1); opacity: 1;}
}

.close-modal {
    position: absolute;
    top: 25px;
    right: 35px;
    color: #f1f5f9;
    font-size: 40px;
    font-weight: bold;
    transition: 0.3s;
    cursor: pointer;
    z-index: 2001;
}

.close-modal:hover {
    color: var(--accent);
    transform: scale(1.1);
}

.modal-caption {
    margin: auto;
    display: block;
    width: 80%;
    max-width: 700px;
    text-align: center;
    color: white;
    padding: 20px 0;
    font-size: 1.2rem;
    font-weight: 600;
}

@media (max-width: 768px) {
    .app-layout { grid-template-columns: 1fr; }
    .sidebar { position: static; }
    .cart-panel { width: 100%; right: -100%; }
    .inventory-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}

@media (max-width: 480px) {
    .nav-container { padding: 0 1rem; flex-wrap: wrap; }
    .search-wrap { order: 3; max-width: 100%; }
    .cart-item { padding: 8px; }
    .modal-content { width: 95%; }
}
