/* --- Global Resets & Base --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Poppins', sans-serif;
    background-color: #f0f2f5;
    color: #333;
    line-height: 1.6;
    margin: 0;
    overflow-x: hidden;
}

.app-layout {
    display: flex;
    min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
    width: 260px;
    background-color: #2c3e50;
    color: #ecf0f1;
    padding: 20px;
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 5px rgba(0,0,0,0.1);
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    overflow-y: auto;
    z-index: 1000;
}

.sidebar-header h2 {
    text-align: center;
    margin-bottom: 25px;
    font-size: 1.5em;
    color: #fff;
    border-bottom: 1px solid #34495e;
    padding-bottom: 15px;
}

.sidebar-nav ul {
    list-style: none;
    padding: 0;
}

.sidebar-nav li a {
    display: block;
    padding: 12px 15px;
    color: #bdc3c7;
    text-decoration: none;
    border-radius: 6px;
    margin-bottom: 5px;
    transition: background-color 0.2s ease, color 0.2s ease;
    font-weight: 500;
}

.sidebar-nav li a:hover {
    background-color: #34495e;
    color: #fff;
}

.sidebar-nav li a.active {
    background-color: #667eea;
    color: #fff;
    font-weight: 600;
}

/* --- Main Content Area --- */
.main-content-area {
    flex-grow: 1;
    padding: 25px 30px;
    margin-left: 260px;
    background-color: #f7f9fc;
    display: flex;
    flex-direction: column;
}

.app-main-header {
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e0e0e0;
}

.app-main-header h1 {
    font-size: 1.8em;
    color: #2c3e50;
    font-weight: 600;
}

.tool-content-wrapper {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.tool-container {
    display: none; /* Hide tools by default */
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    flex-grow: 1;
    flex-direction: column; /* Default for containers */
}

.tool-container.active-tool {
    display: flex; /* Show active tool AND make it a flex container */
}


/* --- Footer for Main Content --- */
.app-main-footer {
    text-align: center;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
    font-size: 0.9em;
    color: #7f8c8d;
}


/* === Styles for API Tester Tool (Postman-like UI) === */
/* Ensure the main #api-tester container itself is set up for its new internal layout */
#api-tester {
    display: flex; /* It's already flex by .active-tool, but good to be explicit */
    flex-direction: column; /* The .api-tester-postman-layout will be its direct child */
    overflow: hidden;
    padding: 0; /* Remove padding from tool-container if layout handles it */
}

#api-tester .api-tester-postman-layout {
    display: flex;
    flex-direction: row; /* Request and Response panels side-by-side */
    height: 100%;     /* Fill the parent tool-container */
    width: 100%;
    gap: 15px;
    padding: 15px; /* Add padding here instead of on #api-tester if this is the main content wrapper */
    overflow: hidden;
}

#api-tester .request-panel,
#api-tester .response-panel {
    display: flex;
    flex-direction: column;
    background-color: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    overflow: hidden;
}

#api-tester .request-panel {
    flex: 1.2;
    min-width: 350px;
}

#api-tester .response-panel {
    flex: 0.8;
    min-width: 300px;
}

/* URL Bar */
#api-tester .url-bar-container {
    display: flex;
    align-items: center;
    padding: 10px;
    border-bottom: 1px solid #e0e0e0;
    background-color: #f8f9fa;
    flex-shrink: 0; /* Prevent shrinking */
}

#api-tester .pm-method-select {
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-right: none;
    border-radius: 4px 0 0 4px;
    background-color: #f0f0f0;
    font-weight: bold;
    font-size: 0.9em;
    outline: none;
}

#api-tester .pm-url-input {
    flex-grow: 1;
    padding: 8px 10px;
    border: 1px solid #ccc;
    font-size: 0.9em;
    outline: none;
    border-radius: 0;
}
#api-tester .pm-url-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

#api-tester .pm-send-btn {
    padding: 8px 18px;
    background-color: #667eea;
    color: white;
    border: 1px solid #667eea;
    border-left: none;
    border-radius: 0 4px 4px 0;
    cursor: pointer;
    font-weight: bold;
    font-size: 0.9em;
}
#api-tester .pm-send-btn:hover {
    background-color: #5a6fcf;
}

