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

@font-face {
  font-family: 'TT Bluescreens';
  src: url('../fonts/TT_Bluescreens_Trial_DemiBold.ttf') format('truetype');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg-dark: #080d14;
  --bg-card: rgba(10, 15, 24, 0.35);
  --bg-card-hover: rgba(10, 15, 24, 0.5);
  --bg-input: rgba(6, 10, 16, 0.35);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: #00d26a;

  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;

  --accent-primary: #00d26a;
  --accent-secondary: #00ff87;
  --accent-gradient: linear-gradient(135deg, #00d26a 0%, #00ff87 100%);
  --accent-glow: rgba(0, 210, 106, 0.35);

  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;

  --font-heading: 'Outfit', -apple-system, sans-serif;
  --font-body: 'Inter', -apple-system, sans-serif;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 10px 25px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 30px rgba(99, 102, 241, 0.2);

  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body.nle-body {
  width: 100vw;
  max-width: 100vw;
  height: 100vh;
  max-height: 100vh;
  margin: 0;
  padding: 0;
  overflow: hidden !important;
  font-family: var(--font-body);
  background-color: #080d14;
  background-image: 
    radial-gradient(circle at 15% 25%, rgba(0, 210, 106, 0.14) 0%, transparent 45%),
    radial-gradient(circle at 85% 75%, rgba(0, 255, 135, 0.09) 0%, transparent 50%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160'%3E%3Cg fill='none' stroke='%2300d26a' stroke-width='2.5' stroke-opacity='0.085'%3E%3Cpath d='M-40,40 Q0,80 40,40 T120,40 T200,40'/%3E%3Cpath d='M-40,80 Q0,120 40,80 T120,80 T200,80'/%3E%3Cpath d='M-40,120 Q0,160 40,120 T120,120 T200,120'/%3E%3Cpath d='M-40,0 Q0,40 40,0 T120,0 T200,0'/%3E%3C/g%3E%3C/svg%3E");
  background-size: cover, cover, 160px 160px;
  animation: bgPewDiePieDrift 60s linear infinite;
  color: var(--text-primary);
  line-height: 1.6;
}

@keyframes bgPewDiePieDrift {
  0% { background-position: 0 0, 0 0, 0 0; }
  100% { background-position: 0 0, 0 0, 160px 160px; }
}

.nle-toolbar {
  height: 62px;
  background: rgba(10, 15, 24, 0.55);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
  position: relative;
  z-index: 100;
  width: 100%;
}

.nle-brand { display: flex; align-items: center; gap: 12px; }
.brand-logo-img { height: 38px; width: auto; object-fit: contain; }
.nle-title {
  font-family: 'TT Bluescreens', sans-serif;
  font-size: 1.7rem;
  font-weight: 600;
  letter-spacing: 0.6px;
  background: linear-gradient(135deg, #ffffff 0%, #00d26a 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.preview-highlight, #previewHighlightSpan {
  background: linear-gradient(135deg, #00d26a 0%, #00ff87 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  color: #00d26a;
}

.nle-workspace {
  display: grid;
  grid-template-columns: var(--left-sidebar-w, 180px) 6px 1fr 6px var(--right-inspector-w, 340px);
  gap: 8px;
  padding: 10px 14px;
  width: 100vw;
  box-sizing: border-box;
  height: calc(100vh - 62px);
  max-height: calc(100vh - 62px);
  overflow: hidden !important;
}

/* CapCut Style Interactive Splitter Gutter Handles */
.nle-resizer {
  width: 6px;
  height: 100%;
  cursor: col-resize;
  background: transparent;
  position: relative;
  transition: background 0.15s ease;
  z-index: 20;
  user-select: none;
}

.nle-resizer::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 2px;
  height: 28px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
  transition: background 0.15s ease;
}

.nle-resizer:hover, .nle-resizer.resizing {
  background: rgba(99, 102, 241, 0.25);
  border-radius: 4px;
}

.nle-resizer:hover::after, .nle-resizer.resizing::after {
  background: var(--accent-primary);
  box-shadow: 0 0 8px var(--accent-primary);
  height: 40px;
}

.nle-feature-sidebar,
.nle-program-area,
.nle-inspector-area {
  min-width: 0;
  box-sizing: border-box;
}

.nle-feature-sidebar {
  background: rgba(10, 15, 24, 0.55);
  backdrop-filter: blur(20px) saturate(190%);
  -webkit-backdrop-filter: blur(20px) saturate(190%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.35), inset 0 1px 1px 0 rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
}

.sidebar-header {
  font-size: 0.78rem; font-weight: 800; letter-spacing: 0.5px;
  color: var(--text-muted); padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06); margin-bottom: 10px;
}

.feature-nav-list { display: flex; flex-direction: column; gap: 6px; }

.nav-feature-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05); border-radius: var(--radius-sm);
  color: var(--text-secondary); font-size: 0.85rem; font-weight: 600;
  cursor: pointer; text-align: left; transition: all 0.15s ease; user-select: none;
}
.nav-feature-btn:hover {
  background: rgba(0, 210, 106, 0.15); color: #fff; border-color: rgba(0, 210, 106, 0.35); transform: translateX(2px);
}
.nav-feature-btn.active {
  background: linear-gradient(135deg, rgba(0, 210, 106, 0.25) 0%, rgba(99, 102, 241, 0.25) 100%);
  border-color: #00d26a; color: #ffffff;
  box-shadow: 0 0 16px rgba(0, 210, 106, 0.3); font-weight: 700;
}
.nav-feature-btn .nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  color: var(--text-secondary);
  transition: color 0.15s ease, transform 0.15s ease;
}
.nav-feature-btn:hover .nav-icon {
  color: #ffffff;
}
.nav-feature-btn.active .nav-icon {
  color: #00ff87;
}
.nav-feature-btn .nav-icon svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
}

