/* ============================================
   API PORTAL — Custom Styles
   Layered on top of HopeUI + custom.css
   ============================================ */

/* Override body centering from custom.css */
body.portal-body {
    display: block;
    align-items: initial;
    justify-content: initial;
    background: linear-gradient(135deg, #72B2D4 0%, #e8f4f8 40%, #ffffff 100%);
    min-height: 100vh;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

/* ─── Layout ─── */
.portal-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ─── Sidebar ─── */
.portal-sidebar {
    width: 300px;
    min-width: 300px;
    background: #ffffff;
    border-right: 1px solid rgba(15, 52, 104, 0.08);
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 20px rgba(15, 52, 104, 0.06);
    z-index: 10;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-header {
    padding: 1.25rem 1.25rem 1rem;
    border-bottom: 1px solid rgba(15, 52, 104, 0.08);
    background: linear-gradient(135deg, #0f3468 0%, #174593 100%);
}

.sidebar-header h4 {
    color: #ffffff;
    font-weight: 700;
    margin: 0;
    font-size: 1.15rem;
    letter-spacing: -0.01em;
}

.sidebar-header .subtitle {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.78rem;
    margin-top: 0.25rem;
}

.sidebar-search {
    padding: 0.85rem 1.25rem;
    border-bottom: 1px solid rgba(15, 52, 104, 0.06);
}

.sidebar-search input {
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    padding: 0.55rem 0.85rem 0.55rem 2.4rem;
    font-size: 0.85rem;
    width: 100%;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001q.044.06.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1 1 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 0.75rem center;
    background-size: 14px;
    transition: all 0.2s ease;
    color: #1e293b;
}

.sidebar-search input:focus {
    border-color: #0f3468;
    box-shadow: 0 0 0 3px rgba(15, 52, 104, 0.08);
    outline: none;
}

.sidebar-search input::placeholder {
    color: #94a3b8;
}

/* Method list */
.method-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(15, 52, 104, 0.15) transparent;
}

.method-category {
    padding: 0.5rem 1.25rem 0.35rem;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #94a3b8;
    margin-top: 0.5rem;
}

.method-category:first-child {
    margin-top: 0;
}

.method-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.65rem 1.25rem;
    cursor: pointer;
    transition: all 0.15s ease;
    border-left: 3px solid transparent;
    position: relative;
}

.method-item:hover {
    background: rgba(15, 52, 104, 0.03);
}

.method-item.active {
    background: rgba(15, 52, 104, 0.06);
    border-left-color: #0f3468;
}

.method-badge {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.2rem 0.45rem;
    border-radius: 4px;
    min-width: 38px;
    text-align: center;
    letter-spacing: 0.02em;
    flex-shrink: 0;
}

.method-badge.post {
    background: rgba(52, 152, 219, 0.12);
    color: #2980b9;
}

.method-badge.get {
    background: rgba(39, 174, 96, 0.12);
    color: #27ae60;
}

.method-badge.put {
    background: rgba(243, 156, 18, 0.12);
    color: #e67e22;
}

.method-badge.delete {
    background: rgba(231, 76, 60, 0.12);
    color: #e74c3c;
}

.method-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: #334155;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.method-danger-badge {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    padding: 0.16rem 0.4rem;
    border-radius: 999px;
    background: rgba(220, 38, 38, 0.12);
    color: #b91c1c;
    border: 1px solid rgba(220, 38, 38, 0.22);
    flex-shrink: 0;
}

.method-danger-badge i {
    font-size: 0.62rem;
}

.method-item.active .method-name {
    color: #0f3468;
    font-weight: 600;
}

/* ─── Main Content ─── */
.portal-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 1.75rem 2rem;
}

/* ─── Welcome state ─── */
.portal-welcome {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: #64748b;
    gap: 1rem;
    padding: 2rem;
    animation: fadeInWelcome 0.5s ease;
}

