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

.week-navigation {
    margin: 20px 0;
    display: flex;
    justify-content: center;
    align-items: center;
}

.card {
    border: none;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.1);
    border-radius: 10px;
}

.card-header {
    font-weight: 600;
    padding: 1rem 1.25rem;
}

.list-group-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.25rem;
    border-left: none;
    border-right: none;
    border-color: rgba(0, 0, 0, 0.05);
}

.list-group-item:first-child {
    border-top: none;
}

.list-group-item:last-child {
    border-bottom: none;
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

.btn-outline-primary {
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

#currentWeek {
    min-width: 200px;
    display: inline-block;
}

.input-group {
    margin-bottom: 1rem;
}

.btn-export {
    margin: 0 5px;
    min-width: 160px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .col-md-6 {
        margin-bottom: 1.5rem;
    }
    
    .week-navigation {
        flex-direction: column;
        gap: 10px;
    }
    
    #currentWeek {
        margin: 10px 0;
    }
}

/* Animation for list items */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.list-group-item {
    animation: fadeIn 0.3s ease-out;
}

/* Hover effects */
.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Card body max height with scroll - desktop responsive */
.card-body {
    max-height: calc(100vh - 300px);
    min-height: 400px;
    overflow-y: auto;
}

/* Desktop layout improvements */
@media (min-width: 1201px) {
    .container {
        max-width: 1200px;
        margin: 0 auto;
    }
    
    .card-body {
        max-height: calc(100vh - 280px);
    }
}

/* Tablet vertical orientation - simplified approach */
@media (max-width: 1200px) {
    body {
        height: 100vh;
        overflow: hidden;
        margin: 0;
        padding: 0;
    }
    
    .container {
        height: 100vh;
        padding: 5px;
        display: flex;
        flex-direction: column;
    }
    
    /* Ensure button container is visible */
    .print-hide {
        position: fixed;
        bottom: 5px;
        left: 50%;
        transform: translateX(-50%);
        background: white;
        padding: 5px;
        border-radius: 3px;
        box-shadow: 0 1px 5px rgba(0,0,0,0.1);
        z-index: 1000;
        display: flex;
        gap: 3px;
    }
    
    /* Make buttons smaller */
    .print-hide .btn {
        font-size: 0.7rem;
        padding: 0.25rem 0.5rem;
    }
    
    /* Ensure buttons are visible */
    .print-hide .btn {
        display: inline-block;
    }
    
    /* Direct button targeting */
    #exportExcel, #emailExport, #printList, #resetData {
        display: inline-block;
        visibility: visible;
    }
    
    header {
        flex-shrink: 0;
    }
    
    .week-navigation {
        margin: 5px 0;
    }
    
    .row {
        flex: 1;
        margin: 0;
        min-height: 0;
    }
    
    .col-12 {
        height: 100%;
        padding: 0;
    }
    
    .card {
        height: 100%;
        display: flex;
        flex-direction: column;
        margin: 0;
        overflow: visible !important;
    }
    
    .card-header {
        flex-shrink: 0;
    }
    
    .card-body {
        flex: 1;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
        padding: 0.5rem;
    }
    
    .table {
        font-size: 0.85rem;
    }
    
    .quantity-input {
        width: 60px;
        font-size: 0.8rem;
    }
    
    .btn {
        font-size: 0.8rem;
    }
    
    .text-center {
        margin: 5px 0;
    }
}

