:root {
    --primary: #6610f2;
    --primary-dark: #3a0ca3;
    --sidebar-width: 260px;
    --sidebar-collapsed: 80px;
    --header-height: 60px;
}

* { box-sizing: border-box; }

body {
    font-family: 'Poppins', sans-serif;
    background: #f0f2f5;
    margin: 0;
}

body.admin-body {
    overflow-x: hidden;
}

.admin-wrapper { display: flex; min-height: 100vh; }

.admin-sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #1a1a2e 0%, #16213e 100%);
    color: #fff;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease;
    overflow: hidden;
}

.admin-sidebar.collapsed { width: var(--sidebar-collapsed); }

.sidebar-brand {
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand a {
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-brand-logo,
.site-brand-logo {
    object-fit: contain;
    flex-shrink: 0;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

.nav-section {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255,255,255,0.4);
    padding: 12px 16px 8px;
    font-weight: 600;
}

.admin-sidebar.collapsed .nav-section,
.admin-sidebar.collapsed .nav-label,
.admin-sidebar.collapsed .submenu-arrow {
    display: none !important;
}

.admin-sidebar.collapsed .sidebar-brand {
    padding: 20px 12px;
}

.admin-sidebar.collapsed .sidebar-brand a {
    justify-content: center;
}

.admin-sidebar.collapsed .sidebar-nav {
    padding: 12px 8px;
    overflow-x: hidden;
}

.admin-sidebar.collapsed .nav-link {
    justify-content: center;
    padding: 12px 8px;
    gap: 0;
}

.admin-sidebar.collapsed .nav-link i:first-child {
    margin: 0;
}

.admin-sidebar.collapsed .nav-link-sub {
    padding: 12px 8px !important;
}

.admin-sidebar.collapsed .btn-logout {
    padding: 10px 8px;
    justify-content: center;
    gap: 0;
}

.admin-sidebar.collapsed .sidebar-footer {
    padding: 12px 8px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 16px;
    color: rgba(255,255,255,0.75);
    text-decoration: none;
    border-radius: 10px;
    margin-bottom: 4px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
}

.nav-link i { font-size: 1.1rem; width: 22px; text-align: center; }

.nav-link:hover {
    background: rgba(102, 16, 242, 0.25);
    color: #fff;
}

.nav-link.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 15px rgba(102, 16, 242, 0.4);
}

.sidebar-footer {
    padding: 16px 12px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.btn-logout {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15);
    color: rgba(255,255,255,0.8);
    padding: 10px 16px;
    border-radius: 10px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
}

.btn-logout i {
    font-size: 1.1rem;
    line-height: 1;
}

.btn-logout:hover {
    background: rgba(220, 53, 69, 0.3);
    border-color: #dc3545;
    color: #fff;
}

.nav-submenu .nav-link-parent {
    cursor: pointer;
}

.nav-submenu .submenu-arrow {
    font-size: 0.75rem;
    transition: transform 0.2s;
    opacity: 0.7;
}

.nav-submenu.open .submenu-arrow {
    transform: rotate(180deg);
}

.nav-submenu-items {
    display: none;
    padding-left: 12px;
    margin-bottom: 4px;
}

.nav-submenu.open .nav-submenu-items {
    display: block;
}

.nav-link-sub {
    padding: 9px 16px 9px 44px !important;
    font-size: 0.85rem !important;
}

.nav-link-sub i {
    font-size: 0.95rem !important;
}

.admin-sidebar.collapsed .nav-submenu-items,
.admin-sidebar.collapsed .submenu-arrow {
    display: none !important;
}

.admin-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-width: 0;
    transition: margin-left 0.3s ease;
}

.admin-main.expanded { margin-left: var(--sidebar-collapsed); }

.admin-header {
    height: var(--header-height);
    background: #fff;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
}

.header-user-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: #495057;
}

.page-heading-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    color: #212529;
    line-height: 1.3;
}

.page-heading-subtitle {
    font-size: 0.875rem;
    margin-top: 4px;
}

.page-heading-actions .btn.btn-primary-admin {
    white-space: nowrap;
}

