/* ── Code editor (line gutter + textarea) ── */
.gp-editor {
    display: flex;
    flex: 1;
    min-height: 0;
    border: 1px solid #272b31;
    border-radius: 0;
    background: #0f1115;
    overflow: hidden;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 12px;
    line-height: 1.5;
}

.gp-editor-gutter {
    flex: 0 0 auto;
    min-width: 2.75rem;
    padding: 0.75rem 0.5rem 0.75rem 0.75rem;
    text-align: right;
    color: #4b5563;
    user-select: none;
    overflow: hidden;
    border-right: 1px solid #272b31;
    background: #0a0c0f;
}

.gp-editor-gutter-line {
    height: 1.5em;
}

.gp-editor-main {
    flex: 1;
    position: relative;
    overflow: auto;
    min-width: 0;
    scrollbar-color: #181b20 #0a0c0f;
}

.gp-editor-main::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.gp-editor-main::-webkit-scrollbar-thumb {
    background-color: #181b20;
    border-radius: 999px;
    border: 2px solid #0a0c0f;
}

.gp-editor-main::-webkit-scrollbar-thumb:hover {
    background-color: #272b31;
}

.gp-editor textarea {
    display: block;
    width: 100%;
    min-height: 100%;
    padding: 0.75rem;
    margin: 0;
    border: none;
    outline: none;
    resize: none;
    background: transparent;
    color: #d1d5db;
    font: inherit;
    line-height: 1.5;
    tab-size: 4;
    white-space: pre;
    overflow-wrap: normal;
}

.gp-editor-readonly textarea {
    color: #9ca3af;
}

.gp-editor-dirty textarea {
    box-shadow: inset 0 2px 0 0 #f59e0b;
}

/* ── IDE shell (explorer + editor) ── */
.gp-ide {
    display: flex;
    flex-direction: row;
    border: 1px solid #272b31;
    border-radius: 0.75rem;
    overflow: hidden;
    background: #0f1115;
    min-height: 20rem;
    max-height: min(72vh, 36rem);
    scrollbar-color: #181b20 #0a0c0f;
}

.gp-ide-sidebar {
    flex: 0 0 13.5rem;
    max-width: 40%;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #272b31;
    background: #0a0c0f;
    min-width: 0;
}

.gp-ide-sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #272b31;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.08em;
    color: #6b7280;
    text-transform: uppercase;
}

.gp-ide-sidebar-actions {
    display: flex;
    gap: 0.25rem;
}

.gp-ide-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    border: none;
    border-radius: 0.25rem;
    background: transparent;
    color: #9ca3af;
    cursor: pointer;
    font-size: 11px;
}

.gp-ide-icon-btn:hover {
    background: #272b31;
    color: #fff;
}

.gp-ide-tree {
    flex: 1;
    overflow: auto;
    padding: 0.35rem 0;
    font-size: 11px;
    user-select: none;
    scrollbar-color: #181b20 #0a0c0f;
}

.gp-ide-tree::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.gp-ide-tree::-webkit-scrollbar-thumb {
    background-color: #181b20;
    border-radius: 999px;
    border: 2px solid #0a0c0f;
}

.gp-ide-tree::-webkit-scrollbar-thumb:hover {
    background-color: #272b31;
}

.gp-ide-tree-folder,
.gp-ide-tree-file {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.5rem 0.2rem 0;
    cursor: pointer;
    color: #9ca3af;
    white-space: nowrap;
    min-height: 1.35rem;
}

.gp-ide-tree-folder:hover,
.gp-ide-tree-file:hover {
    background: #181b20;
    color: #e5e7eb;
}

.gp-ide-tree-file.is-active {
    background: #1e3a2f;
    color: #6ee7b7;
}

.gp-ide-tree-file.is-active i {
    color: #34d399;
}

.gp-ide-tree-chevron {
    width: 0.85rem;
    flex-shrink: 0;
    text-align: center;
    font-size: 8px;
    color: #6b7280;
}

