/* ─── CloudeCode+ Dashboard – MRNPNZR Light Design ─────────────────────────
   Modern light sidebar + session bar.  Terminal stays dark.
   ───────────────────────────────────────────────────────────────────────── */

:root {
    --mp-primary: #6366f1;
    --mp-primary-hover: #4f46e5;
    --mp-primary-light: rgba(99, 102, 241, 0.08);
    --mp-primary-border: rgba(99, 102, 241, 0.18);
    --mp-bg: #f8fafc;
    --mp-surface: #ffffff;
    --mp-text: #1e293b;
    --mp-text-muted: #64748b;
    --mp-text-light: #94a3b8;
    --mp-border: #e2e8f0;
    --mp-border-light: #f1f5f9;
    --mp-success: #22c55e;
    --mp-danger: #ef4444;
    --mp-warning: #f59e0b;
    --mp-radius: 8px;
    --mp-sidebar-width: 380px;
    --mp-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

/* ─── Terminal-screen layout override ──────────────────────────────────── */

#terminal-screen.active {
    flex-direction: column !important;
}

/* Session stats bar */
.session-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 8px 16px;
    background: var(--mp-surface);
    border-bottom: 1px solid var(--mp-border);
    font-family: var(--mp-font);
    font-size: 13px;
    color: var(--mp-text-muted);
    min-height: 40px;
    flex-shrink: 0;
}

.session-bar__project {
    font-weight: 600;
    color: var(--mp-text);
    display: flex;
    align-items: center;
    gap: 6px;
}

.session-bar__project::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--mp-success);
    flex-shrink: 0;
}

.session-bar__project.disconnected::before {
    background: var(--mp-text-light);
}

.session-bar__sep {
    width: 1px;
    height: 16px;
    background: var(--mp-border);
}

.session-bar__duration {
    font-variant-numeric: tabular-nums;
}

.session-bar__spacer {
    flex: 1;
}

.session-bar__toggle {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid var(--mp-border);
    background: var(--mp-bg);
    color: var(--mp-text-muted);
    font-family: var(--mp-font);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s ease;
    width: auto;
    height: auto;
}

.session-bar__toggle:hover {
    background: var(--mp-primary-light);
    border-color: var(--mp-primary-border);
    color: var(--mp-primary);
    transform: none;
    box-shadow: none;
}

.session-bar__toggle svg {
    width: 14px;
    height: 14px;
    transition: transform 0.2s ease;
}

.session-bar__toggle.sidebar-open svg {
    transform: rotate(180deg);
}

/* ─── Main content area (sidebar + terminal) ───────────────────────────── */

.main-content {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.main-content .terminal-container {
    flex: 1;
    min-width: 0;
}

/* ─── Sidebar ──────────────────────────────────────────────────────────── */

.dashboard-sidebar {
    width: var(--mp-sidebar-width);
    max-width: 50vw;
    background: var(--mp-surface);
    border-left: 1px solid var(--mp-border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
    transition: width 0.25s ease, opacity 0.2s ease;
    font-family: var(--mp-font);
    color: var(--mp-text);
}

.dashboard-sidebar.collapsed {
    width: 0;
    border-left: none;
    opacity: 0;
    pointer-events: none;
}

/* ─── Sidebar header / tabs ────────────────────────────────────────────── */

.sidebar-header {
    padding: 12px 16px 0;
    border-bottom: 1px solid var(--mp-border);
    flex-shrink: 0;
}

.sidebar-header__title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.sidebar-header__brand {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--mp-primary);
}

.sidebar-tabs {
    display: flex;
    gap: 2px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding-bottom: 0;
}

.sidebar-tabs::-webkit-scrollbar {
    display: none;
}

.sidebar-tab {
    padding: 6px 10px;
    font-family: var(--mp-font);
    font-size: 12px;
    font-weight: 500;
    color: var(--mp-text-muted);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s ease;
    width: auto;
    height: auto;
}

.sidebar-tab:hover {
    color: var(--mp-text);
    background: var(--mp-bg);
    transform: none;
    box-shadow: none;
}

.sidebar-tab.active {
    color: var(--mp-primary);
    border-bottom-color: var(--mp-primary);
    background: transparent;
}

/* ─── Sidebar body / panels ────────────────────────────────────────────── */

.sidebar-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0;
    scrollbar-width: thin;
    scrollbar-color: var(--mp-border) transparent;
}

.sidebar-body::-webkit-scrollbar {
    width: 4px;
}

.sidebar-body::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-body::-webkit-scrollbar-thumb {
    background: var(--mp-border);
    border-radius: 2px;
}

