/* Mobile Repair Shop Admin Styles - Modern Clean Design */

:root {
    --primary-color: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #3b82f6;
    --secondary-color: #64748b;
    --success-color: #059669;
    --info-color: #0891b2;
    --warning-color: #d97706;
    --danger-color: #dc2626;
    --light-color: #f8fafc;
    --dark-color: #0f172a;
    --sidebar-width: 280px;
    --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    --card-shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --border-color: #e2e8f0;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f8fafc;
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--dark-color);
    min-height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 1000;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
}

.sidebar-brand {
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.3rem;
    font-weight: 700;
    text-decoration: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
    background: var(--primary-color);
}

.sidebar-brand:hover {
    background: var(--primary-dark);
}

.sidebar-brand i {
    margin-right: 10px;
    font-size: 1.5rem;
}

.sidebar-nav {
    padding: 0.5rem 0;
    margin: 0;
    list-style: none;
    overflow-y: auto;
    max-height: calc(100vh - 70px);
    scrollbar-width: thin;
    scrollbar-color: #8b5cf6 #1e293b;
}

/* Beautiful Sidebar Scrollbar - Webkit */
.sidebar-nav::-webkit-scrollbar {
    width: 8px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: #1e293b;
    border-radius: 4px;
    margin: 4px 0;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #60a5fa 0%, #a78bfa 50%, #f472b6 100%);
    border-radius: 4px;
    border: 2px solid #0f172a;
    background-clip: padding-box;
    min-height: 60px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #93c5fd 0%, #c4b5fd 50%, #fbcfe8 100%);
}

/* Hide scrollbar when not hovering for cleaner look */
.sidebar-nav {
    scrollbar-gutter: stable;
}

.sidebar-nav:hover {
    scrollbar-color: #8b5cf6 transparent;
}

.sidebar-nav-item {
    padding: 0;
}

.sidebar-nav-link {
    display: flex;
    align-items: center;
    padding: 0.85rem 1.5rem;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
    margin: 0.15rem 0;
    border-radius: 0 6px 6px 0;
    font-weight: 500;
}

.sidebar-nav-link:hover {
    color: white;
    background: rgba(255, 255, 255, 0.08);
    transform: translateX(2px);
}

.sidebar-nav-link.active {
    color: white;
    background: var(--primary-color);
    border-left-color: white;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.sidebar-nav-link i {
    width: 24px;
    margin-right: 12px;
    font-size: 1rem;
    transition: transform 0.2s ease;
}

.sidebar-nav-link:hover i {
    transform: scale(1.05);
}

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    padding: 0;
    min-height: 100vh;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Topbar */
.topbar {
    height: 70px;
    background: white;
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 999;
    transition: all 0.3s ease;
}

.topbar-brand {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 10px;
}

.topbar-brand i {
    font-size: 1.6rem;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 1rem;
}

#sidebarToggle {
    background: var(--light-color);
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    transition: all 0.3s ease;
    display: none;
}

#sidebarToggle:hover {
    background: var(--primary-color);
    color: white;
    transform: scale(1.05);
}

/* Mobile Menu Button */
.mobile-menu-btn {
    display: none;
    background: var(--primary-color);
    border: none;
    color: white;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.mobile-menu-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4);
}

.mobile-menu-btn:active {
    transform: scale(0.95);
}

