/* =============================================================================
   MegaHostZone Admin — Design System
   v2 · 2026-04
   ========================================================================== */

/* ---------- Design tokens (light theme) ----------------------------------- */
:root {
    /* Layout */
    --sidebar-w: 260px;
    --navbar-h:  60px;

    /* Brand */
    --brand-primary:        #4f46e5;   /* indigo-600 */
    --brand-primary-hover:  #4338ca;
    --brand-primary-soft:   rgba(79, 70, 229, .12);

    /* Semantic */
    --success:        #10b981;
    --success-soft:   rgba(16, 185, 129, .12);
    --warning:        #f59e0b;
    --warning-soft:   rgba(245, 158, 11, .12);
    --danger:         #ef4444;
    --danger-soft:    rgba(239, 68, 68, .12);
    --info:           #06b6d4;
    --info-soft:      rgba(6, 182, 212, .12);

    /* Neutrals — light theme */
    --bg-app:         #f5f7fb;
    --bg-surface:     #ffffff;
    --bg-elevated:    #ffffff;
    --bg-subtle:      #f8fafc;
    --bg-hover:       #f1f5f9;

    --border:         #e5e7eb;
    --border-strong:  #d1d5db;

    --text:           #0f172a;
    --text-muted:     #64748b;
    --text-soft:      #94a3b8;

    /* Sidebar (always dark slate, even in light theme) */
    --sb-bg:          #0f172a;
    --sb-bg-elev:     #1e293b;
    --sb-text:        #cbd5e1;
    --sb-text-muted:  #64748b;
    --sb-divider:     #1e293b;

    /* Shadows */
    --shadow-xs:  0 1px 2px rgba(15, 23, 42, .04);
    --shadow-sm:  0 1px 3px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .03);
    --shadow-md:  0 4px 6px -1px rgba(15, 23, 42, .07), 0 2px 4px -2px rgba(15, 23, 42, .04);
    --shadow-lg:  0 10px 15px -3px rgba(15, 23, 42, .08), 0 4px 6px -4px rgba(15, 23, 42, .05);
    --shadow-xl:  0 20px 25px -5px rgba(15, 23, 42, .10), 0 8px 10px -6px rgba(15, 23, 42, .06);

    /* Radii */
    --r-sm:  6px;
    --r-md:  8px;
    --r-lg:  12px;
    --r-xl:  16px;
    --r-pill: 999px;
}

/* ---------- Dark theme overrides ----------------------------------------- */
[data-bs-theme="dark"] {
    --bg-app:         #020617;
    --bg-surface:     #0f172a;
    --bg-elevated:    #1e293b;
    --bg-subtle:      #1e293b;
    --bg-hover:       #1e293b;

    --border:         #1e293b;
    --border-strong:  #334155;

    --text:           #e2e8f0;
    --text-muted:     #94a3b8;
    --text-soft:      #64748b;

    --sb-bg:          #020617;
    --sb-bg-elev:     #0f172a;
}

/* ---------- Base ---------------------------------------------------------- */
html { scroll-behavior: smooth; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg-app);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';   /* Inter ligatures */
}

h1, h2, h3, h4, h5, h6 {
    color: var(--text);
    letter-spacing: -.011em;
    font-weight: 600;
}
h1 { font-size: 1.75rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.125rem; }
h5 { font-size: 1rem; }
h6 { font-size: .875rem; }

a { color: var(--brand-primary); text-decoration: none; }
a:hover { color: var(--brand-primary-hover); text-decoration: underline; }

code, pre {
    font-family: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
    font-size: .85em;
}
code { color: var(--brand-primary); background: var(--brand-primary-soft); padding: .12em .35em; border-radius: var(--r-sm); }
pre code { background: transparent; padding: 0; color: inherit; }

/* Bootstrap colour overrides */
.text-primary  { color: var(--brand-primary) !important; }
.bg-primary    { background-color: var(--brand-primary) !important; }
.text-muted    { color: var(--text-muted) !important; }
.border        { border-color: var(--border) !important; }

