/* Custom CSS for POS System - Modern Theme */

body {
    font-family: 'Poppins', sans-serif;
    background-color: #f8f9fa; /* Lighter background for a cleaner look */
    color: #333;
}

/* --- Base Theme Styles --- */
:root {
    --primary-color: #007bff; /* Bootstrap primary */
    --secondary-color: #6c757d; /* Bootstrap secondary */
    --success-color: #28a745; /* Bootstrap success */
    --danger-color: #dc3545; /* Bootstrap danger */
    --light-gray: #f1f3f5;
    --medium-gray: #dee2e6;
    --dark-gray: #495057;
    --card-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    --card-hover-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
    --border-radius: 0.3rem; /* Softer border radius */
}

/* Ensure product images are a consistent height and fit well */
.card-img-top {
    height: 180px; /* Slightly reduced height */
    object-fit: contain;
    padding: 10px; /* Padding around image */
    background-color: #fff; /* White background for images if they are transparent */
}

.card {
    border: none; /* Remove default card border, use shadow instead */
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
    transition: box-shadow 0.3s ease-in-out;
    margin-bottom: 2rem; /* Increased spacing between cards */
}

.card:hover {
    box-shadow: var(--card-hover-shadow);
}

.card-body {
    padding: 1.5rem; /* Increased padding in card body */
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    min-height: 3.2em; /* Adjust if necessary based on font size */
}

.card-text { /* Used for price */
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

/* Styling for cart items */
.cart-item-name {
    font-size: 0.95rem;
    font-weight: 500;
    /* Allow wrapping for longer names */
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
    max-width: none;
}

.cart-item-quantity input {
    width: 60px; /* Slightly wider */
    text-align: center;
    border-radius: var(--border-radius);
    border: 1px solid var(--medium-gray);
    padding: 0.3rem;
}

/* Sticky panel for cart and totals */
.sticky-top {
    top: 20px;
    background-color: #ffffff; /* Give sticky panel a background */
    padding: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
}

/* Ensure the product grid has some minimum height if empty */
#product-grid:empty::before {
    content: "Loading products...";
    display: block;
    text-align: center;
    padding: 30px 20px; /* Increased padding */
    font-style: italic;
    color: var(--secondary-color);
    font-size: 1.1rem;
}

/* Error message styling */
#error-message-container {
    position: fixed;
    top: 20px; /* More spacing from top */
    left: 50%;
    transform: translateX(-50%);
    z-index: 1050;
    width: auto; /* Adjust width based on content */
    max-width: 500px;
    border-radius: var(--border-radius);
}

/* General Spacing */
.container-fluid {
    padding-left: 30px;
    padding-right: 30px;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600; /* Bolder headings */
}

h2 { /* Section titles like "Products", "Cart" */
    margin-bottom: 1.5rem; /* More space below section titles */
    font-size: 1.75rem;
    color: var(--dark-gray);
}

/* Header Styling */
header.bg-primary {
    background-color: #fff !important; /* Override Bootstrap primary with white */
    color: var(--dark-gray) !important; /* Dark text color */
    padding: 1.5rem 0; /* Increased padding */
    box-shadow: 0 2px 4px rgba(0,0,0,0.05); /* Subtle bottom shadow */
    margin-bottom: 2rem; /* Space below header */
}

header h1 {
    font-size: 2rem; /* Adjust size as needed */
    font-weight: 700; /* Bold title */
    margin-bottom: 0; /* Remove default margin if any */
}

/* Button Styling */
.btn {
    padding: 0.6rem 1.2rem; /* Larger padding for buttons */
    border-radius: var(--border-radius);
    font-weight: 500;
    text-transform: uppercase; /* Optional: for a more styled look */
    letter-spacing: 0.5px; /* Optional */
    transition: background-color 0.2s ease-in-out, box-shadow 0.2s ease-in-out, transform 0.1s ease-in-out;
}

.btn:active {
    transform: translateY(1px); /* Subtle press effect */
}

