/* ===========================================================================
   AgencyCloudzone — global stylesheet (Vanilla CSS)
   Theme: light, minimal. Layout: TOP NAVIGATION (no left sidebar) +
   centered, max-width content column.
   Accent: teal/cyan (signal/traffic identity). Token names & shared utility
   classes stay stable so existing pages keep working.
   =========================================================================== */

:root {
    /* surfaces */
    --bg: #fbfbfc; /* app background           */
    --surface: #ffffff; /* cards / bar              */
    --surface-soft: #f3f5f7; /* subtle fills             */
    /* borders */
    --border: #e7e9ee;
    --border-soft: #eef0f3;
    /* text */
    --text: #0f172a;
    --text-muted: #5b6573;
    --text-faint: #9aa3b2;
    /* accent — teal/cyan */
    --accent: #0e7490;
    --accent-hover: #155e75;
    --accent-soft: #ecfeff;
    --accent-text: #0e7490;
    /* status (subject: in/out/health) */
    --cyan: #0891b2;
    --cyan-soft: #ecfeff;
    --emerald: #059669;
    --emerald-soft: #ecfdf5;
    --amber: #b45309;
    --amber-soft: #fffbeb;
    --danger: #dc2626;
    --danger-soft: #fef2f2;
    /* shape */
    --radius: 14px;
    --radius-sm: 9px;
    --radius-pill: 999px;
    /* layout */
    --sidebar-w: 248px; /* kept for token contract (unused by top-nav) */
    --topbar-h: 62px;
    /* Nội dung giãn full chiều ngang để chart to theo màn hình.
       Muốn giới hạn lại cho dễ đọc thì đổi sang số px, vd 1440px. */
    --content-max: 100%;
    /* elevation */
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
    --shadow-md: 0 14px 36px -14px rgba(16, 24, 40, .2);
    /* extra */
    --ring: 0 0 0 3px rgba(14, 116, 144, .16);
    --ink-on-accent: #ffffff;
    --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: var(--font);
    color: var(--text);
    background: var(--bg);
    font-size: 15px;
    line-height: 1.55;
    letter-spacing: -0.004em;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

a {
    color: inherit;
    text-decoration: none;
}

h1, h2, h3 {
    letter-spacing: -0.02em;
}

    h1:focus {
        outline: none;
    }

::selection {
    background: var(--accent-soft);
    color: var(--accent-text);
}

:focus-visible {
    outline: none;
    box-shadow: var(--ring);
    border-radius: var(--radius-sm);
}

* {
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

    *::-webkit-scrollbar {
        width: 10px;
        height: 10px;
    }

    *::-webkit-scrollbar-thumb {
        background: var(--border);
        border: 3px solid transparent;
        background-clip: padding-box;
        border-radius: 999px;
    }

.mono {
    font-family: var(--mono);
    font-variant-numeric: tabular-nums;
}

/* ===========================================================================
   LAYOUT — top navigation + centered content
   =========================================================================== */
.app-top {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* hidden checkbox driving the mobile menu (CSS-only, no JS) */
.nav-toggle {
    display: none;
}

/* ---- Top navigation bar -------------------------------------------------- */
.topnav {
    position: sticky;
    top: 0;
    z-index: 30;
    background: rgba(255, 255, 255, .85);
    backdrop-filter: saturate(180%) blur(10px);
    border-bottom: 1px solid var(--border);
}

.topnav-inner {
    max-width: var(--content-max);
    margin: 0 auto;
    height: var(--topbar-h);
    padding: 0 24px;
    display: flex;
    align-items: center;
    gap: 22px;
}

/* brand */
.brand {
    display: flex;
    align-items: center;
    gap: 11px;
    flex-shrink: 0;
}

.brand-badge {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: linear-gradient(140deg, var(--accent), var(--cyan) 120%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 19px;
    box-shadow: 0 2px 10px -3px rgba(14, 116, 144, .5);
}

.brand-text {
    line-height: 1.1;
}

.brand-name {
    font-weight: 700;
    font-size: 16px;
    letter-spacing: -0.01em;
}

.brand-sub {
    font-family: var(--mono);
    font-size: 10px;
    color: var(--text-faint);
    letter-spacing: .14em;
    text-transform: uppercase;
}

/* primary nav (desktop, horizontal) */
.topnav-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
}

.topnav-link {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: var(--topbar-h);
    padding: 0 4px;
    margin: 0 8px;
    font-size: 14.5px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: color .15s ease;
}

    .topnav-link i {
        font-size: 18px;
    }

    .topnav-link:hover {
        color: var(--text);
    }

    /* signature: active underline */
    .topnav-link.active {
        color: var(--accent-text);
        font-weight: 600;
    }

        .topnav-link.active::after {
            content: "";
            position: absolute;
            left: 0;
            right: 0;
            bottom: -1px;
            height: 2px;
            border-radius: 2px 2px 0 0;
            background: var(--accent);
        }

.topnav-link-locked {
    color: var(--text-faint);
    cursor: not-allowed;
}

    .topnav-link-locked:hover {
        color: var(--text-faint);
    }

    .topnav-link-locked i.lock {
        font-size: 15px;
    }

/* right cluster (user + logout) */
.topnav-right {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
    flex-shrink: 0;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 6px 4px 12px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border);
    background: var(--surface);
}

.user-meta {
    text-align: right;
    line-height: 1.2;
    max-width: 170px;
}

    .user-meta .name {
        font-size: 13px;
        font-weight: 600;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .user-meta .email {
        font-family: var(--mono);
        font-size: 10.5px;
        color: var(--text-faint);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

.avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-pill);
    background: var(--accent-soft);
    color: var(--accent-text);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    flex-shrink: 0;
    text-transform: uppercase;
}

.btn-logout {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: background .15s ease, color .15s ease, border-color .15s ease;
}

    .btn-logout i {
        font-size: 18px;
    }

    .btn-logout:hover {
        background: var(--danger-soft);
        color: var(--danger);
        border-color: transparent;
    }

/* hamburger (mobile only) */
.nav-burger {
    display: none;
    margin-left: auto;
}

/* mobile dropdown panel */
.topnav-mobile {
    display: none;
    border-top: 1px solid var(--border);
    background: var(--surface);
    padding: 10px;
}

.m-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 500;
    color: var(--text-muted);
}

    .m-link i {
        font-size: 19px;
    }

    .m-link.active {
        background: var(--accent-soft);
        color: var(--accent-text);
        font-weight: 600;
    }

    .m-link.locked {
        color: var(--text-faint);
    }

.m-divider {
    height: 1px;
    background: var(--border);
    margin: 8px 4px;
}

/* ---- Content (centered) -------------------------------------------------- */
.app-content {
    flex: 1;
    padding: 28px 24px 44px;
}

.content-wrap {
    max-width: var(--content-max);
    margin: 0 auto;
}

/* ===========================================================================
   PAGE HEADER (shared utility)
   =========================================================================== */
.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
}