/* Mobile-first responsive design - Small phones */
@media (max-width: 480px) {
    body {
        height: 100vh;
        overflow: hidden;
        margin: 0;
        padding: 0;
        font-size: 14px;
    }
    
    .container {
        height: 100vh;
        padding: 2px;
        display: flex;
        flex-direction: column;
    }
    
    /* Header adjustments */
    header {
        flex-shrink: 0;
        padding: 5px 0;
    }
    
    h1 {
        font-size: 1.2rem !important;
        margin: 5px 0 !important;
    }
    
    .week-navigation {
        margin: 5px 0;
        flex-direction: column;
        gap: 8px;
    }
    
    #currentWeek {
        font-size: 0.9rem;
        min-width: auto;
        margin: 0;
    }
    
    .btn-outline-primary {
        width: 35px;
        height: 35px;
        font-size: 0.8rem;
    }
    
    /* Card adjustments */
    .row {
        flex: 1;
        margin: 0;
        min-height: 0;
    }
    
    .col-12 {
        height: 100%;
        padding: 0;
    }
    
    .card {
        height: 100%;
        display: flex;
        flex-direction: column;
        margin: 0;
        overflow: visible !important;
        border-radius: 5px;
    }
    
    .card-header {
        flex-shrink: 0;
        padding: 8px 12px !important;
    }
    
    .card-header h4 {
        font-size: 0.9rem !important;
        margin: 0;
    }
    
    .card-header .btn {
        font-size: 0.7rem !important;
        padding: 0.2rem 0.4rem !important;
    }
    
    .card-body {
        flex: 1;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
        padding: 0.2rem;
    }
    
    /* Table adjustments */
    .table {
        font-size: 0.7rem;
        margin: 0;
    }
    
    .table th {
        padding: 4px 2px !important;
        font-size: 0.65rem;
        font-weight: 600;
    }
    
    .table td {
        padding: 3px 2px !important;
        vertical-align: middle;
    }
    
    /* Input adjustments */
    .quantity-input {
        width: 45px;
        font-size: 0.65rem;
        padding: 1px 3px;
        text-align: center;
        height: 24px;
    }
    
    .item-name {
        font-size: 0.65rem;
        line-height: 1.2;
        max-width: 80px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        display: inline-block;
    }
    
    /* Button adjustments */
    .btn {
        font-size: 0.65rem;
        padding: 0.15rem 0.3rem;
        min-height: 24px;
    }
    
    .btn-sm {
        padding: 0.1rem 0.25rem;
        font-size: 0.6rem;
    }
    
    /* Action buttons in table */
    .btn-edit {
        padding: 0.1rem 0.2rem !important;
        font-size: 0.6rem !important;
        min-width: 24px;
        min-height: 24px;
    }
    
    /* Fixed button container at bottom */
    .print-hide {
        position: fixed;
        bottom: 2px;
        left: 50%;
        transform: translateX(-50%);
        background: white;
        padding: 3px;
        border-radius: 3px;
        box-shadow: 0 1px 3px rgba(0,0,0,0.2);
        z-index: 1000;
        display: flex;
        gap: 2px;
        max-width: 95vw;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .print-hide .btn {
        font-size: 0.6rem;
        padding: 0.15rem 0.3rem;
        min-width: auto;
        white-space: nowrap;
    }
    
    /* Ensure buttons are visible */
    .print-hide .btn {
        display: inline-block;
    }
    
    #exportExcel, #emailExport, #printList, #resetData {
        display: inline-block;
        visibility: visible;
    }
}