/* Request Detail Tabs */
#api-tester .request-details-tabs {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    overflow: hidden;
}
#api-tester .pm-tabs-nav {
    display: flex;
    padding: 8px 10px 0 10px;
    border-bottom: 1px solid #e0e0e0;
    background-color: #fdfdfd;
    flex-shrink: 0;
}

#api-tester .pm-tab-link {
    padding: 8px 15px;
    cursor: pointer;
    border: none;
    background-color: transparent;
    color: #555;
    font-weight: 500;
    font-size: 0.9em;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}
#api-tester .pm-tab-link.active {
    color: #667eea;
    border-bottom-color: #667eea;
    font-weight: bold;
}
#api-tester .pm-tab-link:hover:not(.active) {
    color: #333;
}

#api-tester .pm-tabs-content {
    padding: 15px;
    flex-grow: 1;
    overflow-y: auto;
}

#api-tester .pm-tab-pane {
    display: none;
}
#api-tester .pm-tab-pane.active {
    display: block;
}
#api-tester .tab-description {
    font-size: 0.85em;
    color: #777;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px dashed #eee;
}

/* Key-Value Editor */
#api-tester .pm-key-value-editor {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
}
#api-tester .pm-kv-row {
    display: flex;
    gap: 8px;
    align-items: center;
}
#api-tester .pm-kv-row input[type="text"] {
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.85em;
    flex-grow: 1;
}
#api-tester .pm-kv-row .pm-kv-key { flex-basis: 30%; }
#api-tester .pm-kv-row .pm-kv-value { flex-basis: 40%; }
#api-tester .pm-kv-row .pm-kv-desc { flex-basis: 30%; }
#api-tester .pm-kv-remove-btn {
    background: none;
    border: none;
    color: #e74c3c;
    cursor: pointer;
    font-size: 1.2em;
    padding: 0 5px;
    line-height: 1;
    visibility: visible;
}
#api-tester .pm-kv-remove-btn:hover { color: #c0392b; }
#api-tester .pm-add-kv-btn {
    background-color: #f0f2f5;
    color: #34495e;
    border: 1px solid #dcdfe6;
    padding: 6px 12px;
    font-size: 0.85em;
    margin-top: 5px;
    align-self: flex-start; /* Prevent button from stretching */
}
#api-tester .pm-add-kv-btn:hover { background-color: #e9ecef; }

/* Body Tab Specifics */
#api-tester .pm-body-options {
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
    display: flex;
    flex-wrap: wrap;
    gap: 10px 15px; /* row-gap column-gap */
}
#api-tester .pm-body-options label {
    font-size: 0.9em;
    color: #555;
    cursor: pointer;
    margin-bottom: 0;
    display: inline-flex;
    align-items: center;
}
#api-tester .pm-body-options input[type="radio"] {
    margin-right: 5px;
}
#api-tester .pm-body-content-pane {
    display: none;
}
#api-tester .pm-body-content-pane.active {
    display: block;
}
#api-tester #pmRawBodyTextarea {
    width: 100%;
    min-height: 200px;
    font-family: 'Courier New', Courier, monospace;
    border: 1px solid #ddd;
    padding: 10px;
    border-radius: 4px;
    resize: vertical;
}
#api-tester .pm-raw-type-select {
    margin-bottom: 10px;
    padding: 6px 8px;
    border-radius: 4px;
    border: 1px solid #ddd;
    font-size: 0.85em;
    background-color: #f9f9f9;
}

/* Response Panel */
#api-tester .response-panel .response-heading {
    padding: 10px 15px;
    font-size: 1.1em;
    margin: 0;
    font-weight: 600;
    color: #333;
    background-color: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
    flex-shrink: 0;
}
#api-tester .pm-response-status {
    padding: 8px 15px;
    font-size: 0.85em;
    color: #555;
    background-color: #fdfdfd;
    border-bottom: 1px solid #e0e0e0;
    flex-shrink: 0;
    display: flex;
    gap: 15px;
}
#api-tester .pm-response-status .status-value {
    font-weight: bold;
}
#api-tester #pmResponseStatus.status-success { color: #28a745; }
#api-tester #pmResponseStatus.status-redirect { color: #ffc107; }
#api-tester #pmResponseStatus.status-client-error { color: #dc3545; }
#api-tester #pmResponseStatus.status-server-error { color: #dc3545; }
#api-tester #pmResponseStatus.status-info { color: #17a2b8; }
#api-tester #pmResponseStatus.status-processing { color: #6c757d; font-style: italic; }

