/* ============================================
   REST API Mocker — Premium Dark Theme
   ============================================ */

/* --- Design Tokens --- */
:root {
    --primary: #14B8A6;
    --primary-hover: #0D9488;
    --primary-glow: rgba(20, 184, 166, 0.25);
    --secondary: #2DD4BF;
    --accent: #99F6E4;
    --bg: #0D1117;
    --bg-card: rgba(22, 27, 34, 0.85);
    --bg-elevated: rgba(30, 37, 46, 0.9);
    --bg-hover: rgba(45, 212, 191, 0.06);
    --border: rgba(45, 212, 191, 0.12);
    --border-hover: rgba(45, 212, 191, 0.25);
    --text: #E6EDF3;
    --text-muted: #8B949E;
    --text-dim: #484F58;
    --danger: #F85149;
    --danger-bg: rgba(248, 81, 73, 0.1);
    --warning: #D29922;
    --success: #3FB950;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --glass: blur(20px);
    --mono: 'JetBrains Mono', 'Fira Code', monospace;
    --sans: 'Inter', system-ui, -apple-system, sans-serif;
    --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Reset --- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--sans);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
    background-image:
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(20, 184, 166, 0.08), transparent),
        radial-gradient(ellipse 60% 30% at 80% 100%, rgba(45, 212, 191, 0.05), transparent);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* --- Header --- */
.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: var(--glass);
    -webkit-backdrop-filter: var(--glass);
    background: rgba(13, 17, 23, 0.8);
    border-bottom: 1px solid var(--border);
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.logo-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    color: var(--primary);
    display: flex;
    align-items: center;
}

.logo-title {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo-subtitle {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 400;
}

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

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--sans);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    text-decoration: none;
    line-height: 1;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #0D1117;
    box-shadow: 0 0 20px var(--primary-glow);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 0 30px var(--primary-glow), 0 4px 12px rgba(0, 0, 0, 0.3);
}

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

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}

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

.btn-sm {
    padding: 0.35rem 0.65rem;
    font-size: 0.75rem;
}

.btn-danger {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid rgba(248, 81, 73, 0.2);
}

.btn-danger:hover {
    background: rgba(248, 81, 73, 0.2);
}

.btn-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: var(--radius-xs);
    transition: all var(--transition);
    display: flex;
    align-items: center;
}

.btn-close:hover {
    color: var(--text);
    background: var(--bg-hover);
}

/* --- Tabs --- */
.tab-bar {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 1.5rem 0;
    display: flex;
    gap: 0.25rem;
    border-bottom: 1px solid var(--border);
}

.tab {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.6rem 1rem;
    background: none;
    border: none;
    color: var(--text-muted);
    font-family: var(--sans);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: all var(--transition);
}

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

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-badge {
    background: var(--bg-elevated);
    color: var(--text-muted);
    font-size: 0.68rem;
    padding: 0.1rem 0.45rem;
    border-radius: 10px;
    font-weight: 600;
    min-width: 1.2rem;
    text-align: center;
}

.tab.active .tab-badge {
    background: var(--primary-glow);
    color: var(--primary);
}

/* --- Panels --- */
.panel {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.25rem 1.5rem;
}

.panel.hidden {
    display: none;
}

.panel-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

/* --- Empty State --- */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.empty-icon {
    color: var(--text-dim);
    margin-bottom: 0.5rem;
}

.empty-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
}

.empty-description {
    font-size: 0.85rem;
    color: var(--text-muted);
    max-width: 360px;
}

/* --- Endpoint Card --- */
.endpoint-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all var(--transition);
    backdrop-filter: var(--glass);
    -webkit-backdrop-filter: var(--glass);
    animation: slideIn 300ms ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.endpoint-card:hover {
    border-color: var(--border-hover);
    background: var(--bg-elevated);
}

.endpoint-card.inactive {
    opacity: 0.45;
}

.method-badge {
    font-family: var(--mono);
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.25rem 0.55rem;
    border-radius: var(--radius-xs);
    letter-spacing: 0.03em;
    min-width: 4rem;
    text-align: center;
    text-transform: uppercase;
}

.method-GET {
    background: rgba(63, 185, 80, 0.15);
    color: #3FB950;
}

.method-POST {
    background: rgba(88, 166, 255, 0.15);
    color: #58A6FF;
}

.method-PUT {
    background: rgba(210, 153, 34, 0.15);
    color: #D29922;
}

.method-PATCH {
    background: rgba(188, 140, 255, 0.15);
    color: #BC8CFF;
}

.method-DELETE {
    background: rgba(248, 81, 73, 0.15);
    color: #F85149;
}

.method-OPTIONS {
    background: rgba(139, 148, 158, 0.15);
    color: #8B949E;
}

.endpoint-info {
    flex: 1;
    min-width: 0;
}

.endpoint-path {
    font-family: var(--mono);
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text);
    word-break: break-all;
}

.endpoint-meta {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.3rem;
    font-size: 0.72rem;
    color: var(--text-muted);
}