.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-primary:hover {
    background-color: #0069d9; /* Darker shade of primary */
    border-color: #0062cc;     /* Slightly darker for border */
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.btn-success {
    background-color: var(--success-color);
    border-color: var(--success-color);
}

.btn-success:hover {
    background-color: #218838; /* Darker shade of success */
    border-color: #1e7e34;     /* Slightly darker for border */
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.btn-danger {
    background-color: var(--danger-color);
    border-color: var(--danger-color);
}

.btn-danger:hover {
    background-color: #c82333; /* Darker shade of danger */
    border-color: #bd2130;     /* Slightly darker for border */
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

/* Specific button adjustments if needed */
.card .btn-primary { /* Add to Cart button */
    width: 100%; /* Make button full width of card footer area */
}

/* Cart Panel Styling */
#cart-items .list-group-item {
    padding: 1rem 1.25rem; /* Consistent padding with card body */
    border-bottom: 1px solid var(--light-gray); /* Separator for items */
    border-left: none;
    border-right: none;
    border-top: none;
    border-radius: 0; /* Remove individual item radius if panel has one */
}

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

.cart-item-details { /* Container for name and price */
    flex-grow: 1;
    margin-right: 1rem;
}

small.form-text.text-muted { /* Price per item in cart */
    color: var(--secondary-color) !important;
    font-size: 0.85rem;
}

#cart-empty-message {
    padding: 2rem;
    font-size: 1.1rem;
    color: var(--secondary-color);
}

/* Cart item remove button */
#cart-items .btn-danger {
    padding: 0.25rem 0.5rem; /* Smaller padding for compact button */
    font-size: 0.8rem; /* Smaller font size */
    text-transform: none; /* No uppercase for this small button */
    margin-left: 0.5rem;
}

/* Totals Area Styling */
#totals-area {
    margin-top: 2rem; /* Add space above totals */
    padding: 1.5rem;
    background-color: var(--light-gray); /* Subtle background to differentiate */
    border-radius: var(--border-radius);
}

#totals-area h4 {
    margin-bottom: 1rem; /* Space below "Totals" heading */
    font-size: 1.25rem;
    font-weight: 600;
}

#totals-area .list-group-item {
    background-color: transparent; /* Inherit from parent */
    border-color: var(--medium-gray); /* Softer border color */
    padding: 0.75rem 0; /* Adjust padding, remove horizontal for full width text */
}

#totals-area .list-group-item:first-child {
    border-top: none;
}
#totals-area .list-group-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}


#totals-area .font-weight-bold span { /* Total amount */
    font-size: 1.3rem;
    color: var(--primary-color);
}

/* Checkout Button Styling */
#checkout-button {
    margin-top: 1.5rem; /* Space above checkout button */
    padding: 0.8rem 1.5rem; /* Make checkout button prominent */
    font-size: 1.1rem;
}

/* Category Filter Buttons */
#category-filters {
    display: flex;
    flex-wrap: wrap; /* Allow buttons to wrap on smaller screens */
    margin-bottom: 1.5rem; /* Space below filters */
}

.category-filter-btn {
    /* Use default .btn styles and Bootstrap's .btn-outline-secondary */
    text-transform: capitalize; /* Capitalize category names if needed */
    margin-right: 0.5rem !important; /* Override Bootstrap margin if any for spacing */
    margin-bottom: 0.5rem !important;
}

.category-filter-btn.active {
    background-color: var(--primary-color) !important;
    color: white !important;
    border-color: var(--primary-color) !important;
}

/* Stock Display Styling */
.stock-display {
    font-size: 0.9rem;
    font-weight: 500;
}

.card .btn-primary[disabled] {
    background-color: var(--secondary-color);
    border-color: var(--secondary-color);
    cursor: not-allowed;
}

/* Optional: Style for out-of-stock cards to make them visually distinct */
.card.out-of-stock {
    opacity: 0.7; /* Example: slightly faded */
}
.card.out-of-stock .card-img-top {
    /* filter: grayscale(50%); Example: desaturate image */
}

/* Product Card Action Row Spacing */
.card .card-body .mt-2 > .d-flex.mt-1 { /* Targets the flex container for qty and buttons */
    margin-top: 0.5rem !important; /* Increase space above the button row slightly (was mt-1 which is 0.25rem) */
}

.card .product-quantity-input {
    /* width: 60px; is set inline, can override here if needed but 60px is probably fine */
    margin-right: 0.5rem !important; /* Ensure consistent spacing (Bootstrap mr-2 is 0.5rem) */
}

.card .add-to-cart.mr-1 { /* Targeting the Add button specifically if it has mr-1 */
    margin-right: 0.5rem !important; /* Increase to match mr-2, or use a consistent class like mr-2 on it in HTML */
}