/* Data table card */
.data-table-card {
    overflow: hidden;
}

.data-table-toolbar {
    padding: 14px 20px;
    background: #f8f9fb;
    border-bottom: 1px solid #e9ecef;
}

.data-table-toolbar form.data-table-filter {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

form.data-table-filter {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

form.data-table-filter .filter-field {
    flex: 1 1 200px;
    min-width: 140px;
    max-width: 300px;
}

form.data-table-filter select.filter-field {
    flex: 0 1 180px;
    max-width: 200px;
}

form.data-table-filter .form-control,
form.data-table-filter .form-select {
    border-radius: 8px;
    border-color: #dee2e6;
    font-size: 0.8125rem;
    padding: 7px 12px;
    height: 36px;
    background: #fff;
}

form.data-table-filter .form-control:focus,
form.data-table-filter .form-select:focus {
    border-color: #b8a4e8;
    box-shadow: 0 0 0 3px rgba(102, 16, 242, 0.08);
}

form.data-table-filter .btn-filter {
    height: 36px;
    padding: 0 14px;
    font-size: 0.8125rem;
    font-weight: 500;
    line-height: 1;
    border-radius: 8px;
    border: 1px solid #dee2e6;
    background: #fff;
    color: #495057;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex-shrink: 0;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

form.data-table-filter .btn-filter:hover {
    background: #f8f9fa;
    border-color: #ced4da;
    color: #212529;
}

.data-table-toolbar .filter-field {
    flex: 1 1 200px;
    min-width: 0;
    max-width: 300px;
}

.data-table-toolbar .filter-field-sm {
    flex: 0 1 180px;
    max-width: 200px;
}

.data-table-toolbar .form-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #6c757d;
    margin-bottom: 4px;
}

.data-table-toolbar .form-control,
.data-table-toolbar .form-select {
    border-radius: 8px;
    border-color: #dee2e6;
    font-size: 0.8125rem;
    padding: 7px 12px;
    height: 36px;
    background: #fff;
}

.data-table-toolbar .form-control:focus,
.data-table-toolbar .form-select:focus {
    border-color: #b8a4e8;
    box-shadow: 0 0 0 3px rgba(102, 16, 242, 0.08);
}

.data-table-toolbar .btn-filter {
    height: 36px;
    padding: 0 14px;
    font-size: 0.8125rem;
    font-weight: 500;
    line-height: 1;
    border-radius: 8px;
    border: 1px solid #dee2e6;
    background: #fff;
    color: #495057;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex-shrink: 0;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.data-table-toolbar .btn-filter i {
    font-size: 0.85rem;
    opacity: 0.75;
}

.data-table-toolbar .btn-filter:hover {
    background: #faf8ff;
    border-color: #c9b8f0;
    color: var(--primary);
}

.data-table-toolbar .btn-filter:hover i {
    opacity: 1;
}

.data-table-toolbar .btn-filter:active {
    background: #f3effc;
}

.data-table-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 20px;
    background: #fff;
    border-top: 1px solid #e9ecef;
}

.data-table-info strong {
    color: #212529;
    font-weight: 600;
}

.data-table-empty {
    text-align: center;
    padding: 48px 24px !important;
    color: #6c757d;
}

.data-table-empty i {
    font-size: 2rem;
    display: block;
    margin-bottom: 8px;
    opacity: 0.4;
}

.table-admin {
    margin-bottom: 0;
}

.table-admin thead th {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: #495057;
    font-weight: 600;
    background: #f8f9fb;
    border-bottom: 2px solid #e9ecef;
    padding: 14px 16px;
    white-space: nowrap;
}

.table-admin tbody td {
    padding: 14px 16px;
    font-size: 0.875rem;
    color: #212529;
    border-bottom: 1px solid #f0f2f5;
    vertical-align: middle;
}

.table-admin tbody tr:last-child td {
    border-bottom: none;
}

.table-admin tbody tr:hover td {
    background: #f8f6ff;
}

.table-admin .btn-group-table {
    display: flex;
    gap: 4px;
}

.table-status-switch .form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 1.5rem;
    padding-left: 0;
}

