:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #10b981;
    --bg-color: #0f172a;
    --card-bg: #1e293b;
    --card-border: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --input-bg: #0f172a;
    --success-color: #22c55e;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    --get-color: #22c55e;
    --post-color: #f59e0b;
    --put-color: #3b82f6;
    --patch-color: #8b5cf6;
    --delete-color: #ef4444;
    --head-color: #6366f1;
    --options-color: #64748b;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #fff;
    color: #181818;
    min-height: 100vh;
    line-height: 1.6;
    transition: background 0.3s, color 0.3s;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    border-radius: 10px;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 20px;
    padding: 20px;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

header p {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Client-side note */
.client-side-note {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 10px;
    padding: 8px 16px;
    background: rgba(99, 102, 241, 0.1);
    border-radius: 8px;
    display: inline-block;
}

.dark-mode .client-side-note {
    background: rgba(99, 102, 241, 0.15);
    color: #a5b4fc;
}

/* Topbar */
.topbar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 1.2rem;
    margin-top: 1.2rem;
    padding: 0 20px;
}

.theme-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.theme-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.2em 0.2em;
    border-radius: 50%;
    background: none;
    border: none;
    cursor: pointer;
    transition: background 0.2s;
}

.theme-toggle-btn:focus {
    outline: none;
}

#theme-icon svg, .github-link svg {
    width: 28px !important;
    height: 28px !important;
    display: block;
    color: #181818;
    fill: #181818;
    transition: color 0.2s, fill 0.2s;
}

.dark-mode #theme-icon svg, .dark-mode .github-link svg {
    color: #fff !important;
    fill: #fff !important;
}

/* Main Content Layout */
.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

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

/* Sections */
.request-section,
.response-section {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 20px;
    font-size: 0.95rem;
    transition: background 0.3s, color 0.3s, border-color 0.3s;
}

.request-section h2,
.response-section h2 {
    font-size: 1.2rem;
    margin-bottom: 15px;
    color: #181818;
    font-weight: 700;
    letter-spacing: 0.01em;
    transition: color 0.3s;
}

.dark-mode .request-section h2,
.dark-mode .response-section h2 {
    color: #e5e7eb;
}

/* Request Line (Method + URL + Send) */
.request-line {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.method-select {
    padding: 12px 16px;
    font-size: 1rem;
    font-weight: 600;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    background: #fff;
    color: #181818;
    cursor: pointer;
    min-width: 120px;
    transition: border-color 0.3s, background 0.3s;
}

.method-select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.dark-mode .method-select {
    background: #181c1f;
    border-color: #2d3237;
    color: #e5e7eb;
}

.url-input {
    flex: 1;
    padding: 12px 16px;
    font-size: 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    background: #fff;
    color: #181818;
    transition: border-color 0.3s, background 0.3s;
}

.url-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.url-input::placeholder {
    color: #9ca3af;
}

.dark-mode .url-input {
    background: #181c1f;
    border-color: #2d3237;
    color: #e5e7eb;
}

.dark-mode .url-input::placeholder {
    color: #6b7280;
}

.send-btn {
    padding: 12px 30px;
    font-size: 1rem;
    font-weight: 600;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    border: none;
    border-radius: 8px;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

.send-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(99, 102, 241, 0.3);
}

.send-btn:active {
    transform: translateY(0);
}

.send-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Request Tabs */
.request-tabs,
.response-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 15px;
    border-bottom: 2px solid #e5e7eb;
    padding-bottom: 10px;
}

.dark-mode .request-tabs,
.dark-mode .response-tabs {
    border-color: #2d3237;
}

.tab-btn,
.resp-tab-btn {
    padding: 8px 16px;
    font-size: 0.9rem;
    font-weight: 600;
    background: none;
    border: none;
    border-radius: 6px;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s;
}

.tab-btn:hover,
.resp-tab-btn:hover {
    background: #f3f4f6;
    color: #181818;
}

.tab-btn.active,
.resp-tab-btn.active {
    background: var(--primary-color);
    color: white;
}

.dark-mode .tab-btn:hover,
.dark-mode .resp-tab-btn:hover {
    background: #333a41;
    color: #e5e7eb;
}

/* Tab Content */
.tab-content,
.resp-tab-content {
    display: none;
}

.tab-content.active,
.resp-tab-content.active {
    display: block;
}

