
/* Mobile Header */
.mobile-header {
    display: none;
    background-color: var(--white);
    padding: 1rem;
    box-shadow: var(--shadow);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1001;
    align-items: center;
    justify-content: space-between;
}

.mobile-menu-toggle {
    background: none;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-header-logo img {
    height: 35px;
}

.mobile-header-user {
    font-weight: 600;
    color: var(--primary-color);
    font-size: 0.9rem;
}

.sidebar-close {
    display: none;
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    padding: 0.5rem;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

/* Responsive Tables */
@media (max-width: 768px) {
    .mobile-header {
        display: flex;
    }

    .sidebar-close {
        display: block;
    }

    .sidebar-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        bottom: 0;
        width: 280px;
        z-index: 1000;
        transition: left 0.3s ease;
        overflow-y: auto;
    }

    .sidebar.active {
        left: 0;
    }

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

    .main-content {
        margin-left: 0;
        margin-top: 65px;
        padding: 1rem;
    }

    /* Responsive Cards */
    .card {
        margin-bottom: 1rem;
    }

    .card-body {
        padding: 1rem;
        overflow-x: auto;
    }

    /* Responsive Tables */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        min-width: 800px;
        font-size: 0.875rem;
    }

    table th,
    table td {
        padding: 0.75rem 0.5rem;
        white-space: nowrap;
    }
/* Stats Grid - Base Styles (ADD THIS TO YOUR EXISTING CSS) */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    min-width: 0; /* Critical: prevents grid items from overflowing */
    overflow: hidden;
}

/* Mobile Header */
.mobile-header {
    display: none;
    background-color: var(--white);
    padding: 1rem;
    box-shadow: var(--shadow);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1001;
    align-items: center;
    justify-content: space-between;
}

.mobile-menu-toggle {
    background: none;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-header-logo img {
    height: 35px;
}

.mobile-header-user {
    font-weight: 600;
    color: var(--primary-color);
    font-size: 0.9rem;
}

.sidebar-close {
    display: none;
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    padding: 0.5rem;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

/* Responsive Tables */
@media (max-width: 768px) {
    .mobile-header {
        display: flex;
    }

    .sidebar-close {
        display: block;
    }

    .sidebar-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        bottom: 0;
        width: 280px;
        z-index: 1000;
        transition: left 0.3s ease;
        overflow-y: auto;
    }

    .sidebar.active {
        left: 0;
    }

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

    .main-content {
        margin-left: 0;
        margin-top: 65px;
        padding: 1rem;
    }

    /* Responsive Cards */
    .card {
        margin-bottom: 1rem;
    }

    .card-body {
        padding: 1rem;
        overflow-x: auto;
    }

    /* Responsive Tables */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        min-width: 800px;
        font-size: 0.875rem;
    }

    table th,
    table td {
        padding: 0.75rem 0.5rem;
        white-space: nowrap;
    }

 
    .stats-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem;
    }

    .stat-card {
        padding: 1rem;
    }

    /* Responsive Forms */
    .form-group {
        margin-bottom: 1rem;
    }

    .form-control {
        font-size: 16px; /* Prevents zoom on iOS */
    }

    /* Responsive Buttons */
    .btn {
        padding: 0.75rem 1.5rem;
        font-size: 0.9rem;
    }

    .btn-sm {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }

    /* Responsive Page Header */
    .page-header {
        margin-bottom: 1.5rem;
    }

    .page-header h1 {
        font-size: 1.75rem;
    }

    .page-header .d-flex {
        flex-direction: column;
        gap: 1rem;
    }

    /* Responsive Modals */
    .modal-content {
        width: 95%;
        margin: 1rem auto;
    }

    .modal-body {
        padding: 1rem;
    }

    /* Responsive Grid Layouts */
    div[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }

    /* Filters */
    .card-body form.d-flex {
        flex-direction: column !important;
        gap: 0.75rem !important;
    }

    .card-body form.d-flex .form-control,
    .card-body form.d-flex select,
    .card-body form.d-flex .btn {
        width: 100% !important;
    }

    /* Service Details in Order Pages */
    #serviceDetails,
    #ordersSummary,
    #priceEstimate {
        font-size: 0.875rem;
    }
}

