html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

body {
    font-family: monospace;
    background-color: #1e1f2e;
    color: #e0e2eb;
    display: flex;
    flex-direction: column;
}

.page-wrapper {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
}

.container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

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

@media (max-width: 900px) {
    .container {
        grid-template-columns: 1fr;
    }
}

.card {
    background: #2a2b3a;
    border-radius: 10px;
    padding: 16px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.card h2 {
    font-size: 16px;
    margin-bottom: 12px;
    border-bottom: 1px solid #444;
    padding-bottom: 8px;
}

.button {
    color: #64b5f6;
    text-decoration: none;
    font-size: 14px;
    padding: 4px 12px;
    border: 1px solid #64b5f6;
    border-radius: 4px;
    display: inline-block;
    transition: all 0.2s ease;
    background-color: transparent;
    cursor: pointer;
    font-weight: normal;
}

.button:hover {
    background-color: #64b5f6;
    color: #1a1b26;
    text-decoration: none;
}

.button:disabled,
.button.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    border-color: #444;
    color: #888;
}

.button:disabled:hover,
.button.disabled:hover {
    background-color: transparent;
    color: #888;
    border-color: #444;
}

.status {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 6px;
}

.green {
    background-color: #22c55e;
}

.yellow {
    background-color: #eab308;
}

.status.yellow.animated {
    animation: pulse 1.5s ease-in-out infinite;
}

.red {
    background-color: #ef4444;
}

.gray {
    background-color: #6b7280;
}

.build-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

/* Responsive table handling */
.card {
    overflow-x: auto;
}

/* Adjust table column widths for services table */
.build-table.services-table {
    table-layout: auto;
}

.build-table.services-table th:first-child,
.build-table.services-table td:first-child {
    width: 40px;
}

.build-table.services-table th:nth-child(2),
.build-table.services-table td:nth-child(2) {
    width: 120px;
}

.build-table.services-table th:nth-child(3),
.build-table.services-table td:nth-child(3) {
    width: auto;
}

.build-table.services-table th:nth-child(4),
.build-table.services-table td:nth-child(4) {
    width: auto;
}

/* Override inline grid-column styles for responsive layout */
@media (max-width: 1600px) {
    .card[style*="grid-column"] {
        grid-column: span 1 !important;
    }
}

.build-table th, .build-table td {
    padding: 6px 8px;
    border-bottom: 1px solid #444;
}

/* Group header styling */
.group-header-row:hover {
    background-color: #3a3b4a;
}

/* Server section styling */
.server-section {
    margin-bottom: 15px;
    border-bottom: 1px solid #444;
    padding-bottom: 15px;
}

.server-section:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.server-header:hover {
    background-color: #3a3b4a !important;
}

.expand-indicator {
    user-select: none;
    font-family: monospace;
}

/* Server builds table hover effect */
.server-builds tbody tr {
    transition: background-color 0.2s ease;
    cursor: pointer;
}

.server-builds tbody tr:hover {
    background-color: #3a3b4a;
}

/* Small build table in server sections */
.server-builds .build-table {
    margin-bottom: 0;
}

.server-builds .build-table th,
.server-builds .build-table td {
    padding: 4px 8px;
    font-size: 0.85em;
}

.logs {
    white-space: pre;
    background: #1a1b26;
    padding: 12px;
    border-radius: 6px;
    margin-top: 12px;
    font-size: 14px;
    overflow-x: auto;
    overflow-y: auto;
    max-height: 600px;
    height: 600px;
    font-family: 'Courier New', Courier, monospace;
    line-height: 1.4;
}

/* Log page specific layout */
.log-page-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.log-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.log-card .logs {
    flex: 1;
    height: auto;
    max-height: none;
    min-height: 200px;
}

/* Custom scrollbar styling */
.logs::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

.logs::-webkit-scrollbar-track {
    background: #0f0f14;
    border-radius: 6px;
}

.logs::-webkit-scrollbar-thumb {
    background: #444654;
    border-radius: 6px;
    border: 2px solid #1a1b26;
}

.logs::-webkit-scrollbar-thumb:hover {
    background: #565869;
}

.logs::-webkit-scrollbar-corner {
    background: #1a1b26;
}

/* Firefox scrollbar styling */
.logs {
    scrollbar-width: thin;
    scrollbar-color: #444654 #0f0f14;
}

th {
    text-align: left;
}

.build-table th,
.build-table td {
    padding: 6px 10px;
    text-align: left;
    vertical-align: middle;
}
.build-table select {
    font-family: monospace;
    width: 100%;
    max-width: none;
}

/* Form inputs */
input[type="text"],
input[type="password"],
select {
    font-family: monospace;
    font-size: 14px;
    background-color: #1e1f2e;
    border: 1px solid #444;
    color: #e0e2eb;
    border-radius: 4px;
    padding: 6px 10px;
    box-sizing: border-box;
    width: 100%;
    max-width: 300px;
}

