/* ==========================================================================
   1. COLOR PALETTE & GLOBAL DESIGN SYSTEM
   ========================================================================== */
:root {
  --bg-main: #0f1117;
  --bg-card: #181b24;
  --bg-sidebar: #13151d;
  --bg-header: #13151d;
  --border-color: #272b38;
  
  --accent-blue: #2563eb;
  --accent-blue-hover: #1d4ed8;
  --accent-cyan: #06b6d4;
  --accent-green: #10b981;
  --accent-danger: #ef4444;

  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;

  --paper-bg: #ffffff;
  --paper-text: #000000;
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-screenplay: 'Courier Prime', 'Courier New', Courier, monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  font-family: var(--font-ui);
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   2. BRANDING & LOGO INTEGRATION (sluggrs.)
   ========================================================================== */
.brand-logo-wrap {
  display: flex;
  align-items: center;
}

.brand-logo-wrap.center {
  justify-content: center;
}

.brand-logo-img {
  height: 52px;
  width: auto;
  object-fit: contain;
}

.brand-logo-img-sm {
  height: 32px;
  width: auto;
  object-fit: contain;
}

.brand-tagline {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 10px;
}

.header-divider {
  color: var(--border-color);
  margin: 0 8px;
}

/* ==========================================================================
   3. BUTTONS, INPUTS & TYPOGRAPHY
   ========================================================================== */
.btn-primary {
  background-color: var(--accent-blue);
  color: #fff;
  border: none;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn-primary:hover {
  background-color: var(--accent-blue-hover);
}

.btn-primary-sm {
  background-color: var(--accent-blue);
  color: #fff;
  border: none;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.8rem;
  cursor: pointer;
}

.btn-secondary, .btn-secondary-sm {
  background-color: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
}

.btn-secondary:hover, .btn-secondary-sm:hover {
  border-color: var(--text-muted);
}

.btn-link {
  background: none;
  border: none;
  color: var(--accent-cyan);
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
}

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
}

.btn-icon:hover {
  color: #fff;
  background-color: var(--border-color);
}

.full-width {
  width: 100%;
}

.text-dim { color: var(--text-muted); font-size: 0.88rem; }
.text-danger { color: var(--accent-danger) !important; }

/* ==========================================================================
   4. MODAL OVERLAYS & AUTH FORM
   ========================================================================== */
.modal-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal-box {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  width: 100%;
  max-width: 460px;
  padding: 28px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
}

.auth-box {
  text-align: center;
}

.auth-box h2 {
  font-size: 1.2rem;
  margin: 20px 0 16px 0;
}

.form-group {
  text-align: left;
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  padding: 10px 14px;
  background-color: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 0.9rem;
}

.form-group input:focus {
  outline: none;
  border-color: var(--accent-cyan);
}

.form-group.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
}

.toggle-checkbox {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--accent-blue);
}

.toggle-label {
  font-size: 0.88rem;
  color: var(--text-main);
  margin-bottom: 0 !important;
  cursor: pointer;
}

.auth-toggle {
  margin-top: 20px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

.input-with-btn {
  display: flex;
  gap: 8px;
}

.input-with-btn input {
  flex-grow: 1;
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: #fff;
}

/* ==========================================================================
   5. MAIN HUB DASHBOARD
   ========================================================================== */
.view-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.hub-header {
  height: 60px;
  background-color: var(--bg-header);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}

.user-pill {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-right: 12px;
  font-weight: 600;
}

.hub-container {
  display: flex;
  flex-grow: 1;
}

.hub-sidebar {
  width: 240px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hub-nav-btn {
  background: transparent;
  color: var(--text-muted);
  border: none;
  text-align: left;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.hub-nav-btn:hover, .hub-nav-btn.active {
  color: #fff;
  background-color: var(--bg-card);
}

.nav-divider {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 12px 0;
}

.hub-content {
  flex-grow: 1;
  padding: 36px 48px;
}

.hub-title-row {
  margin-bottom: 28px;
}

.hub-title-row h1 {
  font-size: 1.75rem;
  font-weight: 800;
}

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.project-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.15s ease, border-color 0.15s ease;
  cursor: pointer;
}

.project-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent-cyan);
}