/* Cards */
.card {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: white;
    box-shadow: var(--card-shadow);
    margin-bottom: 1.5rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.card:hover {
    box-shadow: var(--card-shadow-hover);
    transform: translateY(-2px);
    border-color: var(--primary-light);
}

.card-header {
    background: #f8fafc;
    border-bottom: 1px solid var(--border-color);
    padding: 1.25rem 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header i {
    color: var(--primary-color);
    margin-right: 8px;
}

.card-body {
    padding: 1.5rem;
}

/* Stats Cards */
.stats-card {
    border-left: 4px solid;
    position: relative;
    overflow: hidden;
}

.stats-card.primary {
    border-left-color: var(--primary-color);
    background: var(--primary-color);
    color: white;
}

.stats-card.success {
    border-left-color: var(--success-color);
    background: var(--success-color);
    color: white;
}

.stats-card.info {
    border-left-color: var(--info-color);
    background: var(--info-color);
    color: white;
}

.stats-card.warning {
    border-left-color: var(--warning-color);
    background: var(--warning-color);
    color: white;
}

.stats-card .stats-label {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.9;
}

.stats-card .stats-value {
    font-size: 2rem;
    font-weight: 700;
    margin: 0.5rem 0;
}

/* Tables */
.table {
    margin-bottom: 0;
    border-collapse: separate;
    border-spacing: 0;
}

.table thead th {
    border-top: none;
    border-bottom: 2px solid #e2e8f0;
    font-weight: 600;
    color: var(--dark-color);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 1rem;
    background: #f8fafc;
}

.table tbody tr {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.table tbody tr:hover {
    background-color: #f8fafc;
    transform: scale(1.01);
}

.table tbody td {
    padding: 1rem;
    vertical-align: middle;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: 8px;
    border: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

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

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.35);
}

.btn-success {
    background: var(--success-color);
    color: white;
    box-shadow: 0 2px 8px rgba(5, 150, 105, 0.25);
}

.btn-success:hover {
    background: #047857;
    box-shadow: 0 4px 16px rgba(5, 150, 105, 0.35);
}

.btn-danger {
    background: var(--danger-color);
    color: white;
    box-shadow: 0 2px 8px rgba(220, 38, 38, 0.25);
}

.btn-danger:hover {
    background: #b91c1c;
    box-shadow: 0 4px 16px rgba(220, 38, 38, 0.35);
}

.btn-warning {
    background: var(--warning-color);
    color: white;
    box-shadow: 0 2px 8px rgba(217, 119, 6, 0.25);
}

.btn-warning:hover {
    background: #b45309;
    box-shadow: 0 4px 16px rgba(217, 119, 6, 0.35);
}

.btn-info {
    background: var(--info-color);
    color: white;
    box-shadow: 0 2px 8px rgba(8, 145, 178, 0.25);
}

.btn-info:hover {
    background: #0e7490;
    box-shadow: 0 4px 16px rgba(8, 145, 178, 0.35);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
    box-shadow: 0 2px 8px rgba(100, 116, 139, 0.25);
}

.btn-secondary:hover {
    background: #475569;
    box-shadow: 0 4px 16px rgba(100, 116, 139, 0.35);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1rem;
}

/* Forms */
.form-control {
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: white;
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
    outline: none;
}

.form-control:hover {
    border-color: #cbd5e1;
}

.form-select {
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: white;
}

.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
    outline: none;
}

.form-label {
    font-weight: 600;
    color: var(--dark-color);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    display: block;
}

.form-floating label {
    color: #64748b;
}

.input-group {
    position: relative;
    display: flex;
    align-items: stretch;
    width: 100%;
}

.input-group-text {
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    border-right: none;
    padding: 0.75rem 1rem;
    border-radius: 10px 0 0 10px;
    color: #64748b;
}

.input-group .form-control {
    border-left: none;
    border-radius: 0 10px 10px 0;
}

.input-group .form-control:focus {
    border-left: none;
}

/* Badges */
.badge {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.badge-primary {
    background: var(--primary-color);
    color: white;
}

.badge-success {
    background: var(--success-color);
    color: white;
}

.badge-warning {
    background: var(--warning-color);
    color: white;
}

.badge-danger {
    background: var(--danger-color);
    color: white;
}

.badge-info {
    background: var(--info-color);
    color: white;
}

.badge-secondary {
    background: var(--secondary-color);
    color: white;
}

/* Status badges */
.status-pending { 
    background: var(--warning-color); 
    color: white; 
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
}
.status-diagnosing { 
    background: var(--info-color); 
    color: white; 
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
}
.status-approved { 
    background: var(--primary-color); 
    color: white; 
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
}
.status-in_progress { 
    background: var(--secondary-color); 
    color: white; 
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
}
.status-completed { 
    background: var(--success-color); 
    color: white; 
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
}
.status-delivered { 
    background: var(--info-color); 
    color: white; 
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
}
.status-cancelled { 
    background: var(--danger-color); 
    color: white; 
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
}

/* Login Page */
.login-page {
    background: var(--primary-color);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 50%);
    animation: pulse 15s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.login-card {
    width: 100%;
    max-width: 420px;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    animation: slideUp 0.6s ease-out;
    position: relative;
    z-index: 1;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-header {
    background: var(--primary-dark);
    padding: 2.5rem 2rem;
    text-align: center;
    color: white;
    position: relative;
    overflow: hidden;
}

.login-header h3 {
    margin: 0;
    font-weight: 700;
    font-size: 1.5rem;
    position: relative;
    z-index: 1;
}

.login-header p {
    margin: 0.5rem 0 0;
    opacity: 0.9;
    font-size: 0.9rem;
    position: relative;
    z-index: 1;
}

.login-header i {
    font-size: 3rem;
    margin-bottom: 1rem;
    display: block;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.login-body {
    padding: 2.5rem 2rem;
    background: white;
}

/* Responsive */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.show {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .mobile-menu-btn {
        display: block;
    }
    
    #sidebarToggle {
        display: none;
    }
}

@media (max-width: 768px) {
    .topbar {
        padding: 0 1rem;
        height: 70px;
    }
    
    .topbar-brand {
        font-size: 1.2rem;
    }
    
    .card-header {
        padding: 1rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .table thead th,
    .table tbody td {
        padding: 0.75rem 0.5rem;
        font-size: 0.85rem;
    }
    
    .btn {
        padding: 0.6rem 1rem;
        font-size: 0.85rem;
    }
    
    .stats-card .stats-value {
        font-size: 1.5rem;
    }
    
    .login-card {
        max-width: 100%;
    }
    
    .login-header,
    .login-body {
        padding: 2rem 1.5rem;
    }
}

@media (max-width: 480px) {
    .topbar-brand span {
        display: none;
    }
    
    .topbar-brand i {
        font-size: 1.5rem;
    }
    
    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .table-responsive {
        font-size: 0.8rem;
    }
    
    .btn-sm {
        padding: 0.4rem 0.8rem;
        font-size: 0.75rem;
    }
}

/* Animations */
@keyframes fadeIn {
    from { 
        opacity: 0; 
        transform: translateY(-10px); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0); 
    }
}

.fade-in {
    animation: fadeIn 0.4s ease-out;
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.slide-in-left {
    animation: slideInLeft 0.5s ease-out;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.slide-in-right {
    animation: slideInRight 0.5s ease-out;
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.scale-in {
    animation: scaleIn 0.3s ease-out;
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-5px);
    }
}

.bounce {
    animation: bounce 0.5s ease-in-out;
}

/* Loading Animation */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Alerts */
.alert {
    border: none;
    border-radius: 8px;
    padding: 1rem 1.5rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideInLeft 0.4s ease-out;
}

.alert-success {
    background: var(--success-color);
    color: white;
    box-shadow: 0 2px 8px rgba(5, 150, 105, 0.25);
}

.alert-danger {
    background: var(--danger-color);
    color: white;
    box-shadow: 0 2px 8px rgba(220, 38, 38, 0.25);
}

.alert-info {
    background: var(--info-color);
    color: white;
    box-shadow: 0 2px 8px rgba(8, 145, 178, 0.25);
}

.alert-warning {
    background: var(--warning-color);
    color: white;
    box-shadow: 0 2px 8px rgba(217, 119, 6, 0.25);
}

/* Pagination */
.pagination {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin-top: 2rem;
}

.page-link {
    padding: 0.6rem 1rem;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    color: var(--dark-color);
    text-decoration: none;
    transition: all 0.3s ease;
    background: white;
}

.page-link:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
    transform: translateY(-2px);
}

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

/* Overlay for mobile sidebar */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
    animation: fadeIn 0.3s ease-out;
}

@media (max-width: 1024px) {
    .sidebar-overlay.show {
        display: block;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Focus visible for accessibility */
*:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Dropdown menu */
.dropdown-menu {
    border: none;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    padding: 0.5rem;
    animation: scaleIn 0.2s ease-out;
}

.dropdown-item {
    padding: 0.6rem 1rem;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.dropdown-item:hover {
    background: #f8fafc;
    transform: translateX(4px);
}

/* Search box enhancement */
.search-box {
    position: relative;
}

.search-box input {
    padding-left: 2.5rem;
}

.search-box i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: #64748b;
}

/* Action buttons in tables */
.action-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.action-buttons .btn {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
}

/* Card hover effects */
.card-hover {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

.card-hover:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

/* Gradient text */
.gradient-text {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Glass morphism effect */
.glass {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Spacing utilities */
.mt-4 { margin-top: 1.5rem; }
.mb-4 { margin-bottom: 1.5rem; }
.p-4 { padding: 1.5rem; }

/* Text utilities */
.text-center { text-align: center; }
.text-muted { color: #64748b; }
.text-primary { color: var(--primary-color); }
.text-success { color: var(--success-color); }
.text-danger { color: var(--danger-color); }
.text-warning { color: var(--warning-color); }

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.3s ease-in-out;
}

/* Alerts */
.alert {
    border: none;
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
}

.alert-success {
    background: var(--success-color);
    color: white;
}

.alert-danger {
    background: var(--danger-color);
    color: white;
}

.alert-info {
    background: var(--info-color);
    color: white;
}

.alert-warning {
    background: var(--warning-color);
    color: white;
}

/* ============================================
   MOBILE RESPONSIVE TABLES - FIXED FIRST COLUMN
   ============================================ */

/* Table wrapper for horizontal scroll - supports both .table-wrap and .table-responsive */
.table-wrap,
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    position: relative;
}

/* Also handle tables directly inside these containers */
.table-wrap table,
.table-responsive table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    min-width: 600px;
}

/* Mobile styles for fixed first column - supports both .table-wrap and .table-responsive */
@media (max-width: 768px) {
    /* Table container with horizontal scroll */
    .table-wrap,
    .table-responsive {
        overflow-x: auto;
        overflow-y: hidden;
        position: relative;
        border-radius: 0 0 12px 12px;
        /* Beautiful gradient fade indicator on right side */
        background: linear-gradient(to right, white 0%, white 95%, transparent 100%);
        -webkit-mask-image: linear-gradient(to right, white 0%, white 90%, transparent 100%);
        mask-image: linear-gradient(to right, white 0%, white 90%, transparent 100%);
    }

    /* Custom scrollbar styling for horizontal scroll */
    .table-wrap::-webkit-scrollbar,
    .table-responsive::-webkit-scrollbar {
        height: 6px;
    }

    .table-wrap::-webkit-scrollbar-track,
    .table-responsive::-webkit-scrollbar-track {
        background: linear-gradient(to right, #f1f5f9, #e2e8f0);
        border-radius: 3px;
    }

    .table-wrap::-webkit-scrollbar-thumb,
    .table-responsive::-webkit-scrollbar-thumb {
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        border-radius: 3px;
    }

    .table-wrap::-webkit-scrollbar-thumb:hover,
    .table-responsive::-webkit-scrollbar-thumb:hover {
        background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
    }

    /* Firefox scrollbar */
    .table-wrap,
    .table-responsive {
        scrollbar-width: thin;
        scrollbar-color: #667eea #f1f5f9;
    }

    /* Table structure for fixed column */
    .table-wrap table,
    .table-responsive table {
        min-width: unset;
        width: max-content;
    }

    .table-wrap thead,
    .table-wrap tbody,
    .table-responsive thead,
    .table-responsive tbody {
        display: table-row-group;
    }

    .table-wrap th,
    .table-wrap td,
    .table-responsive th,
    .table-responsive td {
        white-space: nowrap;
        padding: 12px 16px;
    }

    /* Fixed first column - both header and data cells */
    .table-wrap th:first-child,
    .table-wrap td:first-child,
    .table-responsive th:first-child,
    .table-responsive td:first-child {
        position: sticky;
        left: 0;
        z-index: 10;
        background: linear-gradient(135deg, #f8fafc 0%, #ffffff 100%);
        box-shadow: 4px 0 12px rgba(0, 0, 0, 0.08);
        border-right: 2px solid #e2e8f0;
        min-width: 120px;
        max-width: 180px;
        font-weight: 600;
    }

    /* Header first column specific styling */
    .table-wrap thead th:first-child,
    .table-responsive thead th:first-child {
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        color: white;
        text-transform: uppercase;
        font-size: 0.75rem;
        letter-spacing: 0.5px;
        border-right: 2px solid rgba(255, 255, 255, 0.2);
        box-shadow: 4px 0 16px rgba(102, 126, 234, 0.3);
    }

    /* Data first column styling */
    .table-wrap tbody td:first-child,
    .table-responsive tbody td:first-child {
        color: #1e293b;
        font-weight: 600;
        background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    }

    /* Row hover effect with proper background for sticky cell */
    .table-wrap tbody tr:hover td:first-child,
    .table-responsive tbody tr:hover td:first-child {
        background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    }

    /* Scroll hint animation */
    .table-wrap::after,
    .table-responsive::after {
        content: '← Swipe →';
        position: absolute;
        bottom: 8px;
        right: 16px;
        font-size: 10px;
        color: #64748b;
        background: rgba(255, 255, 255, 0.9);
        padding: 4px 10px;
        border-radius: 12px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        pointer-events: none;
        animation: scrollHint 3s ease-in-out infinite;
        z-index: 20;
    }

    @keyframes scrollHint {
        0%, 100% {
            opacity: 0.6;
            transform: translateX(0);
        }
        50% {
            opacity: 1;
            transform: translateX(5px);
        }
    }

    /* Remove scroll hint when user starts scrolling */
    .table-wrap:active::after,
    .table-wrap:focus-within::after,
    .table-responsive:active::after,
    .table-responsive:focus-within::after {
        display: none;
    }

    /* Card header responsive adjustments */
    .card-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .card-header form {
        width: 100%;
        flex-wrap: wrap;
    }

    .card-header form input,
    .card-header form select {
        flex: 1;
        min-width: 120px;
    }

    /* Action buttons compact layout */
    .table-wrap td:last-child,
    .table-responsive td:last-child {
        min-width: 100px;
    }

    /* Badge sizing for mobile */
    .table-wrap .badge,
    .table-responsive .badge {
        font-size: 0.7rem;
        padding: 0.3rem 0.5rem;
    }
}

/* Extra small devices */
@media (max-width: 480px) {
    .table-wrap th:first-child,
    .table-wrap td:first-child,
    .table-responsive th:first-child,
    .table-responsive td:first-child {
        min-width: 100px;
        max-width: 140px;
        padding: 10px 12px;
        font-size: 0.85rem;
    }

    .table-wrap th,
    .table-wrap td,
    .table-responsive th,
    .table-responsive td {
        padding: 10px 12px;
        font-size: 0.8rem;
    }

    /* Compact action buttons */
    .table-wrap .btn-sm,
    .table-responsive .btn-sm {
        padding: 0.3rem 0.6rem;
        font-size: 0.7rem;
    }

    .table-wrap .btn-sm i,
    .table-responsive .btn-sm i {
        font-size: 12px;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .table-wrap,
    .table-responsive {
        overflow-x: scroll;
        -webkit-overflow-scrolling: touch;
    }
}
