/* DawaFlow POS - Mobile-First Responsive Design */

:root {
    --tblr-primary: #14B8A6;
    --tblr-primary-rgb: 20, 184, 166;
    --sidebar-width: 260px;
}

/* ========== SIDEBAR ========== */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    z-index: 1050;
    overflow-y: auto;
    overflow-x: hidden;
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: 2rem;
}

.sidebar-brand {
    padding: 1rem;
    text-align: center;
    background: linear-gradient(135deg, #14B8A6 0%, #0D9488 100%);
    color: white;
    position: relative;
}

.sidebar-logo {
    max-width: 60px;
    height: auto;
    max-height: 50px;
    object-fit: contain;
    border-radius: 8px;
}

.sidebar-brand i { font-size: 2rem; }
.sidebar-brand h5 { font-weight: 700; margin: 0.5rem 0 0; font-size: 0.95rem; line-height: 1.2; }
.sidebar-brand small { opacity: 0.8; font-size: 0.7rem; }

/* Login Logo */
.login-logo-img {
    max-width: 80px;
    height: auto;
    max-height: 70px;
    object-fit: contain;
    border-radius: 10px;
}

.sidebar-nav { 
    padding: 0.75rem; 
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.nav-item { margin-bottom: 0.15rem; }

.nav-link {
    display: flex;
    align-items: center;
    padding: 0.65rem 0.9rem;
    color: rgba(255,255,255,0.7);
    border-radius: 8px;
    transition: all 0.2s;
    text-decoration: none;
    font-size: 0.9rem;
}

.nav-link i { width: 22px; margin-right: 0.65rem; font-size: 1.15rem; }
.nav-link:hover { background: rgba(255,255,255,0.1); color: white; }
.nav-link.active {
    background: linear-gradient(135deg, #14B8A6 0%, #0D9488 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(20, 184, 166, 0.4);
}

/* Sidebar Close Button */
.sidebar-close {
    display: none;
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    z-index: 10;
    align-items: center;
    justify-content: center;
}

.sidebar-close:hover { background: rgba(255,255,255,0.3); }

/* Sidebar Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1040;
}

.sidebar-overlay.show { display: block; }

/* ========== MAIN CONTENT ========== */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    background: #f4f6fa;
    transition: margin-left 0.3s ease;
}

/* ========== NAVBAR ========== */
.mobile-menu-toggle {
    display: none;
    background: linear-gradient(135deg, #14B8A6, #0D9488);
    border: none;
    color: white;
    width: 38px;
    height: 38px;
    border-radius: 8px;
    cursor: pointer;
    flex-shrink: 0;
}

.mobile-menu-toggle:hover { opacity: 0.9; }
.mobile-menu-toggle i { font-size: 1.25rem; }


/* ========== STAT CARDS ========== */
.stat-card {
    border-radius: 12px;
    padding: 1.25rem;
    color: white;
    position: relative;
    overflow: hidden;
    height: 100%;
}

.stat-card::after {
    content: '';
    position: absolute;
    top: -50%;
    right: -30%;
    width: 100px;
    height: 200px;
    background: rgba(255,255,255,0.1);
    border-radius: 50%;
}

.stat-card .h2 { font-size: 1.5rem; }
.stat-card .small { font-size: 0.7rem; }
.stat-card i { font-size: 2.5rem !important; }

.stat-card.primary { background: linear-gradient(135deg, #14B8A6, #0D9488); }
.stat-card.success { background: linear-gradient(135deg, #22C55E, #16A34A); }
.stat-card.warning { background: linear-gradient(135deg, #F59E0B, #D97706); }
.stat-card.info { background: linear-gradient(135deg, #3B82F6, #2563EB); }
.stat-card.secondary { background: linear-gradient(135deg, #6366F1, #4F46E5); }
.stat-card.danger { background: linear-gradient(135deg, #EF4444, #DC2626); }

/* ========== POS LAYOUT ========== */
.pos-container { display: flex; height: calc(100vh - 60px); }
.products-section { flex: 1; overflow-y: auto; padding: 1rem; background: #f4f6fa; }
.cart-section { width: 380px; background: white; border-left: 1px solid #e6e8eb; display: flex; flex-direction: column; }

.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 0.75rem; }

.product-card {
    background: white;
    border-radius: 10px;
    padding: 0.85rem;
    text-align: center;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.product-card:hover {
    border-color: #14B8A6;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.1);
}

.product-card .icon { font-size: 1.75rem; color: #14B8A6; margin-bottom: 0.4rem; }
.product-card .fw-medium { font-size: 0.8rem; line-height: 1.2; }
.product-card .text-muted { font-size: 0.7rem; }

.cart-header {
    padding: 1rem;
    background: linear-gradient(135deg, #14B8A6, #0D9488);
    color: white;
}

.cart-items { flex: 1; overflow-y: auto; }
.cart-item { padding: 0.85rem; border-bottom: 1px solid #f0f0f0; }
.cart-footer { padding: 1rem; background: #f8fafc; border-top: 1px solid #e6e8eb; }

/* ========== LOGIN ========== */
.login-wrapper {
    min-height: 100vh;
    background-color: #1e293b;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.login-card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    box-shadow: 0 25px 50px rgba(0,0,0,0.3);
    width: 100%;
    max-width: 380px;
    padding: 2rem;
    backdrop-filter: blur(10px);
}

.login-logo {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, #14B8A6, #0D9488);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.25rem;
    box-shadow: 0 8px 24px rgba(20, 184, 166, 0.3);
}

.login-logo i { font-size: 1.75rem; color: white; }

/* ========== CARDS & TABLES ========== */
.card { margin-bottom: 1rem; border-radius: 10px; }
.card-header { padding: 0.85rem 1rem; }
.card-body { padding: 1rem; }
.table-responsive { -webkit-overflow-scrolling: touch; }
.table th, .table td { padding: 0.65rem 0.75rem; vertical-align: middle; }

/* ========== ALERTS ========== */
.alert { padding: 0.75rem 1rem; font-size: 0.875rem; border-radius: 8px; }
.alert .btn-sm { white-space: nowrap; }


/* ========== RESPONSIVE - TABLET (992px) ========== */
@media (max-width: 992px) {
    .sidebar { 
        transform: translateX(-100%); 
        width: 280px;
    }
    .sidebar.show { transform: translateX(0); }
    .sidebar-close { 
        display: flex !important; 
        align-items: center;
        justify-content: center;
    }
    .sidebar-nav {
        max-height: calc(100vh - 120px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 1.5rem;
    }
    .main-content { margin-left: 0; }
    .mobile-menu-toggle { display: flex; align-items: center; justify-content: center; }
    
    .cart-section { width: 300px; }
    .product-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
}

/* ========== RESPONSIVE - MOBILE (768px) ========== */
@media (max-width: 768px) {
    /* Page Layout */
    .container-fluid { padding: 0.75rem !important; }
    .page-body { padding: 0; }
    
    /* Page Header */
    .page-header { margin-bottom: 1rem !important; }
    .page-header .row { flex-direction: column; gap: 0.75rem; }
    .page-header .col-auto.ms-auto { margin-left: 0 !important; width: 100%; }
    .page-header .btn { width: 100%; }
    .page-header h2 { font-size: 1.15rem; }
    .page-header .text-muted { font-size: 0.8rem; }
    
    /* Dashboard Stat Cards - 2x2 Grid */
    .row-deck.row-cards.mb-3 {
        display: flex !important;
        flex-wrap: wrap !important;
        margin: 0 -0.25rem !important;
    }
    .row-deck.row-cards.mb-3 > .col-6 {
        flex: 0 0 50% !important;
        max-width: 50% !important;
        padding: 0.25rem !important;
    }
    .stat-card {
        padding: 0.75rem;
        height: 100%;
        min-height: 85px;
    }
    .stat-card .h2 { 
        font-size: 1.05rem; 
        margin-bottom: 0 !important;
    }
    .stat-card .small { 
        font-size: 0.6rem; 
        line-height: 1.2;
    }
    .stat-card .text-uppercase {
        font-size: 0.55rem !important;
    }
    .stat-card i { 
        font-size: 1.4rem !important; 
    }
    .stat-card .ms-2 {
        margin-left: 0.25rem !important;
    }
    
    /* POS Layout - Mobile First */
    .pos-container { 
        flex-direction: column; 
        height: auto; 
        min-height: calc(100vh - 60px);
        overflow: visible;
    }
    .products-section { 
        padding: 0.5rem; 
        min-height: auto;
        max-height: none;
        overflow-y: visible;
        flex-shrink: 0;
    }
    .products-section .row.g-3 { 
        margin-bottom: 0.5rem !important;
        display: flex !important;
        flex-wrap: wrap !important;
    }
    .products-section .row.g-3 > [class*="col-md"] {
        flex: 0 0 50% !important;
        max-width: 50% !important;
        padding: 0.2rem !important;
    }
    .products-section .row.g-3 > .col-md-1 {
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }
    .products-section .row.g-3 > .col-md-1 .btn {
        width: 100%;
    }
    .products-section .form-control,
    .products-section .form-select {
        font-size: 14px;
        padding: 0.4rem 0.6rem;
    }
    .products-section .input-icon-addon { padding: 0 0.5rem; }
    .products-section .input-icon-addon i { font-size: 0.9rem; }
    .cart-section { 
        width: 100%; 
        border-left: none; 
        border-top: 2px solid #14B8A6;
        max-height: none;
        flex-shrink: 0;
    }
    .cart-header { padding: 0.5rem 0.75rem; }
    .cart-header h4 { font-size: 0.95rem; }
    .cart-items { 
        max-height: 180px; 
        overflow-y: auto; 
        -webkit-overflow-scrolling: touch;
    }
    .cart-item { padding: 0.5rem; font-size: 0.85rem; }
    .cart-item .fw-medium { font-size: 0.8rem; }
    .cart-item .text-muted { font-size: 0.7rem; }
    .cart-item .btn-sm { padding: 0.15rem 0.35rem; font-size: 0.7rem; }
    .cart-footer { padding: 0.5rem 0.75rem; }
    .cart-footer .h4 { font-size: 1rem; }
    .cart-footer .mb-2 { margin-bottom: 0.35rem !important; }
    .cart-footer .mb-3 { margin-bottom: 0.5rem !important; }
    .cart-footer .form-label { font-size: 0.7rem; margin-bottom: 0.15rem; }
    .cart-footer .form-select,
    .cart-footer .form-control { font-size: 13px; padding: 0.35rem 0.5rem; }
    .cart-footer .btn { font-size: 0.85rem; padding: 0.5rem; }
    .cart-footer .input-group-sm .form-control { font-size: 13px; }
    .cart-footer .input-group-sm .form-select { font-size: 13px; }
    
    .product-grid { grid-template-columns: repeat(3, 1fr); gap: 0.4rem; }
    .product-card { padding: 0.5rem; min-height: auto; }
    .product-card .icon { font-size: 1.2rem; margin-bottom: 0.2rem; }
    .product-card .fw-medium { font-size: 0.65rem; line-height: 1.1; }
    .product-card .text-muted { font-size: 0.55rem; margin-bottom: 0.15rem !important; }
    .product-card .text-primary { font-size: 0.7rem; }
    
    /* Cards */
    .card { margin-bottom: 0.75rem; }
    .card-header { padding: 0.65rem 0.85rem; }
    .card-header .card-title { font-size: 0.9rem; }
    .card-body { padding: 0.75rem; }
    
    /* Keep card rows horizontal - 2 columns minimum */
    .row.row-cards > [class*="col-sm-6"],
    .row.row-cards > [class*="col-md-6"],
    .row.row-cards > [class*="col-lg-3"],
    .row.row-cards > [class*="col-lg-4"],
    .row.row-cards > [class*="col-lg-6"] {
        flex: 0 0 50% !important;
        max-width: 50% !important;
    }
    .row.row-cards {
        display: flex !important;
        flex-wrap: wrap !important;
    }
    
    /* Stats cards always 2 columns */
    .row-deck > [class*="col-"] {
        flex: 0 0 50% !important;
        max-width: 50% !important;
        padding: 0.25rem !important;
    }
    
    /* Tables - Horizontal scroll */
    .table-responsive { 
        margin: 0 -0.75rem;
        padding: 0 0.75rem;
        overflow-x: auto;
    }
    .table { min-width: 600px; }
    .table th, .table td { padding: 0.5rem; font-size: 0.8rem; white-space: nowrap; }
    .table .badge { font-size: 0.65rem; padding: 0.2rem 0.4rem; }
    .table .btn-sm { padding: 0.25rem 0.4rem; font-size: 0.7rem; }
    
    /* Quick Actions */
    .card-body .d-flex.flex-wrap.gap-2 { 
        display: grid !important; 
        grid-template-columns: repeat(2, 1fr); 
        gap: 0.5rem !important; 
    }
    .card-body .d-flex.flex-wrap.gap-2 .btn { 
        font-size: 0.75rem; 
        padding: 0.5rem;
        white-space: nowrap;
    }
    
    /* Alerts */
    .alert { 
        flex-direction: column; 
        text-align: center; 
        gap: 0.5rem;
    }
    .alert .flex-fill { margin-bottom: 0.5rem; }
    .alert i { margin: 0 0 0.25rem 0 !important; }
    
    /* Navbar */
    .navbar { padding: 0.5rem 0.75rem; }
    .navbar-brand { font-size: 0.95rem; max-width: 150px; overflow: hidden; text-overflow: ellipsis; }
    .avatar-sm { width: 32px; height: 32px; font-size: 0.75rem; }
    
    /* Forms */
    .form-control, .form-select { font-size: 16px; padding: 0.5rem 0.75rem; } /* 16px prevents iOS zoom */
    .btn { font-size: 0.875rem; padding: 0.5rem 0.85rem; }
    .btn-sm { font-size: 0.75rem; padding: 0.35rem 0.6rem; }
    .input-group { flex-wrap: nowrap; }
    .input-group .form-control { min-width: 0; }
    
    /* Modals */
    .modal-dialog { margin: 0.5rem; max-width: calc(100% - 1rem); }
    .modal-header, .modal-footer { padding: 0.75rem; }
    .modal-body { padding: 0.75rem; }
    .modal-title { font-size: 1rem; }
    
    /* List Groups */
    .list-group-item { padding: 0.65rem 0.85rem; }
    
    /* Settings Page */
    .col-lg-6 { margin-bottom: 0.5rem; }
    
    /* Reports/Analytics Charts */
    canvas { max-height: 250px !important; }
    
    /* Hide on mobile */
    .hide-mobile, .d-none-mobile { display: none !important; }
    
    /* Show on mobile */
    .show-mobile { display: block !important; }
    
    /* Button groups on mobile */
    .btn-group { flex-wrap: wrap; }
    .btn-group .btn { flex: 1 1 auto; }
    
    /* Dropdown menus */
    .dropdown-menu { font-size: 0.875rem; }
    .dropdown-item { padding: 0.5rem 1rem; }
}

/* ========== RESPONSIVE - SMALL MOBILE (480px) ========== */
@media (max-width: 480px) {
    .product-grid { grid-template-columns: repeat(2, 1fr); }
    
    /* Stat cards on small mobile */
    .stat-card { 
        padding: 0.6rem; 
        min-height: 75px;
    }
    .stat-card .h2 { font-size: 0.9rem; }
    .stat-card .small { font-size: 0.5rem; }
    .stat-card .text-uppercase { font-size: 0.5rem !important; }
    .stat-card i { font-size: 1.2rem !important; }
    
    /* Login on mobile */
    .login-wrapper { padding: 0.75rem; }
    .login-card { 
        padding: 1rem; 
        max-width: 320px;
        border-radius: 12px;
    }
    .login-card .mb-3 { margin-bottom: 0.75rem !important; }
    .login-card .mb-4 { margin-bottom: 1rem !important; }
    .login-card .form-label { font-size: 0.85rem; }
    .login-card .form-control { padding: 0.5rem 0.75rem; }
    .login-logo { width: 56px; height: 56px; }
    .login-logo-img { max-width: 50px; max-height: 45px; display: block !important; margin: 0 auto; }
    .login-card h2 { font-size: 1rem; margin-bottom: 0.25rem !important; }
    .login-card p.text-muted { font-size: 0.75rem; margin-bottom: 1rem !important; }
    
    /* Sidebar on mobile */
    .sidebar { width: 85vw; max-width: 260px; }
    .sidebar-brand { padding: 0.6rem; }
    .sidebar-brand i { font-size: 1.5rem; }
    .sidebar-brand h5 { font-size: 0.8rem; display: block !important; margin-top: 0.25rem; }
    .sidebar-brand small { display: block !important; font-size: 0.6rem; }
    .sidebar-logo { max-width: 45px; max-height: 38px; display: block !important; margin: 0 auto; }
    .sidebar-close { 
        display: flex !important; 
        width: 30px; 
        height: 30px;
        top: 0.5rem;
        right: 0.5rem;
    }
    .sidebar-nav {
        max-height: calc(100vh - 100px);
        overflow-y: auto;
        padding: 0.5rem;
        padding-bottom: 2rem;
    }
    .nav-item { margin-bottom: 0.1rem; }
    .nav-link { padding: 0.5rem 0.65rem; font-size: 0.8rem; }
    .nav-link i { font-size: 0.95rem; width: 20px; margin-right: 0.5rem; }
    
    .card-body .d-flex.flex-wrap.gap-2 { 
        grid-template-columns: repeat(2, 1fr); 
    }
    
    /* Keep cards in 2 columns on small mobile */
    .row.row-cards > [class*="col-"],
    .row-deck > [class*="col-"] {
        flex: 0 0 50% !important;
        max-width: 50% !important;
    }
    
    .table th, .table td { padding: 0.4rem; font-size: 0.75rem; }
    
    /* POS on small screens */
    .pos-container { overflow-y: auto; }
    .products-section { 
        min-height: auto; 
        max-height: none; 
        padding: 0.4rem;
    }
    .product-grid { grid-template-columns: repeat(2, 1fr); gap: 0.35rem; }
    .product-card { padding: 0.4rem; }
    .product-card .icon { font-size: 1rem; }
    .product-card .fw-medium { font-size: 0.6rem; }
    .product-card .text-muted { font-size: 0.5rem; }
    .product-card .text-primary { font-size: 0.65rem; }
    .cart-items { max-height: 150px; }
    .cart-footer { padding: 0.4rem 0.5rem; }
    .cart-footer .mb-2 { margin-bottom: 0.25rem !important; }
    .cart-footer .mb-3 { margin-bottom: 0.4rem !important; }
    .cart-footer .form-label { font-size: 0.65rem; }
    .cart-footer .form-select,
    .cart-footer .form-control { font-size: 12px; padding: 0.3rem 0.4rem; }
    .cart-footer .btn { font-size: 0.8rem; padding: 0.4rem; }
    .cart-footer .h4 { font-size: 0.9rem; }
    .cart-footer #discountToggle { font-size: 0.7rem; padding: 0.25rem 0.4rem; }
    .cart-footer .input-group-sm .form-control,
    .cart-footer .input-group-sm .form-select { font-size: 12px; }
    
    /* M-Pesa options on mobile */
    #mpesaOptions { margin-bottom: 0.3rem; }
    #mpesaOptions .mb-2 { margin-bottom: 0.25rem !important; }
    #mpesaOptions .form-control { font-size: 12px; padding: 0.3rem 0.4rem; }
    #mpesaOptions .btn { font-size: 0.75rem; padding: 0.35rem 0.5rem; }
    #mpesaOptions .d-flex.gap-2 { gap: 0.25rem !important; }
    #stkStatus { font-size: 0.7rem; }
    
    /* Page headers */
    .page-header h2 { font-size: 1rem; }
    
    /* Buttons stack on very small screens */
    .d-flex.gap-2 { flex-wrap: wrap; }
    .d-flex.gap-2 > .btn { flex: 1 1 100%; }
    
    /* M-Pesa options */
    #mpesaOptions .btn { font-size: 0.8rem; padding: 0.4rem 0.6rem; }
    #stkStatus { font-size: 0.75rem; }
}

/* ========== RESPONSIVE - EXTRA SMALL (360px) ========== */
@media (max-width: 360px) {
    .container-fluid { padding: 0.35rem !important; }
    
    /* POS on extra small */
    .products-section { padding: 0.3rem; }
    .products-section .row.g-3 { margin-bottom: 0.3rem !important; }
    .products-section .form-control,
    .products-section .form-select { font-size: 12px; padding: 0.3rem 0.4rem; }
    .product-grid { grid-template-columns: repeat(2, 1fr); gap: 0.25rem; }
    .product-card { padding: 0.35rem; }
    .product-card .icon { font-size: 0.9rem; margin-bottom: 0.1rem; }
    .product-card .fw-medium { font-size: 0.55rem; }
    .product-card .text-muted { font-size: 0.45rem; }
    .product-card .text-primary { font-size: 0.6rem; }
    
    .cart-header { padding: 0.4rem 0.5rem; }
    .cart-header h4 { font-size: 0.85rem; }
    .cart-items { max-height: 130px; }
    .cart-item { padding: 0.35rem; font-size: 0.75rem; }
    .cart-footer { padding: 0.35rem 0.4rem; }
    .cart-footer .h4 { font-size: 0.85rem; }
    .cart-footer .form-label { font-size: 0.6rem; }
    .cart-footer .form-select,
    .cart-footer .form-control { font-size: 11px; padding: 0.25rem 0.35rem; }
    .cart-footer .btn { font-size: 0.75rem; padding: 0.35rem; }
    .cart-footer #discountToggle { font-size: 0.65rem; padding: 0.2rem 0.35rem; }
    
    .btn { padding: 0.35rem 0.5rem; font-size: 0.75rem; }
    
    /* Stat cards on extra small */
    .stat-card { 
        padding: 0.5rem; 
        min-height: 65px;
    }
    .stat-card .h2 { font-size: 0.8rem; }
    .stat-card .small { font-size: 0.45rem; }
    .stat-card .text-uppercase { font-size: 0.4rem !important; }
    .stat-card i { font-size: 1rem !important; }
    
    /* Sidebar on extra small */
    .sidebar { width: 80vw; max-width: 240px; }
    .sidebar-brand { padding: 0.4rem; }
    .sidebar-brand h5 { font-size: 0.7rem; }
    .sidebar-brand small { font-size: 0.5rem; }
    .sidebar-logo { max-width: 35px; max-height: 30px; }
    .sidebar-close { display: flex !important; width: 26px; height: 26px; top: 0.4rem; right: 0.4rem; }
    .sidebar-nav { padding: 0.4rem; max-height: calc(100vh - 85px); }
    .nav-link { padding: 0.45rem 0.5rem; font-size: 0.75rem; }
    .nav-link i { font-size: 0.9rem; width: 18px; margin-right: 0.4rem; }
    
    /* Login on extra small */
    .login-wrapper { padding: 0.5rem; }
    .login-card { 
        padding: 0.85rem; 
        max-width: 290px;
        border-radius: 10px;
    }
    .login-logo-img { max-width: 40px; max-height: 38px; }
    .login-card h2 { font-size: 0.9rem; }
    .login-card p.text-muted { font-size: 0.7rem; }
    .login-card .form-label { font-size: 0.8rem; }
    .login-card .form-control { padding: 0.4rem 0.6rem; font-size: 14px !important; }
    .login-card .btn { padding: 0.5rem; font-size: 0.85rem; }
}

/* ========== UTILITY CLASSES ========== */
.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Smooth scrolling */
html { scroll-behavior: smooth; }

/* Better touch targets */
@media (pointer: coarse) {
    .btn, .nav-link, .dropdown-item { min-height: 44px; }
    .product-card { min-height: 80px; }
    .form-control, .form-select { min-height: 44px; }
}

/* ========== LANDSCAPE MOBILE ========== */
@media (max-height: 500px) and (orientation: landscape) {
    .pos-container { flex-direction: row; height: calc(100vh - 50px); }
    .products-section { flex: 1; max-height: none; min-height: auto; }
    .cart-section { width: 280px; border-top: none; border-left: 2px solid #14B8A6; }
    .cart-items { max-height: calc(100vh - 280px); }
    .product-grid { grid-template-columns: repeat(4, 1fr); }
    
    .sidebar { height: 100vh; }
    .login-wrapper { padding: 0.5rem; }
    .login-card { padding: 1rem; }
}

/* ========== PRINT STYLES ========== */
@media print {
    .sidebar, .navbar, .mobile-menu-toggle, .btn, .no-print { display: none !important; }
    .main-content { margin-left: 0 !important; }
    .card { break-inside: avoid; box-shadow: none; border: 1px solid #ddd; }
}

/* ========== ANIMATIONS ========== */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.animate-spin { animation: spin 1s linear infinite; }

/* Pulse animation for loading states */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.animate-pulse { animation: pulse 2s ease-in-out infinite; }

/* ========== SAFE AREA (NOTCH PHONES) ========== */
@supports (padding: max(0px)) {
    .sidebar { padding-top: max(0px, env(safe-area-inset-top)); }
    .navbar { padding-top: max(0.5rem, env(safe-area-inset-top)); }
    .cart-footer { padding-bottom: max(1rem, env(safe-area-inset-bottom)); }
}

/* ========== DARK MODE SUPPORT (Optional) ========== */
@media (prefers-color-scheme: dark) {
    /* Can be enabled later if needed */
}


/* ========== ADDITIONAL MOBILE IMPROVEMENTS ========== */

/* Better scrolling on iOS */
.cart-items, .products-section, .table-responsive {
    -webkit-overflow-scrolling: touch;
}

/* Prevent text selection on buttons */
.btn, .product-card, .nav-link {
    -webkit-user-select: none;
    user-select: none;
}

/* Fix input zoom on iOS */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="number"],
select,
textarea {
    font-size: 16px !important;
}

/* Better focus states for accessibility */
.btn:focus, .form-control:focus, .form-select:focus, .nav-link:focus {
    outline: 2px solid #14B8A6;
    outline-offset: 2px;
}

/* Loading overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

/* Mobile-friendly badges */
@media (max-width: 768px) {
    .badge { 
        font-size: 0.65rem; 
        padding: 0.2rem 0.4rem;
        white-space: nowrap;
    }
    
    /* Stack action buttons in tables */
    .table .btn-group {
        display: flex;
        flex-direction: column;
        gap: 0.25rem;
    }
    .table .btn-group .btn {
        border-radius: 4px !important;
    }
    
    /* Better spacing for form rows */
    .row.g-3 > [class*="col-"] {
        margin-bottom: 0.5rem;
    }
    
    /* Full width inputs on mobile */
    .input-icon { width: 100%; }
    
    /* Receipt modal on mobile */
    .modal-sm { max-width: 100%; }
    
    /* Footer on mobile */
    .footer-watermark {
        font-size: 0.7rem;
        padding: 0.5rem;
    }
}

/* Swipe hint for tables */
.table-responsive::after {
    content: '';
    display: none;
}

@media (max-width: 768px) {
    .table-responsive {
        position: relative;
    }
    .table-responsive.has-scroll::after {
        content: '← Swipe →';
        position: absolute;
        bottom: 0;
        left: 50%;
        transform: translateX(-50%);
        background: rgba(0,0,0,0.6);
        color: white;
        padding: 0.25rem 0.75rem;
        border-radius: 12px;
        font-size: 0.7rem;
        pointer-events: none;
        opacity: 0;
        animation: fadeInOut 3s ease-in-out;
    }
}

@keyframes fadeInOut {
    0%, 100% { opacity: 0; }
    20%, 80% { opacity: 1; }
}

/* Floating action button for mobile POS */
@media (max-width: 768px) {
    .fab-cart {
        position: fixed;
        bottom: 20px;
        right: 20px;
        width: 56px;
        height: 56px;
        border-radius: 50%;
        background: linear-gradient(135deg, #14B8A6, #0D9488);
        color: white;
        border: none;
        box-shadow: 0 4px 12px rgba(20, 184, 166, 0.4);
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.5rem;
        z-index: 1000;
    }
    .fab-cart .badge {
        position: absolute;
        top: -5px;
        right: -5px;
        background: #EF4444;
        min-width: 22px;
        height: 22px;
        border-radius: 50%;
        font-size: 0.75rem;
    }
}

/* Better empty states */
.empty-state {
    text-align: center;
    padding: 2rem 1rem;
    color: #6c757d;
}
.empty-state i {
    font-size: 3rem;
    opacity: 0.3;
    margin-bottom: 1rem;
}

@media (max-width: 480px) {
    .empty-state { padding: 1.5rem 0.75rem; }
    .empty-state i { font-size: 2.5rem; }
}

/* ========== DASHBOARD SPECIFIC MOBILE STYLES ========== */
@media (max-width: 768px) {
    /* Quick Actions - 2x2 Grid */
    .card-body .row.g-2 {
        display: flex !important;
        flex-wrap: wrap !important;
        margin: 0 -0.25rem !important;
    }
    .card-body .row.g-2 > [class*="col-"] {
        flex: 0 0 50% !important;
        max-width: 50% !important;
        padding: 0.25rem !important;
    }
    .card-body .row.g-2 .btn {
        width: 100%;
        padding: 0.5rem;
        font-size: 0.8rem;
    }
}
