/* =====================================================
   Customer Hub — Custom styles (TailPanel-inspired)
   Bootstrap 4.6 base + Bootstrap Icons
   Rule: KHÔNG override Bootstrap class trực tiếp.
         Scope vào wrapper (.page-content, .topbar, v.v.)
         hoặc tạo class riêng.
   ===================================================== */

:root {
    --primary: #4361ee;
    --primary-light: #eef0fd;
    --sidebar-width: 252px;
    --topbar-height: 60px;
    --body-bg: #f1f5f9;
    --shadow-sm: 0 2px 8px rgba(0,0,0,.08), 0 1px 3px rgba(0,0,0,.06);
    --shadow: 0 4px 16px rgba(0,0,0,.10), 0 2px 6px rgba(0,0,0,.06);
    --card-radius: 0.75rem;
}

* { box-sizing: border-box; }

body {
    background: var(--body-bg);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    font-size: 14px;
    color: #1e293b;
}

/* ─── Sidebar ─── */
.sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-width);
    background: #fff;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    overflow-y: auto;
    transition: width .25s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    height: var(--topbar-height);
    padding: 0 18px;
    border-bottom: 1px solid #f1f5f9;
    text-decoration: none !important;
    flex-shrink: 0;
}

.sidebar-brand-icon {
    width: 36px; height: 36px;
    background: var(--primary);
    border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    font-weight: 800;
    font-size: 16px;
    flex-shrink: 0;
}

.sidebar-brand-name {
    font-size: 15px;
    font-weight: 700;
    color: #1e293b;
    white-space: nowrap;
}

.sidebar-nav {
    flex: 1;
    padding: 10px;
}

.sidebar-nav .nav-item { margin-bottom: 2px; }

/* Scoped: chỉ áp dụng cho nav-link trong sidebar */
.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #64748b;
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    transition: background .15s, color .15s;
}

.sidebar-nav .nav-link i {
    font-size: 17px;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-nav .nav-link:hover {
    color: var(--primary);
    background: var(--primary-light);
    text-decoration: none;
}

.sidebar-nav .nav-link.active {
    color: var(--primary);
    background: var(--primary-light);
    font-weight: 600;
}

.sidebar-user {
    padding: 14px 16px;
    border-top: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-avatar {
    width: 36px; height: 36px;
    background: var(--primary);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 13px;
    flex-shrink: 0;
}

.sidebar-user-info { flex: 1; min-width: 0; }

.sidebar-user-name {
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 11px;
    color: #94a3b8;
    text-transform: capitalize;
}

/* ─── Sidebar collapse → icon-only ─── */
body.sidebar-collapsed .sidebar {
    width: 64px;
    overflow: hidden;
}

body.sidebar-collapsed .sidebar-brand-name,
body.sidebar-collapsed .sidebar-user-info,
body.sidebar-collapsed .sidebar-nav .nav-link span {
    display: none;
}

body.sidebar-collapsed .sidebar-brand {
    justify-content: center;
    padding: 16px 0;
}

body.sidebar-collapsed .sidebar-nav .nav-link {
    justify-content: center;
    padding: 10px 0;
}

body.sidebar-collapsed .sidebar-nav .nav-link i {
    width: auto;
    font-size: 19px;
}

body.sidebar-collapsed .sidebar-user {
    justify-content: center;
    padding: 14px 0;
}

/* ─── Main wrapper ─── */
.main-wrapper {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left .25s ease;
}

body.sidebar-collapsed .main-wrapper {
    margin-left: 64px;
}

/* ─── Topbar ─── */
.topbar {
    height: var(--topbar-height);
    background: #fff;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 900;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-title {
    font-size: 15px;
    font-weight: 600;
    color: #1e293b;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-toggle {
    color: #64748b;
    border: none;
    background: transparent;
    font-size: 18px;
    padding: 4px 8px;
    line-height: 1;
    border-radius: 7px;
}

.sidebar-toggle:hover {
    background: #f1f5f9;
    color: var(--primary);
}

/* ─── Topbar user dropdown trigger ─── */
.topbar-user-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    border: none;
    padding: 4px 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: background .15s;
}

.topbar-user-btn:hover,
.topbar-user-btn:focus {
    background: #f1f5f9;
    outline: none;
    box-shadow: none;
}

.topbar-user-btn::after {
    color: #94a3b8;
    margin-left: 2px;
}

.topbar-avatar {
    width: 34px; height: 34px;
    background: var(--primary);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 12px;
}

.topbar-user-name {
    font-size: 13px;
    font-weight: 500;
    color: #1e293b;
}

/* Scoped: dropdown chỉ trong topbar */
.topbar .dropdown-menu {
    border: none;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,.12);
    padding: 6px;
    min-width: 210px;
}