@keyframes fadeInWelcome {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.portal-welcome .welcome-icon {
    font-size: 3.5rem;
    color: #0f3468;
    opacity: 0.3;
}

.portal-welcome h3 {
    color: #334155;
    font-weight: 700;
    margin: 0;
}

.portal-welcome p {
    max-width: 400px;
    line-height: 1.6;
    font-size: 0.9rem;
}

/* ─── Method detail animation ─── */
.method-detail {
    animation: slideInContent 0.3s ease;
}

@keyframes slideInContent {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   UNIFIED PANEL  (replaces stacked cards)
   ============================================ */

.portal-panel {
    background: #ffffff;
    border-radius: 16px;
    border: 1px solid rgba(15, 52, 104, 0.06);
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.05);
    overflow: hidden;
}

/* ─── Panel header ─── */
.panel-header {
    padding: 1.35rem 1.5rem 1.1rem;
    background: linear-gradient(135deg, #0f3468 0%, #174593 100%);
}

.panel-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.panel-title {
    color: #ffffff;
    font-weight: 700;
    margin: 0;
    font-size: 1.1rem;
    letter-spacing: -0.01em;
}

.endpoint-danger-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: rgba(248, 113, 113, 0.18);
    color: #fee2e2;
    border: 1px solid rgba(254, 202, 202, 0.3);
    border-radius: 999px;
    padding: 0.22rem 0.55rem;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.endpoint-danger-note {
    margin-top: 0.7rem;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: rgba(248, 113, 113, 0.12);
    color: rgba(255, 240, 240, 0.95);
    border: 1px solid rgba(254, 202, 202, 0.26);
    border-radius: 8px;
    padding: 0.4rem 0.6rem;
    font-size: 0.76rem;
    line-height: 1.35;
}

.panel-endpoint {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.1);
    padding: 0.3rem 0.7rem;
    border-radius: 8px;
}

.endpoint-method {
    font-size: 0.68rem;
    font-weight: 800;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    letter-spacing: 0.04em;
    flex-shrink: 0;
}

.endpoint-method.post {
    background: rgba(255, 255, 255, 0.2);
    color: #7dd3fc;
}

.endpoint-method.get {
    background: rgba(255, 255, 255, 0.2);
    color: #86efac;
}

.endpoint-method.put {
    background: rgba(255, 255, 255, 0.2);
    color: #fbbf24;
}

.endpoint-method.delete {
    background: rgba(255, 255, 255, 0.2);
    color: #fca5a5;
}

.endpoint-url {
    font-family: 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.85);
    word-break: break-all;
}

.panel-description {
    color: rgba(255, 255, 255, 0.75);
    font-size: 0.84rem;
    line-height: 1.55;
    margin: 0.65rem 0 0;
}

/* ─── Panel sections (parameters, response) ─── */
.panel-section {
    padding: 1.25rem 1.5rem;
    border-top: 1px solid rgba(15, 52, 104, 0.07);
}

/* The section-label-row sits between the label and the mode toggle */
.section-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.section-label-row .section-label {
    margin-bottom: 0;
}

.section-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: #94a3b8;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.section-label i {
    font-size: 0.82rem;
}

/* ─── Test / Manual Mode Toggle ─── */
.mode-toggle {
    display: flex;
    background: #f1f5f9;
    border-radius: 8px;
    padding: 3px;
    gap: 2px;
}

.mode-btn {
    padding: 0.3rem 0.75rem;
    border: none;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    transition: all 0.2s ease;
    background: transparent;
    color: #94a3b8;
}

.mode-btn:hover {
    color: #475569;
}

.mode-btn.active {
    background: linear-gradient(135deg, #0f3468 0%, #174593 100%);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(15, 52, 104, 0.25);
}

.mode-btn i {
    font-size: 0.7rem;
}

.no-params-msg {
    color: #94a3b8;
    font-size: 0.85rem;
    margin: 0;
}

/* ─── Parameter Form ─── */
.param-group {
    margin-bottom: 1rem;
}

.param-group:last-child {
    margin-bottom: 0;
}

.param-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
}

.param-label label {
    font-weight: 600;
    font-size: 0.82rem;
    color: #174593;
    margin: 0;
}

.param-label .required-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #e74c3c;
    flex-shrink: 0;
}

.param-label .param-type {
    font-size: 0.7rem;
    color: #94a3b8;
    font-family: 'Fira Code', monospace;
    background: #f1f5f9;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
}

.param-description {
    font-size: 0.75rem;
    color: #94a3b8;
    margin-bottom: 0.35rem;
}

.param-input {
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    padding: 0.55rem 0.85rem;
    font-size: 0.85rem;
    width: 100%;
    transition: all 0.2s ease;
    color: #1e293b;
}

.param-input:focus {
    border-color: #0f3468;
    box-shadow: 0 0 0 3px rgba(15, 52, 104, 0.08);
    outline: none;
}

.param-input::placeholder {
    color: #cbd5e1;
}

textarea.param-input {
    min-height: 90px;
    resize: vertical;
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 0.82rem;
}

/* ─── Send button area ─── */
.send-area {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding-top: 1.15rem;
    margin-top: 0.5rem;
    border-top: 1px dashed rgba(15, 52, 104, 0.08);
}

