/* Daisi Git — App Layout */

:root {
    --dg-sidebar-width: 240px;
    --dg-header-height: 56px;
    --dg-primary: #2563eb;
    --dg-sidebar-bg: #1e293b;
    --dg-sidebar-text: #cbd5e1;
    --dg-sidebar-active: #3b82f6;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    margin: 0;
    background: #f8fafc;
}

.dg-app {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.dg-sidebar {
    width: var(--dg-sidebar-width);
    background: var(--dg-sidebar-bg);
    color: var(--dg-sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1000;
    transition: width 0.18s ease;
}

.dg-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 16px 12px 16px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.dg-logo {
    color: white;
    text-decoration: none;
    font-weight: 600;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
}

.dg-logo:hover {
    color: white;
}

.dg-logo img {
    height: 24px;
    width: auto;
}

.dg-logo-word {
    margin-left: 0.5rem;
    font-family: 'Anta', system-ui;
    color: #F78C1D;
}

button.dg-logo {
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
}

.dg-nav-collapse {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    margin: 0;
    padding: 0;
    color: var(--dg-sidebar-text);
    background: none;
    border: 0;
    border-radius: 6px;
    cursor: pointer;
}

.dg-nav-collapse:hover {
    background: rgba(255, 255, 255, 0.08);
    color: white;
}

.dg-nav-collapse i {
    width: 20px;
    text-align: center;
}

html.dg-nav-collapsed {
    --dg-sidebar-width: 64px;
}

html.dg-nav-collapsed .dg-sidebar-header {
    display: flex;
    justify-content: center;
    padding: 16px 8px;
}

html.dg-nav-collapsed .dg-logo img {
    height: 28px;
    width: 28px;
}

html.dg-nav-collapsed .dg-logo-word,
html.dg-nav-collapsed .dg-nav-item span,
html.dg-nav-collapsed .dg-nav-collapse {
    display: none;
}

html.dg-nav-collapsed .dg-nav-item {
    justify-content: center;
    padding: 10px 0;
    gap: 0;
}

.dg-sidebar-nav {
    padding: 12px 8px;
    flex: 1;
    overflow-y: auto;
}

.dg-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    color: var(--dg-sidebar-text);
    text-decoration: none;
    border-radius: 6px;
    margin-bottom: 2px;
    font-size: 0.9rem;
    transition: background 0.15s;
}

.dg-nav-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: white;
}

.dg-nav-item.active {
    background: var(--dg-sidebar-active);
    color: white;
}

.dg-nav-item i {
    width: 20px;
    text-align: center;
}

