/* ============================================
 * DESIGN CHAT LANDING — empty no-project chat surface
 * Visual tokens mirror the new Freeform studio
 * (see static/js/mm/modules/freeform/styles/freeformLibrary.css).
 * Shown when no project is active (body.is-design-chat-landing).
 * ============================================ */

#designChatLanding {
    /* Mirror Freeform dark tokens — studio is dark by default */
    --dcl-surface-soft:  rgba(255, 255, 255, 0.06);
    --dcl-surface-subtle: rgba(255, 255, 255, 0.04);
    --dcl-hover:         rgba(255, 255, 255, 0.08);
    --dcl-hover-strong:  rgba(255, 255, 255, 0.14);
    --dcl-border:        rgba(255, 255, 255, 0.14);
    --dcl-border-soft:   rgba(255, 255, 255, 0.10);
    --dcl-divider:       rgba(255, 255, 255, 0.08);
    --dcl-text:          #eef1f7;
    --dcl-text-strong:   #fff;
    --dcl-text-muted:    rgba(255, 255, 255, 0.60);
    --dcl-text-soft:     rgba(255, 255, 255, 0.45);
    --dcl-radius:        8px;
    --dcl-radius-lg:     12px;
}

#designChatLanding[hidden] { display: none !important; }

body.is-design-chat-landing,
body.is-design-chat-landing .main-content,
body.is-design-chat-landing .chat-container,
body.is-design-chat-landing #designChatLanding,
body.is-design-chat-landing .design-chat-landing {
    background: #000 !important;
    background-color: #000 !important;
}

.design-chat-landing {
    flex: 1 1 auto;
    overflow-y: hidden;
    overflow-x: hidden;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: transparent;
    color: var(--dcl-text);
    pointer-events: none;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Desktop: when the sidebar is open it overlays the main content but
 * the header is pushed right by var(--sidebar-width) — the landing must
 * follow so content stays visually centered in the available area
 * rather than under the sidebar overlay. */
@media (min-width: 769px) {
    .sidebar.open ~ .main-content .design-chat-landing {
        margin-left: var(--sidebar-width);
    }
}

.dc-landing-inner {
    width: 100%;
    max-width: 760px;
    display: none;
    flex-direction: column;
    gap: 24px;
}

/* ── Header ─────────────────────────────────────────────────── */
.dc-landing-title {
    margin: 8px 0 0;
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--dcl-text-strong);
}

/* ── Prompt composer ────────────────────────────────────────── */
.dc-landing-prompt {
    position: relative;
    display: flex;
    align-items: stretch;
    gap: 8px;
    background: var(--dcl-surface-soft);
    border: 1px solid var(--dcl-border-soft);
    border-radius: var(--dcl-radius-lg);
    padding: 12px 12px 12px 14px;
    transition: border-color 120ms ease, background 120ms ease;
}

.dc-landing-prompt:focus-within {
    border-color: var(--dcl-hover-strong);
    background: var(--dcl-hover);
}

.dc-landing-input {
    flex: 1 1 auto;
    background: transparent;
    border: 0;
    outline: none;
    resize: none;
    color: inherit;
    font: inherit;
    font-size: 14px;
    line-height: 1.5;
    min-height: 56px;
    max-height: 200px;
    padding: 4px 0;
}

.dc-landing-input::placeholder { color: var(--dcl-text-soft); }

.dc-landing-submit {
    align-self: flex-end;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: rgba(255, 255, 255, 0.95);
    color: #111;
    border: 0;
    border-radius: 7px;
    font-weight: 600;
    font-size: 12px;
    cursor: pointer;
    transition: transform 80ms ease, background 120ms ease, opacity 120ms ease;
}

