/* ==========================================================================
   ✨ HAPPYSTAR STUDIO - MASTER GLOBAL STYLESHEET
   ========================================================================== */

/* 🎨 1. Premium HeyGen-Inspired Minimal Design Tokens */
:root {
    --bg-main: #0a0a0c;
    --bg-sidebar: #121216;
    --bg-card: #18181f;
    --bg-card-hover: #1f1f29;
    --border-color: #262630;
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --accent-green: #10b981;
    --accent-purple: #8b5cf6;
    --accent-burn: #ef4444;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    overflow-x: hidden;
}

.studio-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* 🧭 2. SIDEBAR NAVIGATION LAYOUT */
.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 24px;
}

.studio-brand h2 {
    font-size: 1.3rem;
    font-weight: 700;
}

.studio-brand span {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: block;
    margin-top: 4px;
}

.sidebar-menu {
    margin-top: 40px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-grow: 1;
}

.menu-item {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.menu-item:hover, .menu-item.active {
    background-color: var(--bg-card);
    color: var(--text-primary);
}

.menu-item.highlight {
    border: 1px dashed var(--accent-burn);
    color: #f87171;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.avatar-icon {
    background-color: var(--accent-purple);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

/* 🪐 3. MAIN VIEWPORT & LOBBY HEADERS */
/* 🚀 Main layout container expansion */
#storyboardColumn, 
#storyboardContainer, 
.studio-container, 
.main-content {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    padding: 24px 32px !important;
}
#stage-workspace, 
.engine-workspace {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
}

/* 🎯 Default panel styling */
.engine-panel, 
#storyboardColumn, 
#storyboardContainer {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

.lobby-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 24px;
}

.header-title h1 {
    font-size: 2rem;
    font-weight: 600;
    margin-bottom: 6px;
}

.header-title p {
    color: var(--text-secondary);
}

.clinic-logo-img {
    height: 45px;
    width: auto;
    object-fit: contain;
    display: block;
}

.logo-text {
    font-weight: bold;
    display: block;
    color: var(--text-primary);
}

.logo-sub {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* 🎛️ 4. COMMAND MODULES GRID (Lobby Cards) */
.modules-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
}

.module-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    position: relative;
    display: flex;
    flex-direction: column;
    transition: all 0.2s ease-in-out;
}

.module-card:hover {
    transform: translateY(-4px);
    border-color: #3b3b4f;
    background-color: var(--bg-card-hover);
}

.card-badge {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 0.7rem;
    font-weight: bold;
    padding: 4px 8px;
    border-radius: 6px;
}

.card-badge.green { background: rgba(16, 185, 129, 0.15); color: var(--accent-green); }
.card-badge.purple { background: rgba(139, 92, 246, 0.15); color: var(--accent-purple); }
.card-badge.gray { background: rgba(156, 163, 175, 0.15); color: var(--text-secondary); }
.card-badge.dynamic { background: rgba(239, 68, 68, 0.15); color: var(--accent-burn); }

.card-icon {
    font-size: 2rem;
    margin-bottom: 16px;
}

.module-card h3 {
    font-size: 1.2rem;
    margin-bottom: 10px;
    font-weight: 600;
}

.module-card p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 24px;
    flex-grow: 1;
}

.card-btn {
    display: block;
    text-align: center;
    background-color: #2e2e3a;
    color: var(--text-primary);
    text-decoration: none;
    padding: 12px;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 500;
    border: none;
    transition: background 0.2s;
    cursor: pointer;
}

.card-btn:hover:not(:disabled) {
    background-color: #3e3e4f;
}

