/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #4F46E5;
    --primary-dark: #4338CA;
    --primary-light: #6366F1;
    --secondary: #64748B;
    --success: #10B981;
    --warning: #F59E0B;
    --error: #EF4444;
    --background: #F8FAFC;
    --surface: #FFFFFF;
    --text: #1E293B;
    --text-secondary: #64748B;
    --border: #E2E8F0;
    --shadow: rgba(0, 0, 0, 0.1);
    --radius: 8px;
    --transition: all 0.3s ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    background: var(--background);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* Header */
.header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 3px var(--shadow);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
}

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

.btn-icon {
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    border-radius: var(--radius);
    color: var(--text-secondary);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--background);
    border-radius: 2rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Tabs Navigation */
.tabs {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 73px;
    z-index: 99;
}

.tab-list {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
}

.tab {
    padding: 1rem 1.5rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
}

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

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

.tab svg {
    stroke-width: 2px;
}

/* Main Content */
.main {
    padding: 2rem 0;
    min-height: calc(100vh - 200px);
}

.tab-content {
    display: none;
}

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

/* Cards */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: 0 1px 3px var(--shadow);
    margin-bottom: 1.5rem;
}

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

.card-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text);
}

.card-header p {
    color: var(--text-secondary);
    font-size: 0.875rem;
    width: 100%;
}

.card-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.card-body {
    padding: 1.5rem;
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text);
    font-size: 0.875rem;
}

input[type="text"],
input[type="url"],
input[type="email"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    transition: var(--transition);
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

textarea {
    resize: vertical;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
}

small {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: center;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

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

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

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.8125rem;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Search Box */
.search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.search-box svg {
    position: absolute;
    left: 0.75rem;
    color: var(--text-secondary);
}

.search-box input {
    padding-left: 2.5rem;
    min-width: 200px;
}

/* APIs Grid */
.apis-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
}

.api-card {
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    transition: var(--transition);
    cursor: pointer;
}

.api-card:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 12px var(--shadow);
    transform: translateY(-2px);
}

.api-card-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 0.75rem;
}

.api-card-title {
    font-weight: 600;
    color: var(--text);
    font-size: 1rem;
}

