/* Glass theme */

:root {
    --glass-bg: rgba(255, 255, 255, 0.04);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-blur: blur(16px);
    --accent: #3b82f6;
    --accent2: #8b5cf6;
    --sidebar-width: 220px;
}

html { font-size: 16px; }

body {
    background: linear-gradient(135deg, #0a0e17 0%, #111827 40%, #0f172a 100%) !important;
    background-attachment: fixed;
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    min-height: 100vh;
}

.app-layout { display: flex; min-height: 100vh; }

/* Glass sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: rgba(15, 20, 30, 0.55);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-right: 1px solid var(--glass-border);
    position: fixed; top: 0; left: 0; bottom: 0;
    z-index: 1040;
    display: flex; flex-direction: column;
}

.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 1.25rem 1.5rem;
    min-width: 0;
}

.sidebar-brand {
    display: flex; align-items: center; gap: .5rem;
    padding: 1rem; border-bottom: 1px solid var(--glass-border);
}
.brand-icon { color: var(--accent); font-size: 1.2rem; }
.brand-text { font-weight: 700; font-size: .95rem; color: #fff; }

.sidebar-search {
    display: flex; align-items: center; gap: .4rem;
    margin: .65rem; padding: .4rem .6rem;
    background: var(--glass-bg); border: 1px solid var(--glass-border);
    border-radius: .45rem; backdrop-filter: var(--glass-blur);
}
.sidebar-search input {
    flex: 1; background: transparent; border: none; outline: none;
    color: #e2e8f0; font-size: .875rem;
}

.sidebar-nav { padding: .4rem; flex: 1; }
.nav-item {
    display: flex; align-items: center; gap: .5rem;
    padding: .5rem .7rem; border-radius: .45rem;
    color: #94a3b8; text-decoration: none; font-size: .9375rem;
    margin-bottom: 2px; transition: .15s;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active {
    background: linear-gradient(135deg, rgba(59,130,246,.35), rgba(139,92,246,.25));
    border: 1px solid rgba(99,102,241,.35);
    color: #fff;
}

.sidebar-footer {
    padding: .65rem 1rem; border-top: 1px solid var(--glass-border);
    font-size: .8125rem; color: #64748b;
}

.page-title { font-size: 1.5rem; font-weight: 700; color: #fff; }

.page-toolbar-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem;
}

.mobile-topbar { display: none; }
.sidebar-overlay { display: none; }

/* Glass panels */
.glass-card, .glass-panel, .table-card {
    background: rgba(255, 255, 255, 0.04) !important;
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border) !important;
    border-radius: .75rem !important;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.glass-footer { background: transparent !important; }
.glass-alert { background: rgba(59,130,246,.12) !important; border: 1px solid rgba(59,130,246,.25); backdrop-filter: var(--glass-blur); }

.glass-input {
    background: rgba(0,0,0,.25) !important;
    border: 1px solid var(--glass-border) !important;
    color: #e2e8f0 !important;
    font-size: .9375rem;
}
.glass-input:focus {
    border-color: rgba(99,102,241,.5) !important;
    box-shadow: 0 0 0 2px rgba(99,102,241,.15);
}

.glass-tabs .nav-link {
    font-size: .875rem; color: #94a3b8;
    background: transparent; border-radius: .4rem;
}
.glass-tabs .nav-link.active {
    background: rgba(59,130,246,.2); color: #fff;
}

.glass-list .list-group-item { background: transparent !important; }

.glass-page-link {
    background: rgba(255,255,255,.04) !important;
    border-color: var(--glass-border) !important;
    color: #94a3b8 !important;
    font-size: .875rem;
}
.page-item.active .glass-page-link {
    background: rgba(59,130,246,.3) !important;
    border-color: rgba(59,130,246,.4) !important;
    color: #fff !important;
}

/* Buttons */
.btn-xs { padding: .2rem .5rem; font-size: .8125rem; line-height: 1.4; border-radius: .35rem; }
.btn-sm { font-size: .875rem; }

.btn-glass {
    background: rgba(255,255,255,.06);
    border: 1px solid var(--glass-border);
    color: #cbd5e1;
    font-size: .875rem;
}
.btn-glass:hover { background: rgba(255,255,255,.1); color: #fff; }

.btn-gradient-primary {
    background: linear-gradient(135deg, rgba(59,130,246,.85), rgba(99,102,241,.85));
    border: 1px solid rgba(99,102,241,.4);
    color: #fff; font-weight: 600; font-size: .875rem;
    box-shadow: 0 4px 12px rgba(59,130,246,.25);
}
.btn-gradient-primary:hover { color: #fff; transform: translateY(-1px); }

.btn-gradient-success {
    background: linear-gradient(135deg, rgba(16,185,129,.8), rgba(5,150,105,.8));
    border: 1px solid rgba(16,185,129,.35);
    color: #fff; font-weight: 600; font-size: .875rem;
}
.btn-gradient-success:hover { color: #fff; }

.btn-gradient-view {
    background: rgba(99,102,241,.15);
    border: 1px solid rgba(99,102,241,.35);
    color: #a5b4fc; font-size: .8125rem;
}
.btn-gradient-view:hover { background: rgba(99,102,241,.35); color: #fff; }

.btn-gradient-danger {
    background: linear-gradient(135deg, rgba(239,68,68,.7), rgba(220,38,38,.7));
    border: 1px solid rgba(239,68,68,.4);
    color: #fff; font-size: .875rem;
}
.btn-gradient-danger:hover { color: #fff; }

/* Stat cards */
.stat-card {
    background: rgba(255,255,255,.04) !important;
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border) !important;
    border-radius: .85rem !important;
    min-height: 110px;
}
.stat-card .card-body { padding: 1.25rem !important; }
.stat-value { font-size: 2.25rem; font-weight: 800; line-height: 1; color: #fff; }
.stat-label { font-size: .875rem; color: #94a3b8; margin-top: .25rem; text-transform: uppercase; letter-spacing: .04em; }
.stat-icon {
    width: 52px; height: 52px; border-radius: .65rem;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem; flex-shrink: 0;
    background: rgba(255,255,255,.06);
}
.stat-card-total .stat-icon { color: #60a5fa; }
.stat-card-listed .stat-icon { color: #f87171; }
.stat-card-clean .stat-icon { color: #4ade80; }

.status-cards-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }

/* Table */
.ip-table thead th {
    font-size: .8125rem; text-transform: uppercase; letter-spacing: .05em;
    color: #64748b; border-bottom-color: var(--glass-border) !important;
    padding: .6rem .75rem; font-weight: 600;
    background: rgba(0,0,0,.15);
}
.ip-table tbody td {
    padding: .55rem .75rem;
    border-color: rgba(255,255,255,.04) !important;
    font-size: .9375rem;
    vertical-align: middle;
}
.ip-table tbody tr:hover { background: rgba(59,130,246,.05) !important; }

/* IP cell — original cyan */
.ip-table code.ip-cell-code {
    font-size: .875rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    color: #7dd3fc !important;
    background: transparent !important;
    padding: 0;
    border: none;
}

.monitors-table-wrap {
    transition: opacity 0.22s ease, transform 0.22s ease;
}
.monitors-table-wrap.is-swapping {
    opacity: 0.45;
    transform: translateY(4px);
}

.view-mode-toggle .btn.active {
    background: rgba(59, 130, 246, 0.25);
    border-color: rgba(59, 130, 246, 0.45);
    color: #fff;
}

/* Listed delist links — small red transparent */
.listed-cell { max-width: 420px; }
.listed-inline { display: inline; white-space: normal; line-height: 1.9; }
.listed-link {
    display: inline;
    color: #f87171;
    background: rgba(239, 68, 68, 0.12);
    padding: .1rem .4rem;
    border-radius: .25rem;
    text-decoration: none;
    font-size: .75rem;
    font-weight: 500;
    border: 1px solid rgba(239, 68, 68, 0.35);
    white-space: nowrap;
}
.listed-link:hover {
    background: rgba(239, 68, 68, 0.22);
    color: #fca5a5;
    border-color: rgba(239, 68, 68, 0.5);
}
.listed-sep { color: #64748b; margin: 0 .15rem; font-size: .65rem; }

.listed-more-btn {
    display: inline;
    color: #fb923c;
    background: rgba(249, 115, 22, 0.12);
    padding: .1rem .4rem;
    border-radius: .25rem;
    border: 1px solid rgba(249, 115, 22, 0.35);
    font-size: .75rem;
    font-weight: 600;
    cursor: pointer;
    line-height: 1.4;
    vertical-align: baseline;
}
.listed-more-btn:hover {
    background: rgba(249, 115, 22, 0.22);
    color: #fdba74;
}

.listed-more-list {
    display: flex;
    flex-direction: column;
    gap: .4rem;
    max-height: 320px;
    overflow-y: auto;
}
.listed-more-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .75rem;
    padding: .5rem .65rem;
    border-radius: .4rem;
    background: rgba(239, 68, 68, 0.06);
    border: 1px solid rgba(239, 68, 68, 0.15);
}
.listed-more-row strong { font-size: .875rem; }
.listed-more-row .text-secondary { font-size: .75rem; }

.badge-clean-status {
    color: #4ade80;
    background: rgba(34, 197, 94, 0.12);
    border: 1px solid rgba(34, 197, 94, 0.35);
    font-size: .75rem;
    font-weight: 600;
    padding: .25rem .5rem;
}
.badge-listed-status {
    color: #fb923c;
    background: rgba(249, 115, 22, 0.12);
    border: 1px solid rgba(249, 115, 22, 0.35);
    font-size: .75rem;
    font-weight: 600;
    padding: .25rem .5rem;
}
.badge-unchecked-status {
    color: #94a3b8;
    background: rgba(148, 163, 184, 0.1);
    border: 1px solid rgba(148, 163, 184, 0.25);
    font-size: .75rem;
    font-weight: 500;
    padding: .25rem .5rem;
}

.btn-delist-red {
    color: #f87171 !important;
    background: rgba(239, 68, 68, 0.12) !important;
    border: 1px solid rgba(239, 68, 68, 0.35) !important;
    font-weight: 500;
    font-size: .65rem !important;
    padding: .1rem .35rem !important;
    line-height: 1.3;
}
.btn-delist-red:hover {
    background: rgba(239, 68, 68, 0.22) !important;
    color: #fca5a5 !important;
}

.btn-gradient-view-orange {
    background: rgba(249, 115, 22, 0.18);
    border: 1px solid rgba(249, 115, 22, 0.45);
    color: #fb923c;
    font-size: .8125rem;
}
.btn-gradient-view-orange:hover {
    background: rgba(249, 115, 22, 0.35);
    color: #fff;
}

.detail-offcanvas {
    width: min(400px, 95vw) !important;
    background: rgba(10, 14, 23, 0.45) !important;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-left: 1px solid rgba(255, 255, 255, 0.08) !important;
    z-index: 1060 !important;
}
.offcanvas-backdrop { z-index: 1055 !important; }
.detail-section-title {
    font-size: .8125rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #fb923c;
    margin-bottom: .5rem;
}
.detail-list { display: flex; flex-direction: column; gap: .35rem; }
.detail-list-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .5rem;
    padding: .45rem .55rem;
    border-radius: .4rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
}
.detail-list-listed {
    border-color: rgba(239, 68, 68, 0.15);
    background: rgba(239, 68, 68, 0.06);
}
.detail-list-clean {
    border-color: rgba(34, 197, 94, 0.15);
    background: rgba(34, 197, 94, 0.05);
}

.stop-check-icon {
    background: rgba(255, 204, 51, 0.12) !important;
    border-color: rgba(255, 204, 51, 0.35) !important;
    color: #ffcc33 !important;
}

/* IP check progress */
.check-progress-panel { border: 1px solid rgba(34, 197, 94, .3) !important; }
.check-progress-badge {
    background: rgba(34, 197, 94, 0.15) !important;
    color: #4ade80 !important;
    border: 1px solid rgba(34, 197, 94, 0.45);
}
.check-progress-bar {
    height: 10px;
    background: rgba(0,0,0,.25);
    border-radius: 999px;
    overflow: hidden;
}
.check-progress-fill {
    background-color: #22c55e !important;
}
.check-current-ip code {
    font-size: .9375rem;
    color: #e2e8f0;
}
.check-current-ip code.ip-check-listed { color: #ef4444 !important; }
.check-current-ip code.ip-check-clean { color: #22c55e !important; }
.check-live-log {
    max-height: 160px;
    overflow-y: auto;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: .8125rem;
    background: rgba(0,0,0,.2);
    border-radius: .5rem;
    padding: .5rem .75rem;
}
.check-live-log:empty { display: none; }
.check-log-line { padding: .15rem 0; color: #94a3b8; border-bottom: 1px solid rgba(255,255,255,.04); }
.check-log-line:last-child { border-bottom: none; }
.check-log-line.error { color: #fca5a5; }
.check-log-line.ok-listed { color: #ef4444; }
.check-log-line.ok-clean { color: #22c55e; }

/* Delete modal icon */
.delete-icon-wrap {
    width: 48px; height: 48px; margin: 0 auto;
    border-radius: 50%;
    background: rgba(239,68,68,.15);
    border: 1px solid rgba(239,68,68,.3);
    display: flex; align-items: center; justify-content: center;
    color: #f87171; font-size: 1.1rem;
}

.glass-modal .modal-backdrop { backdrop-filter: blur(4px); }

/* Sidebar sections */
.nav-section {
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #64748b;
    padding: .85rem .7rem .35rem;
    margin-top: .25rem;
}
.nav-item.nav-sub { padding-left: 1.25rem; font-size: .875rem; }
.nav-item.nav-logout {
    display: flex; align-items: center; gap: .5rem;
    padding: .45rem .7rem; margin-bottom: .35rem;
    color: #94a3b8; text-decoration: none; font-size: .875rem;
}
.nav-item.nav-logout:hover { color: #fff; }

/* Logs */
.log-viewer {
    max-height: 420px;
    overflow: auto;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: .8125rem;
    background: rgba(0,0,0,.2);
}
.log-line {
    padding: .35rem .75rem;
    border-bottom: 1px solid rgba(255,255,255,.04);
    white-space: pre-wrap;
    word-break: break-word;
}
.log-line-error {
    background: rgba(239,68,68,.12);
    color: #fca5a5;
    border-left: 3px solid #ef4444;
}

/* Theme picker */
.theme-card { cursor: pointer; transition: .15s; color: inherit; }
.theme-card:hover { transform: translateY(-2px); }
.theme-card-active { outline: 2px solid rgba(59,130,246,.65); }
.theme-preview {
    border-bottom: 1px solid var(--glass-border);
    min-height: 88px;
}
.theme-preview-dark { background: linear-gradient(135deg, #0a0e17, #111827); }
.theme-preview-light { background: linear-gradient(135deg, #f8fafc, #e2e8f0); }
.theme-preview-bar {
    height: 10px; width: 40%; border-radius: 4px; margin-bottom: 8px;
    background: rgba(255,255,255,.15);
}
.theme-preview-light .theme-preview-bar { background: rgba(15,23,42,.12); }
.theme-preview-body {
    height: 36px; border-radius: 6px;
    background: rgba(255,255,255,.06);
}
.theme-preview-light .theme-preview-body { background: rgba(255,255,255,.85); }

/* Login */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.login-wrap { width: min(400px, 100%); }
.login-card { box-shadow: 0 16px 48px rgba(0,0,0,.35); }

/* Light theme */
html[data-bs-theme="light"] body.theme-light,
body.theme-light {
    background: linear-gradient(135deg, #f8fafc 0%, #eef2ff 40%, #f1f5f9 100%) !important;
    color: #0f172a;
}
html[data-bs-theme="light"] .sidebar,
body.theme-light .sidebar {
    background: rgba(255,255,255,.75);
    border-right-color: rgba(15,23,42,.08);
}
html[data-bs-theme="light"] .brand-text,
body.theme-light .brand-text { color: #0f172a; }
html[data-bs-theme="light"] .nav-item,
body.theme-light .nav-item { color: #475569; }
html[data-bs-theme="light"] .nav-item:hover,
html[data-bs-theme="light"] .nav-item.active,
body.theme-light .nav-item:hover,
body.theme-light .nav-item.active { color: #0f172a; }
html[data-bs-theme="light"] .page-title,
body.theme-light .page-title { color: #0f172a; }
html[data-bs-theme="light"] .glass-card,
html[data-bs-theme="light"] .glass-panel,
body.theme-light .glass-card,
body.theme-light .glass-panel {
    background: rgba(255,255,255,.72) !important;
    border-color: rgba(15,23,42,.08) !important;
    box-shadow: 0 8px 24px rgba(15,23,42,.06);
}
html[data-bs-theme="light"] .ip-table thead th,
body.theme-light .ip-table thead th {
    color: #64748b;
    background: rgba(15,23,42,.04);
}
html[data-bs-theme="light"] .log-viewer,
body.theme-light .log-viewer { background: rgba(15,23,42,.04); }
html[data-bs-theme="light"] .log-line-error,
body.theme-light .log-line-error {
    background: rgba(239,68,68,.08);
    color: #b91c1c;
}

@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform .25s ease;
        box-shadow: none;
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
        box-shadow: 8px 0 32px rgba(0, 0, 0, 0.45);
    }

    .sidebar-overlay {
        position: fixed;
        inset: 0;
        z-index: 1035;
        background: rgba(0, 0, 0, 0.55);
        backdrop-filter: blur(2px);
        -webkit-backdrop-filter: blur(2px);
        opacity: 0;
        pointer-events: none;
        transition: opacity .25s ease;
    }

    body.sidebar-open .sidebar-overlay {
        display: block;
        opacity: 1;
        pointer-events: auto;
    }

    .main-content {
        margin-left: 0;
        padding: .75rem;
        width: 100%;
    }

    .mobile-topbar {
        display: flex;
        align-items: center;
        gap: .75rem;
        margin: -.75rem -.75rem .75rem;
        padding: .65rem .75rem;
        position: sticky;
        top: 0;
        z-index: 1020;
        background: rgba(10, 14, 23, 0.88);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        border-bottom: 1px solid var(--glass-border);
    }

    .mobile-menu-btn {
        width: 40px;
        height: 40px;
        padding: 0;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
    }

    .mobile-topbar-title {
        font-weight: 600;
        font-size: .9375rem;
        color: #fff;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .page-title {
        font-size: 1.25rem;
    }

    .page-toolbar-actions {
        width: 100%;
    }

    .page-toolbar-actions .btn,
    .page-toolbar-actions .btn-group {
        flex: 1 1 auto;
    }

    .page-toolbar-actions .btn-group .btn {
        flex: 1;
    }

    .status-cards-3 {
        grid-template-columns: 1fr;
    }

    .stat-value {
        font-size: 1.75rem;
    }

    .stat-card .card-body {
        padding: 1rem !important;
    }

    .ip-table thead th,
    .ip-table tbody td {
        padding: .45rem .5rem;
        font-size: .8125rem;
    }

    .ip-table {
        min-width: 560px;
    }

    .listed-cell {
        max-width: 220px;
    }

    .ip-table .btn-sm {
        padding: .2rem .35rem;
        font-size: .75rem;
    }

    .table-card .card-header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: .5rem;
    }

    .check-progress-panel .d-flex {
        flex-direction: column;
        align-items: flex-start !important;
    }

    .modal-dialog {
        margin: .5rem;
        max-width: calc(100% - 1rem);
    }

    .detail-offcanvas {
        width: 100% !important;
        max-width: 100% !important;
    }

    .detail-list-row {
        flex-direction: column;
        align-items: flex-start !important;
    }

    .log-viewer {
        max-height: 280px;
    }

    .pagination {
        flex-wrap: wrap;
        justify-content: center;
    }

    .btn-lg {
        font-size: .875rem;
        padding: .5rem 1rem;
    }
}

@media (max-width: 575.98px) {
    html { font-size: 15px; }

    .main-content {
        padding: .65rem;
    }

    .mobile-topbar {
        margin: -.65rem -.65rem .65rem;
        padding: .55rem .65rem;
    }

    .page-toolbar-actions .btn span.btn-text,
    .view-mode-toggle .btn-text {
        display: none;
    }

    .view-mode-toggle .btn i {
        margin: 0 !important;
    }

    .sidebar-brand .brand-text {
        font-size: .875rem;
    }
}

html[data-bs-theme="light"] .mobile-topbar,
body.theme-light .mobile-topbar {
    background: rgba(255, 255, 255, 0.92);
    border-bottom-color: rgba(15, 23, 42, 0.08);
}

html[data-bs-theme="light"] .mobile-topbar-title,
body.theme-light .mobile-topbar-title {
    color: #0f172a;
}