.table-status-switch .form-check-input {
    width: 2.5em;
    height: 1.25em;
    margin-left: 0;
    float: none;
    cursor: pointer;
}

.table-status-switch .form-check-label {
    cursor: pointer;
    white-space: nowrap;
    color: #495057;
}

.btn-table-action {
    width: 34px;
    height: 34px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 0.85rem;
}

.pagination-admin .pagination {
    gap: 2px;
}

.pagination-admin .page-link {
    color: #495057;
    border: 1px solid #e9ecef;
    margin: 0;
    border-radius: 8px !important;
    font-weight: 500;
    font-size: 0.8rem;
    min-width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 10px;
    line-height: 1;
}

.pagination-admin .page-item.active .page-link {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    box-shadow: 0 2px 8px rgba(102, 16, 242, 0.35);
}

.pagination-admin .page-link:hover {
    background: #f4efff;
    border-color: #d4c4f7;
    color: var(--primary);
}

.pagination-admin .page-item.disabled .page-link {
    background: #f8f9fa;
    border-color: #e9ecef;
    color: #adb5bd;
}

.card-admin .card-header {
    background: transparent;
    border-bottom: 1px solid #f0f0f0;
    padding: 20px 24px;
    font-weight: 600;
}

.card-admin .card-body { padding: 24px; }