.nle-inspector-area {
  background: rgba(8, 12, 20, 0.25) !important;
  backdrop-filter: blur(20px) saturate(190%) !important;
  -webkit-backdrop-filter: blur(20px) saturate(190%) !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.2), inset 0 1px 1px 0 rgba(255, 255, 255, 0.1) !important;
  border-radius: var(--radius-md); padding: 14px; height: 100%; overflow-y: auto;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.card-nle {
  background: rgba(255, 255, 255, 0.02) !important;
  border: 1px solid rgba(255, 255, 255, 0.06) !important;
  backdrop-filter: blur(12px) !important; -webkit-backdrop-filter: blur(12px) !important;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15), inset 0 1px 1px rgba(255, 255, 255, 0.06) !important;
  border-radius: var(--radius-sm); padding: 14px; margin-bottom: 14px;
}
.inspector-section-title { font-size: 0.88rem; font-weight: 700; color: #fff; margin-bottom: 12px; }

.nle-program-area { display: flex; flex-direction: column; justify-content: flex-start; width: 100%; height: 100%; overflow-y: auto; }
.nle-program-monitor {
  width: 100%;
  background: rgba(8, 12, 20, 0.25) !important;
  backdrop-filter: blur(20px) saturate(190%) !important;
  -webkit-backdrop-filter: blur(20px) saturate(190%) !important;
  border: 1px solid rgba(0, 210, 106, 0.2) !important;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.4), 0 0 24px rgba(0, 210, 106, 0.12) !important;
}
.monitor-top-bar {
  background: rgba(10, 15, 24, 0.4) !important;
  backdrop-filter: blur(10px) !important;
  -webkit-backdrop-filter: blur(10px) !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding: 8px 14px; font-size: 0.78rem; font-weight: 600; color: var(--text-secondary); display: flex; justify-content: space-between;
}
.program-canvas-container { padding: 12px; display: flex; justify-content: center; align-items: center; background: transparent !important; }
.subtitle-preview-box {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: rgba(4, 7, 12, 0.35) !important;
  backdrop-filter: blur(8px) !important;
  -webkit-backdrop-filter: blur(8px) !important;
  border-radius: var(--radius-sm);
  border: 1px dashed rgba(0, 210, 106, 0.3) !important;
  box-shadow: inset 0 0 30px rgba(0, 210, 106, 0.08) !important;
  overflow: hidden;
}
.monitor-bottom-bar {
  background: rgba(10, 15, 24, 0.4) !important;
  backdrop-filter: blur(10px) !important;
  -webkit-backdrop-filter: blur(10px) !important;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding: 8px 14px; font-size: 0.75rem; color: var(--text-muted); display: flex; justify-content: space-between;
}
.btn-nle-export { padding: 8px 18px; font-size: 0.85rem; font-weight: 700; border-radius: var(--radius-sm); }
.btn-nle-main { width: 100%; padding: 14px; font-size: 1.05rem; font-weight: 800; border-radius: var(--radius-md); }