.page-title {
    font-size: 22px;
    font-weight: 700;
    margin: 0;
}

.page-sub {
    margin: 4px 0 0;
    font-size: 13.5px;
    color: var(--text-muted);
}

/* small pill label (used by some cards / future "coming soon" markers) */
.nav-badge {
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 600;
    background: var(--surface-soft);
    color: var(--text-faint);
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    letter-spacing: .04em;
    text-transform: uppercase;
}

/* ===========================================================================
   BUTTONS
   =========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: 8px 14px;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease;
}

.btn-primary {
    background: var(--accent);
    color: var(--ink-on-accent);
    font-weight: 600;
}

    .btn-primary:hover:not(:disabled) {
        background: var(--accent-hover);
    }

    .btn-primary:disabled {
        opacity: .55;
        cursor: not-allowed;
    }

.btn-ghost {
    background: var(--surface);
    border-color: var(--border);
    color: var(--text-muted);
}

    .btn-ghost:hover {
        background: var(--surface-soft);
        color: var(--text);
    }

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-muted);
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
}

    .btn-icon:hover {
        background: var(--surface-soft);
        color: var(--text);
    }

    .btn-icon i {
        font-size: 22px;
    }

/* ===========================================================================
   CARDS / STATS / TABLE
   =========================================================================== */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.card-head {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.card-body {
    padding: 18px;
}

.card-head-search {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 18px;
    display: flex;
    gap: 14px;
    align-items: flex-start;
}

.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 21px;
    flex-shrink: 0;
    background: var(--surface-soft);
    color: var(--text-faint);
}

    .stat-icon.blue {
        background: var(--accent-soft);
        color: var(--accent);
    }

    .stat-icon.cyan {
        background: var(--cyan-soft);
        color: var(--cyan);
    }

    .stat-icon.emerald {
        background: var(--emerald-soft);
        color: var(--emerald);
    }

    .stat-icon.amber {
        background: var(--amber-soft);
        color: var(--amber);
    }

.stat-label {
    font-size: 12.5px;
    color: var(--text-muted);
    font-weight: 500;
}

.stat-value {
    font-size: 21px;
    font-weight: 700;
    margin-top: 2px;
    font-variant-numeric: tabular-nums;
}