.topbar .dropdown-header {
    padding: 8px 12px;
    line-height: 1.4;
}

.topbar .dropdown-item {
    border-radius: 7px;
    font-size: 13px;
    padding: 8px 12px;
    color: #374151;
}

.topbar .dropdown-item:hover {
    background: #f1f5f9;
    color: #1e293b;
}

.topbar .dropdown-item.text-danger:hover {
    background: #fef2f2;
}

.topbar .dropdown-divider {
    margin: 4px 0;
    border-color: #f1f5f9;
}

/* ─── Page content ─── */
.page-content {
    flex: 1;
    padding: 15px;
}

.content-box {
    background: #fff;
    border-radius: var(--card-radius);
    box-shadow: var(--shadow-sm);
    padding: 24px;
    min-height: calc(100vh - var(--topbar-height) - 30px);
}

/* ─── Cards — scoped vào page-content ─── */
.page-content .card {
    border: none;
    border-radius: var(--card-radius);
    box-shadow: var(--shadow-sm);
}

.page-content .card-header {
    background: #fff;
    border-bottom: 1px solid #f1f5f9;
    border-radius: var(--card-radius) var(--card-radius) 0 0;
    padding: 14px 20px;
    font-weight: 600;
}

.page-content .card-body {
    padding: 20px;
}

/* ─── Card-body chứa bảng: padding nhỏ hơn ─── */
.page-content .card-body.table-pad {
    padding: 8px 12px;
}

/* ─── Table trong card: bỏ margin-bottom ─── */
.page-content .card .table-responsive .table,
.page-content .card > .table {
    margin-bottom: 0;
}

/* ─── Tables — scoped vào page-content ─── */
.page-content .table thead th,
.page-content .table thead.thead-light th {
    background: #fff;
    font-weight: 600;
    font-size: 12px;
    border-top: none;
    border-bottom: 2px solid #f1f5f9;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 10px 12px;
}

.page-content .table td {
    font-size: 13px;
    color: #374151;
    border-top: 1px solid #f1f5f9;
    padding: 10px 12px;
}

.page-content .table th {
    padding: 10px 12px;
}

.page-content .table td,
.page-content .table th {
    vertical-align: middle;
}

.page-content .table-hover tbody tr:hover td {
    background-color: #f8fafc;
}

.page-content .table-bordered {
    border: 1px solid #e2e8f0;
}

.page-content .table-bordered td,
.page-content .table-bordered th {
    border-color: #e2e8f0;
}

/* ─── Buttons — scoped vào page-content ─── */
.page-content .btn {
    border-radius: 7px;
    font-size: 13px;
}

.page-content .btn-primary {
    background: var(--primary);
    border-color: var(--primary);
}

.page-content .btn-primary:hover {
    background: #3451d1;
    border-color: #3451d1;
}

/* ─── Alerts — scoped vào page-content ─── */
.page-content .alert {
    border-radius: 8px;
    font-size: 13px;
}

.page-content .alert-success {
    background: #f0fdf4;
    color: #166534;
    border-color: #bbf7d0;
}

.page-content .alert-danger {
    background: #fef2f2;
    color: #991b1b;
    border-color: #fecaca;
}

/* ─── Form controls — scoped vào page-content ─── */
.page-content .form-control {
    border-color: #e2e8f0;
    border-radius: 7px;
    font-size: 14px;
}

.page-content .form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(67,97,238,.12);
}

/* ─── Modals ─── */
.modal .modal-content {
    border: none;
    border-radius: var(--card-radius);
    box-shadow: 0 20px 60px rgba(0,0,0,.15);
}

.modal .modal-header {
    border-bottom: 1px solid #f1f5f9;
    padding: 16px 20px;
}

.modal .modal-footer {
    border-top: 1px solid #f1f5f9;
    padding: 12px 20px;
}

.modal .btn {
    border-radius: 7px;
    font-size: 13px;
}

