/**
 * SalesVu API Explorer — Square-style layout and panels.
 *
 * By Cursor, 2026-07-03: Polished console layout — card workspace, full-width panels, balanced split.
 */

/* ── Page shell ─────────────────────────────────────────────── */
.ae-page {
    background: #eef2f6;
    height: 100vh;
    min-height: 100vh;
    overflow: hidden;
    box-sizing: border-box;
    font-family: "Jost", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.ae-page-console {
    padding: 0;
}

/* By Cursor, 2026-07-09: Guest API Explorer — public header in-flow (not fixed over toolbar). */
.ae-page-public {
    padding: 0;
}

.ae-public-wrap {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    max-width: 1680px;
    margin: 0 auto;
    padding: 12px 16px 16px;
    box-sizing: border-box;
    overflow: hidden;
    gap: 0;
}

/* By Cursor, 2026-07-09: oauth.css fixes api-ref-topbar to viewport; that blocks toolbar clicks for guests. */
.ae-page-public .ae-public-wrap .api-ref-topbar {
    position: sticky;
    top: 0;
    left: auto;
    right: auto;
    width: auto;
    flex-shrink: 0;
    margin-bottom: 10px;
    border-radius: 12px;
    z-index: 200;
}

.ae-public-wrap .ae-shell {
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
}

/* By Cursor, 2026-07-09: Dropdowns must sit above sticky public nav. */
.ae-page-public .ae-dropdown {
    z-index: 300;
}

.ae-console-wrap {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    max-width: 1680px;
    margin: 0 auto;
    padding: 12px 16px 16px;
    box-sizing: border-box;
    overflow: hidden;
    gap: 0;
}

.ae-console-wrap .portal-topbar {
    flex-shrink: 0;
    margin-bottom: 10px;
    border-radius: 12px;
}

.ae-console-wrap .ae-shell {
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
}

.ae-shell {
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
    overflow: hidden;
}

/* ── Main workspace card ──────────────────────────────────── */
.ae-workspace {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.06);
    overflow: hidden;
}

/* ── Toolbar ────────────────────────────────────────────────── */
.ae-toolbar {
    display: flex;
    align-items: center;
    gap: 12px 16px;
    flex-shrink: 0;
    width: 100%;
    box-sizing: border-box;
    padding: 12px 16px;
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    position: relative;
    z-index: 30;
    overflow: visible;
}

.ae-toolbar-selects {
    display: flex;
    gap: 10px;
    flex: 1 1 auto;
    min-width: 0;
}

.ae-select-wrap {
    position: relative;
    flex: 1 1 0;
    min-width: 0;
    max-width: 280px;
}

.ae-select-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 9px 12px;
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 14px;
    color: #0f172a;
    cursor: pointer;
    text-align: left;
    transition: border-color 0.15s, box-shadow 0.15s;
    font-family: inherit;
}

.ae-select-trigger:hover {
    border-color: #94a3b8;
}

.ae-select-trigger-open,
.ae-select-trigger:focus {
    outline: none;
    border-color: #006aff;
    box-shadow: 0 0 0 3px rgba(0, 106, 255, 0.12);
}

.ae-select-trigger-disabled,
.ae-select-trigger:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    background: #f8fafc;
}

.ae-select-label {
    color: #64748b;
    font-size: 12px;
    white-space: nowrap;
    flex-shrink: 0;
}

.ae-select-value {
    flex: 1;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.ae-chevron {
    flex-shrink: 0;
    color: #64748b;
}

.ae-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.14);
    z-index: 50;
    overflow: hidden;
}

.ae-dropdown-search {
    display: block;
    width: 100%;
    padding: 10px 14px;
    border: none;
    border-bottom: 1px solid #e2e8f0;
    font-size: 14px;
    outline: none;
    font-family: inherit;
    box-sizing: border-box;
}

.ae-dropdown-list {
    list-style: none;
    margin: 0;
    padding: 6px 0;
    max-height: 260px;
    overflow-y: auto;
}

.ae-dropdown-item {
    padding: 9px 14px;
    font-size: 14px;
    cursor: pointer;
    color: #0f172a;
}

.ae-dropdown-item:hover,
.ae-dropdown-item-active {
    background: #eff6ff;
    color: #006aff;
}

.ae-toolbar-meta {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.ae-version-badge {
    font-size: 12px;
    color: #475569;
    padding: 6px 10px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    white-space: nowrap;
}

.ae-toolbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    margin-left: auto;
}

.ae-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 16px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 8px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    font-family: inherit;
    line-height: 1.2;
}

