/* ============================================================
   IQ~Code — Live Preview (Device Switcher)
   File: assets/css/preview.css
   ============================================================ */

/* ============================================================
   SECTION WRAPPER
   ============================================================ */
.iq-preview-section{
  padding: 90px 0;
  position: relative;
  overflow: hidden;
}
.iq-preview-section::before{
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(900px 500px at 50% 0%, var(--accent-soft), transparent 70%);
  pointer-events: none;
  opacity: .6;
}

/* ============================================================
   GRID — Left device stage + Right mode cards
   ============================================================ */
.iq-preview-grid{
  display: grid;
  grid-template-columns: 1.55fr 1fr;
  gap: 55px;
  align-items: center;
  position: relative;
  z-index: 1;
  margin-top: 40px;
  min-height: 460px;
}

/* ============================================================
   LEFT: STAGE (device frames live here)
   ============================================================ */
.iq-preview-stage{
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 460px;
}

/* Devices inside stage: toggle visibility */
.iq-device{
  width: 100%;
  transition: opacity .35s ease, transform .35s ease;
}
.iq-device.is-hidden{
  display: none;
}

/* ============================================================
   MACBOOK (Desktop / Admin)
   ------------------------------------------------------------
   FRAME COLOR: invert of the current theme
   - Dark theme  → white/light frame
   - Light theme → dark/black frame
   ============================================================ */
.iq-device-desktop{
  max-width: 100%;
  margin: 0 auto;
}
.iq-device-desktop .iq-device-frame{
  position: relative;
  width: 100%;
}
.iq-device-desktop .iq-device-screen{
  /* Default = dark theme → light frame */
  background: #e8e8ec;
  border-radius: 14px 14px 0 0;
  padding: 16px 16px 0;
  box-shadow:
    0 30px 60px rgba(0,0,0,.35),
    0 0 0 1px rgba(0,0,0,.06),
    inset 0 0 0 1px rgba(255,255,255,.6);
  position: relative;
  transition: background-color .35s ease, box-shadow .35s ease;
}
.iq-device-desktop .iq-device-screen::before{
  content: "";
  position: absolute;
  top: 7px; left: 50%;
  transform: translateX(-50%);
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #b8b8c0;
  box-shadow: inset 0 0 2px rgba(0,0,0,.2);
  transition: background-color .35s ease;
}