/* Ensure stock display has enough space below it if it's not already handled by button row's top margin */
.stock-display.mb-1 {
    margin-bottom: 0.5rem !important; /* Increase space below stock (Bootstrap mb-1 is 0.25rem) */
}

/* General vertical rhythm in card body's action area */
.card .card-body .mt-2 { /* This is the div that holds stock display and the action button row */
    margin-top: 0.75rem !important; /* (Bootstrap mt-2 is 0.5rem) Increase space above stock display */
}

/* Cart Modal Specific Styles */
#cartModal .modal-body {
    /* modal-dialog-scrollable makes this scroll, but we can set a max-height for the items list specifically */
}

#cart-items-modal {
    max-height: 40vh; /* Example: 40% of viewport height, adjust as needed */
    overflow-y: auto;
    margin-bottom: 1rem; /* Space before totals in modal */
}

#totals-area-modal {
    /* Ensure totals are clearly visible below scrollable items */
}

/* Header cart badge - basic styling, can be enhanced */
#cart-item-count-badge {
    font-size: 0.75em;
    padding: .25em .4em;
    position: relative;
    top: -2px; /* Slight adjustment for alignment */
}

/* Skeleton Loading Styles */
.skeleton {
    background-color: #e0e0e0; /* Base skeleton color */
    border-radius: var(--border-radius); /* Use theme's border radius */
    position: relative;
    overflow: hidden; /* Important for shimmer effect */
}

.skeleton::before {
    content: "";
    position: absolute;
    top: 0;
    left: -150%; /* Start shimmer off-screen to the left */
    height: 100%;
    width: 150%; /* Shimmer width */
    background: linear-gradient(
        to right,
        transparent 0%,
        rgba(255, 255, 255, 0.5) 50%, /* Shimmer color and opacity */
        transparent 100%
    );
    animation: shimmer 1.5s infinite; /* Animation properties */
}

@keyframes shimmer {
    0% {
        transform: translateX(0);
    }
    100% {
        transform: translateX(100%); /* Move shimmer to the right */
    }
}

/* Specific skeleton element types */
.skeleton-image {
    /* Height and margin are set inline in HTML for now, can be class-based */
}

.skeleton-text {
    background-color: #e0e0e0; /* Ensure text lines also get base color if not inheriting */
    /* Height, width, margin-bottom are set inline in HTML */
}

.skeleton-title {
    /* Specific adjustments if needed, e.g., if it's typically taller */
}

.skeleton-price {
    /* Specific adjustments */
}

.skeleton-stock {
    /* Specific adjustments */
}

.skeleton-button {
    /* Height, width are set inline in HTML */
}

.skeleton-filter-button {
     /* Height, width, margin are set inline in HTML */
}

/* Custom styling for disabled primary button to ensure consistent layout */
.btn-primary:disabled,
.btn-primary.disabled {
    background-color: #6c757d; /* Bootstrap's standard secondary/disabled gray */
    border-color: #6c757d;
    color: #fff; /* Text color on gray background */
    opacity: 0.65; /* Standard Bootstrap opacity for disabled state */
    /* Ensure no padding/margin changes that would affect layout */
}

/* Product Card Action Row for Stacking */
.card-action-row {
    flex-wrap: wrap;
    gap: 0.5rem; /* Spacing for both horizontal and vertical gaps when wrapped */
}

.card-action-row > .product-quantity-input {
    flex: 1 1 60px; /* Grow, Shrink, Basis - basis matches its fixed width */
    /* min-width: 60px; /* Explicit min-width if basis alone isn't enough */
}

.card-action-row > .btn { /* Target both add-to-cart and view-details buttons */
    flex: 1 1 80px; /* Grow, Shrink, Basis - allow buttons to be a bit wider before wrapping */
    /* min-width: 80px; /* Or a value based on padding + text */
}