.ae-btn-primary {
    background: #006aff;
    color: #fff;
    border-color: #006aff;
    min-width: 120px;
}

.ae-btn-primary:hover:not(:disabled) {
    background: #0052cc;
    border-color: #0052cc;
}

.ae-btn-primary:disabled {
    opacity: 0.65;
    cursor: wait;
}

.ae-btn-icon {
    padding: 9px;
    background: #fff;
    border-color: #cbd5e1;
    color: #475569;
    min-width: 0;
}

.ae-btn-icon:hover {
    background: #f8fafc;
    border-color: #94a3b8;
}

.ae-btn-ghost {
    padding: 8px 12px;
    background: #fff;
    border-color: #cbd5e1;
    color: #475569;
    font-size: 13px;
    min-width: 0;
    flex-shrink: 0;
}

.ae-btn-ghost:hover {
    background: #f8fafc;
}

/* ── Two-column layout ──────────────────────────────────────── */
.ae-layout {
    display: grid;
    grid-template-columns: minmax(300px, 400px) minmax(0, 1fr);
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    width: 100%;
}

/* ── Left sidebar ───────────────────────────────────────────── */
.ae-sidebar {
    background: #fff;
    border-right: 1px solid #e2e8f0;
    padding: 20px 22px 24px;
    min-height: 0;
    min-width: 0;
    overflow-x: hidden;
    overflow-y: auto;
}

.ae-endpoint-header {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid #f1f5f9;
}

.ae-endpoint-title {
    font-size: 20px;
    font-weight: 700;
    color: #0f172a;
    margin: 10px 0 8px;
    line-height: 1.25;
}

.ae-endpoint-path {
    margin: 0;
}

.ae-endpoint-path code {
    display: block;
    max-width: 100%;
    font-size: 12px;
    color: #334155;
    background: #f1f5f9;
    padding: 8px 10px;
    border-radius: 6px;
    overflow-wrap: anywhere;
    word-break: break-word;
    border: 1px solid #e2e8f0;
}

.ae-endpoint-desc {
    font-size: 13px;
    color: #64748b;
    margin-top: 10px;
    line-height: 1.5;
}

.ae-placeholder-title {
    font-size: 17px;
    font-weight: 600;
    color: #334155;
    margin-bottom: 8px;
}

.ae-placeholder-text {
    font-size: 13px;
    color: #64748b;
    line-height: 1.55;
    margin: 0;
}

.ae-section {
    margin-bottom: 20px;
    padding: 14px 0 0;
    border-top: 1px solid #f1f5f9;
}

.ae-section:first-of-type {
    border-top: none;
    padding-top: 0;
}

.ae-section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #64748b;
    margin: 0 0 8px;
}

.ae-section-hint {
    font-size: 13px;
    color: #64748b;
    margin: 0 0 10px;
    line-height: 1.45;
}

.ae-section-hint a {
    color: #006aff;
    text-decoration: none;
}

.ae-section-hint a:hover {
    text-decoration: underline;
}