.modal .form-control {
    border-color: #e2e8f0;
    border-radius: 7px;
    font-size: 14px;
}

.modal .form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(67,97,238,.12);
}

/* ─── Badge soft variants (class riêng, không đè Bootstrap) ─── */
.badge-soft-success {
    background: #dcfce7;
    color: #16a34a;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    padding: 4px 10px;
}

.badge-soft-warning {
    background: #fef9c3;
    color: #a16207;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    padding: 4px 10px;
}

.badge-soft-danger {
    background: #fee2e2;
    color: #dc2626;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    padding: 4px 10px;
}

.badge-soft-info {
    background: #dbeafe;
    color: #1d4ed8;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    padding: 4px 10px;
}

.badge-soft-secondary {
    background: #f1f5f9;
    color: #64748b;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    padding: 4px 10px;
}

.badge-soft-primary {
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    padding: 4px 10px;
}

/* ─── Stat cards (dashboard) ─── */
.stat-card {
    background: #fff;
    border-radius: var(--card-radius);
    box-shadow: var(--shadow-sm);
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.stat-card .stat-label {
    font-size: 13px;
    color: #64748b;
    font-weight: 500;
    margin-bottom: 6px;
}

.stat-card .stat-value {
    font-size: 24px;
    font-weight: 700;
    color: #1e293b;
    line-height: 1;
    margin-bottom: 0;
}

.stat-icon {
    width: 52px; height: 52px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.stat-icon.green  { background: #f0fdf4; color: #16a34a; }
.stat-icon.blue   { background: #eff6ff; color: #2563eb; }
.stat-icon.purple { background: #faf5ff; color: #7c3aed; }
.stat-icon.orange { background: #fff7ed; color: #ea580c; }

/* ─── Sidebar backdrop (mobile) ─── */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 999;
}

body.sidebar-open .sidebar-backdrop { display: block; }

/* ─── Responsive ─── */
@media (max-width: 768px) {
    /* Sidebar ẩn mặc định trên mobile */
    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width) !important;
        transition: transform .25s ease;
    }

    /* Khi mở sidebar trên mobile */
    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    /* Sidebar-collapsed trên mobile không ảnh hưởng (chỉ desktop) */
    body.sidebar-collapsed .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width) !important;
    }

    body.sidebar-collapsed.sidebar-open .sidebar {
        transform: translateX(0);
    }

    .main-wrapper { margin-left: 0 !important; }
    .topbar-user-name { display: none; }
    .page-content { padding: 16px; }

    /* Stat cards stack */
    .stat-card { margin-bottom: 12px; }

    /* Form inline stack */
    .form-inline .form-control { margin-bottom: 8px; width: 100%; }
}

/* ─── Guest / Login layout ─── */
.guest-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-wrapper {
    width: 100%;
    max-width: 420px;
    padding: 20px;
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
    margin-bottom: 28px;
}

.login-brand-icon {
    width: 42px; height: 42px;
    background: var(--primary);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    font-weight: 800;
    font-size: 18px;
}

.login-brand-name {
    font-size: 20px;
    font-weight: 700;
    color: #1e293b;
}

.login-card {
    border-radius: 14px !important;
    box-shadow: 0 4px 24px rgba(0,0,0,.08) !important;
}

.login-card .card-body { padding: 32px; }

.login-card .card-title {
    font-size: 17px;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 4px;
}

.login-card .card-subtitle {
    font-size: 13px;
    color: #64748b;
    margin-bottom: 24px;
    display: block;
}

.login-card .form-control {
    border-color: #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    padding: 10px 14px;
    height: auto;
}

.login-card .form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(67,97,238,.12);
}

.login-card .btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    border-radius: 8px;
    font-weight: 600;
    padding: 10px;
    font-size: 14px;
}

.login-card .btn-primary:hover {
    background: #3451d1;
    border-color: #3451d1;
}

.login-footer {
    text-align: center;
    font-size: 12px;
    color: #94a3b8;
    margin-top: 20px;
}

/* ─── Smooth collapse animation ─── */
.collapsing {
    transition: height .35s ease;
}

.collapse-chevron {
    display: inline-block;
    transition: transform .3s ease;
}

[data-toggle="collapse"][aria-expanded="true"] .collapse-chevron,
[data-toggle="collapse"]:not(.collapsed) .collapse-chevron {
    transform: rotate(180deg);
}
