/* Import Cairo Font */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;500;600;700;800;900&display=swap');

:root {
    --primary-color: #4b5563;      /* Gray-600 */
    --primary-hover: #374151;      /* Gray-700 */
    --accent-color: #475569;       /* Slate-600 — subtle accent */
    --secondary-color: #64748b;    /* Slate-500 */
    --bg-light: #f8fafc;           /* Slate-50 */
    --bg-card: #ffffff;
    --text-main: #1e293b;          /* Slate-800 */
    --text-muted: #64748b;         /* Slate-500 */
    --border-color: #e2e8f0;       /* Slate-200 */
    --link-color: var(--primary-color);
    
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #0ea5e9;

    --transition-speed: 0.25s;
    --border-radius: 10px;
    --box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --box-shadow-hover: 0 10px 25px -5px rgba(0,0,0,0.08), 0 4px 8px -4px rgba(0,0,0,0.05);
    --sidebar-bg: #0f172a;
    --sidebar-hover: rgba(255,255,255,0.07);
    --sidebar-active: #475569;
    --sidebar-text: #94a3b8;
    --sidebar-width: 250px;
}

* {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

html {
    overflow-x: hidden;
    max-width: 100%;
}

body {
    font-family: 'Cairo', sans-serif;
    background-color: var(--bg-light);
    color: var(--text-main);
    direction: rtl;
    text-align: right;
    min-height: 100vh;
    overflow-x: hidden;
    width: 100%;
    margin: 0;
    padding: 0;
}

img {
    max-width: 100%;
    height: auto;
}

a {
    color: var(--link-color);
    transition: color 0.15s ease;
}

a:hover {
    color: var(--primary-hover);
}

a.text-decoration-none:hover {
    opacity: 0.85;
}

.table-responsive {
    width: 100%;
    margin-bottom: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-responsive > .table-bordered {
    border: 0;
}

[class*="col-"] {
    min-width: 0;
    word-break: break-word;
}

/* Fix nav-tabs and nav-pills wrapping on mobile */
.nav {
    flex-wrap: wrap;
}

/* Fix flex headers without wrap — wrap when needed */
.d-flex.justify-content-between {
    flex-wrap: wrap;
}

/* ==============================
   Sidebar
   ============================== */
.sidebar {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #0f172a 0%, #1a2332 100%);
    z-index: 1050;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    box-shadow: 2px 0 20px rgba(0, 0, 0, 0.25);
}

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

.sidebar-close {
    position: absolute;
    top: 10px;
    left: 10px;
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    z-index: 1;
}

.sidebar-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 16px;
    color: #f1f5f9;
    font-weight: 800;
    font-size: 1.05rem;
    text-decoration: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-brand:hover {
    color: #f1f5f9;
}

.sidebar-brand img {
    width: 36px;
    height: 36px;
    object-fit: contain;
    border-radius: 8px;
    background: #fff;
    padding: 4px;
}

.sidebar-brand i {
    font-size: 1.5rem;
    color: #818cf8;
}

.sidebar-user-profile .user-avatar {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: rgba(148, 163, 184, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(148, 163, 184, 0.15);
}

.sidebar-user-profile .user-avatar i {
    font-size: 1.3rem;
    color: #94a3b8 !important;
}

.sidebar-user-profile .user-name {
    color: #f1f5f9 !important;
    font-size: 0.9rem;
    line-height: 1.3;
}

.sidebar-user-profile .user-role .badge {
    background-color: rgba(148, 163, 184, 0.15) !important;
    color: #94a3b8 !important;
    font-weight: 500;
    font-size: 0.7rem;
    padding: 2px 8px;
}

.sidebar-user-profile .badge i {
    color: #94a3b8 !important;
}

/* Navigation */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-nav .nav-link {
    color: var(--sidebar-text);
    font-weight: 500;
    font-size: 0.88rem;
    padding: 10px 14px 10px 10px;
    border-radius: 8px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    position: relative;
    border-right: 3px solid transparent;
}

.sidebar-nav .nav-link i {
    font-size: 1.1rem;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
    transition: color 0.2s ease;
}

.sidebar-nav .nav-link:hover {
    color: #e2e8f0;
    background: var(--sidebar-hover);
}

.sidebar-nav .nav-link.active {
    color: #ffffff;
    background: rgba(255,255,255,0.08);
    border-right-color: var(--primary-color);
}

.sidebar-nav .nav-link.active i {
    color: var(--primary-color);
}

.sidebar-nav .nav-link span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Section Labels */
.nav-section-label {
    color: #64748b;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 14px 14px 4px 14px;
    margin-top: 4px;
    user-select: none;
}

/* Submenu */
.sidebar-submenu {
    display: flex;
    flex-direction: column;
}

.sidebar-submenu .nav-link[data-bs-toggle="collapse"] {
    cursor: pointer;
}

.sidebar-submenu .submenu-arrow {
    margin-right: auto;
    transition: transform 0.3s ease;
    font-size: 0.75rem;
}

.sidebar-submenu .nav-link[aria-expanded="true"] .submenu-arrow {
    transform: rotate(-90deg);
}

.sidebar-submenu .collapse {
    display: none;
}

.sidebar-submenu .collapse.show {
    display: flex;
    flex-direction: column;
}

.sidebar-submenu .subnav-link {
    color: #94a3b8;
    font-weight: 400;
    font-size: 0.82rem;
    padding: 7px 14px 7px 10px;
    padding-right: 46px;
    border-radius: 6px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    margin: 1px 0;
}

.sidebar-submenu .subnav-link:hover {
    color: #e2e8f0;
    background: var(--sidebar-hover);
}

.sidebar-submenu .subnav-link.active {
    color: #ffffff;
    background: rgba(255,255,255,0.08);
}

.sidebar-submenu .subnav-link i {
    font-size: 0.9rem;
    width: 18px;
    text-align: center;
    flex-shrink: 0;
}


/* Sidebar Footer */
.sidebar-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding: 14px 16px;
}

.sidebar-footer .user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #cbd5e1;
}

.sidebar-footer .user-info i {
    font-size: 1.8rem;
    color: #64748b;
}

.sidebar-footer .user-name {
    font-weight: 600;
    font-size: 0.85rem;
    line-height: 1.3;
}

.sidebar-footer .user-role {
    font-size: 0.75rem;
    color: #94a3b8;
}

.sidebar-footer .btn-outline-light {
    border-color: rgba(255,255,255,0.15);
    color: #94a3b8;
}

.sidebar-footer .btn-outline-light:hover {
    background: rgba(255,255,255,0.08);
    border-color: rgba(255,255,255,0.25);
    color: #f1f5f9;
}

/* Overlay */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1049;
    display: none;
}

