/* ==========================================================================
   NIGAMACONNECT ADMIN — BROADCAST POSTS & SMARTPHONE SIMULATOR (PART 8)
   Side-by-Side Composer, 3D Titanium Smartphone Preview, Real-time Binding
   Compatible with Python Server 1 (/api/admin/posts/*)
   ========================================================================== */

:root {
  --pinned-color: #8B5CF6;
  --promoted-color: #F59E0B;
  --normal-color: #10B981;
}

.broadcast-page-content {
  padding: 32px;
  max-width: 1560px;
  margin: 0 auto;
  font-family: var(--nc-font-sans, 'Plus Jakarta Sans', sans-serif);
  color: var(--nc-text-primary, #F8FAFC);
}

/* ── Page Header ─────────────────────────────────────────────────────── */
.broadcast-header {
  margin-bottom: 28px;
}

.broadcast-header h1 {
  font-family: var(--nc-font-heading, 'Outfit', sans-serif);
  font-size: 26px;
  font-weight: 800;
  color: #FFFFFF;
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 6px 0;
  letter-spacing: -0.02em;
}

.broadcast-header h1 svg {
  color: #0FA3D9;
}

.broadcast-header p {
  color: var(--nc-text-secondary, #94A3B8);
  font-size: 14px;
  margin: 0;
}

/* ── Side-by-Side Composer Layout ────────────────────────────────────── */
.broadcast-layout {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 32px;
  align-items: start;
  margin-bottom: 36px;
}

/* ── Glass Section Card ──────────────────────────────────────────────── */
.section-card {
  background: rgba(11, 21, 40, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  padding: 28px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
}

.section-card h2 {
  font-family: var(--nc-font-heading, 'Outfit', sans-serif);
  font-size: 19px;
  font-weight: 700;
  color: #FFFFFF;
  margin: 0 0 20px 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-card h2 svg {
  color: #0FA3D9;
}

.step-label {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #0FA3D9;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ── Step 1: Distribution Type Selector ──────────────────────────────── */
.dist-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}

.dist-card {
  border: 1.5px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  padding: 16px 14px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  background: rgba(15, 29, 56, 0.55);
  position: relative;
  display: flex;
  flex-direction: column;
}

.dist-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.25);
  background: rgba(15, 29, 56, 0.75);
}

.dist-card.selected-pinned {
  border-color: #8B5CF6;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.18) 0%, rgba(109, 40, 217, 0.28) 100%);
  box-shadow: 0 4px 20px rgba(139, 92, 246, 0.25), inset 0 1px 1px rgba(255, 255, 255, 0.15);
}

.dist-card.selected-promoted {
  border-color: #F59E0B;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.18) 0%, rgba(217, 119, 6, 0.28) 100%);
  box-shadow: 0 4px 20px rgba(245, 158, 11, 0.25), inset 0 1px 1px rgba(255, 255, 255, 0.15);
}

.dist-card.selected-normal {
  border-color: #10B981;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.18) 0%, rgba(5, 150, 105, 0.28) 100%);
  box-shadow: 0 4px 20px rgba(16, 185, 129, 0.25), inset 0 1px 1px rgba(255, 255, 255, 0.15);
}

.dist-icon {
  font-size: 1.6rem;
  margin-bottom: 8px;
  display: block;
}

.dist-title {
  font-family: var(--nc-font-heading, 'Outfit', sans-serif);
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 4px;
  color: #FFFFFF;
}

.dist-desc {
  font-size: 11.5px;
  color: var(--nc-text-secondary, #94A3B8);
  line-height: 1.45;
}

.dist-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 2px 7px;
  border-radius: 12px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-pinned {
  background: rgba(139, 92, 246, 0.25);
  color: #C4B5FD;
  border: 1px solid rgba(139, 92, 246, 0.4);
}

.badge-promoted {
  background: rgba(245, 158, 11, 0.25);
  color: #FDE68A;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.badge-normal {
  background: rgba(16, 185, 129, 0.25);
  color: #A7F3D0;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.dist-card input[type="radio"] {
  display: none;
}

/* ── Form Fields ─────────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--nc-text-secondary, #94A3B8);
  margin-bottom: 7px;
}

.form-group input[type="text"],
.form-group textarea {
  width: 100%;
  padding: 12px 16px;
  background: rgba(15, 29, 56, 0.65);
  border: 1.5px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  font-family: var(--nc-font-sans, 'Plus Jakarta Sans', sans-serif);
  font-size: 14px;
  color: #F8FAFC;
  transition: all 0.2s ease;
  box-sizing: border-box;
}

.form-group input[type="text"]:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #0FA3D9;
  box-shadow: 0 0 0 3px rgba(15, 163, 217, 0.2);
  background: rgba(15, 29, 56, 0.85);
}

.form-group textarea {
  resize: vertical;
  min-height: 110px;
  line-height: 1.55;
}

/* ── Hashtag Input Wrapper ───────────────────────────────────────────── */
.hashtag-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 46px;
  padding: 8px 14px;
  border: 1.5px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  background: rgba(15, 29, 56, 0.65);
  align-items: center;
  cursor: text;
  transition: all 0.2s ease;
}

.hashtag-wrap:focus-within {
  border-color: #0FA3D9;
  box-shadow: 0 0 0 3px rgba(15, 163, 217, 0.2);
  background: rgba(15, 29, 56, 0.85);
}

.htag {
  background: rgba(15, 163, 217, 0.2);
  color: #38BDF8;
  border: 1px solid rgba(15, 163, 217, 0.35);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.htag button {
  background: none;
  border: none;
  cursor: pointer;
  color: #38BDF8;
  padding: 0;
  font-size: 14px;
  line-height: 1;
}

#hashtagInput {
  border: none;
  outline: none;
  font-size: 13.5px;
  min-width: 100px;
  color: #F8FAFC;
  background: transparent;
  flex: 1;
}

#hashtagInput::placeholder {
  color: var(--nc-text-muted, #64748B);
}

/* ── Media Grid ──────────────────────────────────────────────────────── */
.media-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 10px;
}

.media-thumb-wrap {
  position: relative;
  display: inline-block;
}

.media-thumb {
  width: 86px;
  height: 86px;
  border-radius: 12px;
  object-fit: cover;
  border: 1.5px solid rgba(255, 255, 255, 0.15);
  cursor: pointer;
  background: #020617;
}

.media-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  background: #EF4444;
  border: none;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  color: #fff;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.add-media-btn {
  width: 86px;
  height: 86px;
  border-radius: 12px;
  border: 2px dashed rgba(255, 255, 255, 0.18);
  background: rgba(15, 29, 56, 0.4);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--nc-text-secondary, #94A3B8);
  font-size: 11px;
  font-weight: 600;
  transition: all 0.2s;
  gap: 6px;
}