.sidebar-panel {
    display: none;
    padding: 16px;
}

.sidebar-panel.active {
    display: block;
}

/* ─── Markdown rendering ───────────────────────────────────────────────── */

.md-content {
    font-family: var(--mp-font);
    font-size: 13.5px;
    line-height: 1.65;
    color: var(--mp-text);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.md-content h1 {
    font-size: 1.35em;
    font-weight: 700;
    color: var(--mp-primary);
    border-bottom: 2px solid var(--mp-border-light);
    padding-bottom: 6px;
    margin: 20px 0 12px;
    cursor: default;
}

.md-content h1:first-child {
    margin-top: 0;
}

.md-content h2 {
    font-size: 1.15em;
    font-weight: 600;
    color: #0ea5e9;
    margin: 18px 0 8px;
    cursor: default;
}

.md-content h3 {
    font-size: 1.0em;
    font-weight: 600;
    color: #8b5cf6;
    margin: 14px 0 6px;
    cursor: default;
}

.md-content h4, .md-content h5, .md-content h6 {
    font-size: 0.95em;
    font-weight: 600;
    color: var(--mp-text);
    margin: 12px 0 4px;
}

.md-content p {
    margin: 8px 0;
}

.md-content ul, .md-content ol {
    margin: 6px 0;
    padding-left: 22px;
}

.md-content li {
    margin: 3px 0;
}

.md-content li::marker {
    color: var(--mp-primary);
}

.md-content code {
    background: var(--mp-bg);
    border: 1px solid var(--mp-border);
    border-radius: 4px;
    padding: 1px 5px;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.88em;
    color: var(--mp-primary-hover);
}

.md-content pre {
    background: #1e293b;
    border-radius: var(--mp-radius);
    padding: 12px 14px;
    margin: 10px 0;
    overflow-x: auto;
    font-size: 12.5px;
    line-height: 1.55;
}

.md-content pre code {
    background: none;
    border: none;
    padding: 0;
    color: #e2e8f0;
    font-size: inherit;
}

.md-content blockquote {
    border-left: 3px solid var(--mp-primary);
    padding: 4px 12px;
    margin: 10px 0;
    color: var(--mp-text-muted);
    background: var(--mp-primary-light);
    border-radius: 0 var(--mp-radius) var(--mp-radius) 0;
}

.md-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 10px 0;
    font-size: 13px;
}

.md-content th {
    background: var(--mp-bg);
    font-weight: 600;
    text-align: left;
    padding: 8px 10px;
    border-bottom: 2px solid var(--mp-border);
}

.md-content td {
    padding: 6px 10px;
    border-bottom: 1px solid var(--mp-border-light);
}

.md-content tr:hover td {
    background: var(--mp-primary-light);
}

.md-content a {
    color: var(--mp-primary);
    text-decoration: none;
}

.md-content a:hover {
    text-decoration: underline;
}

.md-content hr {
    border: none;
    border-top: 1px solid var(--mp-border);
    margin: 16px 0;
}

.md-content strong {
    font-weight: 600;
}

.md-content img {
    max-width: 100%;
    border-radius: var(--mp-radius);
}

/* Checkbox styling in markdown lists */
.md-content input[type="checkbox"] {
    accent-color: var(--mp-primary);
    margin-right: 6px;
}

/* ─── Edit mode ────────────────────────────────────────────────────────── */

.md-panel-toolbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    padding: 8px 16px;
    border-bottom: 1px solid var(--mp-border-light);
    background: var(--mp-bg);
}

.md-panel-btn {
    padding: 4px 10px;
    font-family: var(--mp-font);
    font-size: 12px;
    font-weight: 500;
    border-radius: 5px;
    border: 1px solid var(--mp-border);
    background: var(--mp-surface);
    color: var(--mp-text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
    width: auto;
    height: auto;
}

.md-panel-btn:hover {
    background: var(--mp-primary-light);
    border-color: var(--mp-primary-border);
    color: var(--mp-primary);
    transform: none;
    box-shadow: none;
}

.md-panel-btn.save-btn {
    background: var(--mp-primary);
    color: #fff;
    border-color: var(--mp-primary);
}

.md-panel-btn.save-btn:hover {
    background: var(--mp-primary-hover);
    color: #fff;
}

.md-edit-area {
    width: 100%;
    min-height: 300px;
    padding: 14px 16px;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 13px;
    line-height: 1.6;
    color: var(--mp-text);
    background: var(--mp-surface);
    border: none;
    border-bottom: 1px solid var(--mp-border-light);
    resize: vertical;
    outline: none;
}

.md-edit-area:focus {
    background: #fffef5;
}

/* ─── Empty state ──────────────────────────────────────────────────────── */

.md-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: var(--mp-text-light);
    text-align: center;
}