.sidebar-overlay.show {
    display: block;
}

/* ==============================
   Mobile Top Bar
   ============================== */
.mobile-topbar {
    background: linear-gradient(180deg, #0f172a 0%, #1a2332 100%);
    color: #f1f5f9;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 1020;
}

/* ==============================
   Top Bar Items (desktop)
   ============================== */
.top-bar-btn {
    background: transparent;
    border: none;
    padding: 6px 10px;
    border-radius: 10px;
    color: var(--text-main);
    transition: all 0.2s;
    cursor: pointer;
}
.top-bar-btn:hover {
    background: var(--bg-light);
}
.top-bar-btn:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* ==============================
   Notification Dropdown
   ============================== */
.notification-dropdown {
    width: 380px;
    max-height: 480px;
    border: none;
    border-radius: 14px;
    overflow: hidden;
    margin-top: 8px !important;
}
.notification-dropdown .dropdown-header {
    padding: 12px 16px;
}
.notification-item {
    border-bottom: 1px solid var(--border-color);
    padding: 10px 14px;
    transition: background-color 0.15s;
    text-decoration: none;
    color: var(--text-main);
    display: block;
}
.notification-item:last-child {
    border-bottom: none;
}
.notification-item:hover {
    background-color: #f1f5f9;
    color: var(--text-main);
}
.notification-item .notif-icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
@media (max-width: 575.98px) {
    .notification-dropdown {
        position: fixed !important;
        top: 56px !important;
        left: 10px !important;
        right: 10px !important;
        width: auto !important;
        max-height: 80vh !important;
    }
}
.notification-mobile-panel {
    position: fixed;
    top: 56px;
    left: 0;
    right: 0;
    bottom: 0;
    background: #fff;
    z-index: 1050;
    display: flex;
    flex-direction: column;
    border-top: 1px solid #e2e8f0;
    animation: slideUp 0.2s ease;
}
@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}
#notificationBell .badge {
    transform: translate(50%, -50%) !important;
    font-size: 0.55rem !important;
    padding: 0.2em 0.45em !important;
    border: 2px solid #fff;
}
#notificationBell .bi-bell {
    transition: transform 0.2s;
}
#notificationBell:hover .bi-bell {
    transform: scale(1.1);
}

