/* Import Modern Professional Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Roboto:wght@300;400;500;700&family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
  --google-blue: #1a0dab;
  --google-green: #006621;
  --google-text: #3c4043;
  --google-url: #202124;
  --google-bg-mobile: #f1f3f4;
  --primary-accent: #2563eb; /* modern SaaS blue */
}

html, body {
  height: 100%;
}

body {
  font-family: 'Inter', sans-serif;
  background-color: #f8fafc;
  color: #0f172a;
  /* Desktop: body itself does not scroll — only left panel overflows */
  overflow-x: hidden;
  overflow-y: auto;
}

/* Mobile + Tablet: allow natural page scroll since panels stack vertically */
@media (max-width: 1024px) {
  html, body {
    height: auto !important;
    min-height: 100% !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
  }
}

/* ====== DEFINITIVE SCROLL FIX ======
   On desktop, give each panel an explicit max-height using calc.
   overflow-y: auto requires a constrained height to activate scrolling.
   flex height propagation alone is not reliable with Tailwind CDN. */
@media (min-width: 1025px) {
  .left-panel-scroll {
    max-height: calc(100vh - 4rem); /* 4rem = 64px sticky header */
    overflow-y: auto;
  }
  .right-panel-scroll {
    height: calc(100vh - 3rem); /* fixed height matches new header */
    overflow-y: auto;
  }
}

/* Custom Premium Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Google Search Font Overrides for the Ad Preview Card */
.google-font-family {
  font-family: 'Inter', sans-serif;
}

/* Edit Highlighting Animation (Yellow Flash) */
@keyframes yellow-flash {
  0% {
    background-color: rgba(254, 240, 138, 0.8);
    box-shadow: 0 0 0 4px rgba(254, 240, 138, 0.4);
  }
  100% {
    background-color: transparent;
    box-shadow: none;
  }
}

.edit-highlight {
  animation: yellow-flash 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Drag and Drop Visual Feedback styles */
.draggable-item {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  cursor: grab;
}

.draggable-item:active {
  cursor: grabbing;
}

.draggable-item.dragging {
  opacity: 0.5;
  border: 2px dashed #3b82f6;
  background-color: #eff6ff;
  transform: scale(0.98);
}

.drag-over {
  border-top: 3px solid #3b82f6 !important;
  background-color: #eff6ff;
}

/* Fade and Slide Animations for Shuffle transitions */
.transition-shuffle {
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.shuffle-enter {
  opacity: 0;
  transform: translateY(8px);
}

.shuffle-leave {
  opacity: 0;
  transform: translateY(-8px);
}

/* Base transition for headline/description preview elements (prevents class accumulation) */
#ad-headline-preview,
#ad-description-preview {
  transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Custom Accordion Chevron Transitions */
.accordion-header[aria-expanded="true"] .chevron-icon {
  transform: rotate(180deg);
}
.chevron-icon {
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Custom Toggle Switch for Desktop/Mobile */
.toggle-bg {
  transition: background-color 0.2s ease;
}
.toggle-dot {
  transition: transform 0.2s ease;
}

/* Real Google Search Ad Spacing & Layout Styling */
.google-ad-container {
  max-width: 600px;
  background: #ffffff;
  border-radius: 8px;
  padding: 12px 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  font-family: 'Roboto', Arial, sans-serif;
  text-align: left;
  border: 1px solid #dadce0;
  min-height: 150px;
}

.google-ad-container.mobile {
  max-width: 360px;
  border-radius: 16px;
  border: 1px solid #dadce0;
  padding: 12px;
}

.google-title {
  color: #1a0dab;
  font-size: 20px;
  line-height: 1.3;
  font-weight: 400;
  text-decoration: none;
}

.google-title:hover {
  text-decoration: underline;
}

.google-ad-container.mobile .google-title {
  font-size: 19px;
  color: #1a0dab;
}

.google-description {
  color: #4d5156;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
}

.google-ad-container.mobile .google-description {
  font-size: 14px;
  line-height: 1.43;
}

.google-display-url {
  color: #202124;
  font-size: 12px;
  line-height: 1.3;
  display: flex;
  align-items: center;
  gap: 4px;
}

.google-ad-container.mobile .google-display-url {
  font-size: 11px;
}

.google-sponsored {
  font-size: 12px;
  color: #202124;
  font-weight: 700;
}

.google-ad-container.mobile .google-sponsored {
  font-size: 12px;
}

/* Sitelinks Grid in Desktop vs Carousel in Mobile */
.sitelinks-desktop-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 24px;
  margin-top: 10px;
  border-top: 1px solid #f1f3f4;
  padding-top: 10px;
}

.sitelink-item-title {
  color: #1a0dab;
  font-size: 14px;
  font-weight: 400;
  text-decoration: none;
}
.sitelink-item-title:hover {
  text-decoration: underline;
}

.sitelink-item-desc {
  color: #4d5156;
  font-size: 12px;
  line-height: 1.4;
  margin-top: 2px;
}

.sitelinks-mobile-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  border-top: 1px solid #f1f3f4;
  padding-top: 10px;
}

.sitelink-mobile-pill {
  background: #f1f3f4;
  color: #1a0dab;
  border-radius: 16px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  display: inline-block;
}

/* Price Extension Carousel */
.price-cards-container {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 6px 0;
  margin-top: 8px;
}

.price-card {
  border: 1px solid #dadce0;
  border-radius: 8px;
  padding: 8px 12px;
  min-width: 140px;
  flex-shrink: 0;
  background: #ffffff;
}

.price-card-header {
  font-size: 12px;
  font-weight: 700;
  color: #202124;
}

.price-card-price {
  font-size: 15px;
  font-weight: 700;
  color: #1a0dab;
  margin-top: 4px;
}

.price-card-desc {
  font-size: 11px;
  color: #5f6368;
  margin-top: 2px;
}

/* Image Extension rendering inside Google Ad */
.ad-image-container-right {
  width: 92px;
  height: 92px;
  min-width: 92px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #dadce0;
  margin-left: 12px;
}

.ad-image-container-right img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Lead Form Modal Preview */
.lead-form-modal {
  backdrop-filter: blur(4px);
  background-color: rgba(15, 23, 42, 0.4);
}

/* Dynamic Badge styling */
.badge-count {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 9999px;
}

/* Existing CSS content */
/* Added responsive enhancements */

/* Ensure the preview container does not overflow horizontally */
#ad-capture-target {
  max-width: 100%;
  overflow-x: hidden;
}