.add-media-btn:hover {
  border-color: #0FA3D9;
  color: #0FA3D9;
  background: rgba(15, 163, 217, 0.08);
}

.add-media-btn svg {
  width: 22px;
  height: 22px;
}

/* ── Toggle Settings ─────────────────────────────────────────────────── */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.toggle-row .label {
  font-size: 14px;
  font-weight: 600;
  color: #F8FAFC;
}

.toggle-row .sublabel {
  font-size: 12px;
  color: var(--nc-text-secondary, #94A3B8);
}

.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 24px;
  transition: 0.3s;
}

.slider::before {
  content: '';
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.3s;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

input:checked + .slider {
  background: #0FA3D9;
}

input:checked + .slider::before {
  transform: translateX(20px);
}

/* ── Publish Button ──────────────────────────────────────────────────── */
.btn-publish {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 12px;
  font-family: var(--nc-font-sans, 'Plus Jakarta Sans', sans-serif);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: linear-gradient(135deg, #0FA3D9 0%, #0284C7 100%);
  color: #fff;
  box-shadow: 0 4px 18px rgba(15, 163, 217, 0.4);
  letter-spacing: 0.02em;
}

.btn-publish:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 26px rgba(15, 163, 217, 0.55);
  background: linear-gradient(135deg, #38BDF8 0%, #0FA3D9 100%);
}

.btn-publish:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-publish svg {
  width: 20px;
  height: 20px;
}

/* ══════════════════════════════════════════════════════════════════════
   3D TITANIUM SMARTPHONE SCREEN PREVIEW MOCKUP (Right Side)
   ══════════════════════════════════════════════════════════════════════ */
.phone-preview-container {
  position: sticky;
  top: 24px;
}

.phone-mockup-wrapper {
  perspective: 1200px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.phone-mockup {
  width: 340px;
  height: 690px;
  background: #020617;
  border-radius: 48px;
  border: 5px solid #334155;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.8), 0 0 35px rgba(15, 163, 217, 0.2), inset 0 0 12px rgba(0, 0, 0, 0.8);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Dynamic Island & Speaker */
.phone-island {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: 105px;
  height: 26px;
  background: #000000;
  border-radius: 20px;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 8px;
}

.phone-camera-lens {
  width: 10px;
  height: 10px;
  background: #0d1b2a;
  border-radius: 50%;
  border: 1px solid #1e293b;
}

/* Status Bar */
.phone-status-bar {
  height: 42px;
  padding: 0 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--nc-font-mono, 'JetBrains Mono', monospace);
  font-size: 11px;
  font-weight: 600;
  color: #FFFFFF;
  z-index: 90;
}

.phone-status-icons {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* App Header inside Mockup */
.phone-app-header {
  padding: 8px 18px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(11, 21, 40, 0.8);
}

.phone-app-title {
  font-family: var(--nc-font-heading, 'Outfit', sans-serif);
  font-size: 15px;
  font-weight: 800;
  background: linear-gradient(135deg, #0FA3D9, #38BDF8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Mobile Screen Viewport / Feed Scroll */
.phone-screen-feed {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  background: #020617;
}

.phone-screen-feed::-webkit-scrollbar {
  width: 3px;
}
.phone-screen-feed::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}

/* Simulated Feed Post Card */
.mockup-post-card {
  background: rgba(15, 29, 56, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 18px;
  padding: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  position: relative;
}

.mockup-author-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.mockup-author-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mockup-author-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1.5px solid #0FA3D9;
  background: #0B1528;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.mockup-author-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.mockup-author-name {
  font-size: 13px;
  font-weight: 700;
  color: #FFFFFF;
  display: flex;
  align-items: center;
  gap: 4px;
}

.mockup-verified-badge {
  color: #38BDF8;
  font-size: 12px;
}

.mockup-time {
  font-size: 10.5px;
  color: var(--nc-text-muted, #64748B);
}

.mockup-post-pill {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 10px;
  display: inline-block;
}

.mockup-title {
  font-family: var(--nc-font-heading, 'Outfit', sans-serif);
  font-size: 14px;
  font-weight: 700;
  color: #FFFFFF;
  margin-bottom: 6px;
  line-height: 1.35;
}

.mockup-content {
  font-size: 12px;
  color: #CBD5E1;
  line-height: 1.5;
  margin-bottom: 10px;
  white-space: pre-wrap;
  word-break: break-word;
}

.mockup-hashtags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 10px;
}

.mockup-htag {
  font-size: 11px;
  color: #38BDF8;
  font-weight: 600;
}

.mockup-media-container {
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 10px;
  max-height: 180px;
  background: #020617;
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: none;
}

.mockup-media-container img,
.mockup-media-container video {
  width: 100%;
  height: 100%;
  max-height: 180px;
  object-fit: cover;
  display: block;
}

.mockup-actions-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 11px;
  color: var(--nc-text-secondary, #94A3B8);
}

.mockup-action-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
}

/* ── Active Broadcast Posts Table ────────────────────────────────────── */
.posts-table-wrap {
  overflow-x: auto;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  background: rgba(15, 29, 56, 0.85);
  padding: 14px 18px;
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--nc-text-secondary, #94A3B8);
  letter-spacing: 0.05em;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

td {
  padding: 16px 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 14px;
  vertical-align: middle;
  color: #F8FAFC;
}

tr:hover td {
  background: rgba(255, 255, 255, 0.03);
}

.badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.btn-sm {
  padding: 6px 14px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  transition: all 0.2s;
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #F87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
  background: #EF4444;
  color: #FFFFFF;
}

.btn-type {
  background: rgba(15, 163, 217, 0.15);
  color: #38BDF8;
  border: 1px solid rgba(15, 163, 217, 0.3);
  margin-right: 8px;
}

.btn-type:hover {
  background: #0FA3D9;
  color: #FFFFFF;
}

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--nc-text-muted, #64748B);
}

/* ── Spinner ─────────────────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── Responsive Viewports ────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .broadcast-layout {
    grid-template-columns: 1fr;
  }
  .phone-preview-container {
    position: static;
    margin-top: 24px;
  }
}

@media (max-width: 768px) {
  .broadcast-page-content {
    padding: 16px;
  }
  .dist-grid {
    grid-template-columns: 1fr;
  }
  .phone-mockup {
    width: 300px;
    height: 600px;
  }
}

/* ── Light Theme Overrides ───────────────────────────────────────────── */
:root[data-theme="light"] .broadcast-page-content {
  color: #0F172A;
}

:root[data-theme="light"] .section-card,
:root[data-theme="light"] .broadcast-composer-card,
:root[data-theme="light"] .mockup-post-card {
  background: #FFFFFF !important;
  border: 1px solid rgba(15, 23, 42, 0.09) !important;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.05) !important;
  color: #0F172A !important;
}

:root[data-theme="light"] .section-card-title,
:root[data-theme="light"] .composer-title {
  color: #0F172A !important;
}

:root[data-theme="light"] .section-card-desc,
:root[data-theme="light"] .composer-subtitle {
  color: #475569 !important;
}
