/* Fonts loaded via HTML <link> tag */


/* ================================
   TOKENS
================================ */
:root {
    --bg:        #f0f2f5;
    --white:     #ffffff;
    --sidebar-w: 300px;

    --border:    #e2e5ea;
    --border2:   #c9ced7;

    --text:      #1c2333;
    --text2:     #5a6375;
    --text3:     #9ba3b2;

    --accent:    #4f6ef7;
    --accent-h:  #3b5be6;
    --accent-bg: #eef1ff;

    --green:  #16a34a;
    --yellow: #b45309;
    --purple: #7c3aed;
    --red:    #dc2626;
    --blue:   #1d4ed8;

    --code-bg: #1a1f2e;

    --ff: 'Inter', -apple-system, sans-serif;
    --ff-mono: 'JetBrains Mono', 'Courier New', monospace;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.06);
    --shadow:    0 1px 4px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --r: 8px;
    --r-sm: 5px;
}

/* ================================
   RESET
================================ */
*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }
html { height: 100%; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--ff);
    font-size: 13px;
    line-height: 1.5;
    height: 100%;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

/* ================================
   TOPBAR
================================ */
.topbar {
    background: var(--white);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}

.topbar-inner {
    max-width: 100%;
    padding: 0 20px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.topbar-logo {
    width: 30px; height: 30px;
    background: var(--accent);
    border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

.topbar-logo svg { width: 15px; height: 15px; fill: white; }

.topbar-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.01em;
}

.topbar-sub {
    font-size: 10.5px;
    color: var(--text3);
    margin-top: 1px;
}

.topbar-meta {
    display: flex;
    align-items: center;
    gap: 8px;
}

.meta-chip {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 3px 10px;
    font-size: 11px;
    color: var(--text2);
    white-space: nowrap;
}

.meta-chip code {
    font-family: var(--ff-mono);
    color: var(--text);
    font-size: 10.5px;
}

/* ================================
   LAYOUT
================================ */
.layout {
    display: flex;
    flex: 1;
    overflow: hidden;
    height: calc(100vh - 52px);
}

/* ================================
   SIDEBAR
================================ */
.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--white);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.panel {
    padding: 16px;
    border-bottom: 1px solid var(--border);
}

.panel-recent {
    flex: 1;
}

.panel-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 14px;
    letter-spacing: 0.01em;
}

/* Form fields */
.field-group {
    margin-bottom: 10px;
}

.field-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--text2);
    margin-bottom: 4px;
}

.field-input {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    padding: 7px 10px;
    font-family: var(--ff);
    font-size: 12px;
    color: var(--text);
    transition: border-color 0.15s;
}

.field-input:focus {
    outline: none;
    border-color: var(--accent);
    background: white;
}

.field-input:read-only { cursor: default; opacity: 0.7; }
.field-input:not(:read-only) { opacity: 1; }

.field-token {
    font-family: var(--ff-mono);
    font-size: 10px;
    background: #f8f9fc;
    color: var(--text2);
}

.field-token.has-token {
    color: var(--green);
    background: #f0fdf4;
    border-color: #bbf7d0;
    opacity: 1;
}

/* Select */
.select-wrap {
    position: relative;
}

.select-wrap select {
    width: 100%;
    appearance: none;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    padding: 7px 28px 7px 10px;
    font-family: var(--ff);
    font-size: 12px;
    color: var(--text);
    cursor: pointer;
    transition: border-color 0.15s;
}

.select-wrap select:focus {
    outline: none;
    border-color: var(--accent);
}

.select-arrow {
    position: absolute;
    right: 9px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 10px;
    color: var(--text3);
    pointer-events: none;
}

/* Buttons */
.btn-row {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

.btn-primary {
    flex: 1;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--r-sm);
    padding: 8px;
    font-family: var(--ff);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-primary:hover { background: var(--accent-h); }
.btn-primary:disabled { background: var(--text3); cursor: not-allowed; }

.btn-ghost {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    padding: 8px 12px;
    font-family: var(--ff);
    font-size: 12px;
    color: var(--text2);
    cursor: pointer;
    transition: all 0.15s;
}

.btn-ghost:hover {
    border-color: var(--border2);
    color: var(--text);
    background: var(--bg);
}

/* Login status */
.login-status {
    margin-top: 8px;
    font-size: 11px;
    min-height: 14px;
}

.login-status.ok  { color: var(--green); }
.login-status.err { color: var(--red); }

/* Recent */
.recent-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.recent-empty {
    font-size: 11.5px;
    color: var(--text3);
    text-align: center;
    padding: 12px 0;
}

.recent-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    border-radius: var(--r-sm);
    cursor: pointer;
    transition: background 0.12s;
    border: 1px solid transparent;
}

.recent-item:hover { background: var(--bg); border-color: var(--border); }

.recent-method {
    font-family: var(--ff-mono);
    font-size: 9px;
    font-weight: 700;
    padding: 2px 5px;
    border-radius: 3px;
    color: white;
    flex-shrink: 0;
}

