:root {
    --bg-app: #0A0A0B;
    --bg-panel: #141417;
    --bg-card: #1D1D21;
    --bg-input: #0F0F11;
    --bg-input-focus: #18181A;

    --color-primary: #6366F1;
    /* Indigo */
    --color-primary-hover: #4F46E5;
    --color-secondary: #374151;
    /* Slate */
    --color-secondary-hover: #4B5563;
    --color-accent: #10B981;
    /* Emerald */

    --border-color: #27272A;
    --border-focus: #6366F1;

    --text-main: #F4F4F5;
    --text-muted: #A1A1AA;

    /* Status Colors */
    --status-success: #10B981;
    --status-redirect: #F59E0B;
    --status-client-error: #EF4444;
    --status-server-error: #B91C1C;

    /* Method Colors */
    --method-get: #3B82F6;
    --method-post: #10B981;
    --method-put: #F59E0B;
    --method-patch: #8B5CF6;
    --method-delete: #EF4444;

    --font-ui: 'Inter', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --radius: 8px;
    --radius-lg: 12px;
}

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

body {
    font-family: var(--font-ui);
    background-color: var(--bg-app);
    color: var(--text-main);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

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

.w-full {
    width: 100%;
}

.justify-center {
    justify-content: center;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-family: var(--font-ui);
    font-weight: 500;
    font-size: 0.85rem;
    border-radius: var(--radius);
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--color-primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--color-primary-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--color-secondary);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.1);
}

.btn-secondary:hover {
    background: var(--color-secondary-hover);
}

.btn-icon {
    background: transparent;
    color: var(--text-muted);
    border: none;
    border-radius: 6px;
    padding: 0.4rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.btn-text {
    background: transparent;
    color: var(--color-primary);
    border: none;
    font-family: var(--font-ui);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    transition: color 0.2s;
}

.btn-text:hover {
    color: var(--color-primary-hover);
}

/* Header */
.app-header {
    height: 64px;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    flex-shrink: 0;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: #fff;
}

.brand-icon {
    width: 20px;
    height: 20px;
    color: var(--color-primary);
}

.brand h1 {
    font-size: 1.1rem;
    font-weight: 600;
}

.header-actions {
    display: flex;
    gap: 0.75rem;
}

/* Layout */
.app-layout {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 320px;
    background: var(--bg-card);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 1.25rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header h2 {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.05em;
}

.endpoints-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.endpoint-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: 6px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s;
}

.endpoint-item:hover {
    background: rgba(255, 255, 255, 0.03);
}

.endpoint-item.active {
    background: rgba(99, 102, 241, 0.1);
    border-color: rgba(99, 102, 241, 0.3);
}

.ep-method {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 700;
    width: 48px;
}

.ep-path {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.ep-method[data-method="GET"] {
    color: var(--method-get);
}

.ep-method[data-method="POST"] {
    color: var(--method-post);
}

.ep-method[data-method="PUT"] {
    color: var(--method-put);
}

.ep-method[data-method="PATCH"] {
    color: var(--method-patch);
}

.ep-method[data-method="DELETE"] {
    color: var(--method-delete);
}

.btn-delete-ep {
    opacity: 0;
    color: var(--text-muted);
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0.2rem;
    border-radius: 4px;
}

.btn-delete-ep:hover {
    color: var(--status-client-error);
    background: rgba(239, 68, 68, 0.1);
}

.endpoint-item:hover .btn-delete-ep {
    opacity: 1;
}

/* Main Editor */
.editor-area {
    flex: 1;
    background: var(--bg-app);
    overflow-y: auto;
    position: relative;
}

.empty-state {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    color: var(--text-muted);
}

.empty-state svg {
    width: 48px;
    height: 48px;
    opacity: 0.2;
}

.endpoint-editor {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.editor-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.card-header {
    padding: 1rem 1.5rem;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
}

.card-body {
    padding: 1.5rem;
}

.card-body.row-gap {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Inputs */
.input-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

input,
select,
textarea {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 0.6rem 0.8rem;
    border-radius: 6px;
    font-family: var(--font-ui);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
    width: 100%;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--border-focus);
    background: var(--bg-input-focus);
}

input::placeholder,
textarea::placeholder {
    opacity: 0.5;
}

.endpoint-url-group {
    display: flex;
    gap: 0;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    overflow: hidden;
    transition: border-color 0.2s;
}

.endpoint-url-group:focus-within {
    border-color: var(--border-focus);
}

.method-select {
    width: 110px;
    border: none;
    border-radius: 0;
    border-right: 1px solid var(--border-color);
    font-family: var(--font-mono);
    font-weight: 600;
}

.path-input {
    border: none;
    border-radius: 0;
    font-family: var(--font-mono);
}

.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.status-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.status-indicator {
    position: absolute;
    right: 1rem;
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-indicator.success {
    background: var(--status-success);
    box-shadow: 0 0 8px var(--status-success);
}

.status-indicator.redirect {
    background: var(--status-redirect);
    box-shadow: 0 0 8px var(--status-redirect);
}

.status-indicator.client-error {
    background: var(--status-client-error);
    box-shadow: 0 0 8px var(--status-client-error);
}

.status-indicator.server-error {
    background: var(--status-server-error);
    box-shadow: 0 0 8px var(--status-server-error);
}

/* Headers Array */
.headers-section {
    margin-bottom: 2rem;
}

.headers-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.headers-header h3 {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
}

.headers-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.header-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.header-row input {
    font-family: var(--font-mono);
    font-size: 0.85rem;
}

/* CodeMirror Override */
.body-section h3 {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.editor-wrapper {
    border: 1px solid var(--border-color);
    border-radius: 6px;
    overflow: hidden;
}

.CodeMirror {
    height: 250px;
    font-family: var(--font-mono);
    font-size: 13px;
    background: var(--bg-input) !important;
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 1;
    transition: opacity 0.2s;
}

.modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 600px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    transform: translateY(0);
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal.hidden .modal-content {
    transform: translateY(20px);
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

.modal-body {
    padding: 1.5rem;
}

.modal-desc {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.import-textarea {
    height: 200px;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    resize: none;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-panel);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--text-main);
    color: var(--bg-app);
    padding: 0.75rem 1.5rem;
    border-radius: 30px;
    font-weight: 600;
    font-size: 0.9rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 1000;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

@media (max-width: 768px) {
    .app-layout {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: 250px;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .settings-grid {
        grid-template-columns: 1fr;
    }
}