/**
 * Storefront CMS Management Styles (Advance Edition)
 * Crisp, modern layout with real-time multi-device simulator,
 * modular layout blocks manager, multi-slide carousel builder,
 * flash sale scheduler, and product picker.
 */

#admin-storefront-cms {
  background: #ffffff !important;
  color: #0f172a !important;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
  margin-bottom: 28px;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Header link & button styles */
.cms-head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Auth / Sandbox Banner */
.cms-auth-notice {
  background: #eff6ff;
  border-left: 4px solid #2874f0;
  padding: 12px 18px;
  margin: 16px 20px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.88rem;
  color: #1e3a8a;
  flex-wrap: wrap;
  gap: 10px;
}

.cms-auth-notice strong {
  font-weight: 700;
}

.cms-auth-link {
  background: #2874f0;
  color: #ffffff !important;
  font-weight: 700;
  font-size: 0.8rem;
  padding: 6px 14px;
  border-radius: 6px;
  text-decoration: none;
  transition: opacity 0.2s;
}

.cms-auth-link:hover {
  opacity: 0.9;
}

/* Presets Bar */
.cms-presets-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 14px 20px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}

.cms-presets-label {
  font-size: 0.82rem;
  font-weight: 800;
  color: #475569;
  text-transform: uppercase;
  margin-right: 4px;
}

.cms-preset-chip {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #1e293b;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.cms-preset-chip:hover {
  background: #2874f0;
  border-color: #2874f0;
  color: #ffffff;
  transform: translateY(-1px);
}

/* Editor Form */
.cms-editor-form {
  padding: 24px 20px;
}

.cms-main-layout {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 24px;
  margin-bottom: 24px;
}

@media (max-width: 1100px) {
  .cms-main-layout {
    grid-template-columns: 1fr;
  }
}

.cms-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.cms-editor-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 700;
  color: #334155;
}

.cms-editor-form input,
.cms-editor-form select,
.cms-editor-form textarea {
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 0.88rem;
  color: #0f172a;
  background: #ffffff;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
}

.cms-editor-form input:focus,
.cms-editor-form select:focus,
.cms-editor-form textarea:focus {
  border-color: #2874f0;
  box-shadow: 0 0 0 3px rgba(40, 116, 240, 0.15);
}

.cms-form-full {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 16px;
}

