/* Reset and Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Light theme (default) */
    --bg-primary: #ffffff;
    --bg-secondary: #f6f8fa;
    --bg-tertiary: #ffffff;
    --border-primary: #e3e8ee;
    --border-secondary: #c9d1dc;
    --text-primary: #0a0d14;
    --text-secondary: #5e6470;
    --text-tertiary: #8792a2;
    --accent-primary: #635bff;
    --accent-hover: #5046e4;
    --accent-focus: rgba(99, 91, 255, 0.1);
    --success-bg: #d1fae5;
    --success-text: #065f46;
    --error-bg: #fee2e2;
    --error-text: #991b1b;
    --code-bg: #f6f8fa;
    --code-border: #e3e8ee;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, 'Helvetica Neue', sans-serif;
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-primary);
    padding: 12px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Dark theme */
body.dark-theme {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --border-primary: #30363d;
    --border-secondary: #484f58;
    --text-primary: #c9d1d9;
    --text-secondary: #8b949e;
    --text-tertiary: #6e7681;
    --accent-primary: #58a6ff;
    --accent-hover: #79c0ff;
    --success-bg: #0d2f1a;
    --success-text: #3fb950;
    --error-bg: #2f1318;
    --error-text: #f85149;
    --code-bg: #161b22;
    --code-border: #30363d;
}

/* Preloader */
.preloader {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 120px;
}

.preloader.hidden {
    display: none;
}

.spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border-primary);
    border-top: 2px solid var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Container */
.container {
    max-width: none;
    width: 100%;
    margin: 0;
    display: none;
    animation: fadeIn 0.3s ease;
}

.container.visible {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Header */
.header {
    margin-bottom: 24px;
}

.api-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 8px;
    background: var(--bg-secondary);
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.025em;
    margin-bottom: 8px;
}

.api-badge .method {
    padding: 2px 4px;
    background: var(--accent-primary);
    color: white;
    border-radius: 3px;
    font-weight: 600;
}

.api-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
    letter-spacing: -0.01em;
}

.api-description {
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.6;
}

/* Error Message */
.error-message {
    background: var(--error-bg);
    border: 1px solid var(--error-bg);
    color: var(--error-text);
    padding: 10px 12px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 12px;
    display: none;
}

.error-message.visible {
    display: block;
}

/* Form Sections */
.form-section {
    margin-bottom: 20px;
}

.section-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

/* Form Groups */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.form-label .required {
    color: var(--error-text);
    font-weight: 400;
}

.form-label .type-hint {
    font-size: 10px;
    padding: 2px 4px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border-radius: 3px;
    font-family: 'SF Mono', Monaco, 'Inconsolata', 'Fira Code', monospace;
    font-weight: 400;
}

.form-description {
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    line-height: 1.5;
}

/* Form Inputs */
.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid var(--border-primary);
    border-radius: 6px;
    font-size: 12px;
    font-family: inherit;
    transition: all 0.15s ease;
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.form-input:hover,
.form-select:hover,
.form-textarea:hover {
    border-color: var(--border-secondary);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-focus);
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--text-tertiary);
}

.form-textarea {
    min-height: 60px;
    resize: vertical;
    font-family: 'SF Mono', Monaco, 'Inconsolata', 'Fira Code', monospace;
    font-size: 11px;
}

.form-select {
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%235e6470' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 32px;
    appearance: none;
}

/* Checkbox */
.checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-checkbox {
    width: 14px;
    height: 14px;
    border: 1px solid var(--border-primary);
    border-radius: 3px;
    cursor: pointer;
    position: relative;
    appearance: none;
    transition: all 0.15s ease;
}

.form-checkbox:checked {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

.form-checkbox:checked::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 1px;
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 1.5px 1.5px 0;
    transform: rotate(45deg);
}

.checkbox-label {
    font-size: 12px;
    color: var(--text-primary);
    cursor: pointer;
    user-select: none;
}

/* Form Actions */
.form-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Clear Button */
.clear-button {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: 1px solid var(--border-primary);
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    letter-spacing: 0.01em;
}

.clear-button:hover {
    background: var(--border-primary);
    color: var(--text-primary);
    transform: translateY(-1px);
}

.clear-button:active {
    transform: translateY(0);
}

/* Submit Button */
.submit-button {
    background: var(--accent-primary);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    letter-spacing: 0.01em;
}

.submit-button:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 91, 255, 0.2);
}

.submit-button:active {
    transform: translateY(0);
}

.submit-button:disabled {
    background: var(--border-primary);
    color: var(--text-tertiary);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Response Section */
.response-section {
    margin-top: 24px;
    display: none;
    animation: fadeIn 0.3s ease;
}

.response-section.visible {
    display: block;
}

.response-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.response-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.response-meta {
    display: flex;
    align-items: center;
    gap: 8px;
}

.response-time {
    font-size: 11px;
    color: var(--text-secondary);
}

.response-status {
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
}

.response-status.success {
    background: var(--success-bg);
    color: var(--success-text);
}

.response-status.error {
    background: var(--error-bg);
    color: var(--error-text);
}

/* Tabs */
.response-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border-primary);
}

.tab-button {
    padding: 8px 12px;
    background: none;
    border: none;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    position: relative;
    transition: color 0.15s ease;
}

.tab-button:hover {
    color: var(--text-primary);
}

.tab-button.active {
    color: var(--accent-primary);
}

.tab-button.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--accent-primary);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Raw Response Content */
.raw-content {
    background: var(--code-bg);
    border: 1px solid var(--code-border);
    border-radius: 6px;
    padding: 12px;
    font-family: 'SF Mono', Monaco, 'Inconsolata', 'Fira Code', monospace;
    font-size: 11px;
    overflow-x: auto;
    max-height: 400px;
    overflow-y: auto;
    position: relative;
}