/* Main content */
.dg-main {
    margin-left: var(--dg-sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left 0.18s ease;
}

.dg-header {
    height: var(--dg-header-height);
    background: white;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.dg-header-left,
.dg-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.dg-content {
    flex: 1;
    padding: 24px;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
}

.dg-footer {
    padding: 16px 24px;
    text-align: center;
    color: #94a3b8;
    font-size: 0.85rem;
    border-top: 1px solid #e2e8f0;
}

/* Repository page */
.repo-header {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 24px;
    margin-bottom: 24px;
}

.repo-clone-url {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 8px 12px;
    font-family: monospace;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.repo-clone-url code {
    flex: 1;
    word-break: break-all;
}

/* Repository tabs */
.repo-header .nav-tabs {
    border-bottom: none;
    margin: 0 -24px -24px -24px;
    padding: 0 24px;
}

.repo-header .nav-tabs .nav-link {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

/* Tree (file browser) */
.dg-tree-entry {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    font-size: 0.9rem;
}

.dg-tree-icon {
    width: 18px;
    text-align: center;
}

/* File viewer */
.dg-file-content {
    overflow-x: auto;
}

.dg-code-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'SFMono-Regular', 'Menlo', 'Monaco', 'Consolas', monospace;
    font-size: 0.8rem;
    line-height: 1.5;
}

.dg-code-table pre {
    margin: 0;
    white-space: pre;
    display: inline;
}

.dg-line-num {
    width: 60px;
    min-width: 60px;
    padding: 0 12px;
    text-align: right;
    color: #94a3b8;
    user-select: none;
    background: #f8fafc;
    border-right: 1px solid #e2e8f0;
    vertical-align: top;
}

.dg-line-content {
    padding: 0 16px;
    white-space: pre;
}

/* Commit list */
.dg-commit-date-header {
    font-weight: 600;
    font-size: 0.85rem;
    color: #64748b;
    padding: 12px 0 6px 0;
}

.dg-commit-body {
    font-size: 0.85rem;
    background: #f8fafc;
    padding: 8px 12px;
    border-radius: 4px;
    white-space: pre-wrap;
}

/* Diff view */
.dg-diff-content {
    overflow-x: auto;
}

.dg-diff-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'SFMono-Regular', 'Menlo', 'Monaco', 'Consolas', monospace;
    font-size: 0.8rem;
    line-height: 1.5;
}

.dg-diff-table pre {
    margin: 0;
    white-space: pre;
    display: inline;
}

.dg-diff-num {
    width: 50px;
    min-width: 50px;
    padding: 0 8px;
    text-align: right;
    color: #94a3b8;
    user-select: none;
    border-right: 1px solid #e2e8f0;
    vertical-align: top;
}

.dg-diff-line {
    padding: 0 12px;
    white-space: pre;
}

.dg-diff-added {
    background: #dcfce7;
}

.dg-diff-added .dg-diff-num {
    background: #bbf7d0;
}

.dg-diff-removed {
    background: #fee2e2;
}

.dg-diff-removed .dg-diff-num {
    background: #fecaca;
}

/* PR/Issue colors */
.bg-purple {
    background-color: #8b5cf6 !important;
}

.text-purple {
    color: #8b5cf6 !important;
}

.border-purple {
    border-color: #8b5cf6 !important;
}

/* Settings grid */
.dg-settings-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}

.dg-settings-card {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 24px;
    cursor: pointer;
    transition: box-shadow 0.15s, border-color 0.15s;
    text-decoration: none;
    color: inherit;
    width: 280px;
}

.dg-settings-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border-color: var(--dg-primary);
    color: inherit;
    text-decoration: none;
}

.dg-settings-card i {
    font-size: 1.5rem;
    color: var(--dg-primary);
    margin-bottom: 12px;
}

.dg-settings-card h6 {
    margin: 0 0 6px 0;
    font-weight: 600;
}

.dg-settings-card p {
    margin: 0;
    color: #64748b;
    font-size: 0.875rem;
}

/* File editor */
.dg-editor-wrap { padding: 0; }
.dg-editor {
    width: 100%;
    min-height: 500px;
    border: none;
    outline: none;
    resize: vertical;
    padding: 1em;
    font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
    font-size: 0.875rem;
    line-height: 1.6;
    tab-size: 4;
    background: var(--bs-body-bg);
    color: var(--bs-body-color);
}
.dg-editor:focus { box-shadow: inset 0 0 0 2px var(--bs-primary); }