/* Mobile portrait orientation - Medium phones */
@media (max-width: 768px) and (orientation: portrait) {
    body {
        height: 100vh;
        overflow: hidden;
        margin: 0;
        padding: 0;
    }
    
    .container {
        height: 100vh;
        padding: 3px;
        display: flex;
        flex-direction: column;
    }
    
    header {
        flex-shrink: 0;
    }
    
    .week-navigation {
        margin: 3px 0;
        flex-direction: column;
        gap: 8px;
    }
    
    .row {
        flex: 1;
        margin: 0;
        min-height: 0;
    }
    
    .col-12 {
        height: 100%;
        padding: 0;
    }
    
    .card {
        height: 100%;
        display: flex;
        flex-direction: column;
        margin: 0;
        overflow: visible !important;
    }
    
    .card-header {
        flex-shrink: 0;
    }
    
    .card-body {
        flex: 1;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
        padding: 0.3rem;
    }
    
    .table {
        font-size: 0.75rem;
    }
    
    .quantity-input {
        width: 50px;
        font-size: 0.7rem;
    }
    
    .btn {
        font-size: 0.7rem;
    }
    
    .item-name {
        max-width: 120px;
    }
    
    .print-hide {
        position: fixed;
        bottom: 3px;
        left: 50%;
        transform: translateX(-50%);
        background: white;
        padding: 4px;
        border-radius: 3px;
        box-shadow: 0 1px 5px rgba(0,0,0,0.1);
        z-index: 1000;
        display: flex;
        gap: 3px;
        max-width: 90vw;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* Fallback removed - simplified tablet approach covers all cases */

/* Mobile landscape orientation */
@media (max-width: 768px) and (orientation: landscape) {
    body {
        height: 100vh;
        overflow: hidden;
        margin: 0;
        padding: 0;
    }
    
    .container {
        height: 100vh;
        padding: 3px;
        display: flex;
        flex-direction: column;
    }
    
    header {
        flex-shrink: 0;
    }
    
    .week-navigation {
        margin: 3px 0;
        flex-direction: row;
        gap: 10px;
    }
    
    .card {
        height: 100%;
        display: flex;
        flex-direction: column;
        margin: 0;
        overflow: visible !important;
    }
    
    .card-body {
        flex: 1;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
        max-height: calc(100vh - 120px);
        padding: 0.3rem;
    }
    
    .table {
        font-size: 0.7rem;
    }
    
    .quantity-input {
        width: 50px;
        font-size: 0.7rem;
    }
    
    .print-hide {
        position: fixed;
        bottom: 3px;
        left: 50%;
        transform: translateX(-50%);
        background: white;
        padding: 4px;
        border-radius: 3px;
        box-shadow: 0 1px 5px rgba(0,0,0,0.1);
        z-index: 1000;
        display: flex;
        gap: 3px;
        max-width: 90vw;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    /* Increase touch targets for mobile devices */
    .btn {
        min-height: 32px;
        min-width: 32px;
        padding: 0.3rem 0.6rem;
    }
    
    .btn-outline-primary {
        width: 40px;
        height: 40px;
    }
    
    .quantity-input {
        min-height: 32px;
        min-width: 50px;
        font-size: 0.8rem;
    }
    
    .table td {
        padding: 6px 4px !important;
    }
    
    .print-hide .btn {
        min-height: 28px;
        min-width: 60px;
        padding: 0.3rem 0.5rem;
    }
    
    /* Improve scroll indicators */
    .card-body::-webkit-scrollbar {
        width: 6px;
        height: 6px;
    }
    
    .card-body::-webkit-scrollbar-thumb {
        background: rgba(0, 0, 0, 0.3);
        border-radius: 3px;
    }
    
    /* Better focus states for keyboard navigation */
    .quantity-input:focus,
    .btn:focus {
        outline: 2px solid #007bff;
        outline-offset: 2px;
    }
}

/* Extra small devices (very small phones) */
@media (max-width: 320px) {
    body {
        font-size: 12px;
    }
    
    h1 {
        font-size: 1rem !important;
    }
    
    .week-navigation h3 {
        font-size: 0.8rem !important;
    }
    
    .table {
        font-size: 0.6rem;
    }
    
    .table th {
        font-size: 0.55rem !important;
        padding: 2px 1px !important;
    }
    
    .table td {
        font-size: 0.55rem !important;
        padding: 2px 1px !important;
    }
    
    .quantity-input {
        width: 35px;
        font-size: 0.6rem;
        height: 20px;
        padding: 1px 2px;
    }
    
    .item-name {
        max-width: 60px;
        font-size: 0.6rem;
    }
    
    .btn {
        font-size: 0.55rem;
        padding: 0.1rem 0.2rem;
        min-height: 20px;
    }
    
    .btn-edit {
        min-width: 20px;
        min-height: 20px;
        font-size: 0.55rem !important;
    }
    
    .print-hide .btn {
        font-size: 0.55rem;
        padding: 0.1rem 0.2rem;
        min-width: 50px;
    }
}

/* Print Styles - Only apply during actual printing */
@media print {
    /* Hide unnecessary elements only during printing */
    body {
        background: white !important;
        color: black !important;
    }
    
    .container {
        max-width: none !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }
    
    header {
        margin-bottom: 20px !important;
    }
    
    h1 {
        font-size: 24px !important;
        color: black !important;
        margin-bottom: 10px !important;
    }
    
    .week-navigation {
        margin-bottom: 20px !important;
        font-size: 16px !important;
        font-weight: bold !important;
    }
    
    .card {
        box-shadow: none !important;
        border: 1px solid #ccc !important;
        border-radius: 0 !important;
    }
    
    .card-header {
        background: #f8f9fa !important;
        color: black !important;
        border-bottom: 2px solid #ccc !important;
        font-weight: bold !important;
    }
    
    .card-body {
        overflow: visible !important;
        max-height: none !important;
    }
    
    /* Hide action buttons and other interactive elements */
    .print-hide {
        display: none !important;
    }
    
    .btn-edit {
        display: none !important;
    }
    
    /* Table styling for print */
    .table {
        font-size: 12px !important;
        border-collapse: collapse !important;
        width: 100% !important;
    }
    
    .table th {
        background: #f8f9fa !important;
        color: black !important;
        border: 1px solid #ccc !important;
        padding: 8px !important;
        text-align: center !important;
        font-weight: bold !important;
    }
    
    .table td {
        border: 1px solid #ccc !important;
        padding: 6px 8px !important;
        vertical-align: middle !important;
    }
    
    .item-name {
        font-weight: normal !important;
        color: black !important;
    }
    
    .quantity-input {
        border: none !important;
        background: transparent !important;
        color: black !important;
        font-weight: bold !important;
        text-align: center !important;
        width: 100% !important;
        font-size: 14px !important;
    }
    
    /* Ensure all rows are visible */
    tr {
        page-break-inside: avoid !important;
    }
    
    /* Add print header with date */
    body::before {
        content: 'Inventory List - Printed on: ' attr(data-print-date) !important;
        display: block !important;
        text-align: center !important;
        font-size: 14px !important;
        margin-bottom: 20px !important;
        font-weight: bold !important;
    }
    
    /* Add footer with page numbers */
    @page {
        margin: 1cm;
        size: auto;
    }
    
    /* Remove any background colors */
    * {
        background: transparent !important;
        color: black !important;
        box-shadow: none !important;
        text-shadow: none !important;
    }
}

/* Table styles */
.table th {
    border-top: none;
    font-weight: 600;
    color: #495057;
}

.table td {
    vertical-align: middle;
}

.quantity-input {
    width: 80px;
    text-align: center;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 0.375rem 0.5rem;
}

.quantity-input:focus {
    border-color: #80bdff;
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.item-name {
    font-weight: 500;
    color: #212529;
}

.item-name.editing {
    background-color: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 4px;
    padding: 0.375rem 0.5rem;
    width: 100%;
}

.btn-edit {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
    margin: 0 2px;
}

/* Responsive table */
@media (max-width: 768px) {
    .table-responsive {
        font-size: 0.875rem;
    }
    
    .quantity-input {
        width: 60px;
    }
    
    .btn-edit {
        padding: 0.2rem 0.4rem;
        font-size: 0.75rem;
    }
}

/* Animation for table rows */
@keyframes fadeInRow {
    from { opacity: 0; transform: translateX(-10px); }
    to { opacity: 1; transform: translateX(0); }
}

.table tbody tr {
    animation: fadeInRow 0.3s ease-out;
}

.table tbody tr:hover {
    background-color: rgba(0, 123, 255, 0.05);
}