.badge-status {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-pending { background: #fff3cd; color: #856404; }
.badge-paid { background: #cce5ff; color: #004085; }
.badge-processing { background: #d4edda; color: #155724; }
.badge-completed { background: #d1e7dd; color: #0f5132; }
.badge-failed { background: #f8d7da; color: #842029; }
.badge-cancelled { background: #e2e3e5; color: #41464b; }

.btn-sidebar-toggle {
    background: #f8f9fa;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: #495057;
}

.header-title h1 {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
    color: #212529;
}

/* legacy - removed from header */

.avatar-badge {
    width: 38px;
    height: 38px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
}

.header-profile-avatar,
.platform-avatar {
    width: 38px;
    height: 38px;
    min-width: 38px;
    min-height: 38px;
    border-radius: 50%;
    background: #0f3460;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    flex-shrink: 0;
    font-size: 0.95rem;
    line-height: 1;
}

.header-profile-btn {
    padding: 0;
    border: 0;
    box-shadow: none;
}

.header-profile-info {
    max-width: 220px;
    min-width: 0;
}

.header-profile-name {
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.25;
    color: #212529;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-profile-email {
    font-size: 0.75rem;
    line-height: 1.25;
    color: #6c757d;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#adminProfileDropdown .dropdown-toggle::after {
    margin-left: 0.15rem;
    vertical-align: middle;
    border-top-color: #212529;
}

.admin-content {
    padding: 24px;
    overflow-y: auto;
    max-height: calc(100vh - var(--header-height));
}

.stat-card {
    background: #fff;
    border-radius: 16px;
    padding: 24px;
    border: none;
    box-shadow: 0 2px 12px rgba(0,0,0,0.04);
    transition: transform 0.2s;
}

.stat-card:hover { transform: translateY(-3px); }

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: #212529;
}

.stat-card .stat-label {
    font-size: 0.85rem;
    color: #6c757d;
}

.card-admin {
    background: #fff;
    border-radius: 16px;
    border: none;
    box-shadow: 0 2px 12px rgba(0,0,0,0.04);
}

.btn.btn-primary-admin {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    border-radius: 10px;
    font-weight: 600;
    padding: 8px 20px;
    text-decoration: none;
}

.btn.btn-sm.btn-primary-admin {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
    border-radius: 6px;
    font-weight: 600;
}

.btn.btn-primary-admin:hover,
.btn.btn-primary-admin:focus,
.btn.btn-primary-admin:active,
.btn.btn-primary-admin:focus-visible {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    color: #fff;
    box-shadow: 0 4px 12px rgba(102, 16, 242, 0.35);
}

.btn.btn-primary-admin i {
    color: inherit;
}

.form-admin .form-control,
.form-admin .form-select {
    border-radius: 10px;
    padding: 10px 14px;
    border-color: #dee2e6;
}

.form-admin .form-control:focus,
.form-admin .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(102, 16, 242, 0.15);
}

.product-form-section {
    border: 1px solid #e9ecef;
    border-radius: 12px;
    padding: 1.25rem 1.35rem;
    background: #fafbfc;
}

.product-form-section-title {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6c757d;
    margin-bottom: 1rem;
}

.form-admin .select2-container--bootstrap-5 .select2-selection {
    min-height: 42px;
    border-radius: 10px;
    border-color: #dee2e6;
    padding: 4px 8px;
}

.form-admin .select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered {
    line-height: 32px;
    padding-left: 6px;
}

.form-admin .select2-container--bootstrap-5.select2-container--focus .select2-selection,
.form-admin .select2-container--bootstrap-5.select2-container--open .select2-selection {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(102, 16, 242, 0.15);
}

.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #3a0ca3 0%, #f72585 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    background: #fff;
    border-radius: 20px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.login-brand {
    text-align: center;
    margin-bottom: 32px;
}

.login-brand h2 {
    font-weight: 700;
    color: var(--primary);
    margin-top: 12px;
}

@media (max-width: 991.98px) {
    body.sidebar-open {
        overflow: hidden;
    }

    .admin-wrapper {
        overflow-x: hidden;
    }

    .admin-main,
    .admin-main.expanded {
        margin-left: 0 !important;
        min-width: 0;
        width: 100%;
    }

    .admin-sidebar {
        transform: translateX(-100%);
        width: min(var(--sidebar-width), 88vw) !important;
        transition: transform 0.3s ease, width 0.3s ease;
        z-index: 1001;
    }

    .admin-sidebar.collapsed {
        width: min(var(--sidebar-width), 88vw) !important;
        transform: translateX(-100%);
    }

    .admin-sidebar.show {
        transform: translateX(0);
        box-shadow: 8px 0 30px rgba(0, 0, 0, 0.25);
    }

    .admin-sidebar-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.45);
        z-index: 1000;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.25s ease, visibility 0.25s ease;
    }

    .admin-sidebar-backdrop.show {
        opacity: 1;
        visibility: visible;
    }

    .admin-header {
        padding: 0 16px;
    }

    .header-user-name {
        max-width: 110px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 0.8125rem;
    }

    .admin-content {
        padding: 16px;
        max-height: none;
        overflow-x: hidden;
    }

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

    .page-heading-subtitle {
        font-size: 0.8125rem;
    }

    .data-table-card {
        border-radius: 12px;
    }

    .data-table-toolbar {
        padding: 12px;
    }

    .data-table-toolbar form.data-table-filter {
        flex-direction: column;
        align-items: stretch;
    }

    .data-table-toolbar .filter-field,
    .data-table-toolbar .filter-field-sm {
        flex: 1 1 100%;
        max-width: none;
        width: 100%;
    }

    .data-table-toolbar .btn-filter {
        width: 100%;
    }

    .data-table-footer {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 12px 16px;
        text-align: center;
    }

    .table-responsive {
        -webkit-overflow-scrolling: touch;
    }

    .table-admin thead th,
    .table-admin tbody td {
        padding: 10px 12px;
        font-size: 0.8125rem;
        white-space: nowrap;
    }

    .stat-card {
        padding: 18px;
    }

    .stat-card .stat-value {
        font-size: 1.35rem;
    }

    .card-admin .card-header,
    .card-admin .card-body {
        padding: 16px;
    }

    .card-admin .card-header {
        flex-wrap: wrap;
        gap: 10px;
    }

    .login-card {
        padding: 28px 22px;
    }
}

@media (max-width: 575.98px) {
    .header-user-name {
        display: none;
    }

    .customer-header .header-user {
        display: none;
    }

    .page-heading.mb-4 {
        margin-bottom: 1rem !important;
    }

    .pagination-admin .page-link {
        min-width: 30px;
        height: 30px;
        padding: 0 8px;
        font-size: 0.75rem;
    }
}

@media (min-width: 992px) {
    .admin-sidebar-backdrop {
        display: none !important;
    }
}