/* ---------- App shell ---------------------------------------------------- */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.app-main {
    margin-left: var(--sidebar-w);
    width: calc(100% - var(--sidebar-w));
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg-app);
}

.app-content { flex: 1; padding: 1.5rem 2rem; }

@media (max-width: 768px) {
    .app-content { padding: 1rem; }
}

/* ---------- Sidebar ------------------------------------------------------- */
.sidebar {
    width: var(--sidebar-w);
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 1030;
    background: var(--sb-bg);
    color: var(--sb-text);
    overflow-y: auto;
    border-right: 1px solid var(--sb-divider);
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.1) transparent;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 3px; }

/* ====== "Control Panel" header ====== */
.sidebar .sidebar-header {
    padding: 1.1rem 1.25rem 1rem;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar .cp-title {
    color: #fff;
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: .02em;
}

/* ====== Flat nav list ====== */
.sidebar .sidebar-nav { padding: 0; }

.sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: .85rem;
    padding: .8rem 1.1rem;
    font-size: .92rem;
    font-weight: 400;
    color: #d1d5db;
    border: 0;
    border-bottom: 1px solid rgba(255,255,255,.05);
    border-radius: 0;
    background: transparent;
    transition: background .12s, color .12s;
    position: relative;
    text-decoration: none;
}
.sidebar .nav-link:hover {
    background: rgba(255,255,255,.04);
    color: #fff;
    text-decoration: none;
}

.sidebar .nav-link .nav-ico {
    width: 22px;
    text-align: center;
    font-size: 1.05rem;
    flex-shrink: 0;
    /* color is set inline per-row */
}
.sidebar .nav-link .nav-label { flex-grow: 1; line-height: 1.1; }

/* Right-side chevron for collapsibles */
.sidebar .nav-link .nav-arrow {
    margin-left: auto;
    font-size: .8rem;
    color: rgba(255,255,255,.35);
    transition: transform .2s;
}
.sidebar .nav-link[aria-expanded="true"] .nav-arrow { transform: rotate(-90deg); color: rgba(255,255,255,.65); }

/* Active row — right-edge orange accent + slightly brighter bg */
.sidebar .nav-link.active {
    background: rgba(255,255,255,.07);
    color: #fff;
    font-weight: 500;
}
.sidebar .nav-link.active::after {
    content: '';
    position: absolute;
    top: 0; bottom: 0;
    right: 0;
    width: 3px;
    background: #f97316;
    box-shadow: 0 0 8px rgba(249,115,22,.6);
}

/* Submenu (collapsed group children) */
.sidebar .nav-sub {
    background: rgba(0,0,0,.18);
    border-bottom: 1px solid rgba(255,255,255,.05);
}
.sidebar .nav-sub .nav-link {
    padding: .55rem 1.1rem .55rem 3rem;
    font-size: .82rem;
    color: rgba(255,255,255,.55);
    border-bottom: 1px solid rgba(255,255,255,.03);
    border-left: 2px solid transparent;
}
.sidebar .nav-sub .nav-link:last-child { border-bottom: 0; }
.sidebar .nav-sub .nav-link:hover { color: #fff; background: rgba(255,255,255,.03); border-left-color: rgba(249,115,22,.3); }
.sidebar .nav-sub .nav-link.active {
    color: #fff;
    background: rgba(255,255,255,.05);
    border-left-color: #f97316;
}
.sidebar .nav-sub .nav-link.active::after { display: none; }

/* Logout button — looks like a nav-link */
.sidebar .nav-logout {
    background: transparent;
    cursor: pointer;
    padding: .8rem 1.1rem;
    font-size: .92rem;
    color: #fca5a5;
}
.sidebar .nav-logout:hover { background: rgba(239,68,68,.1); color: #fff; }
.sidebar .logout-row { border-top: 1px solid rgba(255,255,255,.08); margin-top: .5rem; }

.sidebar-footer {
    margin-top: auto;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--sb-divider);
    font-size: .8rem;
}
.sidebar-footer .user-line {
    display: flex; align-items: center; gap: .65rem;
    color: #f1f5f9;
}
.sidebar-footer .user-avatar {
    width: 32px; height: 32px;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: #fff; font-weight: 600;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: .8rem;
}

/* Mobile drawer */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform .25s ease;
        box-shadow: var(--shadow-xl);
    }
    .sidebar.show { transform: translateX(0); }
    .app-main { margin-left: 0; width: 100%; }
}