.endpoint-meta span {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.endpoint-actions {
    display: flex;
    gap: 0.35rem;
    flex-shrink: 0;
}

.endpoint-actions .btn {
    padding: 0.35rem 0.5rem;
}

/* --- Log Items --- */
.log-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.log-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    animation: slideIn 200ms ease-out;
}

.log-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.log-time {
    font-size: 0.7rem;
    color: var(--text-dim);
    font-family: var(--mono);
}

.log-status {
    font-size: 0.7rem;
    font-weight: 600;
    font-family: var(--mono);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
}

.status-2xx {
    background: rgba(63, 185, 80, 0.15);
    color: #3FB950;
}

.status-3xx {
    background: rgba(210, 153, 34, 0.15);
    color: #D29922;
}

.status-4xx {
    background: rgba(248, 81, 73, 0.15);
    color: #F85149;
}

.status-5xx {
    background: rgba(188, 140, 255, 0.15);
    color: #BC8CFF;
}

.log-body {
    font-family: var(--mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    background: rgba(0, 0, 0, 0.2);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-xs);
    overflow-x: auto;
    max-height: 120px;
    white-space: pre-wrap;
    word-break: break-all;
}

/* --- Settings --- */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.setting-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    backdrop-filter: var(--glass);
}

.setting-label {
    font-size: 0.92rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.setting-description {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.setting-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.setting-field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.settings-actions {
    display: flex;
    justify-content: flex-end;
}

.sw-status {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.82rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-dim);
}

.sw-status.active .status-dot {
    background: var(--success);
    box-shadow: 0 0 8px rgba(63, 185, 80, 0.5);
}

.sw-status.error .status-dot {
    background: var(--danger);
}

/* --- Inputs --- */
.input {
    width: 100%;
    padding: 0.55rem 0.75rem;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text);
    font-family: var(--sans);
    font-size: 0.82rem;
    transition: all var(--transition);
    outline: none;
}

.input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.input::placeholder {
    color: var(--text-dim);
}

.input.mono {
    font-family: var(--mono);
    font-size: 0.8rem;
}

.select {
    appearance: none;
    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 1l4 4 4-4' stroke='%238B949E' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.6rem center;
    padding-right: 2rem;
}

.textarea-sm {
    resize: vertical;
    min-height: 52px;
}

.textarea-lg {
    resize: vertical;
    min-height: 120px;
}

.field-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.field-hint {
    text-transform: none;
    letter-spacing: normal;
    opacity: 0.7;
    font-weight: 400;
}

.field-hint code {
    font-family: var(--mono);
    font-size: 0.7rem;
    background: var(--bg-elevated);
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
}

.inline-check {
    flex-direction: row !important;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

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

/* --- Modal --- */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal[open] {
    display: flex;
}

.modal::backdrop {
    display: none;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 100%;
    max-width: 640px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
    animation: modalIn 250ms ease-out;
}

.modal-sm .modal-content,
.modal-content.modal-sm {
    max-width: 540px;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

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

.modal-title {
    font-size: 1.05rem;
    font-weight: 600;
}

.modal-body {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.modal-info {
    font-size: 0.82rem;
    color: var(--text-muted);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
}

.form-row {
    display: flex;
    gap: 0.75rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    flex: 1;
}

.form-group-method {
    flex: 0 0 120px;
}

.form-group-status {
    flex: 0 0 160px;
}

.form-group-delay {
    flex: 0 0 120px;
}

.form-group-content-type {
    flex: 1;
}

.form-group-path {
    flex: 1;
}

/* --- Drop Zone --- */
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    padding: 1.25rem;
    text-align: center;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.82rem;
    transition: all var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.drop-zone:hover,
.drop-zone.dragover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-glow);
}

/* --- Toast --- */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.65rem 1rem;
    font-size: 0.82rem;
    color: var(--text);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    animation: toastIn 300ms ease-out;
    max-width: 360px;
    backdrop-filter: var(--glass);
}

.toast.success {
    border-left: 3px solid var(--success);
}

.toast.error {
    border-left: 3px solid var(--danger);
}

.toast.info {
    border-left: 3px solid var(--primary);
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }

    to {
        opacity: 0;
        transform: translateX(20px);
    }
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        align-items: stretch;
        padding: 0.75rem 1rem;
    }

    .header-actions {
        flex-wrap: wrap;
        justify-content: flex-end;
    }

    .header-actions .btn span,
    .btn-ghost span {
        display: none;
    }

    .form-row {
        flex-direction: column;
    }

    .form-group-method,
    .form-group-status,
    .form-group-delay {
        flex: 1;
    }

    .endpoint-card {
        flex-wrap: wrap;
    }

    .endpoint-actions {
        width: 100%;
        justify-content: flex-end;
    }

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

    .tab-bar {
        padding: 0.5rem 1rem 0;
        overflow-x: auto;
    }

    .panel {
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    .header-actions .btn {
        padding: 0.4rem 0.6rem;
        font-size: 0;
    }

    .header-actions .btn svg {
        width: 18px;
        height: 18px;
    }

    .logo-title {
        font-size: 1rem;
    }

    .modal-content {
        max-height: 95vh;
    }
}