/* Light theme (default) */
body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f4f4f4;
    color: #333;
    transition: background-color 0.3s, color 0.3s;
}

body.subpage {
    padding-top: 4.5rem;
}

.dark-theme {
    background-color: #333;
    color: #f4f4f4;
}

header {
    background-color: #007bff;
    color: white;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dark-theme header {
    background-color: #0056b3;
}

.login-container {
    max-width: 400px;
    margin: 5rem auto;
    padding: 2rem;
    background: white;
    border-radius: 8px;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
}

.dark-theme .login-container {
    background: #444;
    color: #f4f4f4;
}

input, button {
    display: block;
    width: 100%;
    margin: 0.5rem 0;
    padding: 0.5rem;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.dark-theme input, .dark-theme button {
    background: #555;
    color: #f4f4f4;
    border-color: #666;
}

button {
    background: #007bff;
    color: white;
    cursor: pointer;
}

button:hover {
    background: #0056b3;
}

.header-controls a {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: #007bff;
    color: white;
    text-decoration: none;
    border: 1px solid #007bff;
    border-radius: 4px;
    cursor: pointer;
    margin-left: 0.5rem;
    width: 140px;
    text-align: center;
    box-sizing: border-box;
}

.header-controls a:hover {
    background: #0056b3;
    border-color: #0056b3;
}

.header-controls button {
    padding: 0.5rem 1rem;
    margin-left: 0.5rem;
    width: 140px;
    box-sizing: border-box;
}

.dark-theme .header-controls a {
    background: #0056b3;
    border-color: #0056b3;
    color: white;
}

.dark-theme .header-controls a:hover {
    background: #003d82;
    border-color: #003d82;
}

.dark-theme .header-controls button {
    background: #0056b3;
    border-color: #0056b3;
    color: white;
}

.dark-theme .header-controls button:hover {
    background: #003d82;
}

.error {
    color: #dc3545;
}

.login-container ul {
    list-style: none;
    padding: 0;
}

.login-container li {
    background: #f9f9f9;
    margin: 0.5rem 0;
    padding: 0.5rem;
    border-radius: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dark-theme .login-container li {
    background: #555;
}

.login-container li form {
    margin: 0;
}

.check-config {
    background: #f9f9f9;
    margin: 0.6rem 0;
    padding: 0.6rem 0.8rem;
    border-radius: 4px;
}

.dark-theme .check-config {
    background: #555;
}

.check-config h3 {
    margin: 0 0 0.4rem 0;
    font-size: 1rem;
}

.check-config form {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
}

.check-config label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.9rem;
}

.job-config-container {
    width: calc(100vw - 3rem);
    max-width: 1500px;
}

.add-job-form {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.job-row-form {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.job-fields {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem;
    flex: 1;
}

.job-fields label {
    flex: 1 1 220px;
}

.job-fields input[type="text"],
.job-fields input[type="number"] {
    width: auto;
    min-width: 120px;
    margin: 0;
}

.job-fields input[type="checkbox"] {
    width: auto;
    margin: 0;
}

.job-actions {
    margin-left: auto;
    display: flex;
    gap: 0.35rem;
}

.icon-btn {
    width: 34px;
    min-width: 34px;
    height: 34px;
    padding: 0;
    margin: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    line-height: 1;
    border-radius: 6px;
}

.icon-apply {
    background: #17a2b8;
    border-color: #17a2b8;
}

.icon-apply:hover {
    background: #117a8b;
}

.icon-delete {
    background: #dc3545;
    border-color: #dc3545;
}

.icon-schedule {
    background: #6f42c1;
    border-color: #6f42c1;
}

.icon-edit {
    background: #ffc107;
    border-color: #ffc107;
    color: #212529;
}

.icon-edit:hover {
    background: #d39e00;
}

.icon-delete:hover {
    background: #b02a37;
}

.icon-schedule:hover {
    background: #59359c;
}

.dark-theme .icon-apply {
    background: #117a8b;
    border-color: #117a8b;
}

.dark-theme .icon-delete {
    background: #b02a37;
    border-color: #b02a37;
}

.dark-theme .icon-schedule {
    background: #59359c;
    border-color: #59359c;
}

.dark-theme .icon-edit {
    background: #d39e00;
    border-color: #d39e00;
    color: #212529;
}

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

@media (max-width: 900px) {
    .job-config-container {
        width: calc(100vw - 1.5rem);
    }

    .job-fields label {
        flex: 1 1 100%;
    }
}

.chart-widgets {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin: 2rem;
}

.chart-container {
    background: white;
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    max-width: 400px;
    flex: 1 1 300px;
    min-width: 0;
}

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

.chart-container-header h2 {
    margin: 0;
    font-size: 1rem;
}

.chart-expand-btn {
    width: 28px;
    min-width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    border-radius: 4px;
    background: rgba(0,0,0,0.12);
    color: inherit;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.chart-expand-btn:hover {
    background: rgba(0,0,0,0.25);
}

.dark-theme .chart-container {
    background: #444;
}

.checks-list {
    margin: 2rem;
    background: white;
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
}

.dark-theme .checks-list {
    background: #444;
}

.checks-subtitle {
    font-size: 0.8rem;
    font-weight: normal;
    color: #888;
}

.status-widgets {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.status-widget {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.6rem;
    border-radius: 6px;
    font-size: 0.85rem;
    min-width: 130px;
    max-width: 400px;
    flex: 1 1 130px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    position: relative;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

a.status-widget:hover {
    filter: brightness(0.93);
}

.status-widget-icon {
    font-size: 1rem;
    flex-shrink: 0;
}

.status-widget-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.status-widget-badge {
    font-size: 0.7rem;
    font-weight: bold;
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    background: rgba(0,0,0,0.12);
    flex-shrink: 0;
}

.status-widget-expand {
    margin-left: auto;
    flex-shrink: 0;
    width: 20px;
    min-width: 20px;
    height: 20px;
    padding: 0;
    border: none;
    border-radius: 4px;
    background: rgba(0,0,0,0.15);
    color: inherit;
    font-size: 14px;
    font-weight: bold;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.status-widget-expand:hover {
    background: rgba(0,0,0,0.3);
}

/* Fullscreen overlay */
.widget-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
}

.widget-overlay[hidden] {
    display: none;
}

.widget-overlay-inner {
    position: relative;
    border-radius: 16px;
    padding: 1.5rem;
    width: 90vw;
    max-width: 900px;
    max-height: 90vh;
    background: white;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    box-shadow: 0 8px 40px rgba(0,0,0,0.35);
    overflow: hidden;
}

.dark-theme .widget-overlay-inner {
    background: #444;
    color: #f4f4f4;
}

.widget-overlay-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-shrink: 0;
}

.widget-overlay-chart-title {
    font-size: 1.1rem;
    font-weight: bold;
}

.widget-overlay-close {
    width: 32px;
    min-width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: rgba(0,0,0,0.18);
    color: inherit;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-left: auto;
}

.widget-overlay-close:hover {
    background: rgba(0,0,0,0.35);
}

#widget-overlay-canvas {
    flex: 1;
    min-height: 0;
    width: 100% !important;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 0.5rem;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

.dark-theme th, .dark-theme td {
    border-color: #666;
}

.status-ok { background-color: #d4edda; }
.status-warn { background-color: #fff3cd; }
.status-error { background-color: #f8d7da; }
.status-unknown { background-color: #e2e3e5; }
.status-timeout { background-color: #fde8d0; border: 2px dashed #e67e22; }

.dark-theme .status-ok { background-color: #155724; }
.dark-theme .status-warn { background-color: #856404; }
.dark-theme .status-error { background-color: #721c24; }
.dark-theme .status-unknown { background-color: #383d41; }
.dark-theme .status-timeout { background-color: #6b350a; border-color: #e67e22; }

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

#theme-toggle {
    background: #28a745;
    border: none;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
}

#theme-toggle:hover {
    background: #218838;
}

.sticky-back-btn {
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1000;
    display: inline-block;
    padding: 0.6rem 1rem;
    background: #007bff;
    color: white;
    text-decoration: none;
    border: 1px solid #007bff;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.sticky-top-right-btn {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1000;
    display: inline-block;
    padding: 0.6rem 1rem;
    background: #007bff;
    color: white;
    text-decoration: none;
    border: 1px solid #007bff;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.sticky-top-right-btn:hover {
    background: #0056b3;
    border-color: #0056b3;
}

.sticky-back-btn:hover {
    background: #0056b3;
    border-color: #0056b3;
}

.dark-theme .sticky-back-btn {
    background: #0056b3;
    border-color: #0056b3;
    color: white;
}

.dark-theme .sticky-back-btn:hover {
    background: #003d82;
    border-color: #003d82;
}

.dark-theme .sticky-top-right-btn {
    background: #0056b3;
    border-color: #0056b3;
    color: white;
}

.dark-theme .sticky-top-right-btn:hover {
    background: #003d82;
    border-color: #003d82;
}