.btn-send {
    background: linear-gradient(135deg, #0f3468 0%, #174593 100%) !important;
    color: #fff !important;
    font-weight: 600;
    padding: 0.6rem 1.75rem;
    border-radius: 10px;
    border: none;
    font-size: 0.88rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.25s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.btn-send:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(15, 52, 104, 0.35);
}

.btn-send:active {
    transform: translateY(0);
}

.btn-send.loading {
    pointer-events: none;
    opacity: 0.8;
}

.btn-send .spinner {
    display: none;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.btn-send.loading .spinner {
    display: inline-block;
}

.btn-send.loading .send-text {
    display: none;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.btn-clear {
    background: transparent;
    border: 1.5px solid #e2e8f0;
    color: #64748b;
    font-weight: 500;
    padding: 0.6rem 1.25rem;
    border-radius: 10px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-clear:hover {
    border-color: #cbd5e1;
    color: #334155;
    background: #f8fafc;
}

/* ─── Response Panel ─── */
.panel-response-section {
    background: #fafbfc;
}

.response-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.status-badge {
    font-size: 0.78rem;
    font-weight: 700;
    padding: 0.25rem 0.65rem;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.status-badge.success {
    background: rgba(39, 174, 96, 0.1);
    color: #27ae60;
}

.status-badge.client-error {
    background: rgba(243, 156, 18, 0.1);
    color: #e67e22;
}

.status-badge.server-error {
    background: rgba(231, 76, 60, 0.1);
    color: #e74c3c;
}

.status-badge.network-error {
    background: rgba(231, 76, 60, 0.1);
    color: #e74c3c;
}

.response-time {
    font-size: 0.78rem;
    color: #94a3b8;
    font-weight: 500;
}

.response-body {
    background: #0f172a;
    border-radius: 10px;
    padding: 1.25rem;
    margin-top: 0.85rem;
    max-height: 400px;
    overflow: auto;
    position: relative;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

.response-body pre {
    margin: 0;
    font-family: 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
    font-size: 0.82rem;
    line-height: 1.65;
    color: #e2e8f0;
    white-space: pre-wrap;
    word-break: break-word;
}

/* JSON syntax highlighting */
.json-key {
    color: #7dd3fc;
}

.json-string {
    color: #86efac;
}

.json-number {
    color: #fbbf24;
}

.json-boolean {
    color: #c084fc;
}

.json-null {
    color: #fb7185;
}

.btn-copy {
    position: absolute;
    top: 0.6rem;
    right: 0.6rem;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #94a3b8;
    padding: 0.35rem 0.6rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.btn-copy:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #e2e8f0;
}

.btn-copy.copied {
    background: rgba(39, 174, 96, 0.2);
    color: #27ae60;
    border-color: rgba(39, 174, 96, 0.3);
}

/* Empty response */
.response-empty {
    text-align: center;
    padding: 1.75rem;
    color: #b0bec5;
    font-size: 0.84rem;
}

.response-empty i {
    font-size: 1.5rem;
    margin-bottom: 0.4rem;
    display: block;
    opacity: 0.35;
}

/* ─── Base URL Config Bar ─── */
.base-url-bar {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.65rem 1.25rem;
    background: rgba(15, 52, 104, 0.03);
    border-bottom: 1px solid rgba(15, 52, 104, 0.06);
}

.base-url-bar label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #64748b;
    white-space: nowrap;
    margin: 0;
}

.base-url-bar input {
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    padding: 0.4rem 0.7rem;
    font-size: 0.8rem;
    font-family: 'Fira Code', monospace;
    flex: 1;
    color: #334155;
    transition: all 0.2s ease;
}

.base-url-bar input:focus {
    border-color: #0f3468;
    box-shadow: 0 0 0 3px rgba(15, 52, 104, 0.08);
    outline: none;
}

/* ─── Mobile Toggle ─── */
.sidebar-toggle {
    display: none;
    position: fixed;
    bottom: 1.25rem;
    right: 1.25rem;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0f3468 0%, #174593 100%);
    color: #fff;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    z-index: 100;
    box-shadow: 0 4px 15px rgba(15, 52, 104, 0.4);
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
}

.sidebar-toggle:hover {
    transform: scale(1.08);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 9;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* ─── Responsive ─── */
@media (max-width: 768px) {
    .portal-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(-100%);
        z-index: 20;
    }

    .portal-sidebar.open {
        transform: translateX(0);
    }

    .sidebar-toggle {
        display: flex;
    }

    .portal-main {
        padding: 1.25rem 1rem;
    }

    .panel-title-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .send-area {
        flex-direction: column;
    }

    .send-area .btn-send,
    .send-area .btn-clear {
        width: 100%;
        justify-content: center;
    }
}

/* ─── Scrollbar ─── */
.method-list::-webkit-scrollbar,
.response-body::-webkit-scrollbar {
    width: 6px;
}

.method-list::-webkit-scrollbar-track,
.response-body::-webkit-scrollbar-track {
    background: transparent;
}

.method-list::-webkit-scrollbar-thumb {
    background: rgba(15, 52, 104, 0.15);
    border-radius: 3px;
}

.response-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}

/* ─── Checkbox / toggle for boolean params ─── */
.param-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.param-toggle input[type="checkbox"] {
    width: 40px;
    height: 20px;
    cursor: pointer;
    accent-color: #0f3468;
}

.param-toggle span {
    font-size: 0.82rem;
    color: #64748b;
}

/* ─── Array param helper ─── */
.array-helper {
    font-size: 0.72rem;
    color: #94a3b8;
    margin-top: 0.25rem;
    font-style: italic;
}

.back-to-app {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    margin-top: 10px;
    font-size: 0.72rem;
    font-weight: 500;
    color: #6c8cbf;
    text-decoration: none;
    opacity: 0.75;
    letter-spacing: 0.02em;
    transition: opacity 0.15s ease;
}

.back-to-app:hover {
    opacity: 1;
    color: #174593;
}

.back-to-app .bi {
    font-size: 0.9rem;
}