/*
  ANIMATION STUDIO — CANVA-STYLE DESIGN SYSTEM
  Dark mode, icon-first navigation, canvas-centered layout
*/

:root {
    --bg-app:       #141414;
    --bg-surface:   #1c1c1c;
    --bg-panel:     #1c1c1c;
    --bg-elevated:  #242424;
    --bg-hover:     #2a2a2a;

    --border:       rgba(255,255,255,0.07);
    --border-hover: rgba(255,255,255,0.14);

    --text-main:    #f0f0f0;
    --text-muted:   #888;
    --text-dim:     #555;

    --accent:       #4f78ff;
    --accent-soft:  rgba(79,120,255,0.12);
    --accent-glow:  rgba(79,120,255,0.25);

    --success:      #34d399;
    --warning:      #fbbf24;
    --danger:       #f87171;

    --radius-sm:    6px;
    --radius-md:    10px;
    --radius-lg:    14px;
    --radius-xl:    18px;

    --shadow-sm:    0 2px 8px rgba(0,0,0,0.4);
    --shadow-md:    0 4px 20px rgba(0,0,0,0.5);
    --shadow-lg:    0 8px 40px rgba(0,0,0,0.6);

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

    /* Layout dimensions */
    --icon-rail-w:  60px;
    --drawer-w:     300px;
    --inspector-w:  300px;
    --timeline-h:   200px;
    --strip-h:      48px;
    --header-h:     52px;
}

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

body {
    background: var(--bg-app);
    color: var(--text-main);
    font-family: var(--font-ui);
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

button { cursor: pointer; font-family: inherit; }
input  { font-family: inherit; }

/* ══════════════════════════════════════════════════════════════════
   TOP HEADER
══════════════════════════════════════════════════════════════════ */

.studio-header {
    height: var(--header-h);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    gap: 12px;
    z-index: 100;
    position: relative;
}

.header-left  { display: flex; align-items: center; gap: 16px; }
.header-right { display: flex; align-items: center; gap: 8px; }

/* Logo */
.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 700;
    background: linear-gradient(135deg, #fff 30%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    white-space: nowrap;
}

/* Editable project name */
.project-name-input {
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    padding: 4px 8px;
    max-width: 180px;
    transition: all 0.15s;
}
.project-name-input:hover { border-color: var(--border-hover); color: var(--text-main); }
.project-name-input:focus { border-color: var(--accent); color: var(--text-main); outline: none; background: var(--bg-elevated); }

/* Header buttons */
.hdr-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 500;
    transition: all 0.15s;
}
.hdr-btn:hover { background: var(--bg-hover); border-color: var(--border-hover); }
.hdr-btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.hdr-btn-primary:hover { background: #3d65f0; border-color: #3d65f0; }


/* ══════════════════════════════════════════════════════════════════
   MAIN WORKSPACE
══════════════════════════════════════════════════════════════════ */

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.studio-workspace {
    flex: 1;
    display: flex;
    min-height: 0;
}

/* ══════════════════════════════════════════════════════════════════
   ICON RAIL — Canva-style vertical nav
══════════════════════════════════════════════════════════════════ */

.icon-rail {
    width: var(--icon-rail-w);
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 0;
    gap: 2px;
    flex-shrink: 0;
    z-index: 50;
}

.rail-btn {
    width: 46px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    border-radius: var(--radius-md);
    padding: 8px 4px;
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    transition: all 0.15s;
}
.rail-btn i { font-size: 1.1rem; }
.rail-btn:hover { background: var(--bg-hover); color: var(--text-main); }
.rail-btn.active { background: var(--accent-soft); color: var(--accent); }

.rail-sep {
    width: 32px;
    height: 1px;
    background: var(--border);
    margin: 6px 0;
}

/* ══════════════════════════════════════════════════════════════════
   CONTENT DRAWER — slides in from the left
══════════════════════════════════════════════════════════════════ */

.content-drawer {
    width: 0;
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}
.content-drawer.open { width: var(--drawer-w); }

.drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.drawer-title {
    font-family: var(--font-heading);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
}

.drawer-close-btn {
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    transition: all 0.15s;
}
.drawer-close-btn:hover { background: var(--bg-hover); color: var(--text-main); }

.drawer-section {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

/* Upload section */
.upload-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex: 1;
    padding: 32px 20px;
    color: var(--text-muted);
    text-align: center;
}
.upload-icon { font-size: 2.5rem; color: var(--text-dim); margin-bottom: 4px; }
.upload-area p { font-size: 0.9rem; }
.upload-hint { font-size: 0.75rem; color: var(--text-dim); }
.btn-outline {
    margin-top: 12px;
    background: transparent;
    border: 1px solid var(--border-hover);
    color: var(--text-main);
    border-radius: var(--radius-md);
    padding: 8px 20px;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.15s;
}
.btn-outline:hover { background: var(--bg-hover); border-color: var(--accent); color: var(--accent); }

/* ══════════════════════════════════════════════════════════════════
   VIEWPORT — the canvas stage
══════════════════════════════════════════════════════════════════ */

.viewport-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-app);
    position: relative;
    min-width: 0;
}