/* Markdown rendered content */
.markdown-body {
    font-size: 0.95rem;
    line-height: 1.7;
}
.markdown-body h1, .markdown-body h2, .markdown-body h3,
.markdown-body h4, .markdown-body h5, .markdown-body h6 {
    margin-top: 1.5em;
    margin-bottom: 0.5em;
    font-weight: 600;
}
.markdown-body h1 { font-size: 1.75rem; border-bottom: 1px solid var(--bs-border-color); padding-bottom: 0.3em; }
.markdown-body h2 { font-size: 1.4rem; border-bottom: 1px solid var(--bs-border-color); padding-bottom: 0.3em; }
.markdown-body h3 { font-size: 1.15rem; }
.markdown-body p { margin-bottom: 1em; }
.markdown-body code {
    background: var(--bs-tertiary-bg);
    padding: 0.15em 0.4em;
    border-radius: 4px;
    font-size: 0.875em;
}
.markdown-body pre {
    background: var(--bs-tertiary-bg);
    padding: 1em;
    border-radius: 6px;
    overflow-x: auto;
}
.markdown-body pre code {
    background: none;
    padding: 0;
}
.markdown-body blockquote {
    border-left: 4px solid var(--bs-border-color);
    padding: 0.5em 1em;
    margin: 1em 0;
    color: var(--bs-secondary);
}
.markdown-body ul, .markdown-body ol { padding-left: 2em; margin-bottom: 1em; }
.markdown-body li { margin-bottom: 0.25em; }
.markdown-body img { max-width: 100%; border-radius: 6px; }
.markdown-body table { border-collapse: collapse; width: 100%; margin-bottom: 1em; }
.markdown-body th, .markdown-body td { border: 1px solid var(--bs-border-color); padding: 0.5em 0.75em; }
.markdown-body th { background: var(--bs-tertiary-bg); font-weight: 600; }
.markdown-body hr { border: none; border-top: 1px solid var(--bs-border-color); margin: 1.5em 0; }
.markdown-body a { color: var(--bs-primary); }
.markdown-body input[type="checkbox"] { margin-right: 0.4em; }
.markdown-body pre.mermaid { background: transparent; text-align: center; padding: 1em 0; }
.markdown-body pre.mermaid svg { max-width: 100%; height: auto; }

