/* ========================================================================== */
/* ADMIN --> SHARED CSS BETWEEN ADMIN PAGES                                                       */
/* ========================================================================== */

/*read more*/
.read-more {
    color: #556b85;
    font-size: 1.1rem;
    text-decoration: none; 
    font-weight: 700;
    cursor: pointer;
    position: relative;
}

    .read-more::after {
        content: "";
        position: absolute;
        left: 0;
        bottom: -2px;
        width: 0%;
        height: 2px;
        background-color: #2d64d8; 
        transition: width 0.25s ease;
        border-radius: 2px;
    }

    .read-more:hover::after {
        width: 100%; 
    }

/*badges - global admin styling*/

.badge {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03rem;
    display: inline-block;
}

    .badge.running,
    .badge.systemy,
    .badge.online {
        background: rgba(34, 197, 94, 0.15);
        color: #16a34a;
    }

    .badge.stopped,
    .badge.error,
    .badge.offline {
        background: rgba(239, 68, 68, 0.12);
        color: #dc2626;
    }

    .badge.degraded,
    .badge.warning {
        background: rgba(245, 158, 11, 0.15);
        color: #d97706;
    }

    .badge.pending,
    .badge.loading {
        background: rgba(59, 130, 246, 0.12);
        color: #2563eb;
    }

    /* ok / warn — used by Security Posture and any status badge needing plain ok/warn semantics */
    .badge.ok {
        background: rgba(34, 197, 94, 0.15);
        color: #16a34a;
    }

    .badge.warn {
        background: rgba(245, 158, 11, 0.15);
        color: #d97706;
    }

/* system badge */
.system-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 0.83rem;
    font-weight: 750;
    line-height: 1.1;
    text-align: center;
}

/*table and table btn*/

.table-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.table-btn {
    padding: 6px 12px;
    font-size: 0.82rem;
    font-weight: 650;
    border: none;
    border-radius: 10px;
    background: #2d64d8;
    color: white;
    cursor: pointer;
    transition: background 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;

    .table-btn {
        letter-spacing: 0.01rem;
    }
}

    .table-btn:hover {
        background: #1e4cb3;
        transform: translateY(-1px);
    }

    .table-btn:active {
        transform: translateY(0);
    }

    /* Danger */
    .table-btn.danger {
        background: #dc2626; /* modern red */
    }

        .table-btn.danger:hover {
            background: #b91c1c;
        }

    /* Yellow → bättre amber istället för “gul gul” */
    .table-btn.yellow {
        background: #f59e0b; /* amber */
        color: white; /* mörk text funkar bättre än vit på amber */
    }

        .table-btn.yellow:hover {
            background: #d97706;
            
        }

    /* Run now → modern green */
    .table-btn.run-now {
        background: #16a34a;
    }

        .table-btn.run-now:hover {
            background: #15803d;
            transform: translateY(-1px);
        }

    /* Secondary */
    .table-btn.secondary {
        background: #e9edf3;
        color: #022a46;
        border: 1px solid rgba(2, 42, 70, 0.18);
    }

        .table-btn.secondary:hover {
            background: #dde5ef;
        }

    /* Ghost */
    .table-btn.ghost {
        background: rgba(255, 255, 255, 0.75);
        color: #032f4f;
        border: 1px solid rgba(3, 47, 79, 0.18);
    }

        .table-btn.ghost:hover {
            background: rgba(238, 243, 248, 0.98);
            border-color: rgba(3, 47, 79, 0.28);
            transform: translateY(-1px);
        }

/* info icon */

