/* ==== MAIN LAYOUT ==== */
main {
  display: flex;
  justify-content: center;
  height: calc(100vh - 70px);
  margin-top: 1rem;
  gap: 2rem;
}

/* ==== LEFT PANEL (in fixed iPhone-like frame) ==== */

/* ---- Fixed iPhone-like frame ---- */
.iphone-frame{
  aspect-ratio: 390 / 844;              /* iPhone 14/15 ratio */
  height: clamp(640px, 88vh, 900px);    /* constant visual height */
  width: auto;                          /* computed from aspect ratio */
  border: 15px solid var(--pp-black);
  border-radius: 50px;
  background: var(--pp-white);
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  overflow: hidden;                      /* clip rounded corners */
  display: flex;
  flex-direction: column;
  min-height: 0;                         /* allow child to shrink/scroll */
}

/* ---- Scrolling content INSIDE the frame ---- */
.iphone-frame > #leftPanel{
  flex: 1 1 auto;
  min-height: 0;                         /* critical for flex children */
  min-width: 0;                          /* allow shrink to frame width */
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box;

  overflow-y: auto;
  overflow-x: hidden;                    /* no sideways scroll */
  -webkit-overflow-scrolling: touch;

  /* visual styles (no sizing constraints) */
  padding: 1rem;
  background: var(--pp-white);
  border: 0;                             /* frame provides bezel now */
  border-radius: 0;
}

/* Remove old constraints that fight the frame */
#leftPanel{
  flex: 1 1 auto !important;
  width: auto !important;
  max-height: none !important;
  max-width: 100% !important;
  min-width: 0 !important;
}

/* Keep everything inside the frame width */
#leftPanel * { box-sizing: border-box; }
#leftPanel img,
#leftPanel video,
#leftPanel canvas { max-width: 100%; height: auto; display: block; }
#leftPanel textarea,
#leftPanel input[type="text"],
#leftPanel select { width: 100%; }

/* Common blocks should not exceed frame width */
#leftPanel .strategy-header-wrap,
#leftPanel .filter-toolbar,
#leftPanel .unscheduled-section,
#leftPanel .post-card,
#leftPanel .calendar-header,
#leftPanel .calendar-grid,
#leftPanel .profile-grid { width: 100%; }

.empty-state {
  text-align: center;
  color: var(--pp-muted);
  padding: 2rem 0;
}

/* ==== Profile grid media: crop to 4:5 ==== */
#leftPanel .profile-grid-item img,
#leftPanel .profile-grid-item video {
  width: 100%;
  aspect-ratio: 4 / 5;   /* enforce 4:5 tile */
  object-fit: cover;     /* crop to fill */
  display: block;
}

/* Optional: make the grid itself tidy (if not already) */
#leftPanel .profile-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr); /* or 2/4 columns to taste */
  gap: 1px;
}

/* Hide the iPhone frame entirely on real phones */
@media (max-width: 720px) {
  .iphone-frame {
    border: none;
    border-radius: 0;
    box-shadow: none;
    aspect-ratio: auto;
    height: auto;
    width: 100%;
    overflow: visible;
  }

  .iphone-frame > #leftPanel {
    border: 0;
    border-radius: 0;
    padding: 0;
    height: auto;
    overflow-y: visible;
  }
}

/* === STORIES inside the iPhone frame (desktop/web) === */
.iphone-frame > #leftPanel.stories-view {
  padding: 0;
  background: #000;
  position: relative;            /* needed for the overlay */
}

.iphone-frame > #leftPanel.stories-view .swiper {
  width: 100%;
  height: 100%;
  margin: 0;                     /* remove inner gap */
  border: 0;
  border-radius: 0;
}

.iphone-frame > #leftPanel.stories-view .swiper-wrapper,
.iphone-frame > #leftPanel.stories-view .swiper-slide {
  height: 100%;
}

.iphone-frame > #leftPanel.stories-view .swiper-slide img,
.iphone-frame > #leftPanel.stories-view .swiper-slide video {
  width: 100%;
  height: 100%;
  object-fit: cover;             /* fill frame like real stories */
  display: block;
}

/* Subtle top gradient for readability */
.iphone-frame > #leftPanel.stories-view::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 110px;
  background: linear-gradient(
    rgba(0,0,0,.55), rgba(0,0,0,0)
  );
  pointer-events: none;
  z-index: 2;
}

/* Ensure header/progress sit above the gradient */
.iphone-frame > #leftPanel.stories-view .story-header,
.iphone-frame > #leftPanel.stories-view .story-progress {
  position: relative;
  z-index: 3;
}



/* ==== EDITOR PANEL (Right Side) ==== */
#editorPanel {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  flex: 0 0 auto;
  border: 2px solid var(--pp-black);
  padding: 20px;
}

/* Allow independent scrolls and flexible height alignment */
.main-layout {
  align-items: flex-start;
  height: auto;
}

/* Textarea behavior */
#editorPanel textarea {
  resize: vertical;
  min-height: 80px;
  width: 100%;
  padding: 10px;
}

/* Prevent forced equal height panels */
#leftPanel,
#editorPanel {
  align-self: flex-start;
}

/* ==== PANELS GENERAL ==== */
.post-card,
.calendar-day,
.modal-content {
  border: 2px solid var(--pp-black);
  border-radius: var(--radius);
  background: var(--pp-white);
  transition: transform var(--transition);
}

.post-card:hover {
  transform: translateY(-2px);
}

/* ==== SELECTED FEED POST ==== */
.post-card.selected-post {
  border: 2px solid var(--ig-blue);
  box-shadow: 0 0 0 3px rgba(56,151,240,0.25);
  transform: translateY(-2px);
  transition: border 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}

.post-card.selected-post:hover {
  transform: translateY(-2px);
}
