/* =========================
   InstaBill LK v11 - Base Styles
   Lead Architect: Gemini (SaaS Mode) 
   ========================= */

:root {
    --primary-color: #007bff;
    --secondary-color: #6c757d;
    --background-color: #f8f9fa;
    --form-background: #ffffff;
    --receipt-background: #ffffff;
    --text-color: #333;
    --header-color: #fff;
    --danger-color: #dc3545;
    --success-color: #28a745;
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

body {
    font-family: var(--font-family);
    background-color: var(--background-color);
    color: var(--text-color);
    margin: 0;
    padding: 20px;
    display: flex;
    justify-content: center;
}

.container {
    display: flex;
    max-width: 1600px;
    width: 100%;
    gap: 20px;
    background: var(--form-background);
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    border-radius: 8px;
    overflow: hidden;
}

.form-section {
    flex: 1;
    padding: 25px;
    display: flex;
    flex-direction: column;
}

.receipt-section {
    flex: 0 0 400px;
    background-color: #e9ecef;
    padding: 20px;
    overflow-y: auto;
}

/* --- Main Header --- */
.main-header {
    background: var(--primary-color);
    color: var(--header-color);
    padding: 15px;
    margin: -25px -25px 20px -25px;
    border-radius: 8px 8px 0 0;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.header-top h1 {
    margin: 0;
    font-size: 1.8rem;
}

.status-indicators {
    display: flex;
    align-items: center;
    gap: 10px;
}

#current-cashier {
    font-weight: bold;
    background: rgba(255,255,255,0.2);
    padding: 5px 10px;
    border-radius: 4px;
}

#offline-indicator {
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background-color: var(--danger-color);
}

