:root {
    --sidebar-bg: #f8f9fa; /* Lighter grey background */
    --sidebar-border-color: #dee2e6; /* Softer border */
    --sidebar-width: 250px; /* A bit wider */
    --active-bg: #007bff; /* Bootstrap primary blue */
    --active-text: #ffffff;
    --hover-bg: #e9ecef; /* A subtle grey for hover */
    --text-color: #495057; /* Softer text color */
    --link-padding: 8px 20px; /* More padding */
    --border-radius: 8px; /* More rounded corners */
}

body, html {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; /* Modern system fonts */
    overflow: hidden; /* Prevent scrolling on the main page */
    background-color: #ffffff; /* White background for the container */
}

.container {
    display: flex;
    height: 100vh; /* Full viewport height */
}

.sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    padding: 20px 0;
    border-right: 1px solid var(--sidebar-border-color);
    overflow-y: auto;
    height: 100%;
    box-sizing: border-box;
    flex-shrink: 0;
    transition: width 0.3s ease; /* Add transition for potential collapse feature */
    box-shadow: 2px 0 5px rgba(0,0,0,0.05); /* Add a subtle shadow */
}

.sidebar h2 {
    margin-top: 0;
    margin-bottom: 20px; /* More space below title */
    font-size: 1.2em; /* Slightly larger */
    font-weight: 600;
    padding: 0 20px; /* Match link padding */
    color: #343a40; /* Darker title color */
}
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    margin-bottom: 20px;
}

.sidebar-header h2 {
    margin: 0;
    font-size: 1.2em;
    font-weight: 600;
    color: #343a40;
}

.sidebar-header a {
    color: #343a40;
    display: inline-flex;
    align-items: center;
}

.sidebar-header a:hover {
    color: #007bff;
}


#search-box {
    width: calc(100% - 40px);
    padding: 10px;
    margin: 0 20px 20px;
    border: 1px solid var(--sidebar-border-color);
    border-radius: var(--border-radius);
    box-sizing: border-box;
    font-size: 0.9em;
}

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

.sidebar ul li {
    margin-bottom: 2px; /* Small space between items */
}

.sidebar ul li a {
    display: block;
    padding: var(--link-padding);
    color: var(--text-color);
    text-decoration: none;
    cursor: pointer;
    border-radius: var(--border-radius);
    margin: 2px 10px; /* Adjust margin for spacing */
    transition: background-color 0.2s ease, color 0.2s ease;
    font-size: 0.95em; /* Slightly larger font */
    line-height: 1.5;
    font-weight: 500; /* Medium weight */
}

.sidebar ul li a:hover {
    background-color: var(--hover-bg);
    color: #0056b3; /* Darker blue on hover */
}

.sidebar ul li a.active {
    background-color: var(--active-bg);
    color: var(--active-text);
    font-weight: 600; /* Bolder weight for active */
}

.content {
    flex-grow: 1; /* Take remaining space */
    height: 100vh; /* Full viewport height */
    overflow-y: auto;
    padding: 5px; /* Add a small padding around the iframe */
    box-sizing: border-box;
    background-color: #f9f9f9; /* Slightly off-white background for content */
}

#tool-frame {
    border: 1px solid #ddd; /* Add a subtle border */
    border-radius: var(--border-radius);
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    background-color: #ffffff; /* Ensure iframe background is white */
}

/* Styles for categorized tool list */
.sidebar ul li.category-header {
    font-weight: 600; /* Bolder */
    margin-top: 15px; /* More space above category */
    margin-bottom: 5px;
    padding: var(--link-padding);
    padding-left: 15px;
    color: #586069; /* GitHub-like subtle text color */
    font-size: 0.85em; /* Even smaller */
    text-transform: uppercase;
    cursor: pointer;
    position: relative; /* Needed for absolute positioning of ::before */
    user-select: none; /* Prevent text selection on click */
}

/* Add triangle indicator */
.sidebar ul li.category-header::before {
    content: '';
    display: inline-block;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 5px 0 5px 8px; /* Triangle pointing right */
    border-color: transparent transparent transparent #586069; /* Match text color */
    margin-right: 8px;
    transition: transform 0.2s ease;
    transform-origin: 3px center; /* Adjust origin for better rotation appearance */
}

/* Rotate triangle down when expanded */
.sidebar ul li.category-header.expanded::before {
    transform: rotate(90deg);
}

/* Keep triangle right when collapsed (redundant but clear) */
.sidebar ul li.category-header.collapsed::before {
     transform: rotate(0deg);
}