/* Snackbar Styles */
.snackbar {
    visibility: hidden; /* Initially hidden */
    min-width: 280px; /* Minimum width */
    max-width: 500px; /* Max width for snackbar, helps with truncation */
    /* Or use viewport units e.g., max-width: 90vw; */
    background-color: #333; /* Default dark background */
    color: #fff; /* Default white text */
    text-align: left; /* Align text to the left */
    border-radius: var(--border-radius); /* Use theme's border radius */
    padding: 14px 20px;
    padding-right: 50px; /* Space for the close button */
    position: fixed;
    z-index: 1060; /* Above most other content like modals (Bootstrap modals are often 1050) */
    left: 50%;
    transform: translateX(-50%);
    bottom: 30px; /* Position at the bottom center */
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    opacity: 0; /* For fade-in/out transition */
    transition: opacity 0.3s, bottom 0.3s, visibility 0.3s linear;
}

.snackbar.show {
    visibility: visible;
    opacity: 1;
    bottom: 50px; /* Slide up effect */
}

/* Different types of snackbars */
.snackbar.success {
    background-color: var(--success-color); /* #28a745 */
    color: #fff;
}
.snackbar.error {
    background-color: var(--danger-color); /* #dc3545 */
    color: #fff;
}
.snackbar.warning {
    background-color: #ffc107; /* Bootstrap warning yellow */
    color: #212529; /* Dark text for yellow background */
}
.snackbar.info {
    background-color: #17a2b8; /* Bootstrap info cyan */
    color: #fff;
}

#snackbar-message {
    display: inline-block; /* Or block if it's the only child taking width */
    vertical-align: middle;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    /* Ensure it doesn't push the close button out if snackbar padding is tight. */
    /* The snackbar's padding-right should account for the close button's width. */
    max-width: calc(100% - 30px); /* Approximate calculation if close button is ~30px wide with its padding */
                                  /* More robust might be to make message a flex-grow item if snackbar is d-flex */
    cursor: pointer; /* Indicate it's clickable/tappable */
}

#snackbar-close {
    position: absolute;
    top: 50%;
    right: 15px;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: inherit; /* Inherit color from snackbar type, or set explicitly */
    font-size: 1.5rem;
    line-height: 1;
    opacity: 0.7;
    cursor: pointer;
    padding: 0.5rem;
}

#snackbar-close:hover {
    opacity: 1;
}

/* Comment out or remove old #error-message-container if snackbar replaces it too */
/*
#error-message-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1050;
    width: auto;
    max-width: 500px;
    border-radius: var(--border-radius);
}
*/

/* Note: Bootstrap's .toast styles are separate and will remain unless Bootstrap CSS is modified */

/* --- Modal Content Responsiveness --- */
.modal-body #modalProductName,
.modal-body #modalProductDescription,
.modal-body #fullMessageModalBody {
    word-wrap: break-word; /* Older browsers */
    overflow-wrap: break-word; /* Standard */
    -webkit-hyphens: auto; /* Optional: for better word breaking if language is set */
    -ms-hyphens: auto;
    hyphens: auto;
    white-space: normal; /* Ensure it's not set to nowrap by other styles */
}

/* Ensure .cart-item-name, which is also in modal, has robust wrapping */
.cart-item-name { /* Already has white-space: normal; from existing rules */
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.modal-body img { /* General rule for images in modal body if not covered by img-fluid */
    max-width: 100%;
    height: auto;
}

/* Specific adjustments for cart items within the modal */
#cart-items-modal .list-group-item {
    /* Ensure flex items behave well */
}

#cart-items-modal .cart-item-details {
    /* flex-grow: 1; is already applied via .cart-item-details in general */
    /* margin-right: 1rem; is already applied via .cart-item-details in general */
    /* Adding min-width to prevent excessive shrinking if item names are short and quantity controls are wider */
    min-width: 0; /* Allows flex item to shrink below its content size if needed */
}

#cart-items-modal .d-flex.align-items-center { /* Container for quantity input and remove button */
    flex-shrink: 0; /* Prevent this container from shrinking due to long item names */
}

/* Address potential for modal-lg to be too wide on very small screens if Bootstrap defaults aren't sufficient */
/* This is more about the dialog than content, but can be related if dialog is forced too wide */
@media (max-width: 575.98px) { /* xs screens, Bootstrap's breakpoint */
    .modal-dialog.modal-lg {
        /* Bootstrap's default for modal-dialog on small screens is margin: .5rem; */
        /* For modal-lg, max-width is 800px. This might be too wide. */
        /* We can reduce its max-width here if needed, but the primary goal is internal content. */
        /* Example: max-width: calc(100% - 20px); */
    }
}