/* Browser chrome (bar inside laptop) */
.iq-browser-bar{
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  /* Default (dark theme) → light browser bar */
  background: #f4f4f7;
  border-radius: 8px 8px 0 0;
  border-bottom: 1px solid rgba(0,0,0,.06);
  transition: background-color .35s ease, border-color .35s ease;
}
.iq-browser-dots{ display: flex; gap: 6px; flex-shrink: 0; }
.iq-browser-dots span{
  width: 11px; height: 11px;
  border-radius: 50%;
  display: block;
}
.iq-browser-dots span:nth-child(1){ background: #FF5F56; }
.iq-browser-dots span:nth-child(2){ background: #FFBD2E; }
.iq-browser-dots span:nth-child(3){ background: #27C93F; }

.iq-browser-url{
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  /* Default (dark theme) → light url bar */
  background: #ffffff;
  border: 1px solid rgba(0,0,0,.05);
  border-radius: 6px;
  font-size: .75rem;
  color: #6b6b78;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  min-width: 0;
  transition: background-color .35s ease, color .35s ease, border-color .35s ease;
}
.iq-browser-url i{ font-size: .7em; color: #16A34A; flex-shrink: 0; }
.iq-browser-url span{
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* MacBook base (bottom) */
.iq-device-base{
  height: 14px;
  /* Default (dark theme) → light laptop base */
  background: linear-gradient(180deg, #d8d8de 0%, #b6b6be 100%);
  border-radius: 0 0 12px 12px;
  position: relative;
  box-shadow: 0 8px 16px rgba(0,0,0,.25);
  width: 108%;
  margin-left: -4%;
  transition: background .35s ease, box-shadow .35s ease;
}
.iq-device-base::before{
  content: "";
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 60px; height: 4px;
  background: #a8a8b0;
  border-radius: 0 0 4px 4px;
  transition: background-color .35s ease;
}
.iq-device-base .iq-device-notch{
  position: absolute;
  bottom: -4px; left: 50%;
  transform: translateX(-50%);
  width: 90px; height: 4px;
  background: #9c9ca4;
  border-radius: 0 0 6px 6px;
  transition: background-color .35s ease;
}

/* ============================================================
   IPHONE (Mobile)
   ------------------------------------------------------------
   FRAME COLOR: same inversion as laptop
   ============================================================ */
.iq-device-mobile{
  max-width: 320px;
  margin: 0 auto;
}
.iq-device-mobile .iq-device-frame{
  position: relative;
  width: 100%;
}

/* Notch bar — invert of theme */
.iq-device-mobile .iq-device-notch-bar{
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 22px 8px;
  /* Default (dark theme) → light phone frame */
  background: #e8e8ec;
  border-radius: 36px 36px 0 0;
  position: relative;
  color: #1a1a2e;
  font-size: .7rem;
  font-weight: 600;
  font-family: -apple-system, 'SF Pro Display', 'Segoe UI', sans-serif;
  border: 10px solid #d8d8de;
  border-bottom: 0;
  border-top-width: 12px;
  transition: background-color .35s ease, color .35s ease, border-color .35s ease;
}
.iq-device-mobile .iq-device-notch-bar .iq-device-notch{
  position: absolute;
  top: -2px; left: 50%;
  transform: translateX(-50%);
  width: 90px; height: 22px;
  background: #d8d8de;
  border-radius: 0 0 16px 16px;
  border: 1px solid rgba(0,0,0,.06);
  transition: background-color .35s ease, border-color .35s ease;
}
.iq-device-mobile .iq-device-time{ flex: 1; text-align: left; }
.iq-device-mobile .iq-device-status{
  flex: 1;
  display: flex;
  justify-content: flex-end;
  gap: 4px;
  font-size: .65rem;
}

.iq-device-mobile .iq-device-iframe-wrap{
  border-left: 10px solid #d8d8de;
  border-right: 10px solid #d8d8de;
  transition: border-color .35s ease;
}

.iq-device-mobile .iq-device-home-bar{
  height: 28px;
  background: #e8e8ec;
  border-radius: 0 0 36px 36px;
  border: 10px solid #d8d8de;
  border-top: 0;
  position: relative;
  transition: background-color .35s ease, border-color .35s ease;
}
.iq-device-mobile .iq-device-home-bar::before{
  content: "";
  position: absolute;
  top: 8px; left: 50%;
  transform: translateX(-50%);
  width: 110px; height: 5px;
  background: #909098;
  border-radius: 3px;
  opacity: .9;
  transition: background-color .35s ease;
}

/* ============================================================
   LIGHT THEME → DARK FRAMES  (inversion)
   ============================================================ */
[data-theme="light"] .iq-device-desktop .iq-device-screen{
  background: #2a2a2e;
  box-shadow:
    0 30px 60px rgba(0,0,0,.25),
    0 0 0 1px rgba(255,255,255,.06),
    inset 0 0 0 1px rgba(255,255,255,.04);
}
[data-theme="light"] .iq-device-desktop .iq-device-screen::before{
  background: #4a4a52;
  box-shadow: inset 0 0 2px #000;
}
[data-theme="light"] .iq-browser-bar{
  background: #1f1f24;
  border-bottom-color: #16161a;
}
[data-theme="light"] .iq-browser-url{
  background: #16161a;
  border-color: #2a2a30;
  color: #999;
}
[data-theme="light"] .iq-browser-url i{ color: #4ADE80; }

[data-theme="light"] .iq-device-base{
  background: linear-gradient(180deg, #3a3a40 0%, #1e1e22 100%);
  box-shadow: 0 8px 16px rgba(0,0,0,.35);
}
[data-theme="light"] .iq-device-base::before{
  background: #4a4a52;
}
[data-theme="light"] .iq-device-base .iq-device-notch{
  background: #3a3a40;
}

/* Mobile — light theme → dark phone frame */
[data-theme="light"] .iq-device-mobile .iq-device-notch-bar{
  background: #2a2a2e;
  color: #fff;
  border-color: #1e1e22;
}
[data-theme="light"] .iq-device-mobile .iq-device-notch-bar .iq-device-notch{
  background: #1e1e22;
  border-color: #16161a;
}
[data-theme="light"] .iq-device-mobile .iq-device-iframe-wrap{
  border-left-color: #1e1e22;
  border-right-color: #1e1e22;
}
[data-theme="light"] .iq-device-mobile .iq-device-home-bar{
  background: #2a2a2e;
  border-color: #1e1e22;
}
[data-theme="light"] .iq-device-mobile .iq-device-home-bar::before{
  background: #fff;
}

/* ============================================================
   IFRAME WRAPPERS
   ------------------------------------------------------------
   IMPORTANT: hide scrollbars inside iframe-wrapper on host page.
   (Scrollbars *inside* the iframe belong to the iframe's own site,
   we can't style those from here — but the host wrapper is ours.)
   ============================================================ */
.iq-device-iframe-wrap{
  position: relative;
  width: 100%;
  background: #fff;
  overflow: hidden;
}
.iq-device-desktop .iq-device-iframe-wrap{
  aspect-ratio: 16 / 10;
  border-radius: 0 0 4px 4px;
}
.iq-device-mobile .iq-device-iframe-wrap{
  aspect-ratio: 9 / 16;
  overflow: hidden;
}

.iq-device-iframe-wrap iframe{
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: #fff;
  color-scheme: light;
  /* Hide scrollbar on the iframe itself (Chrome/Edge/Safari) */
  scrollbar-width: none;          /* Firefox */
  -ms-overflow-style: none;       /* IE/Edge legacy */
}
.iq-device-iframe-wrap iframe::-webkit-scrollbar{
  display: none;                  /* Chrome/Safari/Edge */
  width: 0;
  height: 0;
}

/* The mobile iframe is scaled via JS */
.iq-device-mobile .iq-device-iframe-wrap iframe{
  transform-origin: top left;
}

/* ============================================================
   RIGHT: MODE SWITCHER CARDS
   ============================================================ */
.iq-preview-modes{
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.iq-preview-mode{
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 14px;
  padding: 36px 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-2);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color .25s ease, background-color .25s ease,
              color .25s ease, transform .25s ease, box-shadow .25s ease;
  text-align: center;
  min-height: 130px;
  -webkit-tap-highlight-color: transparent;
}
.iq-preview-mode:hover{
  border-color: var(--border-2);
  transform: translateY(-2px);
  background: var(--bg-2);
}
.iq-preview-mode.is-active{
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: 0 12px 30px var(--accent-glow);
}
.iq-preview-mode-icon{
  width: 56px; height: 56px;
  border-radius: 14px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  color: var(--text-2);
  display: grid; place-items: center;
  font-size: 1.5rem;
  transition: all .25s ease;
}
.iq-preview-mode:hover .iq-preview-mode-icon{
  border-color: var(--border-2);
  color: var(--text);
}
.iq-preview-mode.is-active .iq-preview-mode-icon{
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
  box-shadow: 0 8px 20px var(--accent-glow);
}
.iq-preview-mode-label{
  font-size: .95rem;
  letter-spacing: .01em;
}

/* ============================================================
   BOTTOM ACTIONS
   ============================================================ */
.iq-preview-actions{
  display: flex;
  justify-content: center;
  margin-top: 55px;
  gap: 12px;
  flex-wrap: wrap;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1199.98px){
  .iq-preview-grid{ gap: 40px; }
  .iq-preview-stage{ min-height: 420px; }
  .iq-device-mobile{ max-width: 290px; }
}

@media (max-width: 991.98px){
  .iq-preview-grid{
    grid-template-columns: 1fr;
    gap: 40px;
    min-height: 0;
  }
  .iq-preview-stage{ min-height: 0; }
  .iq-preview-modes{
    flex-direction: row;
    justify-content: center;
    flex-wrap: wrap;
  }
  .iq-preview-mode{
    flex: 1 1 180px;
    max-width: 240px;
    min-height: 120px;
    padding: 26px 18px;
  }
  .iq-device-mobile{ max-width: 280px; }
}

@media (max-width: 575.98px){
  .iq-preview-section{ padding: 60px 0; }
  .iq-browser-bar{ padding: 8px 10px; }
  .iq-browser-url{ font-size: .68rem; padding: 4px 8px; }
  .iq-device-mobile{ max-width: 240px; }
  .iq-preview-modes{ gap: 12px; }
  .iq-preview-mode{
    flex: 1 1 100%;
    max-width: 100%;
    padding: 22px 18px;
    min-height: 0;
    flex-direction: row;
    justify-content: flex-start;
    gap: 16px;
    text-align: left;
  }
  .iq-preview-mode-icon{
    width: 46px; height: 46px;
    font-size: 1.2rem;
    flex-shrink: 0;
  }
  .iq-preview-actions .iq-btn{ width: 100%; justify-content: center; }
}