/* ── Service Monitor – Dark Command-Center Theme ── */

:root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --border: #30363d;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #484f58;
    --accent: #58a6ff;
    --green: #3fb950;
    --red: #f85149;
    --yellow: #d29922;
    --btn-bg: #21262d;
    --btn-hover: #30363d;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ── Page Centered (login) ── */

body.page-centered {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── Navbar ── */

.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    height: 56px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    gap: 1rem;
    flex-wrap: wrap;
}

.nav-brand {
    display: flex;
    align-items: center;
}

.nav-logo {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary) !important;
    text-decoration: none !important;
}

.nav-links {
    list-style: none;
    display: flex;
    gap: 0.25rem;
    margin: 0;
    padding: 0;
}

.nav-links a {
    padding: 0.4rem 0.85rem;
    border-radius: 6px;
    font-size: 0.875rem;
    color: var(--text-secondary) !important;
    text-decoration: none !important;
    transition: background 0.15s, color 0.15s;
}

.nav-links a:hover {
    background: var(--btn-hover);
    color: var(--text-primary) !important;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.85rem;
}

.nav-username {
    color: var(--text-primary);
}

.nav-role {
    text-transform: uppercase;
    font-size: 0.7rem;
    font-weight: 600;
}

/* ── Badges ── */

.badge {
    padding: 0.15rem 0.5rem;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-admin {
    background: var(--red);
    color: #fff;
}

.badge-operator {
    background: var(--yellow);
    color: #000;
}

.badge-viewer {
    background: var(--btn-bg);
    color: var(--text-secondary);
}

.badge-super {
    background: #8b5cf6;
    color: #fff;
}

/* ── Buttons ── */

.btn {
    padding: 0.4rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    background: var(--btn-bg);
    color: #c9d1d9;
    transition: background 0.15s;
    font-family: inherit;
}

.btn:hover {
    background: var(--btn-hover);
    text-decoration: none;
}

.btn-sm {
    padding: 0.3rem 0.6rem;
    font-size: 0.75rem;
}

.btn-md {
    padding: 0.5rem 1.25rem;
    font-size: 0.9rem;
}

.btn-outline {
    background: transparent;
}

.btn-primary {
    background: #238636;
    border-color: #238636;
    color: #fff;
}

.btn-primary:hover {
    background: #2ea043;
}

.btn-danger {
    border-color: var(--red);
    color: var(--red);
}

.btn-danger:hover {
    background: var(--red);
    color: #fff;
}

.btn-start {
    border-color: #238636;
    color: var(--green);
}

.btn-start:hover {
    background: #238636;
    color: #fff;
}

.btn-stop {
    border-color: #da3633;
    color: var(--red);
}

.btn-stop:hover {
    background: #da3633;
    color: #fff;
}

.btn-restart {
    border-color: var(--yellow);
    color: var(--yellow);
}

.btn-restart:hover {
    background: var(--yellow);
    color: #fff;
}

/* ── Container ── */

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* ── Flash Messages ── */

.flash-messages {
    margin-bottom: 1.5rem;
}

.alert {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.alert-success {
    background: rgba(63, 185, 80, 0.15);
    border: 1px solid rgba(63, 185, 80, 0.4);
    color: var(--green);
}

.alert-danger {
    background: rgba(248, 81, 73, 0.15);
    border: 1px solid rgba(248, 81, 73, 0.4);
    color: var(--red);
}

.alert-info {
    background: rgba(88, 166, 255, 0.15);
    border: 1px solid rgba(88, 166, 255, 0.4);
    color: var(--accent);
}

/* ── Page Header ── */

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.page-header h1 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1.5rem;
}

/* ── TablePlus-style Grid Table ── */

.tp-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 5px;
    overflow: hidden;
    table-layout: fixed;
}

.tp-header {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-secondary);
    background: var(--bg-primary);
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 5px 9px;
    text-align: left;
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
    user-select: none;
}

.tp-row {
    height: 27px;
}

.tp-row--striped {
    background: rgba(255, 255, 255, 0.015);
}

.tp-row:hover {
    background: rgba(88, 166, 255, 0.06);
}

