/* ========= RESET & BASE ========= */
* { margin:0; padding:0; box-sizing:border-box; }
body {
  font-family: 'Segoe UI', Arial, sans-serif;
  color: #222;
  background: #f7f7f9;
  line-height: 1.5;
}
a { text-decoration: none; color: inherit; }
img { max-width: 100%; display: block; }
ul { list-style: none; }
.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }

:root {
  --primary: #d62828;
  --primary-dark: #a81f1f;
  --dark: #1c1c1e;
  --gray: #666;
  --light-gray: #eee;
  --radius: 8px;
}

/* ========= HEADER ========= */
.site-header {
  background: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 10px 20px;
  min-height: 64px;
}
.logo-link {
  flex-shrink: 0;         /* logo never shrinks or gets hidden */
  display: flex;
  align-items: center;
}
.site-logo {
  max-height: 48px;
  width: auto;
  object-fit: contain;
}
.logo-text {
  font-size: 22px;
  font-weight: 800;
  color: var(--primary);
  white-space: nowrap;
}
.main-nav {
  display: flex;
  gap: 24px;
  flex: 1;
}
.main-nav a {
  font-weight: 600;
  color: var(--dark);
  padding: 8px 0;
  border-bottom: 2px solid transparent;
  transition: 0.2s;
}
.main-nav a:hover, .main-nav a.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}
.header-search {
  display: flex;
  border: 1px solid var(--light-gray);
  border-radius: 20px;
  overflow: hidden;
}
.header-search input {
  border: none;
  padding: 8px 12px;
  outline: none;
  width: 160px;
  font-size: 14px;
}
.header-search button {
  border: none;
  background: var(--light-gray);
  padding: 0 12px;
  cursor: pointer;
}
.cart-link {
  font-size: 20px;
  position: relative;
  font-weight: 600;
}
.cart-count {
  position: absolute;
  top: -8px;
  right: -12px;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
}
.nav-toggle span {
  height: 3px;
  background: var(--dark);
  border-radius: 2px;
  transition: 0.2s;
}

/* ========= MOBILE NAV ========= */
@media (max-width: 860px) {
  .header-search { display: none; }
  .nav-toggle { display: flex; }
  .main-nav {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    flex-direction: column;
    gap: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    box-shadow: 0 4px 8px rgba(0,0,0,0.08);
  }
  .main-nav.open { max-height: 300px; }
  .main-nav a { padding: 14px 20px; border-bottom: 1px solid var(--light-gray); }
  .header-inner { flex-wrap: wrap; position: relative; }
}

/* ========= HERO ========= */
.hero {
  background: linear-gradient(135deg, var(--dark), #333);
  color: #fff;
  padding: 60px 20px;
  text-align: center;
}
.hero h1 { font-size: 36px; margin-bottom: 12px; }
.hero p { font-size: 17px; color: #ccc; max-width: 600px; margin: 0 auto 24px; }
.btn {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  padding: 12px 28px;
  border-radius: var(--radius);
  font-weight: 700;
  border: none;
  cursor: pointer;
  font-size: 15px;
  transition: 0.2s;
}
.btn:hover { background: var(--primary-dark); }
.btn-outline {
  background: transparent;
  border: 2px solid #fff;
  color: #fff;
}
.btn-block { width: 100%; text-align: center; }
.btn-sm { padding: 8px 16px; font-size: 13px; }
.btn-secondary { background: var(--dark); }
.btn-danger { background: #b91c1c; }

/* ========= SECTIONS ========= */
.section { padding: 50px 20px; }
.section-title {
  font-size: 26px;
  font-weight: 800;
  margin-bottom: 24px;
  text-align: center;
}

/* ========= PRODUCT GRID ========= */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
  max-width: 1200px;
  margin: 0 auto;
}
.product-card {
  background: #fff;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
  transition: transform 0.2s;
  display: flex;
  flex-direction: column;
}
.product-card:hover { transform: translateY(-4px); box-shadow: 0 6px 16px rgba(0,0,0,0.1); }
.product-card img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  background: #f0f0f0;
}
.product-card-body { padding: 14px; display: flex; flex-direction: column; flex: 1; }
.product-card-body h3 { font-size: 15px; margin-bottom: 6px; min-height: 40px; }
.product-price { color: var(--primary); font-weight: 800; font-size: 17px; margin: 8px 0; }
.product-card .btn { margin-top: auto; }

/* ========= SHOP LAYOUT ========= */
.shop-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 24px;
  max-width: 1200px;
  margin: 30px auto;
  padding: 0 20px;
  align-items: start;
}
.filter-box {
  background: #fff;
  padding: 16px;
  border-radius: var(--radius);
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}
.filter-box h4 { margin-bottom: 10px; }
.filter-box a { display: block; padding: 6px 0; color: var(--gray); }
.filter-box a.active, .filter-box a:hover { color: var(--primary); font-weight: 700; }
@media (max-width: 800px) {
  .shop-layout { grid-template-columns: 1fr; }
}

