/* ===== Mifast B2B Industrial Parts - MISUMI Style ===== */
:root {
  --red: #e53935;
  --red-dark: #c62828;
  --red-light: #ffebee;
  --blue: #1565c0;
  --blue-light: #e3f2fd;
  --green: #2e7d32;
  --orange: #ef6c00;
  --gray-50: #fafafa;
  --gray-100: #f5f5f5;
  --gray-200: #eeeeee;
  --gray-300: #e0e0e0;
  --gray-400: #bdbdbd;
  --gray-500: #9e9e9e;
  --gray-600: #757575;
  --gray-700: #616161;
  --gray-800: #424242;
  --gray-900: #212121;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.12);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.15);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.2);
  --radius: 8px;
  --radius-sm: 4px;
  --transition: all 0.2s ease;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color: var(--gray-800);
  background: var(--gray-50);
  line-height: 1.6;
  padding-top: 40px;
}

a { text-decoration: none; color: var(--blue); }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; }

/* ===== Top Bar ===== */
.top-bar {
  background: var(--red);
  color: #fff;
  text-align: center;
  padding: 8px 0;
  font-size: 14px;
  font-weight: 500;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 1001;
  letter-spacing: 0.3px;
}

/* ===== Header ===== */
header {
  background: #fff;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 40px;
  z-index: 1000;
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 20px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 24px;
  font-weight: 800;
  color: var(--red);
  white-space: nowrap;
}
.logo:hover { text-decoration: none; }
.logo span { color: var(--gray-800); }
.logo-icon { font-size: 28px; }
.search-bar {
  flex: 1;
  display: flex;
  max-width: 500px;
  position: relative;
}
.search-bar input {
  width: 100%;
  padding: 10px 16px;
  border: 2px solid var(--gray-300);
  border-radius: var(--radius) 0 0 var(--radius);
  font-size: 14px;
  outline: none;
  transition: var(--transition);
}
.search-bar input:focus { border-color: var(--blue); }
.search-bar button {
  padding: 10px 20px;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 0 var(--radius) var(--radius) 0;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: var(--transition);
}
.search-bar button:hover { background: #0d47a1; }

.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}
.header-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  background: none;
  border: none;
  font-size: 11px;
  color: var(--gray-600);
  transition: var(--transition);
  padding: 4px 8px;
  position: relative;
}
.header-btn:hover { color: var(--red); }
.header-btn .icon { font-size: 22px; }
.header-btn .badge {
  position: absolute;
  top: 0;
  right: 2px;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

/* ===== Container ===== */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px;
}

/* ===== Breadcrumb ===== */
.breadcrumb {
  padding: 12px 0;
  font-size: 13px;
  color: var(--gray-500);
}
.breadcrumb a { color: var(--gray-500); }
.breadcrumb a:hover { color: var(--blue); }
.breadcrumb span { color: var(--gray-800); }

/* ===== Hero Section ===== */
.hero {
  background: linear-gradient(135deg, var(--red-dark) 0%, var(--red) 100%);
  color: #fff;
  padding: 60px 20px;
  text-align: center;
  margin-bottom: 32px;
}
.hero h1 { font-size: 36px; font-weight: 800; margin-bottom: 12px; }
.hero p { font-size: 18px; opacity: 0.9; max-width: 700px; margin: 0 auto 24px; }
.hero .btn {
  display: inline-block;
  padding: 14px 36px;
  background: #fff;
  color: var(--red);
  font-weight: 700;
  border-radius: var(--radius);
  font-size: 16px;
  transition: var(--transition);
}
.hero .btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); text-decoration: none; }

