:root {
    --sidebar-width: 260px;
}

/* Ensure proper viewport behavior */
html {
    touch-action: manipulation;
}

* {
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f6fa;
}

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

.sidebar {
    width: var(--sidebar-width);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 1000;
    transition: all 0.3s;
}

.sidebar-header {
    padding: 20px;
    background: rgba(0,0,0,0.2);
    color: white;
    text-align: center;
}

.sidebar-header h4 {
    margin: 0;
    font-weight: 600;
}

/* User Profile Section in Sidebar */
.sidebar-user-profile {
    padding: 20px;
    background: rgba(0,0,0,0.15);
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-user-profile .user-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.2rem;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.sidebar-user-profile .user-info {
    flex: 1;
    min-width: 0;
}

.sidebar-user-profile .user-name {
    color: white;
    font-weight: 600;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-profile .user-role {
    color: rgba(255,255,255,0.7);
    font-size: 0.8rem;
    text-transform: capitalize;
}

/* Responsive adjustments for user profile */
@media (max-width: 991px) {
    .sidebar-user-profile {
        padding: 15px;
    }
    
    .sidebar-user-profile .user-avatar {
        width: 40px;
        height: 40px;
        font-size: 1.1rem;
    }
    
    .sidebar-user-profile .user-name {
        font-size: 0.9rem;
    }
    
    .sidebar-user-profile .user-role {
        font-size: 0.75rem;
    }
}

@media (max-width: 575px) {
    .sidebar-user-profile {
        padding: 12px;
    }
    
    .sidebar-user-profile .user-avatar {
        width: 35px;
        height: 35px;
        font-size: 1rem;
    }
}

.sidebar .nav-link {
    color: rgba(255,255,255,0.8);
    padding: 12px 20px;
    border-left: 3px solid transparent;
    transition: all 0.3s;
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active {
    color: white;
    background: rgba(255,255,255,0.1);
    border-left-color: #fff;
}

.sidebar .nav-link i {
    width: 25px;
}

.sidebar .nav-link .fa-chevron-down {
    float: right;
    margin-top: 5px;
    font-size: 0.8em;
}

.sidebar .nav .nav {
    background: rgba(0,0,0,0.1);
}

.sidebar .nav .nav .nav-link {
    padding-left: 45px;
    font-size: 0.9em;
}

.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
}

.navbar {
    border-bottom: 1px solid #e9ecef;
}

.card {
    border: none;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0,0,0,0.05);
    margin-bottom: 20px;
}

.card-header {
    background: white;
    border-bottom: 1px solid #e9ecef;
    font-weight: 600;
}

.table {
    margin-bottom: 0;
}

.table thead th {
    border-bottom: 2px solid #dee2e6;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.85em;
    color: #6c757d;
}

.btn-primary {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    border: none;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #2a5298 0%, #1e3c72 100%);
}

.badge {
    padding: 5px 10px;
    font-weight: 500;
}

.datatable_length,
.datatable_filter {
    margin-bottom: 15px;
}

.datatable_filter input {
    border: 1px solid #dee2e6;
    border-radius: 5px;
    padding: 5px 10px;
}

.dataTables_wrapper .pagination {
    margin-top: 20px;
}

.receipt {
    max-width: 300px;
    margin: 0 auto;
    padding: 20px;
    background: white;
    border: 1px solid #ddd;
}

.receipt-header,
.receipt-footer {
    text-align: center;
}

.sticky-top {
    top: 20px;
}

.alert {
    border-radius: 10px;
}

.progress {
    border-radius: 10px;
}

/* Responsive Sidebar Styles */
@media (max-width: 991px) {
    .sidebar {
        margin-left: calc(-1 * var(--sidebar-width));
        transition: margin-left 0.3s ease-in-out;
    }
    
    .sidebar.active {
        margin-left: 0;
    }
    
    .main-content {
        margin-left: 0;
        transition: margin-left 0.3s ease-in-out;
    }
    
    .main-content.active {
        margin-left: var(--sidebar-width);
    }
    
    /* Overlay when sidebar is open */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        opacity: 0;
        transition: opacity 0.3s ease-in-out;
    }
    
    .sidebar-overlay.active {
        display: block;
        opacity: 1;
    }
}

/* Mobile-specific adjustments */
@media (max-width: 767px) {
    .container-fluid.p-4 {
        padding: 1rem !important;
    }
    
    .card {
        margin-bottom: 15px;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .table-responsive {
        font-size: 0.875rem;
    }
    
    .btn {
        padding: 0.375rem 0.75rem;
        font-size: 0.875rem;
    }
    
    h1, h2, h3 {
        font-size: 1.5rem;
    }
    
    .sidebar-header h4 {
        font-size: 1.1rem;
    }
    
    .sidebar .nav-link {
        padding: 10px 15px;
        font-size: 0.9rem;
    }
    
    .sidebar .nav-link i {
        width: 20px;
        font-size: 0.9rem;
    }
}

/* Extra small devices */
@media (max-width: 575px) {
    .container-fluid.p-4 {
        padding: 0.75rem !important;
    }
    
    .navbar .container-fluid {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
    
    .card-header {
        padding: 0.75rem 1rem;
    }
    
    .card-body {
        padding: 0.75rem;
    }
    
    .table {
        font-size: 0.8rem;
    }
    
    .btn {
        padding: 0.25rem 0.5rem;
        font-size: 0.8rem;
    }
    
    .btn-sm {
        padding: 0.2rem 0.4rem;
        font-size: 0.75rem;
    }
    
    h1, h2 {
        font-size: 1.25rem;
    }
    
    h3, h4 {
        font-size: 1.1rem;
    }
    
    .form-control, .form-select {
        font-size: 0.9rem;
    }
    
    /* Make tables horizontally scrollable */
    .table-responsive {
        border: 1px solid #dee2e6;
        border-radius: 5px;
    }
    
    /* Compact sidebar for very small screens */
    :root {
        --sidebar-width: 240px;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    .sidebar .nav-link {
        padding: 15px 20px;
    }
    
    .btn {
        min-height: 44px;
    }
    
    .form-control, .form-select {
        min-height: 44px;
    }
    
    .dropdown-item {
        padding: 12px 20px;
    }
}

/* Landscape mode on mobile */
@media (max-width: 991px) and (orientation: landscape) {
    .sidebar {
        overflow-y: auto;
        max-height: 100vh;
    }
    
    .sidebar .nav-link {
        padding: 8px 15px;
    }
}

.table-primary {
    background-color: #e3f2fd !important;
}

.text-primary {
    color: #2a5298 !important;
}

.bg-primary {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%) !important;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    -moz-appearance: textfield;
}

.form-label {
    font-weight: 500;
    color: #495057;
}

.nav-tabs .nav-link {
    border: none;
    color: #6c757d;
}

.nav-tabs .nav-link.active {
    color: #2a5298;
    border-bottom: 2px solid #2a5298;
}

#salesChart, #profitChart, #dailySalesChart, #salesBreakdownChart, #categoryChart {
    max-height: 300px;
}

.print-receipt {
    width: 80mm;
    padding: 10mm;
    margin: 0 auto;
    font-family: 'Courier New', monospace;
    font-size: 12px;
}

@media print {
    .sidebar, .navbar, .btn, .card-header, nav {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0 !important;
    }
    
    .card {
        border: none !important;
        box-shadow: none !important;
    }
    
    .card-body {
        padding: 0 !important;
    }
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #2a5298;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.text-auto-add {
    color: #ccc;
}