.pro-features {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.pro-features button {
    background: rgba(255,255,255,0.8);
    color: var(--primary-color);
    border: none;
    padding: 8px 12px;
    border-radius: 4px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
}
.pro-features button:hover { background: #fff; }

/* --- Form Elements --- */
input[type="text"], input[type="number"], input[type="tel"], input[type="date"], select, textarea {
    width: 100%;
    padding: 10px;
    margin-bottom: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
}

.items-section h2 {
    margin-top: 20px;
    margin-bottom: 10px;
}

.item {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}
.item .item-name { flex: 3; }
.item .item-qty { flex: 1; }
.item .item-price { flex: 1; }
.item .remove-item-btn { 
    background: var(--danger-color); 
    color: white; 
    border: none; 
    border-radius: 50%;
    width: 25px;
    height: 25px;
    cursor: pointer;
    font-weight: bold;
}

.item-controls {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

#add-item-btn, #scan-barcode-btn {
    flex: 1;
    background-color: var(--secondary-color);
    color: white;
}

.advanced-calculations, .action-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.discount-control { display: flex; flex: 2; }
.discount-control select { border-right: none; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.discount-control input { border-top-left-radius: 0; border-bottom-left-radius: 0; }

.payment-mode { flex: 2; display: flex; align-items: center; gap: 5px; }

/* --- Buttons --- */
button {
    padding: 12px 15px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    transition: opacity 0.2s;
}
button:hover { opacity: 0.9; }

.main-action { background-color: var(--success-color); color: white; flex: 2; }
#print-receipt-btn { background-color: #17a2b8; color: white; }
#hold-bill-btn { background-color: #ffc107; color: #333; }
#resume-bills-btn { background-color: #fd7e14; color: white; }
.danger-btn { background-color: var(--danger-color); color: white; }


/* --- Receipt Preview --- */
.receipt-preview {
    background: var(--receipt-background);
    padding: 20px;
    font-family: 'Courier New', monospace;
    color: #000;
    font-size: 13px;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.1);
}

.receipt-preview h2, .receipt-preview h3 {
    text-align: center;
    margin: 5px 0;
}

.receipt-preview p { margin: 2px 0; }
.receipt-preview .receipt-header, .receipt-preview .receipt-total {
    text-align: center;
}

.receipt-preview #logo-preview {
    max-width: 100px;
    max-height: 80px;
    display: block;
    margin: 0 auto 10px auto;
}

.receipt-preview table {
    width: 100%;
    border-collapse: collapse;
    margin: 10px 0;
}
.receipt-preview th, .receipt-preview td { 
    text-align: left; padding: 3px; 
} 
.receipt-preview th:nth-child(2), .receipt-preview td:nth-child(2), /* Qty */
.receipt-preview th:nth-child(3), .receipt-preview td:nth-child(3), /* Price */
.receipt-preview th:nth-child(4), .receipt-preview td:nth-child(4) { /* Total */
    text-align: right; 
} 

.qr-code-container {
    display: flex;
    justify-content: center;
    margin-top: 15px;
}

.receipt-footer-notes { font-style: italic; text-align: center; margin-top: 10px; }
.receipt-branding { font-weight: bold; text-align: center; margin-top: 15px; border-top: 1px dashed #ccc; padding-top: 10px; font-size: 11px; color: #555; }

/* Receipt Themes */
.theme-modern { 
    font-family: 'Helvetica Neue', sans-serif;
    font-size: 12px;
}
.theme-modern .receipt-header, .theme-modern .receipt-total { text-align: left; }
.theme-modern h2 { font-size: 1.5em; text-align: right; }

/* --- Modals --- */
.modal {
    display: none; 
    position: fixed; 
    z-index: 1000; 
    left: 0; top: 0; 
    width: 100%; height: 100%;
    overflow: auto; 
    background-color: rgba(0,0,0,0.6);
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: #fefefe;
    margin: 10% auto;
    padding: 25px;
    border: 1px solid #888;
    border-radius: 8px;
    width: 80%;
    max-width: 600px;
    position: relative;
}

.modal-content.wide { max-width: 900px; }

.close-btn {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}
.close-btn:hover, .close-btn:focus { color: black; }

.modal h2 { margin-top: 0; }

.table-container {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-top: 15px;
}

.table-container table { width: 100%; border-collapse: collapse; }
.table-container th, .table-container td { padding: 10px; border-bottom: 1px solid #ddd; text-align: left; }
.table-container th { background: #f2f2f2; position: sticky; top: 0; }

.ledger-actions button {
    font-size: 12px;
    padding: 5px 8px;
    margin-right: 5px;
}

.settle-btn { background: var(--success-color); color: white; }
.remind-btn { background: #17a2b8; color: white; }

.status-paid { color: var(--success-color); font-weight: bold; }
.status-credit { color: var(--danger-color); font-weight: bold; }

.dashboard-actions, .inventory-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    align-items: center;
    flex-wrap: wrap;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}
.dashboard-card { 
    background: #e9ecef; 
    padding: 15px; 
    border-radius: 5px; 
    text-align: center; 
    cursor: pointer;
}
.dashboard-card p { margin: 0 0 10px 0; font-weight: bold; }
.dashboard-card strong { font-size: 1.5rem; }

#sales-chart { 
    max-height: 250px; 
    margin-bottom: 20px;
    width: 100% !important;
}

#add-product-form, #add-cashier-form, #add-expense-form {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.held-bill-item, .cashier-item, #product-list div {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    border-bottom: 1px solid #eee;
}

.inventory-data-management {
    margin-left: auto; /* Pushes buttons to the right */
    display: flex;
    gap: 10px;
}

.csv-export-btn {
    background-color: #28a745;
    color: white;
}

/* --- Toast Notification --- */
#toast {
    visibility: hidden;
    min-width: 250px;
    background-color: #333;
    color: #fff;
    text-align: center;
    border-radius: 4px;
    padding: 16px;
    position: fixed;
    z-index: 1001;
    left: 50%;
    transform: translateX(-50%);
    bottom: 30px;
    font-size: 17px;
}

#toast.show {
    visibility: visible;
    -webkit-animation: fadein 0.5s, fadeout 0.5s 2.5s;
    animation: fadein 0.5s, fadeout 0.5s 2.5s;
}

@-webkit-keyframes fadein {
    from {bottom: 0; opacity: 0;} 
    to {bottom: 30px; opacity: 1;}
}
@keyframes fadein {
    from {bottom: 0; opacity: 0;}
    to {bottom: 30px; opacity: 1;}
}
@-webkit-keyframes fadeout {
    from {bottom: 30px; opacity: 1;} 
    to {bottom: 0; opacity: 0;}
}
@keyframes fadeout {
    from {bottom: 30px; opacity: 1;}
    to {bottom: 0; opacity: 0;}
}