/**
 * PREVIEW STYLESHEET — MYWEBVIETNAM.NET
 * 
 * Thiết kế chuẩn UI/UX cho trang xem mẫu website:
 * - Thanh trên cùng tinh gọn, chuẩn nhận diện thương hiệu (VAZO / Đại lý)
 * - Nút chuyển thiết bị (Desktop / Tablet / Mobile) kèm hiệu ứng mockup mượt mà
 * - Tối ưu mobile-first, 0 tràn ngang màn hình, nút bấm >= 44px
 */

:root {
  --preview-header-height: 60px;
  --color-bg-dark: #0f172a;
  --color-bg-body: #0b0f19;
  --color-border: rgba(255, 255, 255, 0.12);
  --color-text: #f8fafc;
  --color-text-muted: #94a3b8;
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-accent: #38bdf8;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-sans);
  background: var(--color-bg-body);
  color: var(--color-text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ========================================================
   HEADER BAR
======================================================== */
.preview-header {
  height: var(--preview-header-height);
  background: var(--color-bg-dark);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  position: relative;
  z-index: 100;
  gap: 12px;
}

/* Left: Brand + Theme Info */
.preview-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex-shrink: 1;
}

.preview-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--color-text);
  flex-shrink: 0;
}

.preview-logo-img {
  max-height: 36px;
  max-width: 140px;
  object-fit: contain;
  display: block;
  background: #fff;
  border-radius: 6px;
  padding: 3px 8px;
  box-sizing: content-box;
}

.preview-brand-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: #fff;
  font-weight: 800;
  font-size: 1rem;
}

.preview-brand-text {
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -0.01em;
  color: #fff;
  white-space: nowrap;
}

.preview-divider {
  width: 1px;
  height: 24px;
  background: var(--color-border);
  flex-shrink: 0;
}

.preview-theme-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.preview-theme-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

.preview-btn-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--color-text-muted);
  font-size: 0.775rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: all 0.2s;
  min-height: 32px;
}

.preview-btn-back:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

/* Center: Device Switcher */
.preview-header-center {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.device-switcher {
  display: flex;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}

.device-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  font-size: 0.825rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  min-height: 34px;
}

.device-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}

.device-btn.active {
  background: var(--color-primary);
  color: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* Right: Phone + CTA */
.preview-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.preview-phone-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 6px;
  color: var(--color-accent);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 600;
  transition: all 0.2s;
  white-space: nowrap;
  min-height: 40px;
}

.preview-phone-link:hover {
  background: rgba(56, 189, 248, 0.1);
  color: #7dd3fc;
}

.preview-cta-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: #fff;
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.4);
  transition: all 0.2s;
  min-height: 40px;
}

.preview-cta-link:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.5);
  background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
}

/* ========================================================
   MAIN PREVIEW AREA & MOCKUP FRAMES
======================================================== */
.preview-viewport {
  width: 100%;
  height: calc(100vh - var(--preview-header-height));
  display: flex;
  justify-content: center;
  align-items: center;
  background: var(--color-bg-body);
  position: relative;
  overflow: hidden;
}

.preview-frame-wrap {
  width: 100%;
  height: 100%;
  position: relative;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              height 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              border-radius 0.3s ease,
              box-shadow 0.3s ease,
              border 0.3s ease;
  background: #000;
  display: flex;
  flex-direction: column;
}

/* Desktop Mode */
.preview-viewport.mode-desktop .preview-frame-wrap {
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 0;
  box-shadow: none;
}

/* Tablet Mode (iPad Pro mockup) */
.preview-viewport.mode-tablet .preview-frame-wrap {
  width: 820px;
  max-width: 95%;
  height: calc(100% - 32px);
  max-height: 1080px;
  border: 14px solid #1e293b;
  border-radius: 28px;
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

/* Mobile Mode (iPhone mockup) */
.preview-viewport.mode-mobile .preview-frame-wrap {
  width: 390px;
  max-width: 95%;
  height: calc(100% - 32px);
  max-height: 844px;
  border: 12px solid #1e293b;
  border-radius: 36px;
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

/* Iframe */
.preview-iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
  background: #ffffff;
}

/* Loader indicator */
.preview-loader {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: transparent;
  overflow: hidden;
  z-index: 10;
  pointer-events: none;
}

.preview-loader-bar {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #2563eb, #38bdf8, #2563eb);
  transform: translateX(-100%);
  animation: previewLoading 1.5s infinite ease-in-out;
}

.preview-loader.loaded {
  display: none;
}

@keyframes previewLoading {
  0% { transform: translateX(-100%); }
  50% { transform: translateX(0); }
  100% { transform: translateX(100%); }
}

/* ========================================================
   404 ERROR PAGE VIEW (KHI MẪU KHÔNG TỒN TẠI)
======================================================== */
.preview-error-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--color-bg-body);
  color: #fff;
}

.preview-error-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  text-align: center;
  max-width: 580px;
  margin: 0 auto;
}

.preview-error-icon {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
}

.preview-error-code {
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #ef4444;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.preview-error-title {
  font-size: 1.75rem;
  font-weight: 800;
  margin-bottom: 12px;
  letter-spacing: -0.02em;
}

.preview-error-desc {
  font-size: 1rem;
  color: var(--color-text-muted);
  margin-bottom: 28px;
  line-height: 1.6;
}

.preview-error-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}

/* ========================================================
   RESPONSIVE DESIGN (CHỐNG TRÀN NGANG TOÀN DIỆN)
======================================================== */
@media (max-width: 1080px) {
  .preview-theme-title {
    max-width: 130px;
  }
  .device-btn span {
    display: none;
  }
  .device-btn {
    padding: 6px 10px;
  }
}

@media (max-width: 860px) {
  .preview-header-center {
    display: none; /* Mobile view: ẩn bộ đổi kích thước màn hình */
  }
  .preview-viewport.mode-tablet .preview-frame-wrap,
  .preview-viewport.mode-mobile .preview-frame-wrap {
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 0;
    box-shadow: none;
  }
}

@media (max-width: 640px) {
  .preview-header {
    padding: 0 10px;
    gap: 8px;
  }
  .preview-divider {
    display: none;
  }
  .preview-theme-meta {
    display: none; /* Ẩn tên mẫu trên mobile cực hẹp, ưu tiên logo + CTA */
  }
  .preview-brand-text {
    font-size: 0.9rem;
    max-width: 110px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .preview-phone-link span {
    display: none; /* Chỉ hiện icon phone */
  }
  .preview-phone-link {
    padding: 8px;
    min-width: 40px;
    justify-content: center;
  }
  .preview-cta-link {
    padding: 8px 12px;
    font-size: 0.8rem;
  }
  .preview-cta-link span {
    display: inline;
  }
}