.viewport-toolbar {
    height: 38px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    flex-shrink: 0;
}

.viewport-label {
    font-size: 0.75rem;
    color: var(--text-dim);
    font-weight: 500;
}

.viewport-tools { display: flex; gap: 6px; }

.vp-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    transition: all 0.15s;
}
.vp-btn:hover { background: var(--bg-hover); color: var(--text-main); border-color: var(--border-hover); }

/* 3D Viewport fills everything below the toolbar */
#three-viewport {
    position: absolute;
    inset: 38px 0 0 0;
    display: block;
}
#three-canvas { width: 100%; height: 100%; display: block; }

/* AI Prompt bar */
#ai-command-overlay {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: min(560px, 85%);
    z-index: 200;
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(18, 18, 18, 0.92);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(79,120,255,0.25);
    border-radius: var(--radius-xl);
    padding: 8px 8px 8px 16px;
    box-shadow: var(--shadow-lg), 0 0 0 1px rgba(79,120,255,0.1);
}
.ai-icon { color: var(--accent); font-size: 0.9rem; flex-shrink: 0; }
#ai-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 0.9rem;
    outline: none;
}
#ai-input::placeholder { color: var(--text-dim); }
#ai-exe {
    background: var(--accent);
    border: none;
    color: #fff;
    border-radius: var(--radius-md);
    padding: 7px 16px;
    font-size: 0.82rem;
    font-weight: 600;
    transition: all 0.15s;
    flex-shrink: 0;
}
#ai-exe:hover { background: #3d65f0; }

/* ══════════════════════════════════════════════════════════════════
   RIGHT INSPECTOR PANEL
══════════════════════════════════════════════════════════════════ */

.inspector-panel {
    width: 0;
    background: var(--bg-panel);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: row;
    flex-shrink: 0;
    position: relative;
    transition: width 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: visible; /* allow tab to stick out */
}
.inspector-panel.open { width: var(--inspector-w); }

/* The tab that always sticks out — always clickable */
.inspector-tab {
    position: absolute;
    left: -32px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 48px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-right: none;
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
    color: var(--text-muted);
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    z-index: 10;
}
.inspector-tab:hover { color: var(--accent); background: var(--bg-elevated); }
.inspector-panel.open .inspector-tab { color: var(--accent); }

.inspector-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

/* Tabs */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.tab-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-dim);
    padding: 10px 8px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    transition: all 0.15s;
}
.tab-btn:hover { color: var(--text-muted); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); background: var(--accent-soft); }

.panel-content { flex: 1; overflow-y: auto; }

/* Empty state */
.prop-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 48px 20px;
    color: var(--text-dim);
    text-align: center;
}
.prop-empty i { font-size: 1.8rem; opacity: 0.4; }
.prop-empty span { font-size: 0.82rem; }