/* ===== Category Grid ===== */
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin: 24px 0;
}
.category-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
}
.category-card:hover {
  border-color: var(--red);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.category-card .icon { font-size: 36px; margin-bottom: 8px; }
.category-card .name { font-weight: 600; font-size: 14px; color: var(--gray-800); }
.category-card .count { font-size: 12px; color: var(--gray-500); margin-top: 4px; }
.category-card:hover .name { color: var(--red); }

/* ===== Product Grid ===== */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
  margin: 20px 0;
}
.product-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  overflow: hidden;
  transition: var(--transition);
  position: relative;
}
.product-card:hover {
  border-color: var(--red);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.product-card .image-wrap {
  width: 100%;
  height: 200px;
  background: var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.product-card .image-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.product-card .info { padding: 16px; }
.product-card .name {
  font-weight: 600;
  font-size: 15px;
  color: var(--gray-800);
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.product-card .specs {
  font-size: 12px;
  color: var(--gray-500);
  margin-bottom: 8px;
}
.product-card .meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.product-card .price {
  font-size: 20px;
  font-weight: 700;
  color: var(--red);
}
.product-card .price .unit {
  font-size: 12px;
  font-weight: 400;
  color: var(--gray-500);
}
.product-card .moq {
  font-size: 12px;
  color: var(--gray-500);
}
.product-card .moq strong { color: var(--gray-700); }
.product-card .stock {
  font-size: 12px;
  margin-bottom: 12px;
}
.product-card .stock.in-stock { color: var(--green); }
.product-card .stock.low-stock { color: var(--orange); }
.product-card .stock.out-of-stock { color: var(--red); }
.product-card .rating {
  color: #f9a825;
  font-size: 13px;
}
.product-card .add-btn {
  width: 100%;
  padding: 10px;
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}
.product-card .add-btn:hover { background: var(--red-dark); }
.product-card .add-btn:disabled { background: var(--gray-300); cursor: not-allowed; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-dark); text-decoration: none; }
.btn-secondary { background: var(--blue); color: #fff; }
.btn-secondary:hover { background: #0d47a1; text-decoration: none; }
.btn-outline { background: transparent; color: var(--red); border: 2px solid var(--red); }
.btn-outline:hover { background: var(--red); color: #fff; }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { background: #1b5e20; }
.btn-danger { background: var(--red); color: #fff; }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-lg { padding: 14px 36px; font-size: 16px; }
.btn-block { width: 100%; justify-content: center; }

/* ===== Section Titles ===== */
.section-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--gray-800);
  margin: 32px 0 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--gray-200);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.section-title .more {
  font-size: 14px;
  font-weight: 500;
  color: var(--blue);
}

/* ===== Filters / Sort Bar ===== */
.filters-bar {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin: 16px 0;
  padding: 12px 16px;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
}
.filters-bar select, .filters-bar input {
  padding: 8px 12px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-size: 14px;
  outline: none;
}
.filters-bar select:focus, .filters-bar input:focus { border-color: var(--blue); }
.filters-bar label { font-size: 14px; color: var(--gray-600); }

/* ===== Pagination ===== */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin: 32px 0;
}
.pagination button, .pagination span {
  padding: 8px 16px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  background: #fff;
  font-size: 14px;
  cursor: pointer;
  transition: var(--transition);
}
.pagination button:hover:not(:disabled) { border-color: var(--red); color: var(--red); }
.pagination button:disabled { opacity: 0.5; cursor: not-allowed; }
.pagination .active { background: var(--red); color: #fff; border-color: var(--red); }

/* ===== Cart ===== */
.cart-items { margin: 20px 0; }
.cart-item {
  display: flex;
  gap: 16px;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  align-items: center;
}
.cart-item .thumb {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-sm);
  background: var(--gray-100);
  flex-shrink: 0;
  overflow: hidden;
}
.cart-item .thumb img { width: 100%; height: 100%; object-fit: cover; }
.cart-item .details { flex: 1; }
.cart-item .details .name { font-weight: 600; margin-bottom: 2px; }
.cart-item .details .specs { font-size: 12px; color: var(--gray-500); }
.cart-item .details .price { font-weight: 700; color: var(--red); margin-top: 4px; }
.cart-item .qty-ctl {
  display: flex;
  align-items: center;
  gap: 0;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.cart-item .qty-ctl button {
  width: 36px;
  height: 36px;
  border: none;
  background: var(--gray-100);
  cursor: pointer;
  font-size: 16px;
  font-weight: 700;
  transition: var(--transition);
}
.cart-item .qty-ctl button:hover { background: var(--gray-300); }
.cart-item .qty-ctl input {
  width: 50px;
  height: 36px;
  text-align: center;
  border: none;
  border-left: 1px solid var(--gray-300);
  border-right: 1px solid var(--gray-300);
  font-size: 14px;
  outline: none;
}
.cart-item .item-total { font-weight: 700; font-size: 18px; color: var(--gray-800); white-space: nowrap; }
.cart-item .remove-btn {
  padding: 8px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--gray-400);
  font-size: 20px;
  transition: var(--transition);
}
.cart-item .remove-btn:hover { color: var(--red); }

.cart-summary {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 24px;
}
.cart-summary .row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  font-size: 14px;
}
.cart-summary .row.total {
  font-size: 18px;
  font-weight: 700;
  color: var(--red);
  border-top: 2px solid var(--gray-200);
  padding-top: 16px;
  margin-top: 8px;
}

/* ===== Forms ===== */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 4px;
}
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-size: 14px;
  outline: none;
  transition: var(--transition);
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(21, 101, 192, 0.1);
}
.form-group textarea { resize: vertical; min-height: 80px; }
.form-group .error { color: var(--red); font-size: 12px; margin-top: 4px; }

/* ===== Modal ===== */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.5);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.active { display: flex; }
.modal {
  background: #fff;
  border-radius: var(--radius);
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  position: relative;
}
.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-header h2 { font-size: 20px; color: var(--gray-800); }
.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--gray-500);
  transition: var(--transition);
  padding: 4px;
}
.modal-close:hover { color: var(--red); }
.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--gray-200);
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

/* Login Tabs */
.login-tabs {
  display: flex;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--gray-200);
}
.login-tab {
  flex: 1;
  padding: 12px;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  background: none;
  color: var(--gray-500);
  transition: var(--transition);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
}
.login-tab.active { color: var(--red); border-bottom-color: var(--red); }
.login-tab:hover { color: var(--red); }