.info-icon {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: 20px;
    height: 20px;
    margin-left: 10px;
    background: #e9edf3;
    color: #022a46;
    border: 1px solid rgba(2, 42, 70, 0.18);
    border-radius: 50%;
    font-size: 12px;
    font-weight: 750;
    cursor: pointer;
    position: relative;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}

    .info-icon:hover {
        background: #d6dde7; /* lite mörkare hover */
        border-color: rgba(2, 42, 70, 0.26);
        transform: translateY(-1px);
        z-index: 1900; /* raise above siblings so tooltip isn't clipped */
    }

    .info-icon::after {
        content: attr(data-tooltip);
        position: absolute;
        top: 26px;
        left: 0;
        width: min(380px, calc(100vw - 32px));
        background: #ffffff;
        color: #3a4b5c;
        border: 1px solid rgba(0,0,0,0.10);
        padding: 14px 18px;
        border-radius: 8px;
        font-size: 0.82rem;
        font-weight: 400;
        line-height: 1.45;
        text-align: left;
        white-space: pre-line;
        opacity: 0;
        pointer-events: none;
        z-index: 1;
        transform: translateY(4px);
        transition: opacity 0.18s ease, transform 0.18s ease;
        text-transform: none;
    }

    .info-icon::before {
        content: "";
        position: absolute;
        top: 22px;
        left: 10px;
        width: 0;
        height: 0;
        border-left: 8px solid transparent;
        border-right: 8px solid transparent;
        border-bottom: 10px solid white;
        opacity: 0;
        transition: opacity 0.2s ease;
    }

    .info-icon:hover::after,
    .info-icon:hover::before {
        opacity: 1;
        transform: translateY(0);
    }


    .info-icon.wireguard-status {
        background: #e3e7ee;
        color: #032f4f;
        width: 20px;
        height: 20px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        font-weight: 700;
        cursor: pointer;
        position: relative;
        border: 1px solid rgba(3, 47, 79, 0.18);
    }

        .info-icon.wireguard-status:hover {
            background: #d6dde7;
            border-color: rgba(3, 47, 79, 0.26);
            z-index: 1900; /* raise above siblings so tooltip isn't clipped */
        }

        .info-icon.wireguard-status::after {
            content: attr(data-tooltip);
            position: absolute;
            margin-left: -200px;
            width: min(380px, calc(100vw - 32px));
            background: #ffffff;
            color: #3a4b5c;
            border: 1px solid rgba(0,0,0,0.10);
            padding: 14px 18px;
            border-radius: 8px;
            font-size: 0.82rem;
            font-weight: 400;
            line-height: 1.45;
            text-align: left;
            white-space: pre-line;
            opacity: 0;
            pointer-events: none;
            z-index: 1;
            transform: translateY(4px);
            transition: opacity 0.18s ease, transform 0.18s ease;
            text-transform: none
        }

        .info-icon.wireguard-status::before {
            content: "";
            position: absolute;
            top: 22px;
            left: 10px;
            width: 0;
            height: 0;
            border-left: 8px solid transparent;
            border-right: 8px solid transparent;
            border-bottom: 10px solid white;
            opacity: 0;
            transition: opacity 0.2s ease;
        }

        .info-icon.wireguard-status:hover::after,
        .info-icon.wireguard-status:hover::before {
            opacity: 1;
            transform: translateY(0);
        }

/* spinners - genric loading indicators */
.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(45, 100, 216, 0.2);
    border-top-color: #2d64d8;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner-sm {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* modal - shared overlay + panel pattern */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-panel {
    background: white;
    border-radius: 16px;
    width: min(800px, 90vw);
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid #e2e8f0;
}

.modal-header h3 {
    font-size: 1.3rem;
    font-weight: 700;
    color: #022a46;
    margin: 0;
}

.modal-close {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 8px;
    background: #f1f5f9;
    color: #64748b;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.modal-close:hover {
    background: #e2e8f0;
    color: #1e293b;
}

.modal-body {
    padding: 24px;
}

/* VIEWMODE TOGGLE ROW */
.viewmode-toggle-row {
    margin-top: 12px;
}

/* ========================================================================== */
/* CENTRALIZED TABLE STYLES — Used by all admin pages                         */
/* Applies to .admin-table, .app-table, .vpn-table, .system-table, etc.      */
/* Single source of truth for consistent admin table styling                  */
/* ========================================================================== */

/* ── table wrapper container ── */
.admin-table-wrapper,
.app-table-wrapper,
.vpn-table-wrapper,
.system-table-wrapper,
.logs-table-wrapper,
.backup-table-wrapper {
    margin-top: 15px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 22px rgba(0,0,0,0.06);
    overflow: hidden;
}