.sidebar ul ul.nested-tool-list {
    padding-left: 10px; /* Slightly less indent */
    list-style: none;
    margin: 0;
    /* Add a subtle visual cue for nesting */
    border-left: 2px solid #e1e4e8; /* Subtle left border for nested list */
    margin-left: 13px; /* Align border with triangle */
    padding-top: 4px;
    padding-bottom: 4px;
}

/* Adjust nested link margin and padding */
.sidebar ul ul.nested-tool-list li a {
    margin: 1px 8px 1px 5px; /* Adjust margins for nested items */
    padding-left: 10px; /* Align text inside the border */
}

/* --- Common Tool Styles --- */

/* General container for tool UI elements */
.tool-container {
    display: flex;
    flex-direction: column;
    gap: 15px; /* Space between sections */
    width: 95%;
    max-width: 1200px; /* Allow wider content */
    margin: 20px auto; /* Center the container */
    padding: 20px; /* More padding */
    border: 1px solid #e1e4e8; /* GitHub-like border */
    border-radius: 12px; /* Softer radius */
    background-color: #ffffff; /* White background for the tool area */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08); /* Softer shadow */
    box-sizing: border-box;
    height: calc(100vh - 40px); /* Adjust height to fit viewport with margin */
}

/* Container for vertical layouts like JSON/YAML */
.tool-container-vertical {
    display: flex;
    flex-direction: column;
    gap: 15px;
    height: calc(100% - 40px); /* Adjust height dynamically to fill container */
    padding: 15px;
    box-sizing: border-box;
}

/* Section within a tool (e.g., input group, result area) */
.tool-section {
    display: flex;
    flex-direction: column;
    gap: 10px; /* Space between elements within a section */
}

/* Section for side-by-side controls */
.tool-inline-controls {
    display: flex;
    gap: 15px; /* Space between controls */
    align-items: center; /* Align items vertically */
    flex-wrap: wrap; /* Allow wrapping on smaller screens */
}

/* Section for I/O textareas */
.tool-io-section {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    min-height: 0; /* Prevent flex overflow */
}

/* Styling for labels */
.tool-label {
    font-weight: 600; /* Slightly bolder */
    margin-bottom: 5px;
    display: block;
    color: #444; /* Darker label text */
}

/* Common input field styling */
.tool-input,
.tool-select,
.tool-textarea {
    padding: 10px; /* Slightly more padding */
    border: 1px solid #ccc;
    border-radius: var(--border-radius);
    font-size: 1em;
    box-sizing: border-box;
    width: 100%; /* Default to full width */
    transition: border-color 0.2s ease;
}

.tool-input:focus,
.tool-select:focus,
.tool-textarea:focus {
    border-color: var(--active-bg); /* Highlight focus */
    outline: none;
}

/* Specific styling for different input types */
.tool-input[type="text"],
.tool-input[type="number"] {
    /* Specific styles if needed */
}

.tool-select {
    min-width: 120px; /* Ensure select has some width */
    width: auto; /* Allow select to size based on content/min-width */
    flex-grow: 1; /* Allow select to grow in inline controls */
    cursor: pointer;
}

.tool-textarea {
    flex-grow: 1;
    font-family: monospace;
    resize: vertical; /* Allow vertical resize */
    min-height: 100px; /* Minimum height */
}

/* Button styling */
.tool-button {
    padding: 10px 20px;
    background-color: var(--active-bg);
    color: var(--active-text);
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: background-color 0.2s ease, opacity 0.2s ease;
    font-size: 1em;
    /* align-self is removed to allow tool-controls to manage alignment */
}

.tool-button:hover {
    opacity: 0.85; /* Slightly more noticeable hover */
}

.tool-button:disabled {
    background-color: #cccccc;
    color: #666666;
    cursor: not-allowed;
    opacity: 0.7;
}

/* Container for centered buttons */
.tool-controls {
    display: flex;
    justify-content: flex-start; /* Align buttons to the start */
    gap: 15px;
    margin-top: 10px;
    flex-wrap: wrap;
}

/* Result display area */
.tool-result {
    margin-top: 5px;
    padding: 12px; /* More padding */
    background-color: #f0f0f0; /* Lighter background */
    border: 1px solid #e0e0e0; /* Subtle border */
    border-radius: var(--border-radius);
    word-wrap: break-word;
    white-space: pre-wrap; /* Preserve whitespace */
    font-family: monospace; /* Monospace for results often makes sense */
    min-height: 1.5em;
    line-height: 1.4; /* Improve readability */
}
.tool-result ul {
    margin: 5px 0;
    padding-left: 25px;
}
.tool-result li {
    margin-bottom: 3px;
}