/* Make any right side image extensions responsive */
#ad-image-preview-wrapper img {
  max-width: 100%;
  height: auto;
}

/* Ensure scrollable panels do not cause horizontal scroll */
.left-panel-scroll, .right-panel-scroll {
  overflow-x: hidden;
}

/* General utility to prevent input shrink overflow */
input, select, textarea {
  min-width: 0;
  box-sizing: border-box;
}

/* Floating Action buttons container styling */
.floating-actions {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Transition speed for panels and drawers */
.drawer-transition {
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.input-warning {
  border-color: #ef4444 !important;
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2) !important;
}

.input-success {
  border-color: #10b981 !important;
}

/* ====== RESPONSIVE FIXES ====== */

/* Mobile: floating actions row at bottom */
@media (max-width: 639px) {
  .floating-actions {
    bottom: 12px;
    right: 12px;
    flex-direction: row;
    gap: 8px;
  }
  .floating-actions button {
    width: 40px;
    height: 40px;
  }
}

/* Ensure right panel scroll area fills available height */
.right-panel-scroll {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  min-height: 0;
}

/* Preview canvas scroll area must have a real height so children render */
.right-panel-scroll > div.flex-1 {
  min-height: 500px;
}

/* Ensure preview target expands to fill container */
#ad-capture-target {
  min-height: 200px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  width: 100%;
}

/* Keep ad preview container responsive */
#google-search-ad {
  width: 100%;
  max-width: 600px;
}

/* ====== MOBILE AND TABLET SCROLLING & LAYOUT OVERRIDES (below 1025px) ====== */
@media (max-width: 1024px) {

  /* --- Header: un-sticky, add bottom breathing room --- */
  header {
    position: relative !important;
    top: auto !important;
    margin-bottom: 0 !important;
    padding-left: 16px !important;
    padding-right: 16px !important;
    padding-bottom: 12px !important;
  }

  /* --- Action Buttons Row (Row 2 inside header): card-like group --- */
  header > div:nth-child(2) {
    margin-top: 20px !important;       /* Header title → Action Buttons spacing */
    width: 100% !important;
    max-width: 600px !important;
    margin-left: auto !important;
    margin-right: auto !important;
    box-sizing: border-box !important;
    background: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 12px !important;
    padding: 10px !important;
    gap: 8px !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04) !important;
  }

  header > div:nth-child(2) button {
    width: 100% !important;
    min-width: 0 !important;
    height: 44px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-sizing: border-box !important;
  }

  /* --- Main container: natural flow --- */
  main {
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
    padding: 0 16px !important;
  }

  /* --- Left panel (input panel): breathing room when stacked --- */
  .left-panel-scroll {
    max-height: none !important;
    overflow: visible !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  /* --- Right panel (preview column): natural height, outer padding --- */
  .right-panel-scroll {
    height: auto !important;
    max-height: none !important;
    min-height: auto !important;
    overflow: visible !important;
    padding: 0 !important;
    border-left: none !important;
    border-top: none !important;
    margin-top: 20px !important;       /* Action Buttons → Preview Controls spacing */
  }

  .right-panel-scroll > div.flex-1 {
    height: auto !important;
    min-height: auto !important;
    max-height: none !important;
    overflow-y: visible !important;
    overflow-x: hidden !important;
  }

  /* --- Preview Controls Toolbar: card-like group --- */
  .floating-actions button {
    flex: 1 1 0 !important; /* Equal distribution */
    width: 100% !important; /* Ensure full width within flex item */
    max-width: none !important;
    height: auto !important;
    padding: 8px !important;
    min-height: 44px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: #fff !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 8px !important;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04) !important;
  }

  /* --- Export Actions (Copy/Camera/Download/Export): card-like group --- */
  .floating-actions {
    position: static !important;
    transform: none !important;
    display: flex !important;
    flex-direction: row !important;
    justify-content: space-between !important;
    align-items: center !important;
    width: 100% !important;
    max-width: 600px !important; /* Align with other sections */
    margin: 20px auto !important;      /* Centered horizontally */
    gap: 12px !important;
    z-index: auto !important;
    background: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 12px !important;
    padding: 12px 16px !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04) !important;
  }

  /* --- Ad Preview Canvas area: top spacing via padding --- */
  .right-panel-scroll > div.flex-1 {
    padding-top: 4px !important;
  }
}