.project-card-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 6px;
}

.project-card-meta {
  font-size: 0.78rem;
  color: var(--text-dim);
}

.project-card-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 20px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
}

.notice-banner {
  background-color: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-top: 24px;
}

/* ==========================================================================
   6. SCREENPLAY STUDIO EDITOR & STICKY TOOLBARS
   ========================================================================== */
.studio-header {
  height: 52px;
  background-color: var(--bg-header);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  position: sticky;
  top: 0;
  z-index: 200;
}

.studio-header-left, .studio-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.studio-project-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
}

.role-pill {
  font-size: 0.7rem;
  background: var(--border-color);
  color: var(--text-muted);
  padding: 2px 8px;
  border-radius: 12px;
  text-transform: uppercase;
  font-weight: 700;
}

.collab-pills-wrap {
  display: flex;
  gap: 6px;
  align-items: center;
}

.collab-pill {
  font-size: 0.75rem;
  background-color: rgba(6, 182, 212, 0.15);
  color: var(--accent-cyan);
  border: 1px solid rgba(6, 182, 212, 0.3);
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 600;
}

.studio-menu-nav {
  display: flex;
  margin-left: 8px;
}

.menu-item-wrap {
  position: relative;
}

.menu-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 6px 12px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius-sm);
}

.menu-btn:hover {
  color: #fff;
  background-color: var(--bg-card);
}

.menu-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  min-width: 200px;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
  display: none;
  flex-direction: column;
  z-index: 500;
  padding: 6px;
}

.menu-item-wrap:hover .menu-dropdown {
  display: flex;
}

.menu-dropdown button {
  background: transparent;
  border: none;
  color: var(--text-main);
  text-align: left;
  padding: 8px 12px;
  font-size: 0.82rem;
  cursor: pointer;
  border-radius: 4px;
  display: flex;
  justify-content: space-between;
}

.menu-dropdown button:hover {
  background-color: var(--accent-blue);
  color: #fff;
}

.menu-dropdown hr {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 4px 0;
}

.shortcut {
  color: var(--text-dim);
  font-size: 0.75rem;
}

/* Sticky Formatting Toolbar */
.editor-toolbar {
  height: 48px;
  background-color: var(--bg-sidebar);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 10px;
  position: sticky;
  top: 52px;
  z-index: 190;
}

.format-shortcuts-group {
  display: flex;
  gap: 4px;
}

.format-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  padding: 5px 10px;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}

.format-btn:hover {
  color: #fff;
  background-color: var(--bg-card);
}

.format-btn.active {
  background-color: var(--accent-cyan);
  color: #000;
  font-weight: 700;
}

.btn-shortcut {
  font-size: 0.68rem;
  opacity: 0.65;
  font-weight: 400;
}

.toolbar-divider {
  width: 1px;
  height: 24px;
  background-color: var(--border-color);
}

.style-toggles-group {
  display: flex;
  gap: 4px;
}