#api-tester .pm-response-tabs-nav {
    display: flex;
    padding: 8px 10px 0 10px;
    border-bottom: 1px solid #e0e0e0;
    background-color: #fdfdfd;
    flex-shrink: 0;
}
#api-tester .pm-response-tab-link {
    padding: 8px 15px;
    cursor: pointer;
    border: none;
    background-color: transparent;
    color: #555;
    font-weight: 500;
    font-size: 0.9em;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}
#api-tester .pm-response-tab-link.active {
    color: #667eea;
    border-bottom-color: #667eea;
    font-weight: bold;
}

#api-tester .pm-response-tabs-content {
    flex-grow: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
#api-tester .pm-response-tab-pane {
    display: none;
    flex-grow: 1;
    overflow-y: auto; /* This will allow individual panes to scroll if their content (pre) is too long */
    padding: 15px;
}
#api-tester .pm-response-tab-pane.active {
    display: flex; /* Changed from block to flex */
    flex-direction: column;
}
#api-tester .pm-response-tab-pane pre {
    white-space: pre-wrap;
    word-wrap: break-word;
    word-break: break-all;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.85em;
    background-color: #f0f2f5;
    padding: 10px;
    border-radius: 4px;
    border: 1px solid #e0e0e0;
    margin: 0;
    flex-grow: 1; /* Allow pre to fill available space in its tab pane */
    overflow: auto; /* Add scroll to pre itself if content is huge */
}

/* Hide the old API tester layout if it was based on .api-tester-layout */
#api-tester .api-tester-layout {
    display: none !important;
}
/* END OF POSTMAN-LIKE API TESTER STYLES */


/* === Styles from Webhook Hub (prefix with #webhook-tester) === */
#webhook-tester .webhook-app-container { width: 100%; }
#webhook-tester .webhook-main-content { display: flex; flex-wrap: wrap; gap: 30px; }
#webhook-tester .webhook-column { flex: 1; min-width: 320px; display: flex; flex-direction: column; gap: 30px; }
#webhook-tester .card { background-color: #fff; border-radius: 12px; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08); overflow: hidden; display: flex; flex-direction: column; transition: transform 0.25s ease-in-out, box-shadow 0.25s ease-in-out; }
#webhook-tester .card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0, 0, 0, 0.1); }
#webhook-tester .card-header { padding: 20px 25px; background-color: #f8f9fa; border-bottom: 1px solid #e9ecef; }
#webhook-tester .card-header h2, #webhook-tester .card-header h3 { font-size: 1.35em; color: #2c3e50; margin: 0; font-weight: 600; }
#webhook-tester .card-header h3 { font-size: 1.2em; }
#webhook-tester .card-body { padding: 25px; flex-grow: 1; }
#webhook-tester .form-group { margin-bottom: 22px; }
#webhook-tester label { display: block; margin-bottom: 10px; font-weight: 500; color: #34495e; font-size: 0.9em; }
#webhook-tester input[type="text"], #webhook-tester input[type="url"],
#webhook-tester textarea, #webhook-tester select {
    width: 100%; padding: 12px 18px; border: 1px solid #dcdfe6; border-radius: 8px; font-size: 1em; font-family: 'Poppins', sans-serif; color: #34495e; transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
