/* =================================================================
   Pestec Dashboard — custom styles on top of Bootstrap 5
   Organized: 1) variables  2) login page  3) layout/sidebar
   4) topbar  5) cards/charts  6) alerts/table  7) responsive
   ================================================================= */

/* ---------- 1) Design tokens ---------- */
:root {
    --sidebar-width: 248px;
    --sidebar-width-collapsed: 72px;
    --topbar-height: 64px;
    --brand: #2563eb;
    --brand-dark: #1e3a8a;
    --bg: #f4f6fb;
    --card-bg: #ffffff;
    --text: #1e293b;
    --muted: #64748b;
    --radius: 14px;
    --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
    --shadow-lg: 0 12px 32px rgba(16, 24, 40, .12);
    --transition: .25s ease;
}

* { box-sizing: border-box; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ---------- 2) Login page ---------- */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
    padding: 1rem;
}
.login-wrapper { width: 100%; max-width: 400px; }
.login-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 2rem;
}
.login-brand i { font-size: 2.5rem; color: var(--brand); }
.login-card .input-group-text { background: #fff; }

/* ---------- 3) Layout & sidebar ---------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    background: #0f172a;
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 1040;
    transition: width var(--transition), transform var(--transition);
}
.sidebar-brand {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: 0 1.25rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, .07);
    white-space: nowrap;
}
.sidebar-brand i { color: #60a5fa; font-size: 1.5rem; }

.sidebar-nav { flex: 1; padding: 1rem .75rem; overflow-y: auto; }
.sidebar-nav .nav-link,
.sidebar-footer .nav-link {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .65rem .85rem;
    margin-bottom: .25rem;
    border-radius: 10px;
    color: #cbd5e1;
    font-size: .925rem;
    text-decoration: none;
    transition: background var(--transition), color var(--transition);
    white-space: nowrap;
}
.sidebar-nav .nav-link i,
.sidebar-footer .nav-link i { font-size: 1.1rem; min-width: 20px; text-align: center; }
.sidebar-nav .nav-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.sidebar-nav .nav-link.active {
    background: var(--brand);
    color: #fff;
    box-shadow: 0 4px 12px rgba(37, 99, 235, .4);
}
.sidebar-footer { padding: .75rem; border-top: 1px solid rgba(255, 255, 255, .07); }
.sidebar-footer .nav-link:hover { background: rgba(239, 68, 68, .12); }

/* Collapsed (desktop) — icons only */
.sidebar.collapsed { width: var(--sidebar-width-collapsed); }
.sidebar.collapsed .brand-text,
.sidebar.collapsed .badge { display: none; }
.sidebar.collapsed .sidebar-nav .nav-link { justify-content: center; }

/* ---------- 4) Main + topbar ---------- */
.main {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-width: 0;
    transition: margin-left var(--transition);
}
.sidebar.collapsed ~ .main { margin-left: var(--sidebar-width-collapsed); }

.topbar {
    height: var(--topbar-height);
    background: var(--card-bg);
    border-bottom: 1px solid #e7ebf3;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0 1.25rem;
    position: sticky;
    top: 0;
    z-index: 1030;
}
.btn-icon {
    width: 40px; height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-radius: 10px;
}
.topbar-search {
    position: relative;
    flex: 1;
    max-width: 420px;
    align-items: center;
}
.topbar-search i {
    position: absolute;
    left: .85rem;
    color: var(--muted);
    z-index: 2;
}
.topbar-search .form-control { padding-left: 2.4rem; border-radius: 10px; background: var(--bg); border-color: transparent; }
.topbar-search .form-control:focus { background: #fff; }

.topbar-actions { display: flex; align-items: center; gap: .5rem; }
.notif-dot {
    position: absolute;
    top: 8px; right: 9px;
    width: 9px; height: 9px;
    background: #ef4444;
    border: 2px solid #fff;
    border-radius: 50%;
}
.notif-menu { width: 300px; }
.avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--brand);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: .85rem;
}

/* ---------- 5) Content, cards & charts ---------- */
.content { padding: 1.5rem; flex: 1; }

.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.1rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    height: 100%;
    transition: transform var(--transition), box-shadow var(--transition);
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.stat-icon {
    width: 52px; height: 52px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}
.stat-label { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.stat-trend { font-size: .78rem; margin-top: .15rem; }

.card-panel {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
}

/* Keeps the donut a sensible size inside a full-width vertical card.
   ApexCharts sets its own height, so we only constrain the width here. */
.chart-narrow {
    max-width: 380px;
    margin: 0 auto;
}

/* ---------- 6) Alerts & table ---------- */
.alert-item {
    display: flex;
    gap: .85rem;
    align-items: flex-start;
    padding: .75rem .85rem;
    border-radius: 10px;
    margin-bottom: .6rem;
}
.alert-item:last-child { margin-bottom: 0; }
.alert-item i { font-size: 1.15rem; margin-top: .1rem; }
.alert-danger-soft  { background: #fef2f2; }
.alert-danger-soft i  { color: #dc2626; }
.alert-warning-soft { background: #fffbeb; }
.alert-warning-soft i { color: #d97706; }
.alert-info-soft    { background: #eff6ff; }
.alert-info-soft i    { color: #2563eb; }

#activityTable th { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; border-bottom-width: 1px; }
#activityTable td { font-size: .9rem; }
.status-pill { font-size: .72rem; padding: .25rem .6rem; border-radius: 999px; font-weight: 600; }
.status-ok      { background: #dcfce7; color: #16a34a; }
.status-warn    { background: #fef9c3; color: #ca8a04; }
.status-offline { background: #fee2e2; color: #dc2626; }

.footer { padding: 1rem 1.5rem; border-top: 1px solid #e7ebf3; background: var(--card-bg); }

/* ---------- 7) Responsive ---------- */
.sidebar-backdrop {
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, .5);
    z-index: 1035;
    display: none;
}
.sidebar-backdrop.show { display: block; }

@media (max-width: 991.98px) {
    /* On mobile the sidebar slides in over the content instead of pushing it */
    .sidebar { transform: translateX(-100%); width: var(--sidebar-width); }
    .sidebar.show { transform: translateX(0); }
    .main { margin-left: 0; }
    .sidebar.collapsed ~ .main { margin-left: 0; }
}