/* ===== Toast ===== */
#toast {
  position: fixed;
  top: 60px;
  right: 20px;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast-item {
  padding: 14px 20px;
  border-radius: var(--radius);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
  max-width: 400px;
}
.toast-item.success { background: var(--green); }
.toast-item.error { background: var(--red); }
.toast-item.info { background: var(--blue); }
.toast-item.warning { background: var(--orange); }
@keyframes toastIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
@keyframes toastOut {
  from { opacity: 1; }
  to { opacity: 0; transform: translateX(100%); }
}

/* ===== Checkout ===== */
.checkout-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 24px;
}
.checkout-section {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 16px;
}
.checkout-section h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--gray-800);
}
.shipping-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  cursor: pointer;
  transition: var(--transition);
}
.shipping-option:hover { border-color: var(--blue); }
.shipping-option.selected { border-color: var(--red); background: var(--red-light); }
.shipping-option .icon { font-size: 24px; }
.shipping-option .name { font-weight: 600; }
.shipping-option .desc { font-size: 12px; color: var(--gray-500); }
.shipping-option .cost { font-weight: 600; color: var(--red); margin-left: auto; white-space: nowrap; }

/* ===== Order Confirm ===== */
.confirm-icon { font-size: 64px; margin-bottom: 16px; }
.confirm-box {
  text-align: center;
  padding: 48px 24px;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
}
.confirm-box h1 { font-size: 28px; margin-bottom: 8px; }
.confirm-box .order-id {
  font-size: 20px;
  font-weight: 700;
  color: var(--red);
  margin: 16px 0;
}

/* ===== Table ===== */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
table th, table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--gray-200);
}
table th {
  background: var(--gray-100);
  font-weight: 600;
  color: var(--gray-600);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
table tr:hover { background: var(--gray-50); }
table .actions { display: flex; gap: 8px; }

/* ===== Status Badge ===== */
.status-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.status-badge.pending { background: #fff3e0; color: #e65100; }
.status-badge.confirmed { background: #e3f2fd; color: #1565c0; }
.status-badge.shipped { background: #e8f5e9; color: #2e7d32; }
.status-badge.delivered { background: #e8f5e9; color: #1b5e20; }
.status-badge.cancelled { background: #ffebee; color: #c62828; }

/* ===== Admin ===== */
.admin-layout { display: flex; min-height: calc(100vh - 40px); }
.admin-sidebar {
  width: 240px;
  background: var(--gray-900);
  color: #fff;
  flex-shrink: 0;
}
.admin-sidebar .logo {
  padding: 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  color: #fff;
}
.admin-sidebar .logo span { color: var(--gray-400); }
.admin-sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  color: var(--gray-400);
  transition: var(--transition);
  font-size: 14px;
}
.admin-sidebar nav a:hover, .admin-sidebar nav a.active {
  background: rgba(255,255,255,0.1);
  color: #fff;
  text-decoration: none;
}
.admin-sidebar nav a .icon { font-size: 18px; }

.admin-main {
  flex: 1;
  padding: 24px;
  background: var(--gray-50);
}
.admin-main h1 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 24px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 20px;
}
.stat-card .value {
  font-size: 28px;
  font-weight: 700;
  color: var(--red);
}
.stat-card .label {
  font-size: 13px;
  color: var(--gray-500);
  margin-top: 4px;
}

/* ===== Footer ===== */
footer {
  background: var(--gray-900);
  color: var(--gray-400);
  padding: 40px 20px 20px;
  margin-top: 48px;
}
footer .grid {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 32px;
}
footer h4 {
  color: #fff;
  font-size: 16px;
  margin-bottom: 12px;
}
footer ul { list-style: none; }
footer ul li { margin-bottom: 8px; }
footer ul li a { color: var(--gray-400); font-size: 14px; }
footer ul li a:hover { color: #fff; }
footer .bottom {
  max-width: 1200px;
  margin: 24px auto 0;
  padding-top: 16px;
  border-top: 1px solid var(--gray-700);
  text-align: center;
  font-size: 13px;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .header-inner { flex-wrap: wrap; }
  .search-bar { order: 3; max-width: 100%; }
  .checkout-layout { grid-template-columns: 1fr; }
  .product-grid { grid-template-columns: repeat(2, 1fr); }
  .category-grid { grid-template-columns: repeat(3, 1fr); }
  .admin-sidebar { width: 60px; overflow: hidden; }
  .admin-sidebar .logo span { display: none; }
  .admin-sidebar nav a span { display: none; }
  .admin-main { padding: 16px; }
  .cart-item { flex-wrap: wrap; }
}
@media (max-width: 480px) {
  .product-grid { grid-template-columns: 1fr; }
  .category-grid { grid-template-columns: repeat(2, 1fr); }
  .hero h1 { font-size: 24px; }
  .hero p { font-size: 14px; }
}