/* User avatar in top bar */
.user-avatar-sm {
    transition: all 0.2s;
}
.top-bar-btn:hover .user-avatar-sm {
    background: var(--primary-color) !important;
}
.top-bar-btn:hover .user-avatar-sm i {
    color: #fff !important;
}

/* ==============================
   Top Bar (desktop breadcrumb)
   ============================== */
.top-bar {
    background: #fff;
    border-bottom: 1px solid var(--border-color);
    padding: 8px 0;
    margin: 0;
}

/* ==============================
   Main Wrapper
   ============================== */
.main-wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ==============================
   Desktop: Show sidebar fixed
   ============================== */
@media (min-width: 768px) {
    .w-md-auto { width: auto !important; }
}

@media (min-width: 992px) {
    .sidebar {
        transform: translateX(0) !important;
        box-shadow: none;
    }

    .main-wrapper {
        margin-right: var(--sidebar-width);
        transition: margin-right 0.3s ease;
    }

    .sidebar-overlay {
        display: none !important;
    }

    .sidebar-close {
        display: none;
    }
}

/* ==============================
   Sidebar Collapsed (Desktop Only)
   ============================== */
@media (min-width: 992px) {
    .sidebar.sidebar-collapsed {
        width: 68px !important;
        overflow: hidden;
    }

    .sidebar.sidebar-collapsed .sidebar-brand span,
    .sidebar.sidebar-collapsed .sidebar-user-profile .flex-grow-1,
    .sidebar.sidebar-collapsed .sidebar-nav .nav-link span,
    .sidebar.sidebar-collapsed .sidebar-nav .submenu-arrow,
    .sidebar.sidebar-collapsed .sidebar-nav .subnav-link span,
    .sidebar.sidebar-collapsed .sidebar-submenu .collapse,
    .sidebar.sidebar-collapsed .nav-section-label,
    .sidebar.sidebar-collapsed .sidebar-collapse-text,
    .sidebar.sidebar-collapsed .sidebar-footer .btn span {
        display: none !important;
    }

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

    .sidebar.sidebar-collapsed .sidebar-brand img {
        width: 32px;
        height: 32px;
    }

    .sidebar.sidebar-collapsed .sidebar-user-profile {
        padding: 12px 10px !important;
    }

    .sidebar.sidebar-collapsed .sidebar-user-profile .user-avatar {
        width: 36px;
        height: 36px;
    }

    .sidebar.sidebar-collapsed .sidebar-nav .nav-link {
        padding: 10px 0;
        justify-content: center;
        font-size: 1.15rem;
    }

    .sidebar.sidebar-collapsed .sidebar-nav .nav-link i {
        margin: 0;
        font-size: 1.2rem;
    }

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

    .sidebar.sidebar-collapsed .sidebar-nav .subnav-link i {
        margin: 0;
    }

    .sidebar.sidebar-collapsed .sidebar-collapse-btn {
        padding: 6px 0;
    }

    .sidebar.sidebar-collapsed .sidebar-collapse-btn .bi {
        transform: rotate(180deg);
    }

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

    .sidebar.sidebar-collapsed .sidebar-footer .btn {
        padding: 6px 0;
    }

    .sidebar.sidebar-collapsed ~ .sidebar-overlay {
        display: none !important;
    }

    .main-wrapper.sidebar-collapsed {
        margin-right: 68px !important;
    }
}

