/* ===== Viva Mitsumori Frontend CSS ===== */
:root {
	--vm-primary: #1a73e8;
	--vm-primary-dark: #1557b0;
	--vm-accent: #e8711a;
	--vm-bg: #f8f9fa;
	--vm-white: #fff;
	--vm-border: #e0e0e0;
	--vm-text: #333;
	--vm-text-light: #666;
	--vm-radius: 8px;
	--vm-shadow: 0 2px 8px rgba(0,0,0,.1);
	--vm-drawer-width: 380px;
}

.vm-wrap { font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Kaku Gothic ProN', Meiryo, sans-serif; color: var(--vm-text); }

/* ---- Toolbar ---- */
.vm-toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.vm-category-filter { display: flex; flex-wrap: wrap; gap: 6px; }
.vm-cat-btn { padding: 6px 14px; border: 1px solid var(--vm-border); border-radius: 20px; background: var(--vm-white); cursor: pointer; font-size: 14px; transition: all .2s; }
.vm-cat-btn:hover, .vm-cat-btn.active { background: var(--vm-primary); color: #fff; border-color: var(--vm-primary); }
.vm-cat-child { font-size: 13px; padding: 4px 12px; }
.vm-toolbar-right { display: flex; gap: 10px; align-items: center; }
.vm-search-input { padding: 7px 12px; border: 1px solid var(--vm-border); border-radius: 6px; font-size: 14px; width: 200px; }
.vm-view-toggle { display: flex; gap: 4px; }
.vm-view-btn { padding: 6px 10px; border: 1px solid var(--vm-border); border-radius: 6px; background: var(--vm-white); cursor: pointer; }
.vm-view-btn.active { background: var(--vm-primary); color: #fff; border-color: var(--vm-primary); }

/* ---- Product Grid / List ---- */
.vm-products-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px,1fr)); gap: 20px; }
.vm-view-list .vm-products-grid { grid-template-columns: 1fr; }