.ae-token-row {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.ae-input {
    flex: 1;
    min-width: 0;
    padding: 9px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 13px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    box-sizing: border-box;
}

.ae-input:focus {
    outline: none;
    border-color: #006aff;
    box-shadow: 0 0 0 3px rgba(0, 106, 255, 0.1);
}

.ae-body-editor {
    width: 100%;
    padding: 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 12px;
    line-height: 1.55;
    resize: vertical;
    min-height: 140px;
    max-height: 320px;
    box-sizing: border-box;
    display: block;
}

.ae-body-editor:focus {
    outline: none;
    border-color: #006aff;
    box-shadow: 0 0 0 3px rgba(0, 106, 255, 0.1);
}

.ae-scope-code {
    display: inline-block;
    padding: 5px 10px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 12px;
    color: #0f172a;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.ae-signin-hint {
    font-size: 12px;
    color: #64748b;
    margin: 10px 0 0;
}

.ae-signin-hint a {
    color: #006aff;
    text-decoration: none;
}

.ae-signin-hint a:hover {
    text-decoration: underline;
}

/* HTTP method badges */
.ae-method {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    padding: 3px 7px;
    border-radius: 4px;
    text-transform: uppercase;
    vertical-align: middle;
    letter-spacing: 0.03em;
}

.ae-method-lg {
    font-size: 11px;
    padding: 4px 9px;
}

.ae-method-get { background: #dcfce7; color: #166534; }
.ae-method-post { background: #dbeafe; color: #1e40af; }
.ae-method-put { background: #fef3c7; color: #92400e; }
.ae-method-delete { background: #fee2e2; color: #991b1b; }
.ae-method-patch { background: #f3e8ff; color: #6b21a8; }

/* ── Right panels (request + response) ──────────────────────── */
.ae-panels {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-width: 0;
    min-height: 0;
    height: 100%;
    overflow: hidden;
    background: #f1f5f9;
}

.ae-panel {
    display: flex;
    flex-direction: column;
    flex: 1 1 50%;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
    background: #fff;
}

.ae-panel-request {
    border-bottom: 1px solid #e2e8f0;
}

.ae-panel-response {
    border-bottom: none;
}

.ae-panel-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    padding: 0 14px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    min-height: 40px;
    gap: 8px;
}

.ae-panel-bar-dark {
    background: #1e293b;
    border-bottom-color: #0f172a;
    color: #f1f5f9;
}

.ae-panel-title {
    font-size: 12px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    flex: 1;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.ae-panel-tools {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.ae-lang-badge {
    font-size: 11px;
    color: #94a3b8;
    padding: 2px 7px;
    border: 1px solid #475569;
    border-radius: 4px;
}

.ae-panel-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    background: transparent;
    border: none;
    color: inherit;
    cursor: pointer;
    border-radius: 6px;
    opacity: 0.9;
}

.ae-panel-btn:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.12);
}

.ae-panel-bar:not(.ae-panel-bar-dark) .ae-panel-btn:hover {
    background: #e2e8f0;
}

.ae-code {
    flex: 1 1 auto;
    min-height: 0;
    margin: 0;
    padding: 14px 16px;
    overflow: auto;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 12px;
    line-height: 1.65;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
    box-sizing: border-box;
}

.ae-code code {
    font-family: inherit;
}

.ae-code-dark {
    background: #0f172a;
    color: #e2e8f0;
}

.ae-code-light {
    background: #fff;
    color: #0f172a;
}

.ae-status-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 4px;
    white-space: nowrap;
}

.ae-status-ok {
    background: #dcfce7;
    color: #166534;
}

.ae-status-error {
    background: #fee2e2;
    color: #991b1b;
}

/* Expanded panel overlay */
.ae-panel-expanded {
    position: fixed;
    inset: 12px;
    z-index: 950;
    flex: none !important;
    min-height: auto !important;
    max-width: none !important;
    width: auto !important;
    height: auto !important;
    border-radius: 10px;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.2);
    border: 1px solid #e2e8f0;
}

/* Toast */
.ae-toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 10px 18px;
    background: #0f172a;
    color: #fff;
    font-size: 13px;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.25);
    z-index: 2000;
}

/* ── Desktop toolbar grid (single row) ──────────────────────── */
@media (min-width: 1100px) {
    .ae-toolbar {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto auto;
        align-items: center;
    }

    .ae-toolbar-selects {
        grid-column: 1;
        max-width: 560px;
    }

    .ae-toolbar-meta {
        grid-column: 2;
    }

    .ae-toolbar-actions {
        grid-column: 3;
        margin-left: 0;
    }
}

/* ── Tablet / mobile ────────────────────────────────────────── */
@media (max-width: 960px) {
    .ae-page {
        height: auto;
        min-height: 100vh;
        overflow: auto;
    }

    .ae-console-wrap,
    .ae-public-wrap {
        height: auto;
        min-height: 100vh;
        overflow: visible;
        padding: 10px 12px 16px;
    }

    .ae-shell,
    .ae-workspace {
        height: auto;
        min-height: 0;
        overflow: visible;
    }

    .ae-layout {
        grid-template-columns: 1fr;
        height: auto;
        overflow: visible;
    }

    .ae-sidebar {
        border-right: none;
        border-bottom: 1px solid #e2e8f0;
        max-height: none;
    }

    .ae-panels {
        min-height: 520px;
        height: 520px;
    }

    .ae-toolbar {
        flex-wrap: wrap;
    }

    .ae-toolbar-selects {
        flex-direction: column;
        width: 100%;
        max-width: none;
    }

    .ae-select-wrap {
        max-width: none;
    }

    .ae-toolbar-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .ae-toolbar-meta {
        order: 3;
        width: 100%;
    }
}

@media (max-width: 600px) {
    .ae-toolbar {
        padding: 10px 12px;
    }

    .ae-select-label {
        display: none;
    }

    .ae-btn-primary {
        min-width: 0;
        flex: 1;
    }
}