/* ==============================
   Cards
   ============================== */
.card {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    background: var(--bg-card);
    transition: box-shadow 0.2s ease;
}

.card:hover {
    box-shadow: var(--box-shadow-hover);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 16px 20px;
    font-weight: 700;
}

.card-body {
    padding: 20px;
}

/* ==============================
   Tables
   ============================== */
.custom-table-card {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    border: 1px solid var(--border-color);
    margin-bottom: 30px;
    transition: box-shadow 0.2s ease;
}

.custom-table-card:hover {
    box-shadow: var(--box-shadow-hover);
}

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

.custom-table th {
    background-color: #f8fafc;
    color: var(--primary-color);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-top: none;
    border-bottom: 2px solid var(--border-color);
    padding: 14px 18px;
    font-size: 0.78rem;
}

.custom-table td {
    padding: 14px 18px;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
}

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

.custom-table tbody tr:hover {
    background-color: #f1f5f9;
}

.custom-table tbody tr {
    transition: background-color 0.15s ease;
}

.table {
    margin-bottom: 0;
}

.table th {
    background-color: rgba(75, 85, 99, 0.05);
    color: var(--primary-color);
    font-weight: 700;
    border-top: none;
    padding: 12px 16px;
    font-size: 0.85rem;
}

.table td {
    padding: 12px 16px;
    vertical-align: middle;
    font-size: 0.9rem;
}

.table-bordered {
    border: 1px solid var(--border-color);
}

.table-bordered th,
.table-bordered td {
    border: 1px solid var(--border-color);
}

/* ==============================
   Buttons
   ============================== */
.btn {
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    padding: 10px 20px;
    transition: all 0.15s ease;
}

.btn:active {
    transform: scale(0.97);
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.btn-sm:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.btn-lg {
    padding: 12px 28px;
    font-size: 1rem;
    border-radius: 10px;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.8rem;
    border-radius: 6px;
}

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

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

.btn-primary:focus {
    box-shadow: 0 0 0 3px rgba(75, 85, 99, 0.25);
}

.btn-outline-primary {
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    background: transparent;
}

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

.btn-outline-secondary {
    border: 1px solid var(--border-color);
    color: var(--text-main);
}

.btn-outline-secondary:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: var(--text-main);
}

/* ==============================
   Status Badges
   ============================== */
.badge {
    font-weight: 600;
    font-size: 0.78rem;
    padding: 4px 12px;
    border-radius: 20px;
    letter-spacing: 0.02em;
}

.badge-status-new {
    background: #e0f2fe;
    color: #0369a1;
}

.badge-status-assigned {
    background: #fef3c7;
    color: #b45309;
}

.badge-status-outfordelivery {
    background: #e0e7ff;
    color: #4338ca;
}

.badge-status-delivered {
    background: #dcfce7;
    color: #16a34a;
}

.badge-status-suspended {
    background: #ffe4e6;
    color: #e11d48;
}

.badge-status-returned {
    background: #ffedd5;
    color: #ea580c;
}

.badge-status-cancelled {
    background: #f1f5f9;
    color: #64748b;
}

/* ==============================
   Forms
   ============================== */
.form-control, .form-select {
    border-radius: 8px;
    border: 1px solid var(--border-color);
    padding: 10px 15px;
    transition: border-color var(--transition-speed), box-shadow var(--transition-speed);
    font-family: 'Cairo', sans-serif;
    background-color: #fff;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(75, 85, 99, 0.12);
}