.jobs-dropdown-menu {
  position: absolute; top: calc(100% + 8px); right: 0; width: 480px; background: #16171e;
  border: 1px solid rgba(255, 255, 255, 0.12); border-radius: var(--radius-md);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.6); z-index: 200; overflow: hidden;
}
.jobs-dropdown-header {
  padding: 10px 14px; background: #101117; border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  display: flex; justify-content: space-between; align-items: center; font-size: 0.82rem; font-weight: 700; color: #fff;
}
.jobs-dropdown-body { max-height: 320px; overflow-y: auto; padding: 10px; }

/* ═══════════════════════════════════════════════════════
   Mobile Touch Layout (< 900px)
   ═══════════════════════════════════════════════════════ */
@media (max-width: 900px) {
  html, body.nle-body {
    overflow-y: auto !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    display: flex;
    flex-direction: column;
  }

  /* ── Header ── */
  .nle-toolbar {
    height: 44px;
    padding: 0 10px;
    position: sticky;
    top: 0;
    z-index: 1000;
    background: #16171d;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }

  /* Mobile overrides for monitor bars */
  .monitor-top-bar,
  .monitor-bottom-bar {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }

  .nle-telemetry { display: none !important; }
  .jobs-dropdown-wrapper { display: block !important; }

  #healthBadge {
    padding: 2px 6px !important;
    font-size: 0.65rem !important;
    white-space: nowrap;
  }

  #jobsDropdownBtn {
    padding: 2px 6px !important;
    font-size: 0.65rem !important;
    white-space: nowrap;
  }

  .jobs-dropdown-menu {
    width: calc(100vw - 16px) !important;
    max-width: 375px !important;
    right: -8px !important;
  }

  .jobs-dropdown-body { padding: 4px !important; }

  .jobs-table {
    width: 100% !important;
    table-layout: fixed !important;
  }

  .jobs-table th {
    padding: 6px 2px !important;
    font-size: 0.6rem !important;
    letter-spacing: 0 !important;
    text-align: center !important;
  }

  .jobs-table td {
    padding: 6px 2px !important;
    font-size: 0.65rem !important;
    text-align: center !important;
  }

  .jobs-table th:nth-child(1), .jobs-table td:nth-child(1) { width: 12% !important; text-align: left !important; }
  .jobs-table th:nth-child(2), .jobs-table td:nth-child(2) { width: 26% !important; }
  .jobs-table th:nth-child(3), .jobs-table td:nth-child(3) { width: 14% !important; }
  .jobs-table th:nth-child(4), .jobs-table td:nth-child(4) { width: 13% !important; }
  .jobs-table th:nth-child(5), .jobs-table td:nth-child(5) { width: 18% !important; font-size: 0.6rem !important; }
  .jobs-table th:nth-child(6), .jobs-table td:nth-child(6) { width: 17% !important; }

  .jobs-table .badge {
    padding: 1px 4px !important;
    font-size: 0.55rem !important;
    letter-spacing: 0 !important;
  }

  .jobs-table .play-btn {
    padding: 2px 3px !important;
    font-size: 0.62rem !important;
  }

  /* ── Workspace ── */
  .nle-workspace {
    display: flex;
    flex-direction: column;
    width: 100vw;
    flex: 1;
    /* Account for header (44px) + bottom dock (56px) */
    height: calc(100dvh - 44px - 56px);
    padding: 0;
    gap: 0;
    overflow: hidden !important;
  }

  .btn-nle-main {
    position: static !important;
    margin: 0 !important;
    flex-shrink: 0;
    width: auto !important;
    min-width: 90px;
    height: 100%;
    padding: 0 16px;
    font-size: 0.88rem;
    font-weight: 800;
    border-radius: 0;
    border-left: 1px solid rgba(255, 255, 255, 0.12);
  }

  /* Mobile overrides for monitor bars */
  .monitor-top-bar,
  .monitor-bottom-bar {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }

  .nle-resizer { display: none !important; }

  /* ── Program Monitor ── */
  .nle-program-area {
    order: 1;
    width: 100%;
    height: auto;
    flex-shrink: 0;
    background: #000;
    z-index: 900;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }

  .nle-program-monitor {
    border-radius: 0;
    border: none;
  }

  .program-canvas-container { padding: 6px; }

  .subtitle-preview-box {
    max-width: 300px;
    margin: 0 auto;
  }

  .monitor-top-bar,
  .monitor-bottom-bar {
    padding: 5px 10px;
    font-size: 0.72rem;
  }

  /* ── Inspector / Property Panel ── */
  .nle-inspector-area {
    order: 2;
    width: 100%;
    flex: 1;
    height: auto;
    overflow-y: auto !important;
    /* 120px bottom pad: next button (≈60px) + dock (52px) + breathing room */
    padding: 10px 10px 120px 10px;
    border-radius: 0;
    border: none;
    -webkit-overflow-scrolling: touch;
  }



  /* ── Bottom Feature Dock (CapCut style) ── */
  .nle-feature-sidebar {
    order: 3;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100vw;
    height: 52px;
    background: #13141b;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 0;
    padding: 0;
    z-index: 1000;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: stretch;
  }

  .sidebar-header { display: none !important; }

  /* Scrollable tabs — no border, no gaps, CapCut style */
  .feature-nav-list {
    flex: 1;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 0;
    height: 100%;
    align-items: stretch;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 0;
  }

  .feature-nav-list::-webkit-scrollbar { display: none; }

  /* CapCut-style tab button: no border, no bg, no border-radius, icon+label */
  .nav-feature-btn {
    flex-direction: column;
    gap: 3px;
    padding: 4px 2px 2px 2px;
    min-width: 60px;
    flex-shrink: 0;
    font-size: 0.58rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    text-align: center;
    white-space: nowrap;
    border-radius: 0 !important;
    bindSubtitlePreview() {
    // Throttled preview update to avoid excessive redraws on mobile
    if (!this._previewUpdateScheduled) {
      this._previewUpdateScheduled = false;
    }
    this.updateLiveSubtitlePreviewThrottled = () => {
      if (this._previewUpdateScheduled) return;
      this._previewUpdateScheduled = true;
      requestAnimationFrame(() => {
        this.updateLiveSubtitlePreview();
        this._previewUpdateScheduled = false;
      });
    };

    const inputs = [
      this.elements.captionStyleSelect,
      this.elements.textCaseSelect,
      this.elements.captionFontSelect,
      this.elements.captionColorInput,
      this.elements.highlightColorInput,
      this.elements.captionBorderColorInput,
      this.elements.captionFontSizeInput,
      this.elements.captionBorderWidthInput,
      this.elements.enableStrokeToggle,
      this.elements.enableCaptionsToggle
    ];
    inputs.forEach(input => {
      if (input) {
        input.addEventListener('change', this.updateLiveSubtitlePreviewThrottled);
        input.addEventListener('input', this.updateLiveSubtitlePreviewThrottled);
      }
    });
    window.addEventListener('resize', this.updateLiveSubtitlePreviewThrottled);
    this.updateLiveSubtitlePreviewThrottled();
  }, background: transparent !important;
    border: none !important;
    box-shadow: none !important;
  }

  .nav-feature-btn:hover {
    background: transparent !important;
    color: rgba(255, 255, 255, 0.9);
  }

  .nav-feature-btn .nav-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .nav-feature-btn .nav-icon svg {
    width: 20px;
    height: 20px;
  }
}