/* ---------- Navbar ------------------------------------------------------- */
.navbar {
    height: var(--navbar-h);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 1020;
    padding: 0 1.5rem;
    backdrop-filter: blur(8px);
}

.navbar .page-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
    margin: 0;
}
.navbar .breadcrumb {
    margin: 0;
    background: none;
    padding: 0;
    font-size: .8rem;
    color: var(--text-muted);
}

.navbar .nav-icon-btn {
    width: 36px; height: 36px;
    border: none; background: transparent;
    border-radius: var(--r-md);
    color: var(--text-muted);
    display: inline-flex; align-items: center; justify-content: center;
    transition: background .15s, color .15s;
}
.navbar .nav-icon-btn:hover { background: var(--bg-hover); color: var(--text); }

.navbar .user-pill {
    display: inline-flex; align-items: center; gap: .5rem;
    padding: .25rem .25rem .25rem .75rem;
    background: var(--bg-subtle);
    border-radius: var(--r-pill);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: .85rem;
    transition: background .15s;
}
.navbar .user-pill:hover { background: var(--bg-hover); }
.navbar .user-pill .user-avatar {
    width: 26px; height: 26px;
    background: linear-gradient(135deg, var(--brand-primary), #7c3aed);
    color: #fff; font-weight: 600;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: .7rem;
}

/* ---------- Cards -------------------------------------------------------- */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-sm);
    transition: box-shadow .2s, transform .2s;
}
.card:not(.no-hover):hover { box-shadow: var(--shadow-md); }

.card-header, .card-footer {
    background: transparent;
    border-color: var(--border);
}
.card-header { padding: 1rem 1.25rem; }
.card-body { padding: 1.25rem; }

.card-title { font-weight: 600; margin-bottom: .25rem; color: var(--text); }
.card-subtitle { color: var(--text-muted); font-size: .85rem; }

/* Stat cards */
.stat-card { padding: 1.25rem; }
.stat-card .stat-icon {
    width: 44px; height: 44px;
    border-radius: var(--r-md);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem;
    margin-bottom: 1rem;
}
.stat-card .stat-icon.primary { background: var(--brand-primary-soft); color: var(--brand-primary); }
.stat-card .stat-icon.success { background: var(--success-soft);       color: var(--success); }
.stat-card .stat-icon.warning { background: var(--warning-soft);       color: var(--warning); }
.stat-card .stat-icon.danger  { background: var(--danger-soft);        color: var(--danger); }
.stat-card .stat-icon.info    { background: var(--info-soft);          color: var(--info); }

.stat-card .stat-label {
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: .25rem;
}
.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.1;
    letter-spacing: -.025em;
    margin: 0;
}
.stat-card .stat-meta {
    font-size: .8rem;
    color: var(--text-muted);
    margin-top: .35rem;
}
.stat-card .stat-trend {
    display: inline-flex; align-items: center; gap: .15rem;
    padding: .15rem .4rem;
    border-radius: var(--r-pill);
    font-size: .7rem; font-weight: 600;
    background: var(--success-soft); color: var(--success);
}
.stat-card .stat-trend.down { background: var(--danger-soft); color: var(--danger); }

