/**
 * Fresh Milk POS - Custom Styles
 */

/* CSS Variables */
:root {
    --primary-color: #4a90d9;
    --primary-dark: #357abd;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --light-bg: #f8f9fa;
    --card-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    --card-shadow-lg: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

/* Global Styles */
body {
    font-family: 'Sarabun', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--light-bg);
}

/* Card Styles */
.card {
    border-radius: 0.75rem;
    border: none;
    box-shadow: var(--card-shadow);
}

.card:hover {
    box-shadow: var(--card-shadow-lg);
    transition: box-shadow 0.3s ease;
}

/* Navbar */
.navbar-brand {
    font-weight: 600;
}

.navbar .nav-link {
    padding: 0.75rem 1rem;
    transition: background-color 0.2s ease;
}

.navbar .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 0.375rem;
}

/* Sidebar */
.sidebar {
    min-height: calc(100vh - 56px);
    background-color: #fff;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.05);
}

.sidebar .nav-link {
    color: #333;
    padding: 0.75rem 1rem;
    border-radius: 0.375rem;
    margin: 0.25rem 0;
}

.sidebar .nav-link:hover {
    background-color: var(--light-bg);
}

.sidebar .nav-link.active {
    background-color: var(--primary-color);
    color: #fff;
}

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

/* POS Layout */
.pos-container {
    display: flex;
    height: calc(100vh - 56px);
    overflow: hidden;
}

.pos-products {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    background-color: var(--light-bg);
}

.pos-cart {
    width: 350px;
    background-color: #fff;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
}

/* Category Tabs */
.category-tabs {
    display: flex;
    gap: 0.5rem;
    padding: 1rem;
    overflow-x: auto;
    background-color: #fff;
    border-bottom: 1px solid #dee2e6;
}

.category-tab {
    padding: 0.5rem 1rem;
    border: none;
    background-color: var(--light-bg);
    border-radius: 2rem;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s ease;
}

.category-tab:hover {
    background-color: #e9ecef;
}

.category-tab.active {
    background-color: var(--primary-color);
    color: #fff;
}

/* Product Grid */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 1rem;
    padding: 1rem;
}

.product-card {
    background-color: #fff;
    border-radius: 0.75rem;
    padding: 1rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid transparent;
}

.product-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--card-shadow-lg);
    border-color: var(--primary-color);
}

.product-card img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
}

.product-card .product-name {
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.product-card .product-price {
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary-color);
}