/* Key-Value Editor */
.kv-editor {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
}

.dark-mode .kv-editor {
    border-color: #2d3237;
}

.kv-header {
    display: grid;
    grid-template-columns: 1fr 1fr 40px;
    gap: 10px;
    padding: 10px 12px;
    background: #f3f4f6;
    font-weight: 600;
    font-size: 0.85rem;
    color: #6b7280;
}

.dark-mode .kv-header {
    background: #181c1f;
    color: #94a3b8;
}

.kv-rows {
    max-height: 200px;
    overflow-y: auto;
}

.kv-row {
    display: grid;
    grid-template-columns: 1fr 1fr 40px;
    gap: 10px;
    padding: 10px 12px;
    border-top: 1px solid #e5e7eb;
}

.dark-mode .kv-row {
    border-color: #2d3237;
}

.kv-key,
.kv-value {
    padding: 8px 10px;
    font-size: 0.9rem;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: #fff;
    color: #181818;
    transition: border-color 0.3s;
}

.kv-key:focus,
.kv-value:focus {
    outline: none;
    border-color: var(--primary-color);
}

.kv-key::placeholder,
.kv-value::placeholder {
    color: #9ca3af;
}

.dark-mode .kv-key,
.dark-mode .kv-value {
    background: #181c1f;
    border-color: #2d3237;
    color: #e5e7eb;
}

.dark-mode .kv-key::placeholder,
.dark-mode .kv-value::placeholder {
    color: #6b7280;
}

.remove-row-btn {
    padding: 8px;
    font-size: 1.2rem;
    font-weight: 600;
    background: none;
    border: none;
    border-radius: 6px;
    color: #ef4444;
    cursor: pointer;
    transition: background 0.2s;
}

.remove-row-btn:hover {
    background: rgba(239, 68, 68, 0.1);
}

.add-row-btn {
    width: 100%;
    padding: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    background: none;
    border: none;
    border-top: 1px solid #e5e7eb;
    color: var(--primary-color);
    cursor: pointer;
    transition: background 0.2s;
}

.add-row-btn:hover {
    background: rgba(99, 102, 241, 0.1);
}

.dark-mode .add-row-btn {
    border-color: #2d3237;
}

/* Body Type Selector */
.body-type-selector {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
}

.body-type-option {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    color: #374151;
}

.dark-mode .body-type-option {
    color: #d1d5db;
}

.body-type-option input[type="radio"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary-color);
    cursor: pointer;
}

/* Body Content */
.body-content textarea {
    width: 100%;
    min-height: 150px;
    padding: 15px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.95rem;
    background: #fff;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    color: #181818;
    resize: vertical;
    transition: border-color 0.3s ease, background 0.3s;
}

.body-content textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.body-content textarea::placeholder {
    color: #9ca3af;
}

.dark-mode .body-content textarea {
    background: #181c1f;
    border-color: #2d3237;
    color: #e5e7eb;
}

.dark-mode .body-content textarea::placeholder {
    color: #6b7280;
}

/* Auth Fields */
.auth-type-selector {
    margin-bottom: 15px;
}

.auth-type-selector label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 6px;
}

.dark-mode .auth-type-selector label {
    color: #d1d5db;
}

.auth-type-selector select {
    width: 100%;
    padding: 10px 12px;
    font-size: 0.95rem;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    background: #fff;
    color: #181818;
    cursor: pointer;
    transition: border-color 0.3s, background 0.3s;
}

.auth-type-selector select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.dark-mode .auth-type-selector select {
    background: #181c1f;
    border-color: #2d3237;
    color: #e5e7eb;
}

.auth-fields {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.auth-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.auth-field label {
    font-size: 0.9rem;
    font-weight: 600;
    color: #374151;
}

.dark-mode .auth-field label {
    color: #d1d5db;
}

.auth-field input,
.auth-field select {
    padding: 10px 12px;
    font-size: 0.95rem;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    background: #fff;
    color: #181818;
    transition: border-color 0.3s, background 0.3s;
}

.auth-field input:focus,
.auth-field select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.auth-field input::placeholder {
    color: #9ca3af;
}

.dark-mode .auth-field input,
.dark-mode .auth-field select {
    background: #181c1f;
    border-color: #2d3237;
    color: #e5e7eb;
}

.dark-mode .auth-field input::placeholder {
    color: #6b7280;
}

/* Response Section */
.response-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.response-meta {
    display: flex;
    gap: 15px;
    align-items: center;
}

.status-badge {
    padding: 6px 12px;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 6px;
    background: #f3f4f6;
    color: #6b7280;
}

.status-badge.success {
    background: rgba(34, 197, 94, 0.1);
    color: var(--success-color);
}

.status-badge.error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error-color);
}

