/* ============================================================
   Homepage Manager — Styles
   Extends the existing style.css design system
   ============================================================ */

/* ---- Hero Stats ---- */
.hp-hero-stats {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.hp-stat-card {
  background: rgba(255,255,255,0.55);
  border: 1px solid rgba(199,119,44,0.2);
  border-radius: 14px;
  padding: 14px 20px;
  min-width: 110px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  backdrop-filter: blur(4px);
}

.hp-stat-label {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.hp-stat-val {
  font-family: "Unbounded", sans-serif;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent-dark);
  line-height: 1;
}

/* ---- Tab Navigation ---- */
.hp-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 6px;
  width: fit-content;
  box-shadow: 0 2px 8px rgba(35,24,16,0.06);
}

.hp-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: 12px;
  background: transparent;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.hp-tab:hover {
  background: rgba(199,119,44,0.08);
  color: var(--accent);
}

.hp-tab.active {
  background: linear-gradient(120deg, #fff1d2 0%, #f6ddbf 100%);
  color: var(--accent-dark);
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(199,119,44,0.15);
}

/* ---- Tab Panels ---- */
.hp-tab-panel {
  display: none;
}

.hp-tab-panel.active {
  display: block;
}

/* ---- Panel Layout ---- */
.hp-panel-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 20px;
  align-items: start;
}

@media (max-width: 900px) {
  .hp-panel-layout {
    grid-template-columns: 1fr;
  }
  .hp-tabs {
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
  }
}

/* ---- Main Card ---- */
.hp-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.hp-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.hp-card-header h2 {
  font-family: "Unbounded", sans-serif;
  font-size: 1.1rem;
  margin: 0 0 4px;
}

.hp-card-header .btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  flex-shrink: 0;
  padding: 10px 18px;
  font-size: 0.875rem;
}

/* ---- Info/Side Card ---- */
.hp-info-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 22px;
  box-shadow: 0 4px 16px rgba(35,24,16,0.06);
}

.hp-info-icon {
  font-size: 2rem;
  margin-bottom: 10px;
}

.hp-info-card h3 {
  font-family: "Unbounded", sans-serif;
  font-size: 0.95rem;
  margin: 0 0 10px;
  color: var(--accent-dark);
}

.hp-info-card p {
  font-size: 0.875rem;
  color: var(--muted);
  line-height: 1.6;
  margin: 0 0 14px;
}

.hp-legend {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.hp-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--muted);
}

.hp-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.hp-badge.pinned {
  background: rgba(199,119,44,0.15);
  color: var(--accent-dark);
}

.hp-badge.auto {
  background: rgba(39,174,96,0.12);
  color: #1a7a45;
}

.hp-badge.dotd {
  background: rgba(231,76,60,0.12);
  color: #c0392b;
}

.hp-warning-box {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: rgba(199,119,44,0.08);
  border: 1px solid rgba(199,119,44,0.2);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.8rem;
  color: var(--accent-dark);
}

.hp-warning-box.danger {
  background: rgba(231,76,60,0.07);
  border-color: rgba(231,76,60,0.2);
  color: #c0392b;
}

.hp-info-rule {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 12px;
  background: #f9f5ee;
  border-radius: 10px;
  margin-bottom: 10px;
}

.hp-rule-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  font-weight: 600;
}

.hp-info-rule code {
  font-size: 0.85rem;
  color: var(--accent-dark);
  font-family: "Space Mono", monospace;
}

.hp-info-list {
  padding-left: 18px;
  margin: 0 0 16px;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.8;
}

.hp-info-list code {
  background: rgba(199,119,44,0.1);
  color: var(--accent-dark);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.78rem;
}

/* ---- Product List ---- */
.hp-product-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.hp-product-row {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  transition: box-shadow 0.2s;
}

.hp-product-row:hover {
  box-shadow: 0 4px 16px rgba(35,24,16,0.09);
}

.hp-product-row.is-pinned {
  border-left: 3px solid var(--accent);
}

.hp-product-thumb {
  width: 56px;
  height: 56px;
  border-radius: 10px;
  object-fit: cover;
  background: #f5efe6;
  flex-shrink: 0;
  border: 1px solid var(--border);
}

.hp-product-thumb-placeholder {
  width: 56px;
  height: 56px;
  border-radius: 10px;
  background: linear-gradient(135deg, #f5efe6, #ede3d7);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
  border: 1px solid var(--border);
}

.hp-product-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.hp-product-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hp-product-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.hp-product-price {
  font-size: 0.82rem;
  color: var(--accent-dark);
  font-weight: 600;
}

.hp-product-sales {
  font-size: 0.78rem;
  color: var(--muted);
}

.hp-product-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
}

/* DOTD card with custom media preview */
.hp-dotd-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #fff;
  overflow: hidden;
  transition: box-shadow 0.2s;
}

.hp-dotd-card:hover {
  box-shadow: 0 6px 20px rgba(35,24,16,0.1);
}