/* ── Plan board (Stage → Lane → Phase → work-item cards) ── */
.plan-board { display: flex; gap: 16px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; }
.plan-stage { flex: 0 0 320px; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px; padding: 12px; }
.plan-stage-add { background: transparent; border-style: dashed; }
.plan-stage-head { display: flex; justify-content: space-between; align-items: center; font-weight: 600; margin-bottom: 10px; }
.plan-lane { background: #fff; border: 1px solid #e2e8f0; border-radius: 6px; padding: 8px; margin-bottom: 10px; }
.plan-lane-head { display: flex; justify-content: space-between; align-items: center; font-weight: 500; font-size: 0.9rem; margin-bottom: 8px; color: #475569; }
.plan-phase { border-left: 3px solid #8b5cf6; padding-left: 8px; margin-bottom: 10px; }
.plan-phase-head { display: flex; justify-content: space-between; align-items: center; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; color: #64748b; margin-bottom: 6px; }
.plan-card { background: #fff; border: 1px solid #e2e8f0; border-radius: 6px; padding: 8px 10px; margin-bottom: 6px; box-shadow: 0 1px 2px rgba(0,0,0,0.04); }
.plan-card-title { font-size: 0.85rem; font-weight: 500; margin-bottom: 4px; }
.plan-card-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.plan-card-meta .badge { font-size: 0.65rem; }
.plan-add-row { margin-top: 6px; }
.plan-add-row .form-control { background: transparent; }

/* Plan board inline rename */
.plan-head-actions { white-space: nowrap; }
.plan-head-edit { max-width: 200px; }
.plan-name-edit { width: auto; min-width: 200px; vertical-align: baseline; }
.plan-stage-head .btn-link, .plan-lane-head .btn-link, .plan-phase-head .btn-link { color: #94a3b8; }
.plan-stage-head .btn-link:hover, .plan-lane-head .btn-link:hover, .plan-phase-head .btn-link:hover { color: #475569; }
.plan-stage-head .btn-link.text-danger:hover, .plan-lane-head .btn-link.text-danger:hover, .plan-phase-head .btn-link.text-danger:hover { color: #dc2626 !important; }

/* Plan phase aside (side panel) */
.plan-node-name { text-decoration: none; color: inherit; cursor: pointer; }
.plan-node-name:hover { text-decoration: underline; }
.plan-node-name.active { font-weight: 600; color: #8b5cf6; }
.plan-aside-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.12); z-index: 1040; }
.plan-aside { position: fixed; top: 0; right: 0; width: 380px; max-width: 92vw; height: 100vh; background: #fff;
    border-left: 1px solid #e2e8f0; box-shadow: -4px 0 18px rgba(0,0,0,0.08); z-index: 1045; display: flex; flex-direction: column; }
.plan-aside-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; padding: 16px; border-bottom: 1px solid #e2e8f0; }
.plan-aside-body { padding: 16px; overflow-y: auto; flex: 1; }

/* Plan full-status outline */
.plan-status-stage { border: 1px solid #e2e8f0; border-radius: 8px; padding: 16px; margin-bottom: 16px; background: #fff; }

/* Status page header: title + meta on one row; expandable MD description below */
.plan-status-header-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 1rem;
}
.plan-status-title {
    flex: 1 1 12rem;
    min-width: 0;
    font-size: 1.25rem;
    line-height: 1.35;
}
.plan-status-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.65rem;
    flex: 0 1 auto;
}
.plan-status-progress {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.plan-status-progress-bar {
    width: 5.5rem;
    height: 0.45rem;
    margin: 0;
    background: #e2e8f0;
}
.plan-status-progress-bar .progress-bar { transition: width 0.2s ease; }
.plan-status-select {
    width: auto;
    min-width: 7.5rem;
}

/* Plans list: status badge + progress + links on the right */
.plan-list-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem 0.75rem;
    flex: 0 1 auto;
}
.min-w-0 { min-width: 0; }
.plan-status-desc {
    max-width: 56rem;
}
.plan-status-desc-body.collapsed {
    max-height: 4.6em;
    overflow: hidden;
    position: relative;
}
.plan-status-desc-body.collapsed::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 1.75em;
    pointer-events: none;
    background: linear-gradient(to bottom, transparent, var(--bs-body-bg, #fff));
}
.plan-status-desc-body.expanded {
    max-height: none;
}
.plan-status-desc-body .markdown-body {
    font-size: 0.9rem;
    line-height: 1.55;
    color: var(--bs-secondary-color, #64748b);
}
.plan-status-desc-body .markdown-body h1,
.plan-status-desc-body .markdown-body h2,
.plan-status-desc-body .markdown-body h3,
.plan-status-desc-body .markdown-body h4 {
    font-size: 1rem;
    margin-top: 0.75em;
    margin-bottom: 0.35em;
    border-bottom: none;
    padding-bottom: 0;
}
.plan-status-desc-body .markdown-body p:last-child,
.plan-status-desc-body .markdown-body ul:last-child,
.plan-status-desc-body .markdown-body ol:last-child { margin-bottom: 0; }
.plan-status-desc-toggle {
    text-decoration: none;
    font-weight: 500;
}
.plan-status-desc-toggle:hover { text-decoration: underline; }

.plan-stage-toggle { cursor: pointer; user-select: none; }
.plan-stage-toggle:hover { color: #8b5cf6; }

/* Plan board: phase work-item count badge (replaces inline cards) */
.plan-phase-count { display: block; width: 100%; text-align: left; background: #fff; border: 1px solid #e2e8f0;
    border-radius: 6px; padding: 4px 8px; font-size: 0.8rem; color: #334155; cursor: pointer; }
.plan-phase-count:hover, .plan-phase-count.active { border-color: #8b5cf6; background: #faf9ff; }

/* Phase-aside item cards rendered as buttons */
.plan-card-btn { display: block; width: 100%; text-align: left; cursor: pointer; }
.plan-card-btn:hover { border-color: #8b5cf6; }
.plan-card-btn.active { border-color: #8b5cf6; box-shadow: 0 0 0 2px rgba(139,92,246,0.15); }

/* Left aside (work-item detail) sits immediately left of the right phase aside */
.plan-aside-left { right: 380px; width: 460px; z-index: 1044; border-left: 1px solid #e2e8f0; }
@media (max-width: 900px) { .plan-aside-left { display: none; } }

/* Wider single aside (work-item detail opened from the status outline) */
.plan-aside-wide { width: 460px; }

/* Status outline: clickable work-item rows open the detail aside */
.plan-status-item { cursor: pointer; border-radius: 6px; padding: 2px 6px; margin-left: -6px; }
.plan-status-item:hover { background: #faf9ff; }
.plan-status-item.active { background: #faf9ff; box-shadow: 0 0 0 2px rgba(139,92,246,0.15); }
