/* Estilos para Componente de Configuração de API */

/* Container principal */
.api-config-panel {
    width: 100%;
    height: 100%;
    overflow-y: auto;
    background: var(--bg-light, #f8f9fa);
}

/* Header */
.api-config-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 8px 8px 0 0;
    margin-bottom: 20px;
}

.api-config-header h3 {
    margin: 0;
    font-size: 18px;
}

.api-config-header p {
    opacity: 0.9;
}

/* Quick Templates */
.api-quick-templates {
    padding: 20px;
    background: white;
    margin-bottom: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
    margin-top: 10px;
}

.template-btn {
    padding: 12px;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 13px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    color: #333;
}

.template-btn i {
    font-size: 20px;
    color: #667eea;
}

.template-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    border-color: #667eea;
}

/* Request Line (Method + URL) */
.api-request-line {
    padding: 20px;
    background: white;
    margin-bottom: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.method-select {
    padding: 10px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-weight: 600;
    font-size: 14px;
    min-width: 120px;
    background: white;
    cursor: pointer;
    transition: all 0.2s;
}

.method-select:focus {
    border-color: #667eea;
}

.method-select:focus-visible {
    outline: 2px solid #6366f1;
    outline-offset: 2px;
}

/* Cores por método HTTP */
.method-get { color: #4caf50; border-color: #4caf50; }
.method-post { color: #2196f3; border-color: #2196f3; }
.method-put { color: #ff9800; border-color: #ff9800; }
.method-patch { color: #9c27b0; border-color: #9c27b0; }
.method-delete { color: #f44336; border-color: #f44336; }
.method-head { color: #607d8b; border-color: #607d8b; }
.method-options { color: #795548; border-color: #795548; }

.url-input {
    flex: 1;
    padding: 10px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 14px;
    font-family: 'Courier New', monospace;
    transition: border-color 0.2s;
}

.url-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.url-input:focus-visible {
    outline: 2px solid #6366f1;
    outline-offset: 2px;
}

.url-validation {
    margin-top: 8px;
    font-size: 12px;
}

.validation-success {
    color: #4caf50;
}

.validation-error {
    color: #f44336;
}

/* Tabs */
.api-tabs {
    display: flex;
    gap: 5px;
    background: white;
    padding: 15px 15px 0 15px;
    border-radius: 8px 8px 0 0;
    overflow-x: auto;
}

.api-tab {
    padding: 10px 20px;
    border: none;
    background: transparent;
    color: var(--text-secondary, #6c757d);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.api-tab:hover {
    color: var(--primary-color, #667eea);
    background: rgba(102, 126, 234, 0.05);
}

.api-tab.active {
    color: var(--primary-color, #667eea);
    border-bottom-color: var(--primary-color, #667eea);
}

/* Tab Content */
.api-tab-content {
    background: white;
    padding: 20px;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    margin-bottom: 15px;
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tab-header {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #f0f0f0;
}

.tab-header h4 {
    margin: 0 0 8px 0;
    color: var(--text-primary, #333);
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tab-header p {
    margin: 0;
    color: var(--text-secondary, #6c757d);
    font-size: 13px;
}

/* Key-Value Editor */
.key-value-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    align-items: center;
}

.key-input,
.value-input {
    padding: 8px 12px;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    font-size: 13px;
    font-family: 'Courier New', monospace;
    transition: border-color 0.2s;
}

.key-input {
    flex: 0 0 200px;
    font-weight: 600;
}

.value-input {
    flex: 1;
}

.key-input:focus,
.value-input:focus {
    border-color: #667eea;
}

.key-input:focus-visible,
.value-input:focus-visible {
    outline: 2px solid #6366f1;
    outline-offset: 2px;
}

.btn-remove {
    padding: 8px 12px;
    background: #fee;
    border: 1px solid #fcc;
    border-radius: 4px;
    cursor: pointer;
    color: #c00;
    transition: all 0.2s;
}

.btn-remove:hover {
    background: #f44336;
    color: white;
    border-color: #f44336;
}

.btn-add-param {
    padding: 10px 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 6px;
    color: white;
    cursor: pointer;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: transform 0.2s;
    margin-top: 10px;
}

.btn-add-param:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.empty-state {
    text-align: center;
    padding: 30px;
    color: var(--text-secondary, #6c757d);
    font-style: italic;
}

.empty-state i {
    display: block;
    font-size: 32px;
    margin-bottom: 10px;
    opacity: 0.5;
}

/* Header Presets */
.header-presets {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.preset-btn {
    padding: 6px 12px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    color: #495057;
    transition: all 0.2s;
}

.preset-btn:hover {
    background: #e9ecef;
    border-color: #adb5bd;
    transform: translateY(-1px);
}

/* Body Editor */
.body-type-selector {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 6px;
}

.body-type-selector label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 14px;
}

.body-type-selector input[type="radio"] {
    cursor: pointer;
}

.body-editor {
    margin-top: 15px;
}

.body-textarea {
    width: 100%;
    min-height: 200px;
    padding: 15px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    resize: vertical;
    transition: border-color 0.2s;
}

.body-textarea:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.body-textarea:focus-visible {
    outline: 2px solid #6366f1;
    outline-offset: 2px;
}

.body-templates {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #e0e0e0;
}

/* Auth Config */
.auth-type-selector {
    margin-bottom: 20px;
}

.auth-config {
    margin-top: 20px;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary, #333);
}

.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.form-control:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-control:focus-visible {
    outline: 2px solid #6366f1;
    outline-offset: 2px;
}

.form-group small {
    display: block;
    margin-top: 4px;
    font-size: 11px;
    color: var(--text-secondary, #6c757d);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: normal;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Actions */
.api-actions {
    display: flex;
    gap: 10px;
    padding: 20px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.btn-preview,
.btn-test {
    flex: 1;
    padding: 12px 20px;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
}

.btn-preview {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-preview:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-test {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

.btn-test:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(240, 147, 251, 0.4);
}

/* Preview Modal */
.preview-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.2s;
}

.preview-content {
    background: white;
    border-radius: 8px;
    max-width: 800px;
    max-height: 80vh;
    width: 90%;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.preview-header {
    padding: 20px;
    border-bottom: 2px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.preview-header h3 {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.preview-header button {
    padding: 8px 12px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 20px;
    color: #999;
    transition: color 0.2s;
}

.preview-header button:hover {
    color: #333;
}

.preview-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.preview-body pre {
    margin: 0;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 6px;
    overflow-x: auto;
}

.preview-body code {
    font-family: 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.6;
    color: #333;
}

.preview-footer {
    padding: 15px 20px;
    border-top: 2px solid #f0f0f0;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.preview-footer button {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.preview-footer button:first-child {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.preview-footer button:first-child:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.preview-footer button:last-child {
    background: #f8f9fa;
    color: #333;
}

.preview-footer button:last-child:hover {
    background: #e9ecef;
}

/* Responsive */
@media (max-width: 768px) {
    .templates-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .api-request-line > div {
        flex-direction: column;
    }

    .method-select {
        width: 100%;
    }

    .api-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .key-value-row {
        flex-wrap: wrap;
    }

    .key-input {
        flex: 1 1 100%;
    }

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

    .preview-content {
        width: 95%;
        max-height: 90vh;
    }
}

/* Scrollbar customizado */
.api-config-panel::-webkit-scrollbar,
.body-textarea::-webkit-scrollbar,
.preview-body::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.api-config-panel::-webkit-scrollbar-track,
.body-textarea::-webkit-scrollbar-track,
.preview-body::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.api-config-panel::-webkit-scrollbar-thumb,
.body-textarea::-webkit-scrollbar-thumb,
.preview-body::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.api-config-panel::-webkit-scrollbar-thumb:hover,
.body-textarea::-webkit-scrollbar-thumb:hover,
.preview-body::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Estados de loading */
.loading-state {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

.loading-state i {
    font-size: 32px;
    animation: spin 1s linear infinite;
}

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

/* Badges e tags */
.method-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.method-badge.get { background: #e8f5e9; color: #4caf50; }
.method-badge.post { background: #e3f2fd; color: #2196f3; }
.method-badge.put { background: #fff3e0; color: #ff9800; }
.method-badge.patch { background: #f3e5f5; color: #9c27b0; }
.method-badge.delete { background: #ffebee; color: #f44336; }