/* Section Subhead & Helper Text */
.cms-section-heading {
  font-size: 0.95rem;
  font-weight: 800;
  color: #0f172a;
  margin: 16px 0 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cms-subtext {
  font-size: 0.8rem;
  color: #64748b;
  font-weight: 400;
  margin: 0;
}

/* --------------------------------------------------------------------------
 * Multi-Device Responsive Simulator Frame
 * -------------------------------------------------------------------------- */
.cms-simulator-box {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.cms-canvas-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 12px;
}

.cms-canvas-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cms-canvas-title strong {
  font-size: 0.88rem;
  color: #0f172a;
}

.cms-canvas-badge {
  background: #dbeafe;
  color: #1e40af;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
}

.cms-device-toggles {
  display: inline-flex;
  background: #e2e8f0;
  padding: 3px;
  border-radius: 8px;
  gap: 2px;
}

.cms-device-btn {
  background: transparent;
  border: none;
  font-size: 0.78rem;
  font-weight: 700;
  color: #475569;
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.cms-device-btn:hover {
  color: #0f172a;
}

.cms-device-btn.is-active {
  background: #ffffff;
  color: #2874f0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Device Viewport Frame Styles */
.cms-simulator-viewport-wrap {
  width: 100%;
  overflow-x: auto;
  padding: 4px 0;
  display: flex;
  justify-content: center;
}

.cms-simulator-frame {
  width: 100%;
  transition: max-width 0.3s ease, border 0.3s ease, border-radius 0.3s ease;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.05);
}

.cms-simulator-frame.device-desktop {
  max-width: 100%;
}

.cms-simulator-frame.device-tablet {
  max-width: 768px;
  border: 6px solid #334155;
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.cms-simulator-frame.device-mobile {
  max-width: 375px;
  border: 10px solid #1e293b;
  border-radius: 32px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
}

/* Mobile Notch & Status Bar */
.cms-mobile-status-bar {
  display: none;
  background: #1e293b;
  color: #ffffff;
  padding: 6px 14px;
  font-size: 0.7rem;
  justify-content: space-between;
  align-items: center;
}

.cms-simulator-frame.device-mobile .cms-mobile-status-bar {
  display: flex;
}

.cms-mobile-notch-pill {
  width: 60px;
  height: 6px;
  background: #0f172a;
  border-radius: 3px;
}

/* Inside Simulator Canvas Elements */
.cms-sim-canvas {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f8fafc;
}

.cms-sim-hero {
  border-radius: 10px;
  padding: 18px;
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  transition: background 0.3s ease;
  position: relative;
  overflow: hidden;
}

.cms-sim-badge {
  display: inline-block;
  background: #ffe500;
  color: #0f172a;
  font-size: 0.68rem;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 4px;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.cms-sim-headline {
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1.25;
  margin-bottom: 4px;
}

.cms-sim-subtitle {
  font-size: 0.8rem;
  opacity: 0.92;
  line-height: 1.35;
  margin-bottom: 10px;
}

.cms-sim-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  padding-top: 8px;
  font-size: 0.76rem;
  flex-wrap: wrap;
  gap: 6px;
}

.cms-sim-coupon-pill {
  background: rgba(255, 255, 255, 0.2);
  border: 1px dashed rgba(255, 255, 255, 0.6);
  padding: 3px 8px;
  border-radius: 4px;
  font-family: monospace;
  font-weight: 700;
}

.cms-sim-discount-badge {
  background: #ef4444;
  color: #ffffff;
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 800;
  font-size: 0.72rem;
}

/* Flash Sale Countdown Timer Ticker Block */
.cms-sim-ticker {
  background: #fee2e2;
  border: 1px solid #fecaca;
  color: #991b1b;
  padding: 8px 12px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  font-weight: 700;
}

.cms-sim-timer-val {
  font-family: monospace;
  background: #dc2626;
  color: #ffffff;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}

/* Product Spotlight Strip */
.cms-sim-carousel-block {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px;
}

.cms-sim-carousel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 8px;
}

.cms-sim-carousel-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.cms-sim-card {
  min-width: 100px;
  max-width: 110px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 6px;
  font-size: 0.72rem;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.cms-sim-card img {
  width: 100%;
  height: 55px;
  object-fit: cover;
  border-radius: 4px;
}

.cms-sim-card-title {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #0f172a;
}

.cms-sim-card-price {
  font-weight: 800;
  color: #16a34a;
}

/* Trust Strip */
.cms-sim-trust-strip {
  display: flex;
  justify-content: space-around;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 8px;
  font-size: 0.7rem;
  color: #475569;
  font-weight: 600;
  text-align: center;
}

/* --------------------------------------------------------------------------
 * Modular Layout Blocks Manager
 * -------------------------------------------------------------------------- */
.cms-block-manager {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 20px;
}

.cms-block-manager-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}

.cms-block-manager-head strong {
  font-size: 0.92rem;
  color: #0f172a;
}

.cms-blocks-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cms-block-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 10px 14px;
  transition: all 0.2s ease;
}

.cms-block-item:hover {
  border-color: #94a3b8;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.cms-block-item-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cms-block-icon {
  font-size: 1.1rem;
}

.cms-block-info {
  display: flex;
  flex-direction: column;
}

.cms-block-title {
  font-size: 0.84rem;
  font-weight: 700;
  color: #0f172a;
}

.cms-block-desc {
  font-size: 0.74rem;
  color: #64748b;
}

.cms-block-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cms-btn-arrow {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #334155;
  width: 28px;
  height: 28px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 700;
  transition: all 0.15s;
}

.cms-btn-arrow:hover:not(:disabled) {
  background: #2874f0;
  border-color: #2874f0;
  color: #ffffff;
}

.cms-btn-arrow:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Switch Toggle */
.cms-switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
}

.cms-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.cms-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #cbd5e1;
  transition: 0.2s;
  border-radius: 22px;
}

.cms-slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.2s;
  border-radius: 50%;
}

.cms-switch input:checked + .cms-slider {
  background-color: #2874f0;
}