.hp-dotd-banner {
  width: 100%;
  height: 140px;
  object-fit: cover;
  display: block;
  background: linear-gradient(135deg, #f5efe6, #ede3d7);
}

.hp-dotd-banner-placeholder {
  width: 100%;
  height: 140px;
  background: linear-gradient(135deg, #f5efe6, #ede3d7);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
}

.hp-dotd-body {
  padding: 14px 16px;
}

.hp-dotd-name {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 6px;
  color: var(--ink);
}

.hp-dotd-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.hp-dotd-price {
  font-weight: 700;
  color: var(--accent-dark);
  font-size: 0.9rem;
}

.hp-dotd-old-price {
  font-size: 0.82rem;
  color: var(--muted);
  text-decoration: line-through;
}

.hp-dotd-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  padding: 3px 8px;
  border-radius: 999px;
  font-weight: 600;
}

.hp-dotd-chip.has-video {
  background: rgba(41,182,246,0.12);
  color: #0277bd;
}

.hp-dotd-chip.has-thumb {
  background: rgba(102,187,106,0.12);
  color: #2e7d32;
}

.hp-dotd-chip.no-media {
  background: rgba(120,120,120,0.1);
  color: var(--muted);
}

.hp-dotd-footer {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  background: #fffaf4;
}

.hp-dotd-footer .btn-secondary {
  flex: 1;
  text-align: center;
  padding: 9px 12px;
  font-size: 0.82rem;
}

.hp-dotd-footer .btn-danger {
  padding: 9px 14px;
  font-size: 0.82rem;
}

/* DOTD grid layout */
.hp-dotd-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

/* ---- Sections Table ---- */
.hp-sections-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.hp-section-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 14px;
  align-items: center;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  transition: box-shadow 0.2s;
}

.hp-section-row:hover {
  box-shadow: 0 4px 14px rgba(35,24,16,0.08);
}

.hp-section-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 10px;
}

.hp-section-name code {
  font-family: "Space Mono", monospace;
  font-size: 0.85rem;
  color: var(--accent-dark);
  background: rgba(199,119,44,0.08);
  padding: 2px 8px;
  border-radius: 6px;
}

.hp-section-date {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 2px;
}

.hp-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.hp-status-pill.active {
  background: rgba(39,174,96,0.12);
  color: #1a7a45;
}

.hp-status-pill.inactive {
  background: rgba(120,120,120,0.1);
  color: var(--muted);
}

.hp-status-pill::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.hp-section-actions {
  display: flex;
  gap: 6px;
}

/* ---- Skeleton Loader ---- */
.hp-skeleton-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.hp-skeleton {
  height: 72px;
  border-radius: 14px;
  background: linear-gradient(90deg, #f0e8dc 25%, #ede3d5 50%, #f0e8dc 75%);
  background-size: 200% 100%;
  animation: hp-shimmer 1.4s infinite;
}

.hp-skeleton:nth-child(2) { height: 72px; opacity: 0.75; }
.hp-skeleton:nth-child(3) { height: 72px; opacity: 0.5; }

@keyframes hp-shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* ---- Search / Modals ---- */
.hp-search-row {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.hp-search-row input {
  flex: 1;
}

.hp-search-results {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
}

.hp-search-result-item {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.hp-search-result-item:hover {
  background: #fffaf4;
  border-color: var(--accent);
}

.hp-search-result-item img {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  object-fit: cover;
  background: #f5efe6;
  border: 1px solid var(--border);
}

.hp-result-name {
  font-weight: 500;
  font-size: 0.875rem;
  color: var(--ink);
}

.hp-result-price {
  font-size: 0.8rem;
  color: var(--muted);
}

.hp-selected-product {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 2px solid var(--accent);
  border-radius: 12px;
  background: rgba(199,119,44,0.05);
  margin-top: 10px;
}

.hp-selected-product img {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  object-fit: cover;
}

.hp-selected-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--accent-dark);
}

.hp-thumb-preview {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 14px;
}

.hp-thumb-preview img {
  width: 100%;
  max-height: 180px;
  object-fit: cover;
  display: block;
}

.hp-edit-product-name {
  font-weight: 600;
  font-size: 1rem;
  color: var(--accent-dark);
  padding: 10px 14px;
  background: rgba(199,119,44,0.07);
  border-radius: 10px;
  margin-bottom: 16px;
}

/* ---- Empty State ---- */
.hp-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 40px 20px;
  color: var(--muted);
  text-align: center;
}

.hp-empty-icon {
  font-size: 2.5rem;
  opacity: 0.5;
}

.hp-empty p {
  font-size: 0.875rem;
}

/* ---- Error State ---- */
.hp-error {
  padding: 20px;
  border: 1px solid rgba(231,76,60,0.25);
  border-radius: 12px;
  background: rgba(231,76,60,0.06);
  color: #c0392b;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ---- Toast ---- */
.hp-toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.hp-toast-msg {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-radius: 14px;
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(35,24,16,0.18);
  animation: hp-toast-in 0.3s ease;
  pointer-events: auto;
  max-width: 360px;
}

.hp-toast-msg.success {
  background: #1a7a45;
  color: #fff;
}

.hp-toast-msg.error {
  background: #c0392b;
  color: #fff;
}

.hp-toast-msg.info {
  background: var(--accent-dark);
  color: #fff;
}

@keyframes hp-toast-in {
  from { opacity: 0; transform: translateY(16px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---- Action Icon Buttons (icon-only) ---- */
.hp-icon-btn {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 9px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, opacity 0.15s;
  flex-shrink: 0;
}

.hp-icon-btn:hover {
  transform: translateY(-1px);
  opacity: 0.85;
}

.hp-icon-btn.edit {
  background: rgba(33,150,243,0.12);
  color: #1565c0;
}

.hp-icon-btn.remove {
  background: rgba(244,67,54,0.1);
  color: #c62828;
}

.hp-icon-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}