#webhook-tester input[type="text"]:focus, #webhook-tester input[type="url"]:focus,
#webhook-tester textarea:focus, #webhook-tester select:focus {
    border-color: #667eea; box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2); outline: none;
}
#webhook-tester textarea { resize: vertical; min-height: 120px; font-family: 'Menlo', 'Monaco', 'Consolas', "Courier New", monospace; }
#webhook-tester .format-hint { font-size: 0.8em; color: #7f8c8d; display: block; margin-top: 6px; }
#webhook-tester .input-with-button { display: flex; align-items: center; }
#webhook-tester .input-with-button input[type="text"] { border-top-right-radius: 0; border-bottom-right-radius: 0; flex-grow: 1; }
#webhook-tester .input-with-button .copy-button { border-top-left-radius: 0; border-bottom-left-radius: 0; padding: 12px 15px; border-left: 0; }

#webhook-tester button, .cta-button, .utility-button {
    font-family: 'Poppins', sans-serif; font-weight: 500; cursor: pointer; border-radius: 8px; transition: all 0.2s ease; border: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; padding: 10px 18px;
}
#webhook-tester button:active, .cta-button:active, .utility-button:active { transform: translateY(1px) scale(0.98); }
#webhook-tester button svg, .cta-button svg, .utility-button svg { width: 16px; height: 16px; }