.form-control::placeholder {
    color: #94a3b8;
    opacity: 0.8;
}

.form-label {
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-main);
    font-size: 0.88rem;
}

.form-text {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.input-group-text {
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    font-weight: 500;
}

/* ==============================
   Dashboard KPIs
   ============================== */
.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    overflow: hidden;
}

.kpi-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--box-shadow-hover);
}

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

.kpi-card.bg-primary {
    background: linear-gradient(135deg, #4b5563, #374151) !important;
    border-color: transparent;
}

.kpi-icon {
    font-size: 2.3rem;
    padding: 12px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
}

.kpi-value {
    font-size: 1.8rem;
    font-weight: 800;
    line-height: 1.2;
}

.kpi-title {
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
}

/* ==============================
   Alerts
   ============================== */
.alert {
    border-radius: var(--border-radius);
    border: none;
    font-weight: 500;
}

/* ==============================
   Pagination
   ============================== */
.pagination {
    gap: 2px;
}

.page-link {
    border: 1px solid var(--border-color);
    color: var(--text-main);
    border-radius: 6px !important;
    padding: 8px 14px;
    font-weight: 500;
    font-size: 0.85rem;
    transition: all 0.15s ease;
}

.page-link:hover {
    background: rgba(75, 85, 99, 0.08);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.page-item.active .page-link {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
}

.page-item.disabled .page-link {
    color: var(--text-muted);
    opacity: 0.5;
}

/* ==============================
   Modals
   ============================== */
.modal-content {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.modal-dialog-scrollable .modal-content {
    overflow: visible;
}

.modal-header {
    border-bottom: 1px solid var(--border-color);
    padding: 16px 20px;
    background: #f8fafc;
}

.modal-header .modal-title {
    font-weight: 700;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    border-top: 1px solid var(--border-color);
    padding: 16px 20px;
}

.modal-header .btn-close:focus {
    box-shadow: none;
}

/* ==============================
   Dropdowns
   ============================== */
.dropdown-menu {
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    padding: 6px;
}

.dropdown-item {
    border-radius: 6px;
    padding: 8px 14px;
    font-weight: 500;
    font-size: 0.88rem;
    transition: background 0.15s ease;
}

.dropdown-item i {
    width: 20px;
    text-align: center;
}

.dropdown-item:hover {
    background: rgba(75, 85, 99, 0.08);
}

.dropdown-item.text-danger:hover {
    background: rgba(239, 68, 68, 0.08);
}

.dropdown-divider {
    margin: 4px 0;
    border-color: var(--border-color);
}

/* ==============================
   Auth Page
   ============================== */
.login-container {
    max-width: 420px;
    margin: 60px auto;
    padding: 36px 32px;
    background: var(--bg-card);
    border-radius: 12px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
    border: 1px solid var(--border-color);
}

.login-logo {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--primary-color);
    text-align: center;
    margin-bottom: 28px;
}

.login-logo i {
    color: #818cf8;
}

/* ==============================
   Print Styles
   ============================== */
@media print {
    body {
        background-color: #ffffff !important;
        color: #000000 !important;
        font-size: 10pt;
    }

    .no-print {
        display: none !important;
    }

    .print-container {
        width: 100%;
        margin: 0;
        padding: 0;
    }

    .print-card {
        border: 1px solid #000000;
        page-break-inside: avoid;
        margin-bottom: 20px;
        padding: 15px;
    }
}

/* ==============================
   Responsive — Mobile
   ============================== */
.table-responsive {
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 991.98px) {
    /* Sidebar takes full width on mobile */
    .sidebar {
        width: 280px;
    }
}

@media (max-width: 767.98px) {
    .container-fluid {
        padding-left: 12px;
        padding-right: 12px;
    }

    .card-body {
        padding: 16px !important;
    }

    .card-header {
        padding: 12px 16px !important;
    }

    .custom-table th,
    .custom-table td {
        padding: 10px 12px !important;
        font-size: 0.82rem;
    }

    .table th,
    .table td {
        padding: 8px 10px !important;
        font-size: 0.82rem;
    }

    .btn {
        font-size: 0.82rem;
        padding: 8px 14px;
    }

    .btn-sm {
        padding: 5px 10px;
        font-size: 0.75rem;
    }

    .row > [class*="col-"] {
        margin-bottom: 10px;
    }

    .row > [class*="col-"]:last-child {
        margin-bottom: 0;
    }

    .kpi-value {
        font-size: 1.4rem;
    }

    .kpi-icon {
        font-size: 1.8rem;
        width: 50px;
        height: 50px;
    }

    .modal-dialog {
        margin: 10px;
    }

    .pagination .page-link {
        padding: 6px 10px;
        font-size: 0.8rem;
    }
}

@media (max-width: 575.98px) {
    .container-fluid {
        padding-left: 8px;
        padding-right: 8px;
    }

    .card-header h5,
    .card-header .h5 {
        font-size: 0.95rem !important;
    }

    .custom-table th,
    .custom-table td {
        padding: 8px 8px !important;
        font-size: 0.78rem;
    }

    .row.g-3 > [class*="col-"] {
        flex: 0 0 100%;
        max-width: 100%;
        margin-bottom: 8px;
    }
}

/* ==============================
   Order Items Table (Professional)
   ============================== */
.order-items-table {
    border-collapse: separate;
    border-spacing: 0;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
}

.order-items-table thead th {
    background: #f8fafc;
    padding: 10px 12px;
    font-size: 0.82rem;
    font-weight: 700;
    color: #374151;
    border-bottom: 2px solid #e5e7eb;
    letter-spacing: 0.3px;
}

.order-items-table tbody tr {
    transition: background 0.15s ease;
}

.order-items-table tbody tr:hover {
    background: #f9fafb;
}

.order-items-table tbody tr:not(:last-child) td {
    border-bottom: 1px solid #f0f0f0;
}

.order-items-table tbody td {
    padding: 8px 12px;
    vertical-align: middle;
    font-size: 0.88rem;
}

.order-items-table td.item-name-cell {
    font-weight: 600;
    color: #111827;
    font-size: 0.92rem;
}

.order-items-table .form-control-sm {
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.82rem;
    padding: 4px 8px;
    height: 32px;
    text-align: center;
    background: #fff;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.order-items-table .form-control-sm:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(75, 85, 99, 0.1);
}

.order-items-table .btn-outline-danger {
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.15s ease;
}

.order-items-table .btn-outline-danger:hover {
    background: #fef2f2;
    color: #dc2626;
    border-color: #fecaca;
}

.order-items-table .item-total {
    font-size: 0.95rem;
    color: var(--primary-color);
}

@media (max-width: 767.98px) {
    .order-items-table {
        font-size: 0.8rem;
    }
    .order-items-table thead th {
        padding: 8px 8px;
        font-size: 0.75rem;
    }
    .order-items-table tbody td {
        padding: 6px 8px;
        font-size: 0.8rem;
    }
    .order-items-table td.item-name-cell {
        font-size: 0.85rem;
    }
    .order-items-table .form-control-sm {
        font-size: 0.75rem;
        padding: 3px 6px;
        height: 28px;
        max-width: 65px !important;
    }
    .order-items-table .btn-outline-danger {
        width: 26px;
        height: 26px;
    }
    .order-items-table .btn-outline-danger i {
        font-size: 0.75rem;
    }
}

@media (max-width: 575.98px) {
    .order-items-table thead {
        display: none;
    }
    .order-items-table tbody tr {
        display: block;
        border: 1px solid #e5e7eb;
        border-radius: 8px;
        margin-bottom: 8px;
        padding: 10px 12px;
        background: #fff;
    }
    .order-items-table tbody tr td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 4px 0;
        border: none;
        font-size: 0.8rem;
        gap: 8px;
    }
    .order-items-table tbody tr td::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: 0.75rem;
        color: #6b7280;
        flex-shrink: 0;
    }
    .order-items-table tbody tr td:last-child {
        justify-content: flex-end;
    }
    .order-items-table td.item-name-cell {
        font-size: 0.85rem;
    }
    .order-items-table tbody tr td[colspan] {
        display: block;
        text-align: center;
    }
    .order-items-table tbody tr td .form-control-sm {
        max-width: 60px !important;
    }
}