.raw-content::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.raw-content::-webkit-scrollbar-track {
    background: var(--border-primary);
    border-radius: 3px;
}

.raw-content::-webkit-scrollbar-thumb {
    background: var(--border-secondary);
    border-radius: 3px;
}

.raw-content::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Formatted Response Content */
.formatted-content {
    max-height: 500px;
    overflow-y: auto;
    padding: 4px;
}

.formatted-content::-webkit-scrollbar {
    width: 6px;
}

.formatted-content::-webkit-scrollbar-track {
    background: #f6f8fa;
    border-radius: 3px;
}

.formatted-content::-webkit-scrollbar-thumb {
    background: #c9d1dc;
    border-radius: 3px;
}

/* Data Cards */
.data-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 12px;
}

.data-card-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.025em;
    margin-bottom: 8px;
}

.data-row {
    display: flex;
    padding: 6px 0;
    border-bottom: 1px solid var(--bg-secondary);
}

.data-row:last-child {
    border-bottom: none;
}

.data-label {
    flex: 0 0 120px;
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 500;
}

.data-value {
    flex: 1;
    font-size: 12px;
    color: var(--text-primary);
    word-break: break-word;
}

.data-value.string {
    color: #0a3069;
}

.data-value.number {
    color: #8250df;
    font-family: 'SF Mono', Monaco, 'Inconsolata', 'Fira Code', monospace;
}

.data-value.boolean {
    color: #cf222e;
    font-weight: 500;
}

.data-value.null {
    color: #6e7781;
    font-style: italic;
}

.data-value.url {
    color: #0969da;
    text-decoration: none;
}

.data-value.url:hover {
    text-decoration: underline;
}

/* Array Display */
.array-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.array-item {
    padding: 8px;
    background: var(--bg-secondary);
    border-radius: 4px;
    margin-bottom: 6px;
    font-size: 12px;
}

.array-item:last-child {
    margin-bottom: 0;
}

.array-index-label {
    display: inline-block;
    padding: 2px 6px;
    background: var(--border-primary);
    border-radius: 3px;
    font-size: 10px;
    color: var(--text-secondary);
    margin-right: 8px;
    font-weight: 500;
}

/* Nested Object */
.nested-object {
    margin-left: 12px;
    padding-left: 12px;
    border-left: 2px solid var(--border-primary);
}

/* Tags */
.tag {
    display: inline-block;
    padding: 2px 6px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 4px;
    font-size: 11px;
    color: var(--text-primary);
    margin-right: 4px;
    margin-bottom: 4px;
}

.tag.success {
    background: #d1fae5;
    border-color: #a7f3d0;
    color: #065f46;
}

.tag.error {
    background: #fee2e2;
    border-color: #fecaca;
    color: #991b1b;
}

.tag.info {
    background: #dbeafe;
    border-color: #bfdbfe;
    color: #1e40af;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 32px;
    color: var(--text-secondary);
    font-size: 12px;
}

.empty-state-icon {
    font-size: 24px;
    margin-bottom: 8px;
    opacity: 0.5;
}

/* JSON Tree for Raw View */
.json-tree {
    line-height: 1.6;
    font-family: 'SF Mono', Monaco, 'Inconsolata', 'Fira Code', monospace;
    font-size: 11px;
}

.json-tree-item {
    margin-left: 16px;
}

.json-tree-key {
    color: #0969da;
    font-weight: 500;
}

.json-tree-string {
    color: #0a3069;
}

.json-tree-number {
    color: #8250df;
}

.json-tree-boolean {
    color: #cf222e;
}

.json-tree-null {
    color: #6e7781;
}

body.dark-theme .json-tree-key {
    color: #79c0ff;
}

body.dark-theme .json-tree-string {
    color: #a5d6ff;
}

body.dark-theme .json-tree-number {
    color: #d2a8ff;
}

body.dark-theme .json-tree-boolean {
    color: #ff7b72;
}

body.dark-theme .json-tree-null {
    color: #8b949e;
}

.json-tree-toggle {
    cursor: pointer;
    user-select: none;
    display: inline-block;
    width: 16px;
    color: var(--text-secondary);
    font-size: 10px;
    text-align: center;
    transition: transform 0.15s ease;
}

.json-tree-toggle:hover {
    color: var(--text-primary);
}

.json-tree-toggle.collapsed {
    transform: rotate(-90deg);
}

.json-tree-collapsed {
    display: none;
}

.json-array-index {
    color: #6e7781;
    font-size: 10px;
}

body.dark-theme .json-array-index {
    color: #8b949e;
}

/* Copy Button */
.copy-button {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 4px 8px;
    background: var(--bg-primary);
    border: 1px solid var(--border-primary);
    border-radius: 4px;
    font-size: 11px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
}

.copy-button:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.copy-button.copied {
    background: var(--success-bg);
    color: var(--success-text);
    border-color: var(--success-bg);
}

/* Loading States */
.skeleton {
    background: linear-gradient(90deg, #f6f8fa 25%, #e3e8ee 50%, #f6f8fa 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    border-radius: 4px;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Footer */
.footer {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border-primary);
    text-align: center;
}

.powered-by {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 11px;
    font-weight: 500;
    opacity: 0.8;
    transition: opacity 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.powered-by:hover {
    opacity: 1;
    color: var(--accent-primary);
}

.powered-by::before {
    content: '';
    display: inline-block;
    width: 14px;
    height: 14px;
    background-image: url('../images/favicon.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

/* Responsive */
@media (max-width: 640px) {
    body {
        padding: 12px;
    }
}