.api-badge {
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-GET { background: #DBEAFE; color: #1E40AF; }
.badge-POST { background: #D1FAE5; color: #065F46; }
.badge-PUT { background: #FEF3C7; color: #92400E; }
.badge-DELETE { background: #FEE2E2; color: #991B1B; }
.badge-PATCH { background: #E0E7FF; color: #3730A3; }

.api-card-endpoint {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    word-break: break-all;
    margin-bottom: 0.75rem;
    font-family: 'Monaco', 'Menlo', monospace;
}

.api-card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    color: var(--text-secondary);
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

.api-card-actions {
    display: flex;
    gap: 0.5rem;
}

.api-card-actions button {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    border: none;
    background: none;
    cursor: pointer;
    color: var(--primary);
    transition: var(--transition);
}

.api-card-actions button:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

.api-card-actions .delete {
    color: var(--error);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
}

.empty-state svg {
    stroke-width: 1.5px;
    color: var(--text-secondary);
    opacity: 0.5;
    margin-bottom: 1rem;
}

.empty-state h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: var(--text-secondary);
}

/* Scenarios */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 1.5rem 0 1rem;
}

.section-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.scenario-item {
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1rem;
}

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

/* Test Results */
.test-result-item {
    background: var(--background);
    border-left: 4px solid var(--border);
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: var(--radius);
}

.test-result-item.success {
    border-left-color: var(--success);
}

.test-result-item.error {
    border-left-color: var(--error);
}

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

.result-title {
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.result-status {
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-success {
    background: #D1FAE5;
    color: #065F46;
}

.status-error {
    background: #FEE2E2;
    color: #991B1B;
}

.result-details {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

.result-code {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem;
    margin-top: 0.75rem;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.8125rem;
    overflow-x: auto;
}

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

.stat-card {
    background: var(--background);
    padding: 1.25rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--text);
}

.stat-trend {
    font-size: 0.75rem;
    color: var(--success);
    margin-top: 0.25rem;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--text);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: var(--radius);
    box-shadow: 0 10px 25px var(--shadow);
    transform: translateY(100px);
    opacity: 0;
    transition: var(--transition);
    z-index: 1000;
    max-width: 400px;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast.success {
    background: var(--success);
}

.toast.error {
    background: var(--error);
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-overlay p {
    color: white;
    margin-top: 1rem;
    font-size: 0.875rem;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal-content {
    background: var(--surface);
    border-radius: var(--radius);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 40px var(--shadow);
}

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

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
}

.modal-close:hover {
    background: var(--background);
}

.modal-body {
    padding: 1.5rem;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 0 1rem;
    }

    .header-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .tabs {
        top: auto;
        position: relative;
    }

    .tab-list {
        padding-bottom: 0.5rem;
    }

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

    .form-row {
        grid-template-columns: 1fr;
    }

    .card-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .card-actions {
        width: 100%;
        flex-direction: column;
    }

    .search-box input {
        width: 100%;
    }

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

    .btn {
        width: 100%;
    }
}

/* Code Formatting */
pre {
    background: var(--background);
    padding: 1rem;
    border-radius: var(--radius);
    overflow-x: auto;
    font-size: 0.8125rem;
}

code {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    background: var(--background);
    padding: 0.125rem 0.25rem;
    border-radius: 0.25rem;
    font-size: 0.875em;
}
/* Chat Interface */
.chat-messages {
    max-height: 500px;
    overflow-y: auto;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--background);
    border-radius: var(--radius);
    min-height: 300px;
}

.chat-message {
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    max-width: 85%;
}

.chat-message.user {
    background: var(--primary);
    color: white;
    margin-left: auto;
    text-align: right;
}

.chat-message.assistant {
    background: var(--card);
    border: 1px solid var(--border);
}

.chat-message.system {
    background: var(--background);
    border: 1px dashed var(--border);
    font-style: italic;
    color: var(--text-muted);
}

.chat-message-header {
    font-weight: 600;
    font-size: 0.75rem;
    margin-bottom: 0.5rem;
    opacity: 0.8;
}

.chat-message-content {
    line-height: 1.5;
}

.chat-message-content pre {
    margin-top: 0.5rem;
    font-size: 0.75rem;
}

.chat-input-container {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
    margin-bottom: 1rem;
}

.chat-input-container textarea {
    flex: 1;
    resize: vertical;
    min-height: 60px;
}

.chat-input-container .btn {
    height: fit-content;
    white-space: nowrap;
}

.query-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    padding: 1rem;
    background: var(--background);
    border-radius: var(--radius);
}

.query-suggestions strong {
    margin-right: 0.5rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.suggestion-btn {
    background: var(--card);
    border: 1px solid var(--border);
    padding: 0.5rem 0.75rem;
    border-radius: calc(var(--radius) * 2);
    font-size: 0.8125rem;
    cursor: pointer;
    transition: all 0.2s;
}

.suggestion-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.chat-typing {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
}

.chat-typing .dot {
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.chat-typing .dot:nth-child(2) {
    animation-delay: 0.2s;
}

.chat-typing .dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        opacity: 0.3;
        transform: translateY(0);
    }
    30% {
        opacity: 1;
        transform: translateY(-10px);
    }
}

.chat-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 3rem 1rem;
}

.chat-empty svg {
    margin-bottom: 1rem;
    opacity: 0.5;
}

@media (max-width: 768px) {
    .chat-message {
        max-width: 95%;
    }
    
    .chat-input-container {
        flex-direction: column;
    }
    
    .chat-input-container .btn {
        width: 100%;
    }
    
    .query-suggestions {
        flex-direction: column;
        align-items: stretch;
    }
    
    .suggestion-btn {
        width: 100%;
        text-align: left;
    }
}

/* ============================================
   Parameter Builder Styles
   ============================================ */
.parameter-row {
    display: grid;
    grid-template-columns: 2fr 1.5fr 1fr 1.5fr 40px;
    gap: 0.5rem;
    align-items: end;
    margin-bottom: 0.75rem;
    padding: 0.75rem;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid var(--border);
}

.parameter-row input,
.parameter-row select {
    font-size: 0.875rem;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: white;
}

.parameter-row input:focus,
.parameter-row select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.parameter-row label {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.parameter-field {
    display: flex;
    flex-direction: column;
}

.remove-param-btn {
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 4px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    font-size: 1.2rem;
    line-height: 1;
}

.remove-param-btn:hover {
    background: #c82333;
    transform: scale(1.05);
}

#parametersBuilder:empty::before {
    content: 'No parameters defined. Click "Add Parameter" to add one.';
    display: block;
    padding: 1rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.875rem;
    background: #f8f9fa;
    border: 2px dashed var(--border);
    border-radius: 6px;
    margin-bottom: 0.5rem;
}

@media (max-width: 768px) {
    .parameter-row {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .remove-param-btn {
        width: 100%;
        height: 36px;
    }
}

/* ============================================
   Scenario Parameter Input Styles
   ============================================ */
.params-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.param-input-row {
    display: grid;
    grid-template-columns: minmax(200px, 1fr) 2fr;
    gap: 1rem;
    align-items: center;
}

.param-key {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
}

.param-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.param-type-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    background: #4F46E5;
    color: white;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

.param-type-badge.header-badge {
    background: #10B981;
}

.param-value {
    width: 100%;
    padding: 0.625rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.875rem;
    transition: var(--transition);
}

.param-value:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.param-value::placeholder {
    color: #9ca3af;
}

@media (max-width: 768px) {
    .param-input-row {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .param-key {
        flex-wrap: wrap;
    }
}