.response-time,
.response-size {
    font-size: 0.85rem;
    color: #6b7280;
}

.dark-mode .response-time,
.dark-mode .response-size {
    color: #94a3b8;
}

/* Response Body Actions */
.response-body-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.copy-btn,
.format-btn,
.download-btn {
    padding: 8px 16px;
    font-size: 0.85rem;
    font-weight: 600;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    color: #374151;
    cursor: pointer;
    transition: all 0.2s;
}

.copy-btn:hover,
.format-btn:hover,
.download-btn:hover {
    background: #e5e7eb;
}

.copy-btn.copied {
    background: var(--success-color);
    color: white;
    border-color: var(--success-color);
}

.dark-mode .copy-btn,
.dark-mode .format-btn,
.dark-mode .download-btn {
    background: #23272b;
    border-color: #2d3237;
    color: #d1d5db;
}

.dark-mode .copy-btn:hover,
.dark-mode .format-btn:hover,
.dark-mode .download-btn:hover {
    background: #333a41;
}

/* Response Body Textarea */
#response-body {
    width: 100%;
    min-height: 300px;
    padding: 15px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.95rem;
    background: #fff;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    color: #181818;
    resize: vertical;
    transition: border-color 0.3s ease, background 0.3s;
}

#response-body:focus {
    outline: none;
    border-color: var(--primary-color);
}

#response-body::placeholder {
    color: #9ca3af;
}

.dark-mode #response-body {
    background: #181c1f;
    border-color: #2d3237;
    color: #e5e7eb;
}

.dark-mode #response-body::placeholder {
    color: #6b7280;
}

/* Response Headers List */
.response-headers-list {
    max-height: 300px;
    overflow-y: auto;
}

.header-item {
    display: flex;
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid #e5e7eb;
}

.dark-mode .header-item {
    border-color: #2d3237;
}

.header-key {
    font-weight: 600;
    color: #374151;
    min-width: 150px;
}

.dark-mode .header-key {
    color: #d1d5db;
}

.header-value {
    color: #6b7280;
    word-break: break-all;
}

.dark-mode .header-value {
    color: #94a3b8;
}

.placeholder-text {
    color: #9ca3af;
    font-style: italic;
    padding: 20px;
    text-align: center;
}

.dark-mode .placeholder-text {
    color: #6b7280;
}