/* ==============================
   Icon circle for form labels
   ============================== */
.icon-circle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    flex-shrink: 0;
}
.icon-circle i {
    font-size: 1rem;
}

/* ==============================
   Search Results Table (Responsive)
   ============================== */
@media (max-width: 575.98px) {
    .search-results-table thead {
        display: none;
    }
    .search-results-table tbody tr {
        display: block;
        border: 1px solid #e5e7eb;
        border-radius: 8px;
        margin-bottom: 8px;
        padding: 10px 12px;
        background: #fff;
    }
    .search-results-table tbody tr td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 4px 0;
        border: none;
        font-size: 0.85rem;
    }
    .search-results-table tbody tr td::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: 0.8rem;
        color: #6b7280;
        margin-left: 8px;
        flex-shrink: 0;
    }
    .search-results-table tbody tr td:last-child {
        justify-content: flex-end;
    }
}

/* ==============================
   Item Cards Grid
   ============================== */
.item-cards-grid {
    display: grid;
    gap: 12px;
    max-height: 420px;
    overflow-y: auto;
    padding: 4px;
}

@media (min-width: 768px) {
    .item-cards-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 992px) {
    .item-cards-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.item-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    transition: all 0.2s ease;
    cursor: pointer;
    position: relative;
}

.item-card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(75, 85, 99, 0.12);
    transform: translateY(-1px);
}