.gp-ide-tree-chevron.is-hidden {
    visibility: hidden;
}

.gp-ide-tree-label {
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
}

.gp-ide-tree-children {
    display: none;
}

.gp-ide-tree-children.is-open {
    display: block;
}

.gp-ide-tree-file-actions {
    margin-left: auto;
    display: none;
    gap: 0.15rem;
    padding-right: 0.25rem;
}

.gp-ide-tree-file:hover .gp-ide-tree-file-actions,
.gp-ide-tree-file.is-active .gp-ide-tree-file-actions {
    display: flex;
}

.gp-ide-tree-del {
    color: #f87171;
    opacity: 0.7;
    padding: 0 0.2rem;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 9px;
}

.gp-ide-tree-del:hover {
    opacity: 1;
}

.gp-ide-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
}

.gp-editor-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.4rem 0.6rem;
    border-bottom: 1px solid #272b31;
    background: #181b20;
    flex-shrink: 0;
}

.gp-editor-path {
    font-size: 11px;
    color: #9ca3af;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    flex: 1;
}

.gp-editor-path-dirty::after {
    content: ' •';
    color: #f59e0b;
}

.gp-editor-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
}

.gp-ide-btn {
    font-size: 10px;
    padding: 0.25rem 0.5rem;
    border: 1px solid #3a4149;
    border-radius: 0.25rem;
    background: transparent;
    color: #9ca3af;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.gp-ide-btn:hover {
    background: #272b31;
    color: #fff;
}

.gp-ide-btn-primary {
    border-color: #065f46;
    color: #6ee7b7;
    background: #064e3b40;
}

.gp-ide-btn-primary:hover {
    background: #065f46;
    color: #fff;
}

.gp-ide-btn-primary:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.gp-ide-editor-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.gp-ide-editor-wrap .gp-editor {
    border: none;
    border-radius: 0;
    max-height: none;
}

/* ── Fullscreen ── */
body.gp-ide-fs-active {
    overflow: hidden;
}

.gp-ide.gp-ide-fullscreen {
    position: fixed;
    inset: 0;
    z-index: 200;
    max-height: none;
    min-height: 0;
    height: 100dvh;
    border-radius: 0;
    border: none;
}

.gp-ide-fullscreen .gp-ide-sidebar {
    flex: 0 0 15rem;
}

.gp-ide-fs-only {
    display: none;
}

.gp-ide-fullscreen .gp-ide-fs-only {
    display: inline-flex;
}

.gp-ide-fullscreen .gp-ide-fs-hide {
    display: none;
}

/* ── Drawer toggle button (mobile fullscreen) ── */
.gp-ide-drawer-toggle {
    display: none;
}

/* ── Tree row affordances (drag/drop, pending, drop target) ── */
.gp-ide-tree-folder,
.gp-ide-tree-file {
    position: relative;
}

.gp-ide-tree-folder.gp-ide-drop-target,
.gp-ide-tree-root.gp-ide-drop-target {
    background: #1e3a2f;
    color: #6ee7b7;
    box-shadow: inset 0 0 0 1px #047857;
}

.gp-ide-tree-folder.is-pending .gp-ide-tree-label,
.gp-ide-tree-file.is-pending .gp-ide-tree-label {
    color: #fbbf24;
    font-style: italic;
}

.gp-ide-tree-folder.is-pending::before {
    content: "•";
    color: #fbbf24;
    margin-right: 0.15rem;
    font-weight: bold;
}

.gp-ide-tree-folder.is-pending,
.gp-ide-tree-file.is-pending {
    outline: 1px dashed #4b5563;
    outline-offset: -2px;
}

.gp-ide-tree-row-dragging {
    opacity: 0.4;
}