.stat-sub {
    font-size: 12px;
    color: var(--text-faint);
    margin-top: 2px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

    .data-table thead th {
        text-align: left;
        font-family: var(--mono);
        font-weight: 600;
        font-size: 11.5px;
        letter-spacing: .04em;
        text-transform: uppercase;
        color: var(--text-muted);
        background: var(--surface-soft);
        border-bottom: 1px solid var(--border);
        padding: 11px 16px;
    }

    .data-table tbody td {
        padding: 11px 16px;
        border-bottom: 1px solid var(--border-soft);
        font-variant-numeric: tabular-nums;
    }

    .data-table tbody tr:last-child td {
        border-bottom: none;
    }

    .data-table tbody tr:hover {
        background: var(--surface-soft);
    }

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 9px;
    border-radius: var(--radius-pill);
    font-size: 12px;
    font-weight: 600;
}

    .badge.in {
        background: var(--cyan-soft);
        color: var(--cyan);
    }

    .badge.out {
        background: var(--amber-soft);
        color: var(--amber);
    }

/* segmented control */
.segmented {
    display: inline-flex;
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 3px;
    gap: 2px;
}

    .segmented button {
        border: none;
        background: transparent;
        padding: 5px 13px;
        font-size: 14px;
        font-weight: 500;
        font-family: inherit;
        border-radius: 6px;
        color: var(--text-muted);
        cursor: pointer;
        transition: background .15s ease, color .15s ease;
    }

        .segmented button:hover {
            color: var(--text);
        }

        .segmented button.active {
            background: var(--surface);
            color: var(--accent-text);
            box-shadow: var(--shadow-sm);
        }

/* ===========================================================================
   FORMS
   =========================================================================== */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
}

.field-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    background: var(--surface);
    transition: border-color .15s ease, box-shadow .15s ease;
}

    .field-input::placeholder {
        color: var(--text-faint);
    }

    .field-input:focus {
        outline: none;
        border-color: var(--accent);
        box-shadow: var(--ring);
    }

    .field-input:disabled {
        background: var(--surface-soft);
        cursor: not-allowed;
    }

.table-search {
    position: relative;
    display: inline-flex;
    align-items: center;
}

    .table-search i {
        position: absolute;
        left: 11px;
        color: var(--text-faint);
        pointer-events: none;
    }

    .table-search .field-input {
        padding-left: 34px;
        min-width: 220px;
    }

/* ===========================================================================
   LOGIN
   =========================================================================== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(820px 460px at 88% -8%, rgba(8, 145, 178, .10), transparent 60%), radial-gradient(820px 460px at 8% 108%, rgba(14, 116, 144, .10), transparent 60%), var(--bg);
    padding: 24px;
}

.login-card {
    width: 100%;
    max-width: 408px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow-md);
    padding: 34px;
}

.login-header {
    text-align: center;
    margin-bottom: 26px;
}

.login-logo {
    width: 48px;
    height: 48px;
    border-radius: 13px;
    background: linear-gradient(140deg, var(--accent), var(--cyan) 120%);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 25px;
    margin-bottom: 14px;
    box-shadow: 0 8px 24px -6px rgba(14, 116, 144, .55);
}

.login-header h1 {
    font-size: 21px;
    font-weight: 700;
    margin: 0;
}

.login-subtitle {
    font-size: 13px;
    color: var(--text-faint);
    margin-top: 4px;
}

.login-error {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--danger-soft);
    color: var(--danger);
    border: 1px solid #fecaca;
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-size: 13px;
    margin-bottom: 16px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.btn-login {
    margin-top: 4px;
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: var(--ink-on-accent);
    font-size: 14.5px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background .15s ease;
}

    .btn-login:hover:not(:disabled) {
        background: var(--accent-hover);
    }

    .btn-login:disabled {
        opacity: .7;
        cursor: not-allowed;
    }

.spinner-login {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, .4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .6s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ===========================================================================
   RESPONSIVE
   =========================================================================== */
@media (min-width: 1600px) {
    .topnav-inner {
        padding: 0 40px;
    }

    .app-content {
        padding: 28px 40px 44px;
    }
}

@media (max-width: 860px) {
    .topnav-nav,
    .topnav-right {
        display: none;
    }

    .nav-burger {
        display: inline-flex;
    }

    /* checkbox is a sibling rendered before .topnav */
    .nav-toggle:checked ~ .topnav .topnav-mobile {
        display: block;
    }

    .stat-grid {
        grid-template-columns: 1fr;
    }

    .app-content {
        padding: 20px 16px 36px;
    }
}

@media (max-width: 576px) {
    .card-head-search {
        flex-direction: column;
        align-items: stretch;
    }

    .table-search .field-input {
        width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
        animation-duration: .001ms !important;
    }
}

/* ===========================================================================
   BLAZOR ERROR UI
   =========================================================================== */
#blazor-error-ui {
    background: #fef3c7;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: 0.75rem;
        top: 0.5rem;
    }

.blazor-error-boundary {
    background: var(--danger);
    padding: 1rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred.";
    }

.brand-tag {
    align-self: center;
    margin-left: 8px;
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: #fff;
    background: var(--accent); /* nền đặc indigo */
    padding: 3px 9px;
    border-radius: var(--radius-pill);
    box-shadow: 0 2px 8px -2px rgba(79, 70, 229, .55);
}