/* Error message styling */
.tool-error {
    color: #d9534f; /* Bootstrap danger color */
    font-size: 0.9em;
    margin-top: 8px;
    min-height: 1em; /* Ensure space is reserved */
}

/* Specific overrides if needed */
/* Unified Tool Header */
.tool-header {
    text-align: center;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e1e4e8;
}

.tool-header h1 {
    margin: 0;
    font-size: 2em;
    font-weight: 700;
    color: #24292e;
    background: linear-gradient(135deg, #0366d6, #0969da);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tool-header p {
    margin: 10px 0 0;
    color: #586069;
    font-size: 1.1em;
}

/* Adjustments for JSON/YAML converter layout */
.tool-container-vertical .tool-label {
    text-align: left; /* Align labels left */
}
.tool-container-vertical .tool-error {
    text-align: center;
}

/* Tool Cards Grid */
.tool-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
    padding: 20px;
}

.tool-card {
    background-color: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.tool-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.tool-card h4 {
    margin: 0 0 10px;
    font-size: 16px;
    color: #333;
}

.tool-card p {
    margin: 0;
    font-size: 14px;
    color: #777;
}
/* Tool Category Section */
.tool-category-section {
    margin-bottom: 30px;
}

.tool-category-title {
    font-size: 20px;
    font-weight: 600;
    color: #333;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--active-bg);
}

/* --- Socket.IO Tester Styles --- */

.sio-config-grid,
.sio-interaction-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.sio-transports .tool-checkbox-group {
    display: flex;
    gap: 15px;
    align-items: center;
    padding-top: 5px; /* Align with input field's top padding */
}

.tool-help {
    font-size: 12px;
    color: #666;
    margin-top: 5px;
}

.tool-input-group {
    display: flex;
    gap: 10px;
}

.tool-input-group .tool-input {
    flex-grow: 1;
}
.tool-label-inline {
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

.sio-subscriptions-list {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.sio-subscription-tag {
    display: flex;
    align-items: center;
    background-color: #e9ecef;
    padding: 5px 10px;
    border-radius: var(--border-radius);
    font-size: 14px;
}

.sio-subscription-tag button {
    background: none;
    border: none;
    cursor: pointer;
    margin-left: 8px;
    font-size: 16px;
    color: #6c757d;
    padding: 0;
    line-height: 1;
}
.sio-subscription-tag button:hover {
    color: #343a40;
}


.tool-label-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

.tool-button-sm {
    padding: 5px 12px;
    font-size: 13px;
    background-color: #6c757d; /* A neutral color */
    border-radius: var(--border-radius);
    color: white;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.tool-button-sm:hover {
    background-color: #5a6268;
}


.sio-log {
    border: 1px solid #dee2e6;
    padding: 12px;
    overflow-y: auto;
    background-color: #f8f9fa;
    white-space: pre-wrap;
    font-family: monospace;
    font-size: 14px;
    border-radius: var(--border-radius);
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.06);
    transition: all 0.2s ease;
}

.sio-log .log-message {
    margin-bottom: 5px;
}

.sio-log .log-message.sent {
    color: #007bff;
}

.sio-log .log-message.received {
    color: #28a745;
}

.sio-log .log-message.error {
    color: #dc3545;
}

.sio-log .log-message.status {
    color: #fd7e14;
}

/* New layout styles for Socket.IO tester */
.sio-layout-wrapper {
    display: flex;
    flex-wrap: wrap; /* Allow wrapping on smaller screens */
    gap: 20px;
    height: 100%; /* Make wrapper fill the container height */
}

.sio-config-panel {
    flex: 1; /* Take up 1 part of the space */
    min-width: 320px; /* Minimum width before wrapping */
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.sio-interaction-panel {
    flex: 1.5; /* Take up 1.5 parts of the space, making it wider */
    min-width: 320px; /* Minimum width before wrapping */
    display: flex;
    flex-direction: column;
    gap: 15px;
    height: calc(100% - 120px);
}
.sio-interaction-panel hr {
    display: none; /* Hide the hr on large screens */
}


.sio-log-section {
    flex-grow: 1; /* Allow this section to grow */
    display: flex;
    flex-direction: column;
    min-height: 0; /* Prevent flex overflow */
}

.sio-log {
    flex-grow: 1; /* Make the log div grow to fill available space */
    min-height: 150px; /* Ensure a minimum height */
    height: auto; /* Override fixed height */
}

/* On smaller screens, stack the columns */
@media (max-width: 768px) {
    .sio-layout-wrapper {
        flex-direction: column;
    }
    .sio-interaction-panel {
       height: auto;
    }
    .sio-interaction-panel hr {
       display: block; /* Show the hr on small screens */
    }
}