.dc-landing-submit:hover { background: #fff; }
.dc-landing-submit:active { transform: translateY(1px); }
.dc-landing-submit:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── New Folder modal ───────────────────────────────────────── */
.dcl-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: dcl-modal-fade-in 120ms ease;
}
@keyframes dcl-modal-fade-in { from { opacity: 0; } to { opacity: 1; } }
.dcl-modal {
    width: min(420px, calc(100vw - 32px));
    background: #1a1a1c;
    border: 1px solid var(--dcl-border);
    border-radius: 12px;
    padding: 22px 22px 18px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
    color: var(--dcl-text);
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.dcl-modal-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}
.dcl-modal-subtitle {
    margin: 0;
    font-size: 13px;
    color: var(--dcl-text-muted);
}
.dcl-modal-input {
    margin-top: 4px;
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--dcl-border);
    color: var(--dcl-text);
    font-size: 14px;
    outline: none;
    transition: border-color 120ms ease, background 120ms ease;
}
.dcl-modal-input:focus {
    border-color: rgba(255, 255, 255, 0.4);
    background: rgba(255, 255, 255, 0.06);
}
.dcl-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 4px;
}
.dcl-modal-btn {
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}
.dcl-modal-btn-secondary {
    background: transparent;
    color: var(--dcl-text-muted);
    border-color: var(--dcl-border-soft);
}
.dcl-modal-btn-secondary:hover {
    color: var(--dcl-text);
    background: var(--dcl-hover);
    border-color: var(--dcl-border);
}
.dcl-modal-btn-primary {
    background: #fff;
    color: #111;
}
.dcl-modal-btn-primary:hover { background: #f5f5f5; }

/* ── Action row (New Chat / New Folder) ─────────────────────── */
.dc-landing-actions {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}
.dc-landing-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: var(--dcl-radius);
    background: transparent;
    color: var(--dcl-text);
    border: 1px solid var(--dcl-border-soft);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 120ms ease, border-color 120ms ease;
}
.dc-landing-action-btn:hover {
    background: var(--dcl-hover);
    border-color: var(--dcl-border);
}
.dc-landing-action-btn .dc-action-plus {
    font-size: 16px;
    line-height: 1;
    opacity: 0.85;
}

/* ── Recent chats section ───────────────────────────────────── */
.dc-landing-recent {
    margin-top: 4px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dc-landing-recent-title {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--dcl-text);
}

.dc-landing-recent-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.dc-landing-recent-empty {
    color: var(--dcl-text-soft);
    font-size: 13px;
    padding: 14px 4px;
}

/* Flatten the bucket structure — single header above ("Recent chats") is
 * enough; bucket sub-headers add noise. Items still flow in the same
 * date order because Most Recent comes before Older in the source DOM. */
.dc-landing-recent-list .project-bucket-section {
    display: contents;
}

.dc-landing-recent-list .project-bucket-header {
    display: none !important;
}

.dc-landing-recent-list .project-bucket-body {
    display: contents;
}

/* Pagination — items beyond the first VISIBLE_COUNT (set in JS) are hidden
 * until the user clicks "Load more". */
.dc-landing-recent-list .sidebar-item.project-item.dcl-hidden {
    display: none !important;
}

.dcl-load-more {
    align-self: flex-start;
    margin: 8px 0 0;
    padding: 6px 8px;
    background: transparent;
    border: 0;
    color: var(--dcl-text-soft);
    font: inherit;
    font-size: 12px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    border-radius: 6px;
    transition: color 100ms ease, background 100ms ease;
}

.dcl-load-more:hover {
    color: var(--dcl-text);
    background: var(--dcl-hover);
}

/* ── Folders section (conditional) ─────────────────────────── */
/* Only rendered into the landing if the user already has folders.
 * New users never see this surface. */
.dc-landing-folders[hidden] { display: none !important; }