/* Tablet */
@media (min-width: 769px) and (max-width: 1024px) {
    .sidebar {
        width: 220px;
    }

    .main-content {
        margin-left: 220px;
        padding: 1.5rem;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* Large Mobile */
@media (max-width: 480px) {
    .page-header h1 {
        font-size: 1.5rem;
    }

    .stat-value {
        font-size: 1.5rem !important;
    }

    .stat-icon {
        width: 50px;
        height: 50px;
        font-size: 1.25rem;
    }

    table {
        min-width: 600px;
        font-size: 0.8rem;
    }

    .alert {
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
    }

    .hero-stats {
        grid-template-columns: 1fr !important;
        gap: 1rem;
    }
}

/* Landscape Mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .sidebar {
        padding-top: 0.5rem;
    }

    .sidebar-menu {
        padding: 0.5rem 0;
    }

    .sidebar-menu a {
        padding: 0.5rem 1.5rem;
        font-size: 0.9rem;
    }

    .sidebar-menu svg {
        width: 16px;
        height: 16px;
    }
}

/* Print Styles */
@media print {
    .sidebar,
    .mobile-header,
    .sidebar-overlay,
    .btn,
    .alert {
        display: none !important;
    }

    .main-content {
        margin-left: 0 !important;
        margin-top: 0 !important;
    }

    .card {
        break-inside: avoid;
    }
}

/* Mobile Header */
.mobile-header {
    display: none;
    background-color: var(--white);
    padding: 1rem;
    box-shadow: var(--shadow);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1001;
    align-items: center;
    justify-content: space-between;
}

.mobile-menu-toggle {
    background: none;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-header-logo img {
    height: 35px;
}

.mobile-header-user {
    font-weight: 600;
    color: var(--primary-color);
    font-size: 0.9rem;
}

.sidebar-close {
    display: none;
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    padding: 0.5rem;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

/* Stats Grid - Base Styles */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    min-width: 0; /* Critical: prevents grid items from overflowing */
    overflow: hidden;
}

/* Dashboard Grid for Cards - MOBILE FRIENDLY */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

/* Alerts with icons */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem 1.5rem;
    border-radius: 5px;
    margin-bottom: 1rem;
}

.alert svg {
    flex-shrink: 0;
    margin-top: 0.125rem;
}

.alert div {
    flex: 1;
}

/* Responsive Breakpoints */
@media (max-width: 768px) {
    .mobile-header {
        display: flex;
    }

    .sidebar-close {
        display: block;
    }

    .sidebar-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 1rem 1.5rem;
    }

    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        bottom: 0;
        width: 280px;
        z-index: 1000;
        transition: left 0.3s ease;
        overflow-y: auto;
    }

    .sidebar.active {
        left: 0;
    }

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

    .main-content {
        margin-left: 0;
        margin-top: 65px;
        padding: 1rem;
    }

    /* Responsive Cards */
    .card {
        margin-bottom: 1rem;
    }

    .card-header {
        padding: 1rem;
    }

    .card-header h2 {
        font-size: 1.1rem;
    }

    .card-body {
        padding: 1rem;
    }

    /* Responsive Tables */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: -1rem;
        padding: 1rem;
    }

    table {
        min-width: 600px;
        font-size: 0.875rem;
    }

    table th,
    table td {
        padding: 0.75rem 0.5rem;
        white-space: nowrap;
    }

    /* Stats Grid on Mobile - STACK VERTICALLY */
    .stats-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem;
    }

    .stat-card {
        padding: 1rem;
    }

    .stat-value {
        font-size: 1.5rem !important;
    }

    .stat-icon {
        width: 50px;
        height: 50px;
    }

    /* Dashboard Grid - STACK ON MOBILE */
    .dashboard-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem;
    }

    /* Responsive Forms */
    .form-group {
        margin-bottom: 1rem;
    }

    .form-control,
    .form-control select {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 0.75rem;
    }

    /* Responsive Buttons */
    .btn {
        padding: 0.75rem 1.5rem;
        font-size: 0.9rem;
    }

    .btn-sm {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }

    /* Responsive Page Header */
    .page-header {
        margin-bottom: 1.5rem;
    }

    .page-header h1 {
        font-size: 1.75rem;
    }

    .page-header p {
        font-size: 0.9rem;
    }

    .page-header .d-flex {
        flex-direction: column;
        gap: 1rem;
    }

    /* Responsive Modals */
    .modal-content {
        width: 95%;
        margin: 1rem auto;
        max-width: 500px;
    }

    .modal-header {
        padding: 1rem;
    }

    .modal-body {
        padding: 1rem;
    }

    .modal-title {
        font-size: 1.1rem;
    }

    /* Override ANY inline grid styles on mobile */
    div[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }

    /* Filters and Search Forms */
    .card-body form.d-flex,
    .card-body form[style*="display: flex"] {
        flex-direction: column !important;
        gap: 0.75rem !important;
    }

    .card-body form.d-flex > div,
    .card-body form .form-control,
    .card-body form select,
    .card-body form .btn {
        width: 100% !important;
    }

    /* Date inputs on mobile */
    input[type="date"] {
        width: 100% !important;
    }

    /* Service Details in Order Pages */
    #serviceDetails,
    #ordersSummary,
    #priceEstimate {
        font-size: 0.875rem;
    }

    /* Alert on mobile */
    .alert {
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
    }

    .alert svg {
        width: 18px;
        height: 18px;
    }

    /* Badge adjustments */
    .badge {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }

    /* Quick Actions Grid */
    div[style*="grid-template-columns"][style*="auto-fit"] {
        grid-template-columns: 1fr !important;
    }

    /* Ensure no element causes horizontal scroll */
    body, html {
        overflow-x: hidden;
        max-width: 100vw;
    }

    .main-content {
        max-width: 100%;
        overflow-x: hidden;
    }

    .card,
    .stat-card,
    .card-body,
    .table-responsive {
        max-width: 100%;
    }
}