/* ========= PRODUCT DETAIL ========= */
.product-detail {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
  max-width: 1100px;
  margin: 30px auto;
  padding: 0 20px;
}
.product-detail img { border-radius: var(--radius); width: 100%; }
.product-detail h1 { font-size: 26px; margin-bottom: 10px; }
.product-detail .product-price { font-size: 26px; }
.product-detail .desc { color: var(--gray); margin: 16px 0; line-height: 1.7; }
.qty-selector { display: flex; align-items: center; gap: 10px; margin: 20px 0; }
.qty-selector input {
  width: 60px; text-align: center; padding: 8px; border: 1px solid var(--light-gray); border-radius: 6px;
}
@media (max-width: 700px) {
  .product-detail { grid-template-columns: 1fr; }
}

/* ========= CART & CHECKOUT ========= */
.cart-table { width: 100%; border-collapse: collapse; background: #fff; border-radius: var(--radius); overflow: hidden; }
.cart-table th, .cart-table td { padding: 12px; border-bottom: 1px solid var(--light-gray); text-align: left; }
.cart-table img { width: 60px; height: 60px; object-fit: cover; border-radius: 4px; }
.cart-item-name { display: flex; align-items: center; gap: 10px; }
.cart-qty-input { width: 55px; padding: 6px; border: 1px solid var(--light-gray); border-radius: 4px; }
.cart-summary { max-width: 380px; margin-left: auto; background: #fff; padding: 20px; border-radius: var(--radius); margin-top: 20px; }
.cart-summary .row { display: flex; justify-content: space-between; padding: 8px 0; }
.cart-summary .total { font-weight: 800; font-size: 18px; border-top: 1px solid var(--light-gray); padding-top: 12px; }

.form-box { max-width: 600px; margin: 30px auto; background: #fff; padding: 30px; border-radius: var(--radius); box-shadow: 0 2px 6px rgba(0,0,0,0.06); }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 600; font-size: 14px; }
.form-group input, .form-group textarea, .form-group select {
  width: 100%; padding: 10px 12px; border: 1px solid #ddd; border-radius: 6px; font-size: 14px;
}
.form-group textarea { resize: vertical; min-height: 90px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }

.alert { padding: 14px 18px; border-radius: 6px; margin-bottom: 20px; }
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-info { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

.empty-state { text-align: center; padding: 60px 20px; color: var(--gray); }

/* ========= FOOTER ========= */
.site-footer { background: var(--dark); color: #ccc; margin-top: 60px; }
.footer-inner {
  max-width: 1200px; margin: 0 auto; padding: 40px 20px;
  display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 30px;
}
.footer-logo { max-height: 40px; margin-bottom: 12px; filter: brightness(0) invert(1); }
.footer-col h4 { color: #fff; margin-bottom: 12px; }
.footer-col a, .footer-col p { display: block; color: #aaa; padding: 4px 0; font-size: 14px; }
.footer-bottom { text-align: center; padding: 16px; border-top: 1px solid #333; font-size: 13px; color: #888; }
@media (max-width: 700px) { .footer-inner { grid-template-columns: 1fr; } }

/* ========= ADMIN ========= */
.admin-body { background: #f1f2f6; min-height: 100vh; }
.admin-header {
  background: var(--dark); color: #fff; padding: 14px 24px;
  display: flex; justify-content: space-between; align-items: center;
}
.admin-header a { color: #fff; }
.admin-wrap { display: flex; min-height: calc(100vh - 58px); }
.admin-sidebar { width: 220px; background: #fff; padding: 20px 0; box-shadow: 1px 0 4px rgba(0,0,0,0.05); }
.admin-sidebar a {
  display: block; padding: 12px 24px; color: #444; font-weight: 600; font-size: 14px; border-left: 3px solid transparent;
}
.admin-sidebar a:hover, .admin-sidebar a.active { background: #f7f7f9; border-left-color: var(--primary); color: var(--primary); }
.admin-content { flex: 1; padding: 30px; max-width: 1100px; }
.admin-card { background: #fff; padding: 24px; border-radius: var(--radius); box-shadow: 0 2px 6px rgba(0,0,0,0.05); margin-bottom: 20px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px,1fr)); gap: 16px; margin-bottom: 24px; }
.stat-box { background: #fff; padding: 20px; border-radius: var(--radius); box-shadow: 0 2px 6px rgba(0,0,0,0.05); }
.stat-box .num { font-size: 28px; font-weight: 800; color: var(--primary); }
.stat-box .label { color: var(--gray); font-size: 13px; }

.admin-table { width: 100%; border-collapse: collapse; background: #fff; }
.admin-table th { background: #f7f7f9; text-align: left; padding: 10px 12px; font-size: 13px; text-transform: uppercase; color: var(--gray); }
.admin-table td { padding: 10px 12px; border-bottom: 1px solid var(--light-gray); font-size: 14px; vertical-align: middle; }
.admin-table img { width: 44px; height: 44px; object-fit: cover; border-radius: 4px; }
.badge { padding: 4px 10px; border-radius: 12px; font-size: 12px; font-weight: 700; }
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-processing { background: #dbeafe; color: #1e40af; }
.badge-shipped { background: #e0e7ff; color: #3730a3; }
.badge-delivered { background: #dcfce7; color: #166534; }
.badge-cancelled { background: #fee2e2; color: #991b1b; }

.action-icons a { margin-right: 10px; font-size: 15px; }

@media (max-width: 800px) {
  .admin-wrap { flex-direction: column; }
  .admin-sidebar { width: 100%; display: flex; overflow-x: auto; padding: 0; }
  .admin-sidebar a { white-space: nowrap; border-left: none; border-bottom: 3px solid transparent; }
  .admin-sidebar a.active { border-left: none; border-bottom-color: var(--primary); }
}

/* ========= PRINT SLIP ========= */
@media print {
  .no-print { display: none !important; }
  body { background: #fff; }
}
.slip {
  max-width: 700px; margin: 20px auto; background: #fff; padding: 30px; border: 2px solid #222;
  font-family: Arial, sans-serif;
}
.slip-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 3px solid #222; padding-bottom: 16px; margin-bottom: 16px; }
.slip-header img { max-height: 50px; }
.slip-header .order-no { text-align: right; }
.slip-header .order-no .big { font-size: 20px; font-weight: 800; }
.slip-section { margin-bottom: 16px; }
.slip-section h4 { text-transform: uppercase; font-size: 12px; color: #888; margin-bottom: 6px; letter-spacing: 1px; }
.slip-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.slip table { width: 100%; border-collapse: collapse; margin: 16px 0; }
.slip th, .slip td { border: 1px solid #ccc; padding: 8px; font-size: 13px; text-align: left; }
.slip .totals { text-align: right; font-size: 16px; font-weight: 800; margin-top: 10px; }
.slip-footer { text-align: center; margin-top: 24px; padding-top: 16px; border-top: 1px dashed #999; font-size: 12px; color: #888; }
.barcode-text { font-family: 'Courier New', monospace; font-size: 22px; letter-spacing: 4px; text-align: center; margin: 10px 0; }