.dc-landing-folders {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dc-landing-folders-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Folder rows — adapt the sidebar's project-folder visual to the landing */
.dc-landing-folders-list .project-folder {
    margin: 0;
    border-radius: var(--dcl-radius);
    background: transparent;
    border: 1px solid transparent;
    transition: background 100ms ease, border-color 100ms ease;
}

.dc-landing-folders-list .folder-header {
    padding: 8px 12px;
    border-radius: var(--dcl-radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
}

.dc-landing-folders-list .project-folder:hover,
.dc-landing-folders-list .folder-header:hover {
    background: var(--dcl-hover);
}

/* Hide the chevron — the folder icon + name carry enough signal */
.dc-landing-folders-list .folder-arrow,
.dc-landing-folders-list .folder-icon-wrapper {
    display: none !important;
}

.dc-landing-folders-list .folder-name-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.dc-landing-folders-list .folder-name {
    flex: 1 1 auto;
    font-size: 14px;
    color: var(--dcl-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Folder management actions (rename / delete) — show on hover only,
 * matching the sidebar's pattern. Cloned buttons proxy clicks to the
 * originals in the hidden sidebar. */
.dc-landing-folders-list .folder-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 120ms ease;
}
.dc-landing-folders-list .folder-header:hover .folder-actions,
.dc-landing-folders-list .project-folder:focus-within .folder-actions {
    opacity: 1;
}

.dc-landing-folders-list .folder-content {
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* Project rows nested inside a folder match the Recent chats row size
 * exactly — same height, same padding, same icon gap. The folder
 * grouping comes from the folder name above; rows shouldn't visually
 * differ from the flat list. */
.dc-landing-folders-list .sidebar-item.project-item {
    margin: 0;
    width: 100%;
    border-radius: var(--dcl-radius);
    background: transparent;
    border: 1px solid transparent;
    min-height: 44px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: background 100ms ease;
}

.dc-landing-folders-list .sidebar-item.project-item:hover {
    background: var(--dcl-hover);
}

/* Hide the sidebar's own per-row controls + cloned mgmt buttons inside folders */
.dc-landing-folders-list .sidebar-item .project-actions,
.dc-landing-folders-list .sidebar-item .project-actions-menu-container,
.dc-landing-folders-list .sidebar-item .project-actions-toggle,
.dc-landing-folders-list .sidebar-item .project-mobile-menu,
.dc-landing-folders-list .sidebar-item .project-action-btn,
.dc-landing-folders-list .sidebar-item .project-menu-btn {
    display: none !important;
}

/* ── Project rows (cloned from sidebar items) ────────────────
 * Zero left padding so the icon circle's left edge is flush with the
 * recent-list's vertical edge. Hover state stays as a hairline-soft
 * background, no border to avoid drifting outside the row when active. */
.dc-landing-recent-list .sidebar-item.project-item {
    margin: 0;
    width: 100%;
    border-radius: var(--dcl-radius);
    background: transparent;
    border: none;
    min-height: 40px;
    padding: 6px 10px 6px 0;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: background 100ms ease;
    box-shadow: none;
}

.dc-landing-recent-list .sidebar-item.project-item:hover {
    background: var(--dcl-hover);
}

.dc-landing-recent-list .sidebar-item.project-item.active {
    background: var(--dcl-hover-strong);
}

/* Project icon circle in the landing list — uniform "black bg / white
 * text / white outline" instead of the per-project pastel colors. The
 * sidebar JS still writes background-color inline, so override with
 * !important to win. Also zero the legacy left margin so the circle
 * actually starts at the row's left edge. */
.dc-landing-recent-list .sidebar-item-icon.project-thumb {
    background: #000 !important;
    background-color: #000 !important;
    border: 1px solid rgba(255, 255, 255, 0.85) !important;
    color: #fff !important;
    margin-left: 0 !important;
    font-weight: 600;
    letter-spacing: 0.02em;
}
.dc-landing-recent-list .sidebar-item-icon.project-thumb .project-icon-initials,
.dc-landing-recent-list .project-icon-initials {
    color: #fff !important;
}

/* Hide the sidebar's own per-row inline controls (clones don't carry their
 * handlers). The landing has its own kebab (.dcl-kebab) wired below. */
.dc-landing-recent-list .sidebar-item .project-actions,
.dc-landing-recent-list .sidebar-item .project-actions-menu-container,
.dc-landing-recent-list .sidebar-item .project-actions-toggle,
.dc-landing-recent-list .sidebar-item .project-mobile-menu,
.dc-landing-recent-list .sidebar-item .project-menu-btn,
.dc-landing-recent-list .sidebar-item .project-action-btn,
.dc-landing-recent-list .sidebar-item .project-kebab,
.dc-landing-recent-list .sidebar-item button[aria-label*="more" i],
.dc-landing-recent-list .sidebar-item button[aria-label*="menu" i] {
    display: none !important;
}

/* Hide cloned New Project / New Folder buttons + folders list — these
 * controls belong to the sidebar surface; the landing replaces them with
 * the prompt composer at the top. */
.dc-landing-recent-list .new-project-btn,
.dc-landing-recent-list .new-folder-btn,
.dc-landing-recent-list #projectFoldersList,
.dc-landing-recent-list .sidebar-action-buttons {
    display: none !important;
}

/* Upgrade pill (free/basic users at limit) — already rendered into
 * #projectsList by mm_ui.js; we just style it in the landing context. */
.dc-landing-recent-list .project-upgrade-pill {
    margin: 4px 0 12px !important;
    width: 100% !important;
    align-self: stretch;
}

/* Per-row kebab button injected by design-chat-landing.js */
.dc-landing-recent-list .dcl-kebab {
    margin-left: auto;
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--dcl-text-muted);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    opacity: 0;
    transition: opacity 80ms ease, background 100ms ease, color 100ms ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.dc-landing-recent-list .sidebar-item.project-item:hover .dcl-kebab,
.dc-landing-recent-list .dcl-kebab:focus-visible {
    opacity: 1;
}

.dc-landing-recent-list .dcl-kebab:hover {
    background: var(--dcl-hover-strong);
    color: var(--dcl-text-strong);
}

/* When landing is visible, hide the empty conversation log. The shared
 * chat promptbar remains mounted in .input-section and is centered by
 * chat_prompt_bar.css for this no-project state. */
body.is-design-chat-landing #chatMessages,
body.is-design-chat-landing #scrollBottomBtn {
    display: none !important;
}

/* ── Mobile ─────────────────────────────────────────────────── */
@media (max-width: 640px) {
    .design-chat-landing { padding: 0; }
    .dc-landing-title { font-size: 18px; }
    .dc-landing-prompt { flex-direction: column; padding: 10px; }
    .dc-landing-submit { align-self: flex-end; }
}