/* ══════════════════════════════════════════════════════════════════
   TIMELINE STRIP — always visible control bar
══════════════════════════════════════════════════════════════════ */

.timeline-strip {
    height: var(--strip-h);
    background: var(--bg-surface);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 16px;
    flex-shrink: 0;
    z-index: 30;
}

.strip-controls { display: flex; align-items: center; gap: 4px; }

.strip-btn {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    transition: all 0.15s;
}
.strip-btn:hover { background: var(--bg-hover); color: var(--text-main); }
.play-btn { background: var(--accent-soft); color: var(--accent); font-size: 0.75rem; }
.play-btn:hover { background: var(--accent); color: #fff; }

.strip-scrubber { flex: 1; }
.strip-scrubber input[type="range"] {
    width: 100%;
    accent-color: var(--accent);
    cursor: pointer;
}

.strip-frame {
    font-size: 0.75rem;
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    font-family: 'Courier New', monospace;
}

.strip-expand-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    padding: 5px 12px;
    font-size: 0.75rem;
    font-weight: 600;
    transition: all 0.15s;
    white-space: nowrap;
}
.strip-expand-btn:hover { background: var(--bg-hover); color: var(--text-main); border-color: var(--border-hover); }
.strip-expand-btn i { font-size: 0.65rem; transition: transform 0.2s; }
.strip-expand-btn.expanded i { transform: rotate(180deg); }

/* ══════════════════════════════════════════════════════════════════
   TIMELINE PANEL
══════════════════════════════════════════════════════════════════ */

.studio-footer {
    height: 0;
    background: var(--bg-surface);
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: height 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}
.studio-footer.open { height: var(--timeline-h); }

.timeline-header-row {
    height: 28px;
    background: var(--bg-app);
    display: flex;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.timeline-track-label {
    width: 180px;
    border-right: 1px solid var(--border);
    padding: 0 16px;
    font-size: 0.6rem;
    color: var(--text-dim);
    line-height: 28px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    flex-shrink: 0;
}
.timeline-frames-header { flex: 1; position: relative; overflow: hidden; }

#timeline-sequencer {
    flex: 1;
    overflow-y: auto;
    overflow-x: auto;
    position: relative;
}

.playhead {
    position: absolute;
    top: 0;
    width: 2px;
    height: 100%;
    background: var(--danger);
    pointer-events: none;
    z-index: 10;
}
.playhead::before {
    content: '';
    position: absolute;
    top: 0;
    left: -4px;
    width: 10px;
    height: 10px;
    background: var(--danger);
    border-radius: 2px;
}

/* ══════════════════════════════════════════════════════════════════
   SCROLLBAR STYLING
══════════════════════════════════════════════════════════════════ */

.scroller { overflow-y: auto; }
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ══════════════════════════════════════════════════════════════════
   SEARCH BOX
══════════════════════════════════════════════════════════════════ */

.search-box {
    position: relative;
    padding: 12px 14px;
    flex-shrink: 0;
}
.search-box input {
    width: 100%;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 8px 12px 8px 32px;
    border-radius: var(--radius-md);
    font-size: 0.83rem;
    transition: all 0.15s;
}
.search-box input:focus { border-color: var(--accent); outline: none; background: var(--bg-app); }
.search-box input::placeholder { color: var(--text-dim); }
.search-icon {
    position: absolute;
    left: 26px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-dim);
    font-size: 0.75rem;
    pointer-events: none;
}


/* ══════════════════════════════════════════════════════════════════
   CONTEXT MENU
══════════════════════════════════════════════════════════════════ */

.context-menu {
    position: fixed;
    z-index: 10000;
    width: 170px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-hover);
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius-md);
    padding: 6px;
}
.menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-muted);
    transition: all 0.12s;
}
.menu-item i { width: 14px; text-align: center; }
.menu-item:hover { background: var(--bg-hover); color: var(--text-main); }
.menu-item.danger:hover { background: rgba(248,113,113,0.1); color: var(--danger); }
.menu-divider { height: 1px; background: var(--border); margin: 4px 0; }