input[type="text"]:focus,
input[type="password"]:focus,
select:focus {
    outline: none;
    border-color: #00ffd5;
}

/* Invalid branch selector styling */
select.invalid-branch {
    border-color: #ef4444;
    background-color: rgba(239, 68, 68, 0.1);
}

/* Invalid branch selector when focused */
select.invalid-branch:focus {
    background-color: #1e1f2e;
    border-color: #ef4444;
}

/* Invalid branch styling for searchable select input */
.searchable-select-input.invalid-branch {
    border-color: #ef4444;
    background-color: rgba(239, 68, 68, 0.1);
}

.searchable-select-input.invalid-branch:focus {
    background-color: #1e1f2e;
    border-color: #ef4444;
}

/* Searchable select component */
.searchable-select {
    position: relative;
    display: inline-block;
    width: 100%;
    max-width: 300px;
}

.searchable-select-input {
    font-family: monospace;
    font-size: 14px;
    background-color: #1e1f2e;
    border: 1px solid #444;
    color: #e0e2eb;
    border-radius: 4px;
    padding: 6px 10px;
    box-sizing: border-box;
    width: 100%;
    cursor: pointer;
}

.searchable-select-input:focus {
    outline: none;
    border-color: #00ffd5;
    cursor: text;
}

.searchable-select-dropdown {
    position: absolute;
    top: 100%;
    left: 10px;
    right: 10px;
    background-color: #1e1f2e;
    border: 1px solid #00ffd5;
    border-top: none;
    border-radius: 0 0 4px 4px;
    max-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: max-height 0.2s ease-out, opacity 0.2s ease-out;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    box-sizing: border-box;
}

.searchable-select-dropdown.open {
    max-height: 300px;
    opacity: 1;
    visibility: visible;
}

/* Custom scrollbar styling for dropdown */
.searchable-select-dropdown::-webkit-scrollbar {
    width: 8px;
}

.searchable-select-dropdown::-webkit-scrollbar-track {
    background: transparent;
    margin: 0 0 4px 0;
}

.searchable-select-dropdown::-webkit-scrollbar-thumb {
    background-color: #444654;
    border-radius: 4px;
    border: 2px solid #1e1f2e;
    background-clip: padding-box;
}

.searchable-select-dropdown::-webkit-scrollbar-thumb:hover {
    background-color: #565869;
}

.searchable-select-option {
    font-family: monospace;
    font-size: 14px;
    padding: 8px 10px;
    color: #e0e2eb;
    cursor: pointer;
    transition: background-color 0.1s ease;
}

.searchable-select-option:hover,
.searchable-select-option.selected {
    background-color: #2a2b3d;
}

.searchable-select-option.no-results {
    color: #888;
    cursor: default;
    font-style: italic;
}

.searchable-select-option.no-results:hover {
    background-color: transparent;
}

/* Searchable select in build table */
.build-table .searchable-select {
    width: 100%;
    max-width: none;
}

/* Form labels - use class for specific styling */
.form-label {
    display: block;
    margin: 0 0 0.25rem;
    font-size: 14px;
}

/* Animations */
@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

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

@keyframes highlight {
    0% {
        background-color: #3a3b4a;
    }
    50% {
        background-color: #4a5568;
        box-shadow: 0 0 10px rgba(100, 181, 246, 0.3);
    }
    100% {
        background-color: #3a3b4a;
    }
}

/* Highlight new build row */
.build-row-highlight {
    animation: highlight 3s ease-out;
    position: relative;
}

/* Status indicators */
#ws-connection-status,
#auto-scroll-indicator {
    transition: background-color 0.3s ease;
    font-family: monospace;
}

/* Hover tooltip for truncated content */
.truncate-hover {
    position: relative;
}