/* ── base table ── */
.admin-table,
.app-table,
.vpn-table,
.system-table,
.service-system-table,
.device-system-table,
.security-system-table,
.logs-table,
.backup-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

/* ── table header ── */
.admin-table th,
.app-table th,
.vpn-table th,
.system-table th,
.service-system-table th,
.device-system-table th,
.security-system-table th,
.logs-table th,
.backup-table th {
    background: #e9edf3;
    font-weight: 800;
    padding: 14px;
    text-align: left;
    font-size: 0.9rem;
    color: #022a46;
    border-bottom: none;
}

/* ── table cells ── */
.admin-table td,
.app-table td,
.vpn-table td,
.system-table td,
.service-system-table td,
.device-system-table td,
.security-system-table td,
.logs-table td,
.backup-table td {
    padding: 14px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    color: #032f4f;
    font-size: 0.9rem;
    vertical-align: middle;
    font-variant-numeric: tabular-nums;
}

/* ── row hover ── */
.admin-table tbody tr:hover,
.app-table tbody tr:hover,
.vpn-table tbody tr:hover,
.system-table tbody tr:hover,
.service-system-table tbody tr:hover,
.device-system-table tbody tr:hover,
.security-system-table tbody tr:hover,
.logs-table tbody tr:hover,
.backup-table tbody tr:hover {
    background: rgba(45, 100, 216, 0.03);
}

/* ── zebra striping ── */
.admin-table tbody tr:nth-child(even),
.app-table tbody tr:nth-child(even),
.vpn-table tbody tr:nth-child(even),
.system-table tbody tr:nth-child(even),
.service-system-table tbody tr:nth-child(even),
.device-system-table tbody tr:nth-child(even),
.security-system-table tbody tr:nth-child(even),
.logs-table tbody tr:nth-child(even),
.backup-table tbody tr:nth-child(even) {
    background: rgba(2, 42, 70, 0.018);
}

/* ── stronger hover over zebra rows ── */
.admin-table tbody tr:nth-child(even):hover,
.app-table tbody tr:nth-child(even):hover,
.vpn-table tbody tr:nth-child(even):hover,
.system-table tbody tr:nth-child(even):hover,
.service-system-table tbody tr:nth-child(even):hover,
.device-system-table tbody tr:nth-child(even):hover,
.security-system-table tbody tr:nth-child(even):hover,
.logs-table tbody tr:nth-child(even):hover,
.backup-table tbody tr:nth-child(even):hover {
    background: rgba(45, 100, 216, 0.055) !important;
}

/* ── first column: left-aligned for labels ── */
.admin-table th:first-child,
.admin-table td:first-child,
.app-table th:first-child,
.app-table td:first-child,
.vpn-table th:first-child,
.vpn-table td:first-child,
.system-table th:first-child,
.system-table td:first-child,
.service-system-table th:first-child,
.service-system-table td:first-child,
.device-system-table th:first-child,
.device-system-table td:first-child,
.security-system-table th:first-child,
.security-system-table td:first-child,
.logs-table th:first-child,
.logs-table td:first-child,
.backup-table th:first-child,
.backup-table td:first-child {
    text-align: left;
    white-space: normal;
    overflow-wrap: anywhere; /* Forces continuous strings to wrap */
    word-break: break-word;  /* Fallback for older browsers */
}

/* ── first column: stronger visual weight ── */
.admin-table td:first-child,
.app-table td:first-child,
.vpn-table td:first-child,
.system-table td:first-child,
.service-system-table td:first-child,
.device-system-table td:first-child,
.security-system-table td:first-child,
.logs-table td:first-child,
.backup-table td:first-child {
    font-weight: 660;
    color: #022a46;
}

/* ── last column: right-aligned for actions ── */
.admin-table th:last-child,
.admin-table td:last-child,
.app-table th:last-child,
.app-table td:last-child,
.vpn-table th:last-child,
.vpn-table td:last-child,
.system-table th:last-child,
.system-table td:last-child,
.service-system-table th:last-child,
.service-system-table td:last-child,
.device-system-table th:last-child,
.device-system-table td:last-child,
.security-system-table th:last-child,
.security-system-table td:last-child,
.logs-table th:last-child,
.logs-table td:last-child,
.backup-table th:last-child,
.backup-table td:last-child {
    text-align: right;
}