.gp-ide-drag-ghost {
    position: fixed;
    z-index: 250;
    pointer-events: none;
    background: #181b20;
    border: 1px solid #4b5563;
    border-radius: 4px;
    padding: 0.2rem 0.5rem;
    font-size: 11px;
    color: #d1d5db;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.5);
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    max-width: 16rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Inline rename input ── */
.gp-ide-tree-rename-input {
    flex: 1;
    min-width: 0;
    background: #0f1115;
    border: 1px solid #4b5563;
    border-radius: 2px;
    padding: 1px 4px;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 11px;
    color: #fff;
    outline: none;
}

.gp-ide-tree-rename-input:focus {
    border-color: #10b981;
}

/* ── Context menu ── */
.gp-context-menu {
    position: fixed;
    z-index: 300;
    background: #181b20;
    border: 1px solid #272b31;
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
    padding: 4px;
    min-width: 12rem;
    font-family: Inter, system-ui, sans-serif;
}

.gp-context-menu button {
    width: 100%;
    text-align: left;
    background: transparent;
    border: none;
    color: #d1d5db;
    font-size: 12px;
    padding: 7px 10px;
    border-radius: 3px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: inherit;
}

.gp-context-menu button:hover:not(:disabled) {
    background: #272b31;
    color: #fff;
}

.gp-context-menu button:disabled {
    color: #4b5563;
    cursor: not-allowed;
}

.gp-context-menu button i {
    width: 14px;
    color: #6b7280;
    flex-shrink: 0;
    text-align: center;
}

.gp-context-menu button.is-danger {
    color: #f87171;
}

.gp-context-menu button.is-danger:hover:not(:disabled) {
    background: #7f1d1d33;
    color: #fca5a5;
}

.gp-context-menu hr {
    border: none;
    border-top: 1px solid #272b31;
    margin: 3px 0;
}

/* ── Mobile (≤ 767px): stack IDE vertically; fullscreen turns sidebar into a slide-in drawer ── */
@media (max-width: 767px) {
    .gp-ide {
        flex-direction: column;
        max-height: none;
    }

    .gp-ide-sidebar {
        flex: 0 0 auto;
        max-width: 100%;
        border-right: none;
        border-bottom: 1px solid #272b31;
        max-height: 14rem;
    }

    .gp-ide-tree-folder,
    .gp-ide-tree-file {
        min-height: 2.1rem;
        font-size: 12px;
        padding-top: 0.35rem;
        padding-bottom: 0.35rem;
    }

    .gp-ide-tree-file-actions {
        display: flex;
        opacity: 0.6;
    }

    .gp-ide-icon-btn {
        width: 2.25rem;
        height: 2.25rem;
        font-size: 13px;
    }

    .gp-ide-sidebar-head {
        padding: 0.5rem 0.75rem;
    }

    .gp-ide.gp-ide-fullscreen {
        flex-direction: row;
    }

    .gp-ide.gp-ide-fullscreen .gp-ide-sidebar {
        position: absolute;
        top: 0;
        bottom: 0;
        left: 0;
        z-index: 5;
        max-height: none;
        width: 80vw;
        max-width: 18rem;
        transform: translateX(-100%);
        transition: transform 0.22s ease;
        border-right: 1px solid #272b31;
        border-bottom: none;
        background: #0a0c0f;
    }

    .gp-ide.gp-ide-fullscreen.gp-ide-drawer-open .gp-ide-sidebar {
        transform: translateX(0);
        box-shadow: 8px 0 24px rgba(0, 0, 0, 0.55);
    }

    .gp-ide.gp-ide-fullscreen .gp-ide-main {
        width: 100%;
    }

    .gp-ide.gp-ide-fullscreen .gp-ide-drawer-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 1.75rem;
        height: 1.75rem;
        border: 1px solid #3a4149;
        background: transparent;
        color: #9ca3af;
        border-radius: 4px;
        cursor: pointer;
        margin-right: 0.35rem;
        flex-shrink: 0;
    }

    .gp-ide.gp-ide-fullscreen .gp-ide-drawer-toggle:hover {
        background: #272b31;
        color: #fff;
    }

    .gp-context-menu {
        min-width: 14rem;
    }

    .gp-context-menu button {
        font-size: 13px;
        padding: 10px 12px;
    }
}