.product-placeholder {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #e0e0e0 0%, #f5f5f5 100%);
    border-radius: 0.5rem;
    margin: 0 auto 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.product-placeholder i {
    font-size: 2rem;
    color: #aaa;
}

/* Cart Styles */
.cart-header {
    padding: 1rem;
    border-bottom: 1px solid #dee2e6;
    background-color: var(--primary-color);
    color: #fff;
}

.cart-items {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.cart-item {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    border-bottom: 1px solid #f0f0f0;
}

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

.cart-item-info {
    flex: 1;
}

.cart-item-name {
    font-weight: 500;
    font-size: 0.9rem;
}

.cart-item-price {
    color: var(--secondary-color);
    font-size: 0.85rem;
}

.cart-item-qty {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cart-item-qty button {
    width: 28px;
    height: 28px;
    padding: 0;
    border-radius: 50%;
}

.cart-item-qty span {
    min-width: 24px;
    text-align: center;
    font-weight: 500;
}

.cart-footer {
    padding: 1rem;
    border-top: 1px solid #dee2e6;
    background-color: #fff;
}

.cart-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    font-size: 1.25rem;
    font-weight: 600;
}

.cart-empty {
    text-align: center;
    padding: 2rem;
    color: var(--secondary-color);
}

.cart-empty i {
    font-size: 3rem;
    margin-bottom: 1rem;
}

/* Buttons */
.btn-checkout {
    background: linear-gradient(135deg, var(--success-color) 0%, #20c997 100%);
    border: none;
    font-size: 1.1rem;
    padding: 0.75rem;
}

.btn-checkout:hover {
    background: linear-gradient(135deg, #218838 0%, #1aa179 100%);
}

.btn-clear-cart {
    color: var(--danger-color);
}

/* Status Indicators */
.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.75rem;
    border-radius: 2rem;
    font-size: 0.85rem;
}

.status-online {
    background-color: #d4edda;
    color: #155724;
}

.status-offline {
    background-color: #f8d7da;
    color: #721c24;
}

.status-syncing {
    background-color: #fff3cd;
    color: #856404;
}

/* Sync Badge */
.sync-badge {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    z-index: 1000;
    padding: 0.5rem 1rem;
    border-radius: 2rem;
    box-shadow: var(--card-shadow-lg);
    cursor: pointer;
}

/* Tables */
.table-responsive {
    border-radius: 0.5rem;
    overflow: hidden;
}

.table thead th {
    background-color: var(--primary-color);
    color: #fff;
    border: none;
    font-weight: 500;
}

.table tbody tr:hover {
    background-color: #f8f9fa;
}

/* Forms */
.form-control:focus,
.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(74, 144, 217, 0.25);
}

/* Dashboard Cards */
.dashboard-card {
    border-radius: 0.75rem;
    padding: 1.5rem;
    color: #fff;
}

.dashboard-card.bg-primary {
    background: linear-gradient(135deg, #4a90d9 0%, #357abd 100%) !important;
}

.dashboard-card.bg-success {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%) !important;
}

.dashboard-card.bg-warning {
    background: linear-gradient(135deg, #ffc107 0%, #fd7e14 100%) !important;
}

.dashboard-card.bg-info {
    background: linear-gradient(135deg, #17a2b8 0%, #6f42c1 100%) !important;
}

.dashboard-card .card-icon {
    font-size: 2.5rem;
    opacity: 0.8;
}

.dashboard-card .card-value {
    font-size: 2rem;
    font-weight: 700;
}

.dashboard-card .card-label {
    font-size: 0.9rem;
    opacity: 0.9;
}

/* Modal Styles */
.modal-content {
    border-radius: 0.75rem;
    border: none;
}

.modal-header {
    background-color: var(--primary-color);
    color: #fff;
    border-radius: 0.75rem 0.75rem 0 0;
}

.modal-header .btn-close {
    filter: brightness(0) invert(1);
}

/* Receipt Styles */
.receipt {
    background-color: #fff;
    padding: 2rem;
    max-width: 300px;
    margin: 0 auto;
    font-family: 'Courier New', monospace;
}

.receipt-header {
    text-align: center;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px dashed #000;
}

.receipt-items {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px dashed #000;
}

.receipt-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.receipt-total {
    font-weight: 700;
    font-size: 1.25rem;
}

.receipt-footer {
    text-align: center;
    margin-top: 1rem;
    font-size: 0.85rem;
}

/* Image Upload */
.image-upload {
    border: 2px dashed #dee2e6;
    border-radius: 0.5rem;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.image-upload:hover {
    border-color: var(--primary-color);
}

.image-upload img {
    max-width: 150px;
    max-height: 150px;
    object-fit: cover;
    border-radius: 0.5rem;
}

/* Reports */
.report-filter {
    background-color: #fff;
    padding: 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
}

.report-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

/* Loading Spinner */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

/* Responsive */
@media (max-width: 992px) {
    .pos-cart {
        width: 300px;
    }

    .product-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }
}

@media (max-width: 768px) {
    .pos-container {
        flex-direction: column;
    }

    .pos-products {
        flex: none;
        height: 50vh;
    }

    .pos-cart {
        width: 100%;
        height: 50vh;
    }

    .product-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 0.5rem;
    }

    .product-card {
        padding: 0.5rem;
    }

    .product-card img {
        width: 60px;
        height: 60px;
    }

    .sidebar {
        position: fixed;
        left: -250px;
        width: 250px;
        transition: left 0.3s ease;
        z-index: 1000;
    }

    .sidebar.show {
        left: 0;
    }
}

/* Print Styles */
@media print {
    body * {
        visibility: hidden;
    }

    .receipt, .receipt * {
        visibility: visible;
    }

    .receipt {
        position: absolute;
        left: 0;
        top: 0;
    }
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.3s ease;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.pulse {
    animation: pulse 2s infinite;
}

/* Payment Dialog Styles */
.swal2-popup .form-control-lg {
    border: 2px solid var(--primary-color);
}

.swal2-popup .form-control-lg:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.25rem rgba(74, 144, 217, 0.25);
}

/* Quick Pay Buttons */
.quick-pay-btn {
    min-width: 70px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.quick-pay-btn.active {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
}

.quick-pay-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Receipt Payment Section */
.receipt-payment {
    border-top: 1px dashed #000;
    margin-top: 10px;
    padding-top: 10px;
}

.receipt-payment > div {
    display: flex;
    justify-content: space-between;
    margin: 3px 0;
}