.recent-route {
    font-family: var(--ff-mono);
    font-size: 10px;
    color: var(--text2);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.recent-status {
    font-size: 10px;
    font-weight: 700;
    flex-shrink: 0;
}

.recent-status.ok  { color: var(--green); }
.recent-status.err { color: var(--red); }

/* ================================
   MAIN CONTENT
================================ */
.main-content {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 16px;
    gap: 14px;
}

/* Request Bar */
.request-bar {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--r);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.request-bar-empty {
    padding: 14px 18px;
    font-size: 12.5px;
    color: var(--text3);
    display: flex;
    align-items: center;
    gap: 8px;
}

.request-bar-active {
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.request-bar-active.hidden { display: none; }
.request-bar-empty.hidden  { display: none; }

/* Method pill */
.method-pill {
    font-family: var(--ff-mono);
    font-size: 11px;
    font-weight: 700;
    padding: 5px 12px;
    border-radius: var(--r-sm);
    color: white;
    flex-shrink: 0;
}

.method-pill.GET    { background: var(--green); }
.method-pill.POST   { background: var(--yellow); }
.method-pill.PATCH  { background: var(--purple); }
.method-pill.DELETE { background: var(--red); }
.method-pill.PUT    { background: var(--blue); }

.url-text {
    font-family: var(--ff-mono);
    font-size: 12.5px;
    color: var(--text);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-send {
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--r-sm);
    padding: 8px 18px;
    font-family: var(--ff);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    flex-shrink: 0;
}

.btn-send:hover { background: var(--accent-h); }
.btn-send svg { width: 13px; height: 13px; fill: currentColor; }

/* Content panels */
.content-panels {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

@media (max-width: 900px) {
    .content-panels { grid-template-columns: 1fr; }
}

.content-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--r);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.content-card-header {
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fafbfc;
}

.content-card-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
}

.content-card-hint {
    font-weight: 400;
    color: var(--text3);
    font-size: 11px;
}

.btn-format {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 3px 9px;
    font-size: 11px;
    color: var(--text2);
    cursor: pointer;
    font-family: var(--ff);
    transition: all 0.12s;
}

.btn-format:hover { background: var(--bg); }

/* JSON Editor */
.editor-wrap {
    flex: 1;
    display: flex;
}

.json-editor {
    width: 100%;
    min-height: 220px;
    max-height: 340px;
    background: var(--code-bg);
    border: none;
    padding: 14px;
    font-family: var(--ff-mono);
    font-size: 12px;
    color: #93c5fd;
    line-height: 1.65;
    resize: vertical;
    outline: none;
}

.json-editor::placeholder { color: #4b5563; }

.editor-hint {
    padding: 8px 14px;
    font-size: 11px;
    color: var(--text3);
    border-top: 1px solid var(--border);
    background: #fafbfc;
}

/* Response */
.response-meta {
    display: flex;
    align-items: center;
    gap: 6px;
}

.res-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--text3);
    flex-shrink: 0;
}

.res-dot.ok  { background: var(--green); }
.res-dot.err { background: var(--red); }
.res-dot.pending { background: var(--yellow); animation: blink 1s infinite; }

@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.3} }

.res-label {
    font-size: 11.5px;
    color: var(--text2);
    font-weight: 600;
}

.res-label.ok  { color: var(--green); }
.res-label.err { color: var(--red); }

.res-time {
    font-family: var(--ff-mono);
    font-size: 10px;
    color: var(--text3);
}

.response-view {
    flex: 1;
    min-height: 220px;
    max-height: 340px;
    overflow-y: auto;
    padding: 14px;
    font-family: var(--ff-mono);
    font-size: 12px;
    line-height: 1.65;
    color: #86efac;
    background: var(--code-bg);
    white-space: pre-wrap;
    word-break: break-word;
}

.response-view.empty  { color: #6b7280; font-style: italic; }
.response-view.error  { color: #fca5a5; }

/* Example block */
.example-block {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--r);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.example-block.hidden { display: none; }

.example-block-title {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    font-weight: 600;
    color: var(--text2);
    background: #fafbfc;
}

.example-pre {
    padding: 14px;
    font-family: var(--ff-mono);
    font-size: 11.5px;
    color: #6ee7b7;
    background: var(--code-bg);
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 200px;
    overflow-y: auto;
    line-height: 1.65;
}

/* Method colors for recent */
.bg-GET    { background: var(--green); }
.bg-POST   { background: var(--yellow); }
.bg-PATCH  { background: var(--purple); }
.bg-DELETE { background: var(--red); }
.bg-PUT    { background: var(--blue); }

/* ================================
   TOAST
================================ */
.toast-wrap {
    position: fixed;
    bottom: 18px;
    right: 18px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 6px;
    pointer-events: none;
}

.toast {
    background: var(--text);
    color: white;
    border-left: 4px solid var(--accent);
    padding: 9px 14px;
    border-radius: var(--r-sm);
    font-size: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    animation: toastIn 0.2s ease;
    max-width: 250px;
}

.toast.ok  { border-left-color: var(--green); }
.toast.err { border-left-color: var(--red); }

@keyframes toastIn {
    from { transform: translateX(110%); opacity: 0; }
    to   { transform: translateX(0); opacity: 1; }
}

/* ================================
   RESPONSIVE
================================ */
@media (max-width: 768px) {
    .layout { flex-direction: column; height: auto; }
    .sidebar { width: 100%; height: auto; border-right: none; border-bottom: 1px solid var(--border); }
    .topbar-sub { display: none; }
}