/* ── center-aligned cells (for status, metrics) ── */
.admin-table td.cell-center,
.admin-table th.cell-center,
.app-table td.cell-center,
.app-table th.cell-center,
.vpn-table td.cell-center,
.vpn-table th.cell-center {
    text-align: center;
}

/* ── table cell severity tints ── */
.admin-table td.cell-ok,
.app-table td.cell-ok,
.vpn-table td.cell-ok,
.system-table td.cell-ok,
.service-system-table td.cell-ok,
.device-system-table td.cell-ok,
.security-system-table td.cell-ok {
    color: #15803d;
    font-weight: 600;
}

.admin-table td.cell-warn,
.app-table td.cell-warn,
.vpn-table td.cell-warn,
.system-table td.cell-warn,
.service-system-table td.cell-warn,
.device-system-table td.cell-warn,
.security-system-table td.cell-warn {
    color: #b45309;
    font-weight: 600;
}

.admin-table td.cell-crit,
.app-table td.cell-crit,
.vpn-table td.cell-crit,
.system-table td.cell-crit,
.service-system-table td.cell-crit,
.device-system-table td.cell-crit,
.security-system-table td.cell-crit {
    color: #b91c1c;
    font-weight: 700;
}

/* ── gradient cells for temp/disk/cpu (uses CSS variable) ── */
.admin-table td.cell-gradient,
.app-table td.cell-gradient,
.vpn-table td.cell-gradient,
.system-table td.cell-gradient,
.service-system-table td.cell-gradient,
.device-system-table td.cell-gradient,
.security-system-table td.cell-gradient {
    font-weight: 640;
    color: hsl(calc(120 - var(--cell-pct, 0) * 1.2), 62%, 24%);
    transition: color 0.4s ease;
}

/* ── column widths ── */
col.col-name        { width: 35%; }
col.col-status      { width: 150px; }
col.col-metric      { width: 150px; }
col.col-uptime      { width: 150px; }
col.col-actions-sm  { width: 190px; }
col.col-actions-lg  { width: 190px; }

/* ── issue cell styling ── */
.admin-table .issue-cell,
.app-table .issue-cell,
.vpn-table .issue-cell,
.system-table .issue-cell,
.service-system-table .issue-cell,
.device-system-table .issue-cell,
.security-system-table .issue-cell {
    text-align: center;
}

.admin-table .issue-icon,
.app-table .issue-icon,
.vpn-table .issue-icon,
.system-table .issue-icon,
.service-system-table .issue-icon,
.device-system-table .issue-icon,
.security-system-table .issue-icon {
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
    margin-right: 4px;
    position: relative;
    top: -1px;
}

.admin-table .issue-icon.issue-ok,
.app-table .issue-icon.issue-ok,
.vpn-table .issue-icon.issue-ok,
.system-table .issue-icon.issue-ok,
.service-system-table .issue-icon.issue-ok,
.device-system-table .issue-icon.issue-ok,
.security-system-table .issue-icon.issue-ok {
    color: #15803d;
}

.admin-table .issue-icon.issue-warn,
.app-table .issue-icon.issue-warn,
.vpn-table .issue-icon.issue-warn,
.system-table .issue-icon.issue-warn,
.service-system-table .issue-icon.issue-warn,
.device-system-table .issue-icon.issue-warn,
.security-system-table .issue-icon.issue-warn {
    color: #b45309;
}

/* ── error text pill styling ── */
.admin-table .last-error-text,
.app-table .last-error-text,
.vpn-table .last-error-text,
.system-table .last-error-text,
.service-system-table .last-error-text,
.device-system-table .last-error-text,
.security-system-table .last-error-text {
    display: inline-block;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.77rem;
    color: #5a7a8c;
    background: rgba(2, 42, 70, 0.05);
    border-radius: 6px;
    padding: 2px 7px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
    border: 1px solid rgba(2, 42, 70, 0.07);
}