.vm-product-card { background: var(--vm-white); border-radius: var(--vm-radius); box-shadow: var(--vm-shadow); overflow: hidden; transition: transform .2s, box-shadow .2s; cursor: pointer; }
.vm-product-card:hover { transform: translateY(-3px); box-shadow: 0 6px 20px rgba(0,0,0,.15); }
.vm-product-thumb { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; background: var(--vm-bg); }
.vm-product-thumb-placeholder { width: 100%; aspect-ratio: 4/3; display: flex; align-items: center; justify-content: center; background: var(--vm-bg); color: var(--vm-text-light); font-size: 40px; }
.vm-product-info { padding: 14px; }
.vm-product-name { font-size: 15px; font-weight: 600; margin: 0 0 6px; }
.vm-product-category { font-size: 12px; color: var(--vm-text-light); margin: 0 0 8px; }
.vm-product-price { font-size: 14px; color: var(--vm-accent); font-weight: 600; }
.vm-product-stock { font-size: 12px; color: var(--vm-text-light); margin-top: 4px; }
.vm-product-card-btn { margin-top: 10px; width: 100%; padding: 8px; background: var(--vm-primary); color: #fff; border: none; border-radius: 6px; cursor: pointer; font-size: 14px; }
.vm-product-card-btn:hover { background: var(--vm-primary-dark); }

/* List view card */
.vm-view-list .vm-product-card { display: flex; }
.vm-view-list .vm-product-thumb, .vm-view-list .vm-product-thumb-placeholder { width: 140px; min-width: 140px; aspect-ratio: auto; height: 105px; }
.vm-view-list .vm-product-info { flex: 1; display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.vm-view-list .vm-product-name { min-width: 200px; }

/* ---- Modal ---- */
.vm-modal { position: fixed; inset: 0; z-index: 9999; display: flex; align-items: center; justify-content: center; }
.vm-modal-overlay { position: absolute; inset: 0; background: rgba(0,0,0,.5); }
.vm-modal-content { position: relative; background: var(--vm-white); border-radius: var(--vm-radius); max-width: 860px; width: 95%; max-height: 90vh; overflow-y: auto; padding: 28px; box-shadow: 0 10px 40px rgba(0,0,0,.3); }
.vm-modal-close { position: absolute; top: 12px; right: 16px; background: none; border: none; font-size: 22px; cursor: pointer; color: var(--vm-text-light); }
.vm-modal-close:hover { color: var(--vm-text); }

/* Product modal layout */
.vm-modal-product { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
.vm-gallery-main img { width: 100%; border-radius: var(--vm-radius); }
.vm-gallery-thumbs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.vm-gallery-thumbs img { width: 70px; height: 52px; object-fit: cover; border-radius: 4px; cursor: pointer; border: 2px solid transparent; }
.vm-gallery-thumbs img.active { border-color: var(--vm-primary); }
.vm-modal-product-title { font-size: 22px; font-weight: 700; margin: 0 0 10px; }
.vm-modal-product-desc { font-size: 14px; line-height: 1.7; color: var(--vm-text-light); margin-bottom: 16px; }
.vm-period-select-label { font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.vm-period-options { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.vm-period-option { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border: 1px solid var(--vm-border); border-radius: 6px; cursor: pointer; transition: border-color .2s; }
.vm-period-option:hover, .vm-period-option.selected { border-color: var(--vm-primary); background: rgba(26,115,232,.05); }
.vm-period-option input { margin: 0; }
.vm-period-label { font-size: 14px; flex: 1; }
.vm-period-price { font-size: 16px; font-weight: 700; color: var(--vm-accent); }
.vm-qty-row { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.vm-qty-btn { width: 36px; height: 36px; border: 1px solid var(--vm-border); background: var(--vm-white); border-radius: 6px; font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.vm-qty-input { width: 60px; text-align: center; padding: 6px; border: 1px solid var(--vm-border); border-radius: 6px; font-size: 16px; }
.vm-add-to-cart-btn { width: 100%; padding: 14px; background: var(--vm-primary); color: #fff; border: none; border-radius: var(--vm-radius); font-size: 16px; font-weight: 600; cursor: pointer; transition: background .2s; }
.vm-add-to-cart-btn:hover { background: var(--vm-primary-dark); }
.vm-add-to-cart-btn:disabled { background: #aaa; cursor: not-allowed; }

/* ---- Cart Drawer ---- */
.vm-cart-toggle { position: fixed; bottom: 28px; right: 28px; width: 56px; height: 56px; border-radius: 50%; background: var(--vm-primary); color: #fff; border: none; cursor: pointer; box-shadow: 0 4px 16px rgba(0,0,0,.3); font-size: 22px; display: flex; align-items: center; justify-content: center; z-index: 9990; transition: transform .2s; }
.vm-cart-toggle:hover { transform: scale(1.1); }
.vm-cart-badge { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%; background: var(--vm-accent); color: #fff; font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.vm-cart-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 9991; display: none; }
.vm-cart-overlay.visible { display: block; }
.vm-cart-drawer { position: fixed; top: 0; right: 0; width: var(--vm-drawer-width); max-width: 100vw; height: 100vh; background: var(--vm-white); box-shadow: -4px 0 20px rgba(0,0,0,.2); z-index: 9992; transform: translateX(100%); transition: transform .3s ease; display: flex; flex-direction: column; }
.vm-cart-drawer.is-open { transform: translateX(0); }
.vm-cart-header { padding: 18px 20px; border-bottom: 1px solid var(--vm-border); display: flex; justify-content: space-between; align-items: center; }
.vm-cart-header h3 { margin: 0; font-size: 18px; }
.vm-cart-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--vm-text-light); }
.vm-cart-body { flex: 1; overflow-y: auto; padding: 16px; }
.vm-cart-item { display: flex; align-items: flex-start; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--vm-border); }
.vm-cart-item-info { flex: 1; }
.vm-cart-item-name { font-size: 14px; font-weight: 600; margin-bottom: 3px; }
.vm-cart-item-period { font-size: 12px; color: var(--vm-text-light); }
.vm-cart-item-price { font-size: 14px; color: var(--vm-accent); }
.vm-cart-item-controls { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.vm-cart-item-controls input { width: 44px; text-align: center; padding: 3px; border: 1px solid var(--vm-border); border-radius: 4px; }
.vm-cart-item-remove { background: none; border: none; color: #c00; cursor: pointer; font-size: 18px; padding: 0 4px; }
.vm-cart-footer { padding: 16px; border-top: 1px solid var(--vm-border); }
.vm-cart-row { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 6px; }
.vm-cart-total-row { font-size: 16px; font-weight: 700; border-top: 1px solid var(--vm-border); padding-top: 8px; margin-top: 8px; }
.vm-cart-checkout-btn { display: block; width: 100%; padding: 14px; text-align: center; margin-top: 14px; }

/* ---- Buttons ---- */
.vm-btn { display: inline-block; padding: 10px 20px; border-radius: 6px; font-size: 15px; font-weight: 600; cursor: pointer; border: none; text-decoration: none; transition: background .2s; }
.vm-btn-primary { background: var(--vm-primary); color: #fff; }
.vm-btn-primary:hover { background: var(--vm-primary-dark); color: #fff; }
.vm-btn-secondary { background: var(--vm-bg); color: var(--vm-text); border: 1px solid var(--vm-border); }
.vm-btn-large { padding: 14px 28px; font-size: 16px; }

/* ---- Estimate Form ---- */
.vm-estimate-wrap { max-width: 900px; margin: 0 auto; }
.vm-estimate-wrap h2 { font-size: 20px; border-bottom: 2px solid var(--vm-primary); padding-bottom: 8px; margin-bottom: 20px; }
.vm-form-group { margin-bottom: 18px; }
.vm-form-group label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.vm-input, .vm-textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--vm-border); border-radius: 6px; font-size: 15px; box-sizing: border-box; }
.vm-input:focus, .vm-textarea:focus { outline: none; border-color: var(--vm-primary); }
.required { color: #c00; }
.vm-error-msg { color: #c00; padding: 10px; background: #fff0f0; border-radius: 6px; margin-bottom: 14px; }
.vm-estimate-items table { width: 100%; border-collapse: collapse; font-size: 14px; }
.vm-estimate-items th, .vm-estimate-items td { padding: 10px; border: 1px solid var(--vm-border); }
.vm-estimate-items th { background: var(--vm-bg); }
.vm-totals-table { width: 100%; max-width: 360px; margin-left: auto; border-collapse: collapse; }
.vm-totals-table td { padding: 8px 12px; }
.vm-totals-table td:last-child { text-align: right; font-weight: 600; }
.vm-total-row td { border-top: 2px solid var(--vm-border); font-size: 18px; font-weight: 700; }
.vm-success-box { text-align: center; padding: 40px 20px; }
.vm-success-box h2 { color: var(--vm-primary); }

/* ---- Pagination ---- */
.vm-pagination { display: flex; gap: 6px; justify-content: center; margin-top: 28px; flex-wrap: wrap; }
.vm-pagination button { padding: 6px 12px; border: 1px solid var(--vm-border); border-radius: 6px; background: var(--vm-white); cursor: pointer; }
.vm-pagination button.active { background: var(--vm-primary); color: #fff; border-color: var(--vm-primary); }
.vm-loading { text-align: center; padding: 40px; color: var(--vm-text-light); }
.vm-empty-msg { text-align: center; padding: 40px; color: var(--vm-text-light); }

/* ---- Responsive ---- */
@media (max-width: 640px) {
	.vm-products-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
	.vm-modal-product { grid-template-columns: 1fr; }
	:root { --vm-drawer-width: 100vw; }
	.vm-view-list .vm-product-card { flex-direction: column; }
	.vm-view-list .vm-product-thumb, .vm-view-list .vm-product-thumb-placeholder { width: 100%; height: 160px; }
	.vm-toolbar { flex-direction: column; align-items: flex-start; }
}