.card-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-green { background-color: var(--accent-green); color: #0a0a0c; font-weight: bold; }
.btn-green:hover { background-color: #059669 !important; }

.btn-burn { background-color: transparent; border: 1px solid var(--accent-burn); color: var(--accent-burn); }
.btn-burn:hover { background-color: var(--accent-burn) !important; color: #fff; }

/* ==========================================================================
   🎬 5. SCRIPT ENGINE & DYNAMICS INTERFACE ADD-ONS
   ========================================================================== */

/* 2-Column Internal Panel Layout inside the .main-content view */
.engine-workspace {
    display: block;
    width: 100%;
    margin-top: 24px;
}

.engine-panel {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    width: 100% !important;
    max-width: 100% !important;
}

#stage-workspace {
    width: 100% !important;
}

/* FORM LABELS & STRUCTURAL CONTROLS */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* INPUTS, TEXTAREAS, DROPDOWNS */
.form-control {
    width: 100%;
    background-color: var(--bg-sidebar);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    padding: 14px;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s ease-in-out;
}

.form-control:focus {
    border-color: var(--accent-purple);
}

textarea.form-control {
    resize: vertical; /* Allows vertical dragging only */
    overflow-y: auto; /* Adds vertical scrollbar when text overflows */
    min-height: 80px;  /* Prevents shrinking too small */
    max-height: 500px; /* Optional limit to keep page layout clean */
    line-height: 1.6;
}

/* THE GLOBAL LANGUAGE PILLS ROW */
.pill-container {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.pill {
    background-color: var(--bg-sidebar);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

.pill:hover {
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

.pill.active {
    background-color: var(--accent-purple);
    border-color: var(--accent-purple);
    color: #ffffff;
}

/* ==========================================================================
   🌐 6. GLOBAL LANGUAGE DROPDOWN MENU
   ========================================================================== */
.dropdown-wrapper {
    position: relative;
    display: inline-block;
}

.dropdown-content {
    display: none;
    position: absolute;
    background-color: var(--bg-card-hover);
    min-width: 150px;
    box-shadow: 0px 8px 24px rgba(0,0,0,0.8);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    z-index: 100;
    top: 110%;
    left: 0;
    overflow: hidden;
}

.dropdown-content.show {
    display: block;
}

.dropdown-item {
    background: transparent;
    color: var(--text-secondary);
    padding: 12px 16px;
    text-align: left;
    border: none;
    width: 100%;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    transition: 0.2s;
}

.dropdown-item:hover {
    background-color: var(--accent-purple);
    color: #ffffff;
}

/* INTERACTIVE STORYBOARD REFLECTION CARDS */
.scene-card {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    background: #18181b;
    border: 1px solid #27272a;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}

.scene-actions-grid, 
.scene-card > div[style*="display: flex"] {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 20px !important;
    width: 100% !important;
    margin-top: 16px !important;
}

.scene-card strong {
    color: var(--text-primary);
    font-size: 0.95rem;
}

.scene-meta {
    margin: 8px 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.scene-text-highlight {
    color: var(--accent-green);
    font-weight: 500;
}

.btn-purple {
    background-color: #8b5cf6; /* Vibrant Purple */
    color: #ffffff;
}
.btn-purple:hover {
    background-color: #7c3aed; /* Slightly Darker Purple */
}

/* Divider Taper */
hr {
    border: 0;
    height: 1px;
    background: var(--border-color);
    margin: 15px 0;
}

/* 🧘‍♂️ Zen Focus Workspace Stylings */
.expand-trigger-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 2px 8px;
    font-size: 0.75rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}
.expand-trigger-btn:hover {
    color: var(--accent-green);
    border-color: var(--accent-green);
    background: rgba(0, 255, 170, 0.05);
}

.zen-overlay {
    display: none; /* Secretly hidden until activated */
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(10, 10, 12, 0.85);
    backdrop-filter: blur(8px);
    z-index: 9999;
    align-items: center;
    justify-content: center;
}
.zen-overlay.active {
    display: flex;
}

.zen-modal-card {
    background: #16161a;
    border: 1px solid #2a2a32;
    border-radius: 12px;
    width: 80%;
    max-width: 900px;
    height: 70vh;
    display: flex;
    flex-direction: column;
    padding: 24px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.5);
}

.zen-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
.zen-modal-header h3 {
    font-weight: 600;
    color: #ffffff;
    margin: 0;
}

.zen-close-btn {
    background: #00ffaa;
    color: #000000;
    border: none;
    padding: 6px 16px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: transform 0.2s;
}
.zen-close-btn:hover {
    transform: scale(1.03);
}

.zen-large-text {
    flex-grow: 1;
    background: #0e0e11;
    border: 1px solid #22222a;
    border-radius: 8px;
    color: #e4e4e7;
    font-family: 'Inter', sans-serif;
    font-size: 1.1rem;
    line-height: 1.6;
    padding: 16px;
    resize: none;
    outline: none;
}
.zen-large-text:focus {
    border-color: #00ffaa;
    box-shadow: 0 0 10px rgba(0, 255, 170, 0.1);
}

/* 1. Fix Top Stage Navigation Tabs */
.stage-nav-bar, 
.nav-tabs-container,
div[style*="1. Concept & Persona"] {
    width: 100% !important;
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    gap: 8px !important;
    background: #09090b !important;
    padding: 12px 16px !important;
    border: 1px solid #27272a !important;
    border-radius: 8px !important;
    margin-bottom: 20px !important;
    overflow-x: auto !important;
}

.stage-tab, 
.nav-tab {
    flex-shrink: 0 !important;
    white-space: nowrap !important;
    padding: 8px 14px !important;
    font-size: 0.85rem !important;
    border-radius: 6px !important;
}

/* 2. Responsive 9:16 Media Slots Grid */
.scene-media-grid {
  display: flex;
  gap: 16px;
  justify-content: center;
  align-items: center;
  margin-top: 12px;
}

/* 3. Force 9:16 Vertical Portrait Aspect Ratio */
.media-slot-card {
  width: 140px;                 /* Fixed portrait width */
  aspect-ratio: 9 / 16;         /* Locks vertical drama ratio */
  background: #18181b;
  border: 1px dashed #3f3f46;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.media-slot-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;            /* Full vertical frame fit */
  border-radius: 7px;
}

/* Vertical 9:16 Drama Slot Container */
.storyboard-media-slot {
  width: 130px;
  height: 231px; /* Enforces strict 9:16 ratio */
  background: #18181b;
  border: 1px dashed #3f3f46;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  transition: border-color 0.2s ease;
}

.storyboard-media-slot:hover {
  border-color: #10b981;
}

.storyboard-media-slot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Live Radar Spinner & Cyber Glow */
.radar-spinner {
  width: 50px;
  height: 50px;
  border: 3px solid rgba(0, 255, 170, 0.15);
  border-radius: 50%;
  border-top-color: #00ffaa;
  animation: spin 1s infinite linear;
  box-shadow: 0 0 15px rgba(0, 255, 170, 0.3);
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.monitor-rendering-active {
  border-color: #00ffaa !important;
  box-shadow: 0 0 20px rgba(0, 255, 170, 0.25) !important;
}