/* ==========================================================================
   LOVABLE-STYLE DEVICE PREVIEW & SIMULATOR STYLES
   ========================================================================== */

/* Hide simulator when embedded inside an iframe */
body.is-in-iframe #device-preview-bar,
body.is-in-iframe #device-studio-container {
  display: none !important;
}

body.simulator-active-mobile #app {
  display: none !important;
}

body.simulator-active-mobile {
  overflow: hidden;
  background-color: #0b0f12 !important;
}

/* ==========================================================================
   TOP PREVIEW TOOLBAR (LOVABLE / DEV STUDIO STYLE)
   ========================================================================== */
#device-preview-bar {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  height: 52px;
  background: rgba(18, 24, 28, 0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 99999;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  color: #f1f5f9;
  user-select: none;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  transition: transform 0.25s ease, opacity 0.25s ease;
}

#device-preview-bar.bar-minimized {
  transform: translateY(-100%);
  pointer-events: none;
}

/* Floating Restore Button when Bar is Minimized */
#device-preview-restore-btn {
  position: fixed;
  top: 12px;
  right: 16px;
  z-index: 999999;
  background: #2D6A4F;
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 14px rgba(45, 106, 79, 0.5);
  cursor: pointer;
  transition: all 0.2s ease;
}

#device-preview-restore-btn:hover {
  background: #1B4332;
  transform: translateY(-1px);
}

/* Toolbar Sections */
.dp-section {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dp-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.86rem;
  font-weight: 700;
  color: #ffffff;
  padding-right: 12px;
  border-right: 1px solid rgba(255, 255, 255, 0.12);
}

.dp-brand-logo-img {
  height: 28px;
  width: auto;
  object-fit: contain;
  display: block;
}

.dp-brand-badge {
  background: rgba(45, 106, 79, 0.35);
  color: #52B788;
  border: 1px solid rgba(82, 183, 136, 0.4);
  font-size: 0.7rem;
  padding: 2px 7px;
  border-radius: 6px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* Segmented Control (Desktop | Mobile | Tablet) */
.dp-segmented-control {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 3px;
  border-radius: 10px;
  gap: 2px;
}

.dp-segment-btn {
  background: transparent;
  color: #94a3b8;
  border: none;
  border-radius: 7px;
  padding: 5px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.dp-segment-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
}

.dp-segment-btn.active {
  background: #2D6A4F;
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(45, 106, 79, 0.45);
}

/* Device Selector Dropdown */
.dp-device-select-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.dp-device-select {
  appearance: none;
  -webkit-appearance: none;
  background: rgba(255, 255, 255, 0.07);
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 5px 28px 5px 10px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s;
}

.dp-device-select:hover, .dp-device-select:focus {
  border-color: #52B788;
  background: rgba(255, 255, 255, 0.12);
}

.dp-device-select-arrow {
  position: absolute;
  right: 8px;
  pointer-events: none;
  font-size: 0.65rem;
  color: #94a3b8;
}

/* Dimensions Info Pill */
.dp-dimensions-pill {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.75rem;
  color: #94a3b8;
  background: rgba(0, 0, 0, 0.3);
  padding: 4px 9px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

/* Action Icon Buttons */
.dp-icon-btn {
  background: rgba(255, 255, 255, 0.07);
  color: #cbd5e1;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  height: 32px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.dp-icon-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.2);
}

.dp-icon-btn.active {
  background: rgba(82, 183, 136, 0.2);
  color: #52B788;
  border-color: #52B788;
}

/* Scale Selector */
.dp-scale-control {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 2px 6px;
  gap: 4px;
}

.dp-scale-btn {
  background: none;
  border: none;
  color: #cbd5e1;
  font-size: 0.85rem;
  padding: 2px 6px;
  cursor: pointer;
  border-radius: 4px;
}

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

.dp-scale-label {
  font-size: 0.75rem;
  font-weight: 600;
  min-width: 44px;
  text-align: center;
  color: #e2e8f0;
}

/* ==========================================================================
   STUDIO WORKSPACE CANVAS (LOVABLE CANVAS BACKGROUND)
   ========================================================================== */
#device-studio-container {
  display: none;
  position: fixed;
  top: 52px;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #0d1317;
  background-image: 
    radial-gradient(rgba(255, 255, 255, 0.09) 1px, transparent 1px),
    radial-gradient(rgba(45, 106, 79, 0.12) 1px, transparent 1px);
  background-size: 24px 24px;
  background-position: 0 0, 12px 12px;
  overflow: auto;
  align-items: center;
  justify-content: center;
  padding: 32px 20px 48px;
  z-index: 99990;
}

#device-studio-container.visible {
  display: flex;
}

/* Device Mockup Wrapper */
.dp-mockup-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), width 0.25s ease, height 0.25s ease;
  transform-origin: center center;
}

/* Device Label Above Phone */
.dp-mockup-tag {
  margin-bottom: 12px;
  background: rgba(18, 24, 28, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #94a3b8;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.dp-mockup-tag span.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #52B788;
  display: inline-block;
}

/* ==========================================================================
   REALISTIC PHONE FRAME (SMARTPHONE MOCKUP)
   ========================================================================== */
.dp-phone-frame {
  position: relative;
  background: #111417;
  border-radius: 46px;
  box-shadow: 
    0 0 0 10px #1e242b,
    0 0 0 12px #2d3748,
    0 25px 60px -10px rgba(0, 0, 0, 0.75),
    0 10px 25px -5px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  transition: width 0.25s ease, height 0.25s ease, border-radius 0.25s ease;
  display: flex;
  flex-direction: column;
}

/* Frame without Bezel (Frameless mode) */
.dp-phone-frame.frameless {
  border-radius: 12px;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.15);
}

.dp-phone-frame.frameless .dp-status-bar,
.dp-phone-frame.frameless .dp-dynamic-island,
.dp-phone-frame.frameless .dp-home-indicator {
  display: none !important;
}

/* Dynamic Island (iPhone style) */
.dp-dynamic-island {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: 105px;
  height: 26px;
  background: #000000;
  border-radius: 20px;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  pointer-events: none;
}

.dp-island-camera {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #0b1d3a;
  border: 1px solid #1a365d;
}

.dp-island-sensor {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #1a202c;
}

/* Top Mobile Status Bar */
.dp-status-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 24px 0;
  font-size: 0.78rem;
  font-weight: 600;
  color: #111;
  z-index: 999;
  pointer-events: none;
}

.dp-status-time {
  font-weight: 700;
  letter-spacing: -0.2px;
}

.dp-status-icons {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
}

/* Mobile Iframe */
.dp-iframe-container {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
  background: #FAFDF7;
}

#device-iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
  background: #FAFDF7;
}

/* Bottom Home Indicator */
.dp-home-indicator {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 130px;
  height: 4px;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 999px;
  z-index: 999;
  pointer-events: none;
}

/* Tablet Adjustments */
.dp-phone-frame.is-tablet {
  border-radius: 30px;
  box-shadow: 
    0 0 0 14px #1c2229,
    0 0 0 16px #2d3748,
    0 30px 70px -10px rgba(0, 0, 0, 0.7);
}

.dp-phone-frame.is-tablet .dp-dynamic-island {
  display: none;
}

.dp-phone-frame.is-tablet .dp-status-bar {
  height: 32px;
  padding: 6px 20px 0;
}

/* Ocultar simulador em telas móveis reais */
@media (max-width: 600px) {
  #device-preview-bar,
  #device-preview-restore-btn {
    display: none !important;
  }
}