.md-empty__icon {
    font-size: 32px;
    margin-bottom: 10px;
    opacity: 0.5;
}

.md-empty__text {
    font-size: 13px;
    line-height: 1.5;
}

.md-empty__create-btn {
    margin-top: 12px;
    padding: 6px 14px;
    font-family: var(--mp-font);
    font-size: 12px;
    border-radius: 6px;
    border: 1px solid var(--mp-primary-border);
    background: var(--mp-primary-light);
    color: var(--mp-primary);
    cursor: pointer;
    transition: all 0.15s ease;
    width: auto;
    height: auto;
}

.md-empty__create-btn:hover {
    background: var(--mp-primary);
    color: #fff;
    transform: none;
    box-shadow: none;
}

/* ─── File browser ─────────────────────────────────────────────────────── */

.file-tree {
    font-family: var(--mp-font);
    font-size: 13px;
}

.file-tree__item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.1s;
    color: var(--mp-text);
}

.file-tree__item:hover {
    background: var(--mp-primary-light);
}

.file-tree__item.active {
    background: var(--mp-primary-light);
    color: var(--mp-primary);
    font-weight: 500;
}

.file-tree__icon {
    flex-shrink: 0;
    width: 16px;
    text-align: center;
    color: var(--mp-text-muted);
    font-size: 12px;
}

.file-tree__icon.dir {
    color: var(--mp-warning);
}

.file-tree__name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-tree__size {
    font-size: 11px;
    color: var(--mp-text-light);
    flex-shrink: 0;
}

.file-tree__children {
    padding-left: 16px;
}

.file-tree__dir-toggle {
    user-select: none;
}

/* File preview */
.file-preview {
    margin-top: 12px;
    border-top: 1px solid var(--mp-border-light);
    padding-top: 12px;
}

.file-preview__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.file-preview__name {
    font-weight: 600;
    font-size: 13px;
    color: var(--mp-text);
}

.file-preview__close {
    padding: 2px 6px;
    font-size: 11px;
    border-radius: 4px;
    border: 1px solid var(--mp-border);
    background: var(--mp-surface);
    color: var(--mp-text-muted);
    cursor: pointer;
    width: auto;
    height: auto;
}

.file-preview__close:hover {
    background: var(--mp-bg);
    transform: none;
    box-shadow: none;
}

.file-preview__content {
    background: #1e293b;
    color: #e2e8f0;
    border-radius: var(--mp-radius);
    padding: 12px 14px;
    font-family: 'SF Mono', monospace;
    font-size: 12px;
    line-height: 1.55;
    max-height: 400px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

/* ─── Loading / status ─────────────────────────────────────────────────── */

.sidebar-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--mp-text-light);
    font-size: 13px;
}

.sidebar-loading::before {
    content: '';
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--mp-border);
    border-top-color: var(--mp-primary);
    border-radius: 50%;
    margin-right: 8px;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Toast for file save feedback */
.sidebar-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 10px 18px;
    background: var(--mp-text);
    color: #fff;
    font-family: var(--mp-font);
    font-size: 13px;
    border-radius: var(--mp-radius);
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    z-index: 10001;
    animation: toastIn 0.25s ease;
}

.sidebar-toast.success {
    background: var(--mp-success);
}

.sidebar-toast.error {
    background: var(--mp-danger);
}

@keyframes toastIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ─── Responsive ───────────────────────────────────────────────────────── */

@media (max-width: 900px) {
    :root {
        --mp-sidebar-width: 300px;
    }
}

@media (max-width: 768px) {
    .dashboard-sidebar {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        z-index: 9990;
        width: 85vw;
        max-width: 380px;
        box-shadow: -4px 0 24px rgba(0,0,0,0.12);
    }

    .dashboard-sidebar.collapsed {
        transform: translateX(100%);
        opacity: 1;
        width: 85vw;
        pointer-events: none;
    }

    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.3);
        z-index: 9989;
        animation: fadeIn 0.2s ease;
    }

    .session-bar__toggle {
        font-size: 0;
        padding: 6px;
    }

    .session-bar__toggle svg {
        width: 16px;
        height: 16px;
    }

    .session-bar {
        padding: 6px 12px;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .session-bar__duration,
    .session-bar__clients {
        display: none;
    }
}