.cms-switch input:checked + .cms-slider:before {
  transform: translateX(18px);
}

/* --------------------------------------------------------------------------
 * Multi-Slide Hero Carousel Builder
 * -------------------------------------------------------------------------- */
.cms-slides-manager {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 20px;
}

.cms-slides-manager-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}

.cms-slides-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cms-slide-card {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 12px 14px;
}

.cms-slide-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-weight: 700;
  font-size: 0.82rem;
  color: #0f172a;
}

.cms-slide-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
}

/* --------------------------------------------------------------------------
 * Enhanced Product Picker
 * -------------------------------------------------------------------------- */
.cms-product-picker-section {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 20px;
}

.cms-picker-filter-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.cms-product-search-input {
  flex: 1;
  min-width: 200px;
  padding: 9px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 0.85rem;
  box-sizing: border-box;
}

.cms-product-category-filter {
  padding: 9px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 0.85rem;
  background: #ffffff;
}

.cms-picker-actions-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  flex-wrap: wrap;
  gap: 8px;
}

.cms-picker-buttons {
  display: flex;
  gap: 8px;
}

.cms-btn-xs {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #334155;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}

.cms-btn-xs:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
}

.cms-selected-count-badge {
  background: #e0f2fe;
  color: #0369a1;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 12px;
}

.cms-product-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
  max-height: 240px;
  overflow-y: auto;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 12px;
}

.cms-product-checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.82rem;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid #f1f5f9;
  transition: background 0.15s, border-color 0.15s;
}

.cms-product-checkbox:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.cms-prod-thumb {
  width: 36px;
  height: 36px;
  border-radius: 4px;
  object-fit: cover;
  background: #f1f5f9;
}

.cms-prod-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cms-prod-title {
  font-weight: 700;
  color: #0f172a;
}

.cms-prod-sub {
  font-size: 0.74rem;
  color: #64748b;
}

/* --------------------------------------------------------------------------
 * Form Actions & Quick Share Toolbar
 * -------------------------------------------------------------------------- */
.cms-form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid #e2e8f0;
  flex-wrap: wrap;
}

.cms-btn-primary {
  background: #2874f0;
  color: #ffffff;
  border: none;
  font-weight: 800;
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.2s, transform 0.1s;
}

.cms-btn-primary:hover {
  background: #1e5bc6;
  transform: translateY(-1px);
}

.cms-btn-secondary {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #334155;
  font-weight: 700;
  padding: 10px 18px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.88rem;
  transition: all 0.2s;
}

.cms-btn-secondary:hover {
  background: #f8fafc;
  border-color: #94a3b8;
}

/* Campaigns Table */
.cms-campaigns-list-wrapper {
  padding: 24px 20px;
  border-top: 2px solid #f1f5f9;
}

.cms-campaigns-list-wrapper h3 {
  font-size: 1.15rem;
  font-weight: 800;
  color: #0f172a;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cms-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.cms-table th {
  background: #f8fafc;
  color: #475569;
  font-weight: 700;
  text-align: left;
  padding: 12px 14px;
  border-bottom: 2px solid #e2e8f0;
}

.cms-table td {
  padding: 12px 14px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}

.cms-table tr:hover td {
  background: #f8fafc;
}

.cms-status-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.cms-status-ACTIVE {
  background: #dcfce7;
  color: #15803d;
}

.cms-status-PAUSED {
  background: #fef9c3;
  color: #a16207;
}

.cms-status-ARCHIVED {
  background: #f1f5f9;
  color: #64748b;
}

.cms-theme-pill {
  background: #f1f5f9;
  color: #334155;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-family: monospace;
}

.cms-table-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.cms-btn-action {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #1e293b;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s;
}

.cms-btn-action:hover {
  background: #2874f0;
  border-color: #2874f0;
  color: #ffffff;
}

.cms-btn-danger:hover {
  background: #ef4444;
  border-color: #ef4444;
  color: #ffffff;
}

/* Toast Notification */
.cms-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #0f172a;
  color: #ffffff;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  z-index: 9999;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.3s ease;
  pointer-events: none;
}

.cms-toast.show {
  opacity: 1;
  transform: translateY(0);
}
