/* ── Reset & Base ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font-family: 'Segoe UI', system-ui, sans-serif; background: #f4f5f7; color: #222; }

/* ── Login Overlay ────────────────────────────────────── */
.login-overlay {
  position: fixed; inset: 0;
  background: linear-gradient(135deg, #c0392b 0%, #922b21 100%);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
}
.login-card {
  background: #fff;
  border-radius: 12px;
  padding: 2.5rem 2rem;
  width: 100%; max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
  text-align: center;
}
.login-logo {
  font-size: 2.5rem;
  color: #c0392b;
  margin-bottom: .5rem;
}
.login-card h4 {
  font-weight: 700;
  letter-spacing: -.3px;
  margin-bottom: .25rem;
}

/* ── Navbar ───────────────────────────────────────────── */
.navbar { box-shadow: 0 2px 8px rgba(0,0,0,.2); }

/* ── Main Layout ──────────────────────────────────────── */
.main-layout {
  display: flex;
  height: calc(100vh - 52px);
  overflow: hidden;
}

/* ── Filter Panel ─────────────────────────────────────── */
.filter-panel {
  width: 260px;
  min-width: 260px;
  background: #fff;
  border-right: 1px solid #e5e7eb;
  padding: 1rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: .25rem;
}
.filter-section {
  padding-bottom: 1rem;
  border-bottom: 1px solid #f0f0f0;
  margin-bottom: .5rem;
}
.filter-section:last-child { border-bottom: none; }
.filter-title {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #888;
  margin-bottom: .75rem;
}

/* ── Product Area ─────────────────────────────────────── */
.product-area {
  flex: 1;
  padding: 1.25rem 1.5rem;
  overflow-y: auto;
}

/* ── Product Grid ─────────────────────────────────────── */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

/* ── Product Card ─────────────────────────────────────── */
.pcard {
  background: #fff;
  border: 2px solid transparent;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .1s;
  position: relative;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
}
.pcard:hover {
  border-color: #f5b7b1;
  box-shadow: 0 4px 16px rgba(192,57,43,.12);
  transform: translateY(-2px);
}
.pcard.selected {
  border-color: #c0392b;
  box-shadow: 0 4px 16px rgba(192,57,43,.2);
}

.pcard-check {
  position: absolute; top: 6px; right: 6px; z-index: 2;
}
.pcard-check .form-check-input {
  width: 18px; height: 18px;
  cursor: pointer;
  border: 2px solid #ccc;
  background-color: #fff;
}
.pcard-check .form-check-input:checked {
  background-color: #c0392b;
  border-color: #c0392b;
}

.pcard-img {
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  background: #f8f8f8;
  display: flex; align-items: center; justify-content: center;
}
.product-img {
  width: 100%; height: 100%;
  object-fit: contain;
  display: block;
}
.product-no-img {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem;
  color: #d0d0d0;
}

.pcard-body {
  padding: 8px 10px 10px;
}
.pcard-name {
  font-size: .8rem;
  font-weight: 600;
  line-height: 1.3;
  max-height: 2.6em;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  color: #222;
}
.pcard-code {
  font-size: .72rem;
  margin-top: 2px;
}
.pcard-cores {
  font-size: .68rem;
  margin-top: 4px;
  color: #666;
  line-height: 1.3;
}

/* ── Sync Status ──────────────────────────────────────── */
.sync-status {
  font-size: .72rem;
  line-height: 1.6;
}

/* ── Badges ───────────────────────────────────────────── */
.bg-success-subtle { background-color: #d4edda !important; }
.bg-danger-subtle  { background-color: #f8d7da !important; }

/* ── Templates Screen ─────────────────────────────────── */
.tpl-screen {
  position: fixed;
  inset: 0;
  background: #f4f5f7;
  z-index: 1000;
  overflow-y: auto;
}
.tpl-screen-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.tpl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.tpl-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,.07);
}
.tpl-thumb-wrap {
  width: 100%;
  height: 110px;
  background: #f8f8f8;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-bottom: 1px solid #f0f0f0;
}
.tpl-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.tpl-card-body {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  gap: 6px;
}
.tpl-card-name {
  font-size: .8rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 768px) {
  .main-layout { flex-direction: column; height: auto; }
  .filter-panel { width: 100%; min-width: unset; border-right: none; border-bottom: 1px solid #e5e7eb; }
  .product-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
}