/* ---------- Tables ------------------------------------------------------- */
.table {
    color: var(--text);
    margin-bottom: 0;
    --bs-table-bg: transparent;
}
.table > :not(caption) > * > * { background-color: transparent; }
.table thead th {
    background: var(--bg-subtle);
    color: var(--text-muted);
    font-weight: 600;
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--border);
    border-top: 1px solid var(--border);
}
.table tbody td { padding: .75rem 1rem; border-color: var(--border); vertical-align: middle; }
.table-sm thead th, .table-sm tbody td { padding: .5rem .75rem; }
.table-hover tbody tr:hover { background: var(--bg-hover); }

/* ---------- Badges ------------------------------------------------------- */
.badge {
    font-weight: 500;
    font-size: .72rem;
    padding: .3em .65em;
    border-radius: var(--r-pill);
    letter-spacing: .01em;
}
.badge.bg-primary    { background: var(--brand-primary-soft) !important; color: var(--brand-primary) !important; }
.badge.bg-success    { background: var(--success-soft)       !important; color: var(--success)       !important; }
.badge.bg-warning, .badge.bg-warning.text-dark
                     { background: var(--warning-soft)       !important; color: #b45309              !important; }
.badge.bg-danger     { background: var(--danger-soft)        !important; color: var(--danger)        !important; }
.badge.bg-info       { background: var(--info-soft)          !important; color: var(--info)          !important; }
.badge.bg-secondary  { background: var(--bg-hover)           !important; color: var(--text-muted)    !important; }
.badge.bg-light      { background: var(--bg-subtle)          !important; color: var(--text-muted)    !important; }
.badge.bg-dark       { background: var(--text)               !important; color: #fff                 !important; }

/* ---------- Buttons ------------------------------------------------------ */
.btn {
    border-radius: var(--r-md);
    font-weight: 500;
    font-size: .875rem;
    padding: .5rem 1rem;
    transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .1s;
    border: 1px solid transparent;
}
.btn:active { transform: translateY(1px); }
.btn-sm { padding: .375rem .75rem; font-size: .8rem; border-radius: var(--r-sm); }

.btn-primary {
    background: var(--brand-primary);
    border-color: var(--brand-primary);
    color: #fff;
    box-shadow: 0 1px 2px rgba(79,70,229,.2);
}
.btn-primary:hover, .btn-primary:focus {
    background: var(--brand-primary-hover);
    border-color: var(--brand-primary-hover);
    color: #fff;
    box-shadow: 0 4px 10px -2px rgba(79,70,229,.4);
}

.btn-outline-primary {
    color: var(--brand-primary);
    border-color: var(--brand-primary);
    background: transparent;
}
.btn-outline-primary:hover {
    background: var(--brand-primary);
    color: #fff;
}

.btn-outline-secondary {
    color: var(--text-muted);
    border-color: var(--border-strong);
    background: var(--bg-surface);
}
.btn-outline-secondary:hover {
    background: var(--bg-hover);
    color: var(--text);
    border-color: var(--border-strong);
}

.btn-outline-danger {
    color: var(--danger);
    border-color: var(--danger);
    background: transparent;
}
.btn-outline-danger:hover {
    background: var(--danger);
    color: #fff;
}

.btn-link { color: var(--text-muted); text-decoration: none; }
.btn-link:hover { color: var(--text); text-decoration: underline; }

/* ---------- Forms -------------------------------------------------------- */
.form-control, .form-select {
    background: var(--bg-surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    color: var(--text);
    padding: .5rem .75rem;
    font-size: .875rem;
    transition: border-color .15s, box-shadow .15s;
}
.form-control:focus, .form-select:focus {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px var(--brand-primary-soft);
    background: var(--bg-surface);
    color: var(--text);
}
.form-control-sm, .form-select-sm { padding: .375rem .65rem; font-size: .8rem; }

.form-label { font-weight: 500; font-size: .825rem; color: var(--text); margin-bottom: .35rem; }
.form-label.small { font-size: .75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.form-text { font-size: .75rem; color: var(--text-muted); }

.input-group-text {
    background: var(--bg-subtle);
    border: 1px solid var(--border-strong);
    color: var(--text-muted);
    font-size: .8rem;
}

/* ---------- Alerts ------------------------------------------------------- */
.alert {
    border: 1px solid transparent;
    border-radius: var(--r-md);
    padding: .75rem 1rem;
    font-size: .85rem;
}
.alert-info    { background: var(--info-soft);    border-color: rgba(6,182,212,.25);   color: #0e7490; }
.alert-warning { background: var(--warning-soft); border-color: rgba(245,158,11,.25);  color: #b45309; }
.alert-danger  { background: var(--danger-soft);  border-color: rgba(239,68,68,.25);   color: #b91c1c; }
.alert-success { background: var(--success-soft); border-color: rgba(16,185,129,.25);  color: #047857; }
.alert-light   { background: var(--bg-subtle);    border-color: var(--border);          color: var(--text-muted); }

/* ---------- Progress ----------------------------------------------------- */
.progress {
    background: var(--bg-subtle);
    border-radius: var(--r-pill);
    overflow: hidden;
}
.progress-bar { transition: width .4s ease; }

/* ---------- Modal / dropdown -------------------------------------------- */
.dropdown-menu {
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg);
    padding: .35rem;
    background: var(--bg-surface);
    color: var(--text);
}
.dropdown-item { border-radius: var(--r-sm); padding: .5rem .75rem; font-size: .85rem; color: var(--text); }
.dropdown-item:hover { background: var(--bg-hover); color: var(--text); }
.dropdown-divider { border-top-color: var(--border); }

/* ---------- Accordion (used on /api/endpoints) -------------------------- */
.accordion-item {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md) !important;
    margin-bottom: .5rem;
    overflow: hidden;
}
.accordion-button {
    background: var(--bg-surface);
    color: var(--text);
    font-weight: 500;
    padding: .85rem 1rem;
    box-shadow: none;
    border-radius: 0 !important;
}
.accordion-button:not(.collapsed) {
    background: var(--brand-primary-soft);
    color: var(--text);
    box-shadow: none;
}
.accordion-button:focus { box-shadow: none; border-color: var(--border); }
.accordion-body { background: var(--bg-subtle); padding: 1.25rem; }

/* ---------- List groups -------------------------------------------------- */
.list-group-item {
    background: var(--bg-surface);
    border-color: var(--border);
    color: var(--text);
    padding: .75rem 1rem;
    font-size: .875rem;
}
.list-group-flush > .list-group-item { border-left: 0; border-right: 0; }
.list-group-item.active { background: var(--brand-primary); border-color: var(--brand-primary); color: #fff; }

/* ---------- Pagination -------------------------------------------------- */
.pagination .page-link {
    color: var(--text-muted);
    border-color: var(--border);
    background: var(--bg-surface);
    font-size: .85rem;
    padding: .35rem .65rem;
    border-radius: var(--r-sm);
    margin: 0 2px;
}
.pagination .page-link:hover { background: var(--bg-hover); color: var(--text); }
.pagination .page-item.active .page-link {
    background: var(--brand-primary); border-color: var(--brand-primary); color: #fff;
}

/* ---------- Misc utilities ---------------------------------------------- */
.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.divider {
    height: 1px;
    background: var(--border);
    margin: 1rem 0;
}

.bg-elevated { background: var(--bg-elevated); }
.bg-subtle   { background: var(--bg-subtle); }

/* Status dot */
.status-dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    margin-right: .35rem;
    vertical-align: middle;
}
.status-dot.up   { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.status-dot.down { background: var(--danger);  box-shadow: 0 0 0 3px var(--danger-soft); }

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}
.empty-state .empty-icon {
    font-size: 2.5rem;
    color: var(--text-soft);
    margin-bottom: 1rem;
}

/* Selection */
::selection { background: var(--brand-primary-soft); color: var(--brand-primary-hover); }