/* Far-Right Controls Group */
.utility-controls-group {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.style-btn {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.style-btn:hover {
  background-color: var(--bg-card);
  color: #fff;
}

.style-btn.active {
  background-color: var(--accent-blue) !important;
  border-color: var(--accent-blue) !important;
  color: #ffffff !important;
  box-shadow: 0 0 8px rgba(37, 99, 235, 0.4);
}

.zoom-dropdown {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  color: #fff;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  outline: none;
}

/* ==========================================================================
   7. SCREENPLAY PAPER CANVAS & CELTX LINE SPACING RULES
   ========================================================================== */
.studio-workspace {
  flex-grow: 1;
  background-color: #0a0b0e;
  overflow-y: auto;
  position: relative;
  padding: 40px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.editor-panel {
  width: 100%;
  display: flex;
  justify-content: center;
}

.paper-wrapper {
  display: flex;
  flex-direction: column;
  gap: 30px;
  transition: transform 0.2s ease;
  transform-origin: top center;
}

.screenplay-page {
  width: 8.5in;
  min-height: 11in;
  background-color: var(--paper-bg);
  color: var(--paper-text);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  padding: 1in 1in 1in 1.5in;
  font-family: var(--font-screenplay);
  font-size: 12pt;
  line-height: 1.0;
  position: relative;
}

/* Page Number Header */
.page-number-header {
  position: absolute;
  top: 0.5in;
  right: 1in;
  font-family: var(--font-screenplay);
  font-size: 12pt;
  color: #000;
}

/* Title Page Layout */
.title-page {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.title-page-center {
  margin-top: 3.2in;
  text-align: center;
}

.title-input {
  font-family: var(--font-screenplay);
  font-size: 14pt;
  font-weight: bold;
  text-transform: uppercase;
  text-align: center;
  border: none;
  outline: none;
  width: 100%;
  background: transparent;
  margin-bottom: 18pt;
}

.byline-input {
  font-family: var(--font-screenplay);
  font-size: 12pt;
  text-align: center;
  border: none;
  outline: none;
  width: 100%;
  background: transparent;
  margin-bottom: 12pt;
}

.author-input {
  font-family: var(--font-screenplay);
  font-size: 12pt;
  text-align: center;
  border: none;
  outline: none;
  width: 100%;
  background: transparent;
}

.title-page-spacing-gap {
  height: 24pt;
}

.date-input {
  font-size: 10pt;
}

.title-page-bottom-wrap {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  width: 100%;
}

.title-page-bottom-left { width: 3.2in; }
.title-page-bottom-right { width: 3.2in; text-align: right; }

.meta-input {
  font-family: var(--font-screenplay);
  font-size: 10pt;
  border: none;
  outline: none;
  width: 100%;
  background: transparent;
}

.meta-input.right-align {
  text-align: right;
}

/* Editable Screenplay Elements (Strict Celtx Formatting) */
.script-content-editable {
  outline: none;
  min-height: 9in;
}

.script-element {
  margin-bottom: 12pt;
  min-height: 12pt;
  word-wrap: break-word;
  line-height: 1.0;
}

.script-element.scene-heading {
  text-transform: uppercase;
  font-weight: bold;
  margin-top: 12pt;
  margin-bottom: 12pt;
  background-color: rgba(6, 182, 212, 0.08);
  padding: 1px 2px;
}

.script-element.action {
  margin-left: 0;
  margin-right: 0;
}

.script-element.character {
  text-transform: uppercase;
  margin-left: 2.2in;
  margin-top: 12pt;
  margin-bottom: 0;
}

.script-element.dialogue {
  margin-left: 1.0in;
  margin-right: 1.5in;
  margin-bottom: 12pt;
}

.script-element.parenthetical {
  margin-left: 1.6in;
  margin-right: 2.0in;
  margin-bottom: 0;
}

.script-element.transition {
  text-transform: uppercase;
  text-align: right;
  margin-top: 12pt;
  margin-bottom: 12pt;
}

/* Guest Banner */
.guest-banner {
  background-color: #312e81;
  color: #e0e7ff;
  width: 100%;
  padding: 10px;
  text-align: center;
  font-size: 0.88rem;
  position: sticky;
  top: 100px;
  z-index: 100;
}

/* Panel Containers for Characters & Schedule */
.panel-inner-container {
  width: 100%;
  max-width: 900px;
  padding: 20px;
}

.panel-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.inline-add-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 16px;
  border-radius: var(--radius-sm);
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.inline-add-box input {
  flex-grow: 1;
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: #fff;
}

.character-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 10px;
}

.character-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 16px;
}

.schedule-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.schedule-table th, .schedule-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.88rem;
}

.schedule-table th {
  background-color: var(--bg-sidebar);
  color: var(--text-muted);
}

.drag-row {
  cursor: grab;
}

.drag-row:active {
  cursor: grabbing;
  background-color: rgba(37, 99, 235, 0.2);
}

.drag-handle {
  color: var(--text-dim);
  user-select: none;
}

/* Sticky Bottom Status Bar */
.studio-footer-bar {
  height: 32px;
  background-color: var(--bg-header);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  font-size: 0.78rem;
  color: var(--text-muted);
  position: sticky;
  bottom: 0;
  z-index: 200;
}

.dot-separator { margin: 0 8px; }