/* History Section */
.history-section {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 20px;
    font-size: 0.95rem;
    transition: background 0.3s, color 0.3s, border-color 0.3s;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.history-header h2 {
    font-size: 1.2rem;
    color: #181818;
    font-weight: 700;
    letter-spacing: 0.01em;
    transition: color 0.3s;
}

.dark-mode .history-header h2 {
    color: #e5e7eb;
}

.clear-history-btn {
    padding: 8px 16px;
    font-size: 0.85rem;
    font-weight: 600;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    color: #ef4444;
    cursor: pointer;
    transition: all 0.2s;
}

.clear-history-btn:hover {
    background: rgba(239, 68, 68, 0.1);
}

.dark-mode .clear-history-btn {
    background: #23272b;
    border-color: #2d3237;
}

.history-list {
    max-height: 300px;
    overflow-y: auto;
}

.history-item {
    display: grid;
    grid-template-columns: 80px 1fr 60px 80px 150px 60px;
    gap: 10px;
    align-items: center;
    padding: 12px;
    border-bottom: 1px solid #e5e7eb;
    transition: background 0.2s;
}

.history-item:hover {
    background: #f9fafb;
}

.dark-mode .history-item {
    border-color: #2d3237;
}

.dark-mode .history-item:hover {
    background: #23272b;
}

.history-method {
    padding: 4px 8px;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: 4px;
    text-align: center;
    color: white;
}

.history-method.get { background: var(--get-color); }
.history-method.post { background: var(--post-color); }
.history-method.put { background: var(--put-color); }
.history-method.patch { background: var(--patch-color); }
.history-method.delete { background: var(--delete-color); }
.history-method.head { background: var(--head-color); }
.history-method.options { background: var(--options-color); }

.history-url {
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.85rem;
    color: #374151;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dark-mode .history-url {
    color: #d1d5db;
}

.history-status {
    font-size: 0.85rem;
    font-weight: 600;
    text-align: center;
}

.history-status.success {
    color: var(--success-color);
}

.history-status.error {
    color: var(--error-color);
}

.history-time {
    font-size: 0.85rem;
    color: #6b7280;
    text-align: center;
}

.dark-mode .history-time {
    color: #94a3b8;
}

.history-date {
    font-size: 0.8rem;
    color: #9ca3af;
}

.dark-mode .history-date {
    color: #6b7280;
}

.history-load-btn {
    padding: 6px 12px;
    font-size: 0.8rem;
    font-weight: 600;
    background: var(--primary-color);
    border: none;
    border-radius: 4px;
    color: white;
    cursor: pointer;
    transition: background 0.2s;
}

.history-load-btn:hover {
    background: var(--primary-hover);
}

/* Status Messages */
.status {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    z-index: 1000;
    animation: slideIn 0.3s ease;
}

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

.status.success {
    background: var(--success-color);
    color: white;
}

.status.error {
    background: var(--error-color);
    color: white;
}

.status.info {
    background: var(--primary-color);
    color: white;
}

.status.hidden {
    display: none;
}

/* Hidden class */
.hidden {
    display: none !important;
}

/* Footer */
footer {
    text-align: center;
    padding: 20px;
    margin-top: 40px;
    border-top: 1px solid #e5e7eb;
}

.dark-mode footer {
    border-color: #2d3237;
}

footer p {
    color: #6b7280;
    font-size: 0.9rem;
}

.dark-mode footer p {
    color: #94a3b8;
}

footer a {
    color: var(--primary-color);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

.copyright {
    margin-top: 5px;
    font-size: 0.85rem;
}

/* Dark Mode Styles */
body.dark-mode {
    background: var(--bg-color);
    color: var(--text-primary);
}

.dark-mode .request-section,
.dark-mode .response-section,
.dark-mode .history-section {
    background: var(--card-bg);
    border-color: var(--card-border);
}

.dark-mode .method-select,
.dark-mode .url-input,
.dark-mode .kv-key,
.dark-mode .kv-value,
.dark-mode .auth-field input,
.dark-mode .auth-field select,
.dark-mode .auth-type-selector select,
.dark-mode .body-content textarea,
.dark-mode #response-body {
    background: var(--input-bg);
    border-color: var(--card-border);
    color: var(--text-primary);
}

.dark-mode .method-select:focus,
.dark-mode .url-input:focus,
.dark-mode .kv-key:focus,
.dark-mode .kv-value:focus,
.dark-mode .auth-field input:focus,
.dark-mode .auth-field select:focus,
.dark-mode .auth-type-selector select:focus,
.dark-mode .body-content textarea:focus,
.dark-mode #response-body:focus {
    border-color: var(--primary-color);
}

.dark-mode .kv-header {
    background: var(--input-bg);
    color: var(--text-secondary);
}

.dark-mode .kv-row {
    border-color: var(--card-border);
}

.dark-mode .add-row-btn {
    border-color: var(--card-border);
}

.dark-mode .copy-btn,
.dark-mode .format-btn,
.dark-mode .download-btn,
.dark-mode .clear-history-btn {
    background: var(--input-bg);
    border-color: var(--card-border);
    color: var(--text-primary);
}

.dark-mode .copy-btn:hover,
.dark-mode .format-btn:hover,
.dark-mode .download-btn:hover,
.dark-mode .clear-history-btn:hover {
    background: var(--card-border);
}

.dark-mode .history-item {
    border-color: var(--card-border);
}

.dark-mode .history-item:hover {
    background: var(--input-bg);
}

.dark-mode .header-item {
    border-color: var(--card-border);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .request-line {
        flex-direction: column;
    }

    .method-select {
        width: 100%;
    }

    .history-item {
        grid-template-columns: 1fr;
        gap: 5px;
    }

    .history-method,
    .history-url,
    .history-status,
    .history-time,
    .history-date,
    .history-load-btn {
        text-align: left;
    }

    .response-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .response-meta {
        flex-wrap: wrap;
    }
}