/* Tablet - 2 columns for stats and dashboard */
@media (min-width: 769px) and (max-width: 1024px) {
    .sidebar {
        width: 220px;
    }

    .main-content {
        margin-left: 220px;
        padding: 1.5rem;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .dashboard-grid {
        grid-template-columns: 1fr !important;
    }

    table {
        font-size: 0.9rem;
    }
}

/* Large Mobile - Extra small adjustments */
@media (max-width: 480px) {
    .mobile-header {
        padding: 0.75rem 1rem;
    }

    .mobile-header-logo img {
        height: 30px;
    }

    .page-header h1 {
        font-size: 1.5rem;
    }

    .stat-value {
        font-size: 1.25rem !important;
    }

    .stat-icon {
        width: 45px;
        height: 45px;
    }

    table {
        min-width: 500px;
        font-size: 0.8rem;
    }

    table th,
    table td {
        padding: 0.5rem 0.35rem;
    }

    /* Pagination on mobile */
    .mt-3.text-center a {
        padding: 0.5rem 0.75rem !important;
        font-size: 0.85rem !important;
        margin: 0 1px !important;
    }
}

/* Landscape Mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .sidebar {
        padding-top: 0.5rem;
    }

    .sidebar-menu {
        padding: 0.5rem 0;
    }

    .sidebar-menu a {
        padding: 0.5rem 1.5rem;
        font-size: 0.9rem;
    }

    .sidebar-menu svg {
        width: 16px;
        height: 16px;
    }
}

/* Print Styles */
@media print {
    .sidebar,
    .mobile-header,
    .sidebar-overlay,
    .btn,
    .alert {
        display: none !important;
    }

    .main-content {
        margin-left: 0 !important;
        margin-top: 0 !important;
    }

    .card {
        break-inside: avoid;
    }
}