.tp-cell {
    font-family: "SF Mono", "Cascadia Code", "Consolas", "Menlo", monospace;
    font-size: 12px;
    color: #c9d1d9;
    padding: 4px 9px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    line-height: 1.3;
}

.tp-cell:last-child {
    border-right: 0;
}

.tp-cell--null {
    font-style: italic;
    color: var(--text-muted);
}

.tp-cell--number {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.tp-cell--text {
    text-align: left;
}

.tp-cell--selected {
    background: rgba(88, 166, 255, 0.12);
    box-shadow: inset 0 0 0 1px var(--accent);
}

.tp-row--selected {
    background: rgba(88, 166, 255, 0.08);
}

.tp-row--selected .tp-cell {
    border-bottom-color: rgba(88, 166, 255, 0.2);
}

.tp-row:last-child .tp-cell {
    border-bottom: 0;
}

.tp-table .actions {
    display: flex;
    gap: 0.25rem;
    align-items: center;
}

/* legacy alias — keep old templates working */
.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 5px;
    overflow: hidden;
    table-layout: fixed;
}

.data-table th {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-secondary);
    background: var(--bg-primary);
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 5px 9px;
    text-align: left;
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
    user-select: none;
}

.data-table td {
    font-family: "SF Mono", "Cascadia Code", "Consolas", "Menlo", monospace;
    font-size: 12px;
    color: #c9d1d9;
    padding: 4px 9px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    line-height: 1.3;
}

.data-table tr {
    height: 27px;
}

.data-table tr:last-child td {
    border-bottom: 0;
}

.data-table tr:hover td {
    background: rgba(88, 166, 255, 0.06);
}

.data-table .actions {
    display: flex;
    gap: 0.25rem;
    align-items: center;
}

/* ── Form Elements ── */

input,
select,
textarea {
    font-family: inherit;
}

.form-container {
    max-width: 500px;
}

.form-container h1 {
    color: var(--text-primary);
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.25rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    box-sizing: border-box;
    padding: 0.5rem 0.75rem;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.15);
}

.form-group textarea {
    min-height: 80px;
    resize: vertical;
}

.form-group select option {
    background: var(--bg-primary);
    color: var(--text-primary);
}

.form-error {
    color: var(--red);
    font-size: 0.8rem;
    margin-top: 0.25rem;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.form-control {
    width: 100%;
    box-sizing: border-box;
    padding: 0.5rem 0.75rem;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.15);
}

/* ── Login ── */

.login-container {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
}

.login-container h1 {
    margin-top: 0;
    text-align: center;
    font-size: 1.5rem;
    color: var(--text-primary);
}

/* ── Dashboard Cards ── */

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.dashboard-header h1 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1.5rem;
}

.refresh-indicator {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.service-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
}

.service-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem;
}

.service-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}

.service-card-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.service-card-desc {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

.service-card-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.status-dot.active {
    background: var(--green);
    box-shadow: 0 0 6px var(--green);
}

.status-dot.inactive {
    background: var(--red);
    box-shadow: 0 0 6px var(--red);
}

.status-dot.unknown {
    background: var(--yellow);
    box-shadow: 0 0 6px var(--yellow);
}

.status-text {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.service-card-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.inline-form {
    display: inline;
}

/* ── Pagination ── */

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

.pagination a,
.pagination span {
    padding: 0.35rem 0.75rem;
    background: var(--btn-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: #c9d1d9;
    text-decoration: none;
    font-size: 0.85rem;
}

.pagination a:hover {
    background: var(--btn-hover);
}

.pagination .current {
    background: var(--bg-secondary);
    color: var(--text-secondary);
}

/* ── Empty State ── */

.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

.empty-state a {
    color: var(--accent);
}

/* ── Utility ── */

.text-muted {
    color: var(--text-muted);
}

.text-you {
    color: var(--accent);
    font-size: 0.75rem;
}

code {
    background: var(--bg-primary);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.85em;
    color: var(--text-primary);
}

/* ── Scrollbar ── */

::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ── Modal Dialog ── */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-dialog {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    margin: 0;
    font-size: 1.2rem;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-dialog form {
    padding: 1.25rem 1.5rem;
}

.modal-dialog .form-group {
    margin-bottom: 1rem;
}

.modal-dialog .form-actions {
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}