.truncate-hover:hover::after {
    content: attr(data-full-content);
    position: absolute;
    left: 0;
    bottom: 100%;
    margin-bottom: 5px;
    padding: 8px 12px;
    background-color: #1a1b26;
    color: #e0e2eb;
    border: 1px solid #444;
    border-radius: 6px;
    white-space: nowrap;
    z-index: 1000;
    font-size: 14px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.truncate-hover:hover::before {
    content: '';
    position: absolute;
    left: 20px;
    bottom: 100%;
    margin-bottom: -5px;
    border: 5px solid transparent;
    border-top-color: #444;
    z-index: 1001;
}

/* Group-related styles */
.group-row {
    background-color: #3a3b4a;
    font-weight: 500;
}

.group-header-row {
    background-color: #3a3b4a;
    font-weight: 500;
}

.group-service-row {
    background-color: #2a2b3a;
}

.group-service-row.server-builds-hidden {
    display: none;
}

.customize-link, .simplify-link, .toggle-customize-link {
    color: #64b5f6;
    text-decoration: none;
    font-size: 14px;
    padding: 4px 12px;
    border: 1px solid #64b5f6;
    border-radius: 4px;
    display: inline-block;
    transition: all 0.2s ease;
}

.customize-link:hover, .simplify-link:hover, .toggle-customize-link:hover {
    background-color: #64b5f6;
    color: #1a1b26;
    text-decoration: none;
}

.group-checkbox {
    cursor: pointer;
}

.group-branch-select {
    font-weight: 500;
}

/* Table cell spacing */
.table-cell-indent {
    padding-left: 20px;
}

/* Group/service helpers */
.helper-text {
    font-size: 0.9em;
    color: #888;
}

/* Separators */
.table-separator {
    height: 10px;
    background-color: #2a2b3a;
}

/* Status messages */
.status-paragraph {
    margin-bottom: 5px;
}

/* Building status indicator */
.building-status-indicator {
    background-color: #fef3c7;
    border-left: 4px solid #eab308;
    padding: 8px 12px;
    margin: 8px 0 8px 32px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.building-status-indicator .status {
    flex-shrink: 0;
}

.building-status-indicator .building-text {
    color: #92400e;
    font-weight: 500;
    font-size: 0.9em;
}

/* Current deployment state */
.current-deployment-state {
    margin-left: 32px;
    margin-bottom: 10px;
    font-size: 0.85em;
    color: #a0a2b0;
    line-height: 1.4;
}

.current-deployment-state .state-label {
    color: #888;
    font-weight: 500;
}

/* Server builds */
.server-builds-container {
    margin-top: 10px;
    margin-left: 20px;
}

.server-builds-hidden {
    display: none;
}

/* Service info in build rows */
.server-builds .build-table td:nth-child(2) {
    font-size: 0.8em;
    color: #a0a2b0;
    max-width: 400px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Make services column wider */
.server-builds .build-table th:nth-child(2),
.server-builds .build-table td:nth-child(2) {
    width: 50%;
}

.no-builds-message {
    color: #888;
    font-size: 0.9em;
}

/* Build tables */
.build-table-small {
    font-size: 0.9em;
}

.clickable-row {
    cursor: pointer;
}

/* WebSocket status colors */
.ws-connected {
    color: #00ffd5;
}

.ws-error {
    color: #ef4444;
}

.ws-connecting {
    color: #eab308;
}

/* Error messages */
.error-text {
    color: #ef4444;
}

/* Update expand indicators to include all properties */
.expand-indicator {
    display: inline-block;
    width: 12px;
    user-select: none;
    font-family: monospace;
}

/* Update server header to include all properties */
.server-header {
    cursor: pointer;
    padding: 10px;
    margin: -10px;
    margin-bottom: 5px;
    border-radius: 6px;
    transition: background-color 0.2s;
}

/* Database Operations Collapsible Section */
.collapsible-section {
    margin: 15px 0;
    border: 1px solid #444;
    border-radius: 6px;
}

.collapsible-header {
    padding: 10px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: #2a2b3a;
    border-radius: 6px;
    transition: background-color 0.2s;
}

.collapsible-header:hover {
    background-color: #3a3b4a;
}

.collapsible-content {
    padding: 12px;
    border-top: 1px solid #444;
}

.collapsible-content.hidden {
    display: none;
}

.db-operation-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.radio-option {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.radio-option:hover {
    background-color: #3a3b4a;
}

.radio-option input[type="radio"] {
    margin-top: 3px;
    cursor: pointer;
}

.radio-option span {
    line-height: 1.4;
}

.radio-option .option-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.radio-option .option-content small {
    color: #9ca3af;
    font-size: 0.85em;
}

.radio-option .option-content .service-hint {
    color: #6b7280;
    font-size: 0.8em;
    font-style: italic;
    margin-top: 2px;
}

.db-operation-warning {
    margin-top: 12px;
    padding: 10px 12px;
    background-color: #422006;
    border-left: 4px solid #f59e0b;
    border-radius: 4px;
    color: #fcd34d;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.db-operation-warning.hidden {
    display: none;
}

.warning-icon {
    font-size: 1.2em;
    flex-shrink: 0;
}

.warning-text {
    line-height: 1.4;
}

/* Highlight db-manager row when required */
.db-manager-required {
    background-color: rgba(59, 130, 246, 0.15);
}

.db-manager-required input[type="checkbox"] {
    cursor: not-allowed;
}

/* Highlight id-service row when required */
.id-service-required {
    background-color: rgba(59, 130, 246, 0.15);
}

.id-service-required input[type="checkbox"] {
    cursor: not-allowed;
}