.item-card.selected {
    border-color: var(--primary-color);
    background: #f0fdf4;
}

.item-card-img {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    object-fit: cover;
    background: #f3f4f6;
    flex-shrink: 0;
}

.item-card-img-placeholder {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.item-card-body {
    flex: 1;
    min-width: 0;
}

.item-card-body .item-card-name {
    font-weight: 700;
    font-size: 1.05rem;
    color: #111827;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.item-card-body .item-card-code {
    font-size: 0.85rem;
    color: #9ca3af;
    margin-bottom: 6px;
}

.item-card-body .item-card-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.item-card-body .item-card-price {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--primary-color);
}

.item-card-body .item-card-stock {
    font-size: 0.82rem;
}

.item-card .item-card-add {
    position: absolute;
    top: 8px;
    left: 8px;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.item-card:hover .item-card-add {
    opacity: 1;
}

@media (max-width: 575.98px) {
    .item-cards-grid {
        gap: 8px;
    }
    .item-card {
        padding: 10px;
        gap: 10px;
    }
    .item-card-img,
    .item-card-img-placeholder {
        width: 50px;
        height: 50px;
    }
    .item-card-body .item-card-name {
        font-size: 0.85rem;
    }
    .item-card-body .item-card-price {
        font-size: 0.88rem;
    }
    .item-card .item-card-add {
        opacity: 1;
    }
}

/* Item filters bar */
.item-filters-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}

.item-filters-bar .search-wrapper {
    flex: 1;
}

.item-filters-bar .search-wrapper .form-control {
    font-size: 1rem;
}

.item-filters-bar .filter-wrapper {
    flex-shrink: 0;
    min-width: 180px;
}

.item-filters-bar .filter-wrapper .form-select {
    font-size: 1rem;
}

@media (max-width: 575.98px) {
    .item-filters-bar {
        flex-direction: column;
    }
    .item-filters-bar .filter-wrapper {
        min-width: 100%;
    }
}