.cta-button {
    background-color: #667eea; color: white; padding: 14px 28px; font-size: 1.05em; width: 100%; box-shadow: 0 2px 5px rgba(102, 126, 234, 0.3);
}
.cta-button:hover { background-color: #5a6fcf; box-shadow: 0 4px 8px rgba(102, 126, 234, 0.4); }
.cta-button:disabled { background-color: #adb5bd; cursor: not-allowed; box-shadow: none; }

.utility-button { background-color: #f0f2f5; color: #34495e; border: 1px solid #dcdfe6; }
.utility-button:hover { background-color: #e9ecef; border-color: #ced4da; }
.utility-button.add-button { background-color: #2ecc71; color: white; border: none; }
.utility-button.add-button:hover { background-color: #27ae60; }
.utility-button.remove-button { background-color: #e74c3c; color: white; padding: 6px 10px; font-size: 0.8em; border: none; }
.utility-button.remove-button:hover { background-color: #c0392b; }

#webhook-tester #generateCallbackUrlBtn { margin: 10px 0 15px 0; }
#webhook-tester #fetchCallbacksBtn { margin-bottom: 15px; }
#webhook-tester #fetchCallbacksBtn:disabled, #webhook-tester #copyCallbackUrlBtn:disabled { background-color: #e9ecef; color: #adb5bd; cursor: not-allowed; border-color: #dcdfe6; }
#webhook-tester .copy-button.copied { background-color: #2ecc71 !important; color: white !important; border-color: #2ecc71 !important; }

#webhook-tester #webhookCustomHeadersContainer .header-entry { display: flex; gap: 10px; margin-bottom: 12px; align-items: center; }
#webhook-tester #webhookCustomHeadersContainer .header-entry input[type="text"] { flex: 1; padding: 10px 14px; }

#webhook-tester .status-message { margin-top: 10px; padding: 18px; border-radius: 8px; font-size: 0.9em; word-break: break-word; white-space: pre-wrap; max-height: 450px; overflow-y: auto; background-color: #f8f9fa; border: 1px solid #e9ecef; line-height: 1.5; }
#webhook-tester .status-message.success { background-color: #e6ffed; color: #1db954; border-color: #a1e9c0; }
#webhook-tester .status-message.error { background-color: #ffebee; color: #f44336; border-color: #ffcdd2; }
#webhook-tester .status-message.info { background-color: #e3f2fd; color: #2196f3; border-color: #bbdefb; }

#webhook-tester .callbacks-listing { margin-top: 20px; border: 1px solid #e0e0e0; border-radius: 8px; max-height: 600px; overflow-y: auto; background-color: #fdfdfd; }
#webhook-tester .callbacks-listing .no-callbacks { padding: 25px; text-align: center; color: #7f8c8d; font-style: italic; }
#webhook-tester .callback-item { border-bottom: 1px solid #e9ecef; transition: background-color 0.2s ease; }
#webhook-tester .callback-item:last-child { border-bottom: none; }
#webhook-tester .callback-item.open { background-color: #f8f9fa; }
#webhook-tester .callback-summary { padding: 15px 20px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; font-weight: 500; }
#webhook-tester .callback-summary:hover { background-color: #f1f3f5; }
#webhook-tester .callback-summary .method-path { flex-grow: 1; display: flex; align-items: baseline; gap: 10px;}
#webhook-tester .callback-summary .method { padding: 4px 10px; border-radius: 20px; color: white; font-size: 0.75em; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
#webhook-tester .callback-summary .method.GET { background-color: #3498db; }
#webhook-tester .callback-summary .method.POST { background-color: #2ecc71; }
#webhook-tester .callback-summary .method.PUT { background-color: #f1c40f; color: #333;}
#webhook-tester .callback-summary .method.PATCH { background-color: #e67e22; }
#webhook-tester .callback-summary .method.DELETE { background-color: #e74c3c; }
#webhook-tester .callback-summary .path { word-break: break-all; color: #2980b9; font-size: 0.95em; }
#webhook-tester .callback-summary .timestamp { font-size: 0.8em; color: #7f8c8d; margin-left: 15px; white-space: nowrap; }
#webhook-tester .callback-summary .toggle-icon { transition: transform 0.25s ease-in-out; color: #95a5a6; }
#webhook-tester .callback-item.open .toggle-icon { transform: rotate(90deg); color: #667eea; }
#webhook-tester .callback-details { padding: 0 20px 20px 20px; background-color: #fff; border-top: 1px dashed #e0e0e0; display: none; }
#webhook-tester .callback-details h4 { margin-top: 18px; margin-bottom: 10px; font-size: 1em; color: #34495e; font-weight: 600; border-bottom: 1px solid #f0f2f5; padding-bottom: 6px; }
#webhook-tester .callback-details pre, #webhook-tester .callback-details p strong { font-family: 'Menlo', 'Monaco', 'Consolas', "Courier New", monospace; }
#webhook-tester .callback-details pre { background-color: #f0f2f5; padding: 12px; border-radius: 6px; font-size: 0.85em; white-space: pre-wrap; word-break: break-all; max-height: 250px; overflow-y: auto; color: #2c3e50; border: 1px solid #e0e0e0; }
#webhook-tester .callback-details p { font-size: 0.9em; margin-bottom: 5px; word-break: break-all; }

/* Loading Spinner (can be generic or specific) */
.loading-spinner { display: inline-block; width: 20px; height: 20px; border: 3px solid rgba(255, 255, 255, 0.3); border-radius: 50%; border-top-color: #fff; animation: spin 0.8s ease-in-out infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#webhook-tester #fetchCallbacksBtn svg { transition: transform 0.5s ease; }
#webhook-tester #fetchCallbacksBtn.loading svg { animation: spin 0.8s linear infinite; }

/* Responsive Adjustments for overall layout */
@media (max-width: 992px) { /* Breakpoint for Postman-like stacking */
    #api-tester .api-tester-postman-layout {
        flex-direction: column;
        height: auto;
    }
    #api-tester .request-panel,
    #api-tester .response-panel {
        flex: none;
        min-height: 400px;
    }
    #api-tester .response-panel {
        margin-top: 15px;
    }
}

@media (max-width: 768px) {
    .app-layout {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        position: static;
        height: auto;
        max-height: 300px;
        box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    }
    .main-content-area {
        margin-left: 0;
        padding: 15px;
    }
    /* API Tester URL bar stacking */
    #api-tester .url-bar-container {
        flex-direction: column;
        gap: 8px;
        align-items: stretch;
    }
    #api-tester .pm-method-select,
    #api-tester .pm-url-input,
    #api-tester .pm-send-btn {
        border-radius: 4px !important;
        border: 1px solid #ccc !important;
    }
    /* API Tester Key-Value row stacking */
     #api-tester .pm-kv-row {
        flex-direction: column;
        align-items: stretch;
    }
    #api-tester .pm-kv-row input[type="text"] {
        flex-basis: auto !important;
        margin-bottom: 5px;
    }
    #api-tester .pm-kv-remove-btn {
        align-self: flex-end;
    }


    /* Stack Webhook tester columns on smaller screens */
    #webhook-tester .webhook-main-content {
        flex-direction: column;
    }
    #webhook-tester .webhook-column {
        min-width: 100%;
    }
}