/* ================= GLOBAL ================= */
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow-y: auto;   /* 🔥 NO SCROLL ANYWHERE */
    background: #ffffff;
}

body {
    font-family: Arial, sans-serif;
    background-color: #f2f6f3;
}

:root {
    --control-height: 30px;
    --control-radius: 8px;
    --control-padding-x: 6px;
}

/* ================= AUTH PAGES ================= */

body.auth-page {
    position: relative;
    background: url("/static/images/bg_login.jpg") no-repeat center center fixed;
    background-size: cover;
}

body.auth-page::before {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(200, 230, 200, 0.05);
    z-index: -1;
}

/* Login / Register card */
.login-container {
    width: 320px;
    margin: 120px auto;
    padding: 25px;
    background: rgba(255, 255, 255, 0.92);
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.login-container a {
    font-size: 15px;
    font-weight: 500;
}

h2 {
    margin-bottom: 20px;
}

/* Global input appearance (NO margin here) */
input,
select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 14px;
    box-sizing: border-box;
}

/* Auth page spacing */
.login-container input,
.login-container select {
    margin-bottom: 14px;
}

/* Password eye */
.password-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}

.password-wrapper input {
    flex: 1;
}

.eye {
    cursor: pointer;
    font-size: 18px;
    user-select: none;
}

.eye-placeholder {
    width: 22px;
}

/* Buttons */
.button-row {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

button {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    cursor: pointer;
}

button[type="submit"] {
    background-color: #8fd19e;
    color: #1f3d2b;
}

button[type="submit"]:hover {
    background-color: #7acb8d;
}

button[type="button"] {
    background-color: #9fd3f6;
    color: #0b3c5d;
}

button[type="button"]:hover {
    background-color: #88c6ef;
}

/* Flash messages */
.flash {
    padding: 10px;
    margin-bottom: 15px;
    border-radius: 6px;
    font-size: 14px;
}

.flash.success {
    display: flex;
    align-items: center;
    gap: 10px;
    background-color: #d4edda;
    color: #155724;
    padding: 12px;
    border-radius: 8px;
    font-weight: bold;
}

.flash.success button {
    background: #28a745;
    color: white;
    border: none;
    padding: 4px 10px;
    border-radius: 6px;
    cursor: pointer;
}

.flash.error {
    background-color: #f8d7da;
    color: #721c24;
}

/* ================= DASHBOARD ================= */

.dashboard-container {
    width: 420px;
    margin: 100px auto;
    padding: 20px;
    background: #D6D5F7;
    border-radius: 12px;
    text-align: center;
}

.dashboard-container h2 {
    margin-bottom: 25px;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

.dash-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 70px;
    font-size: 18px;
    border-radius: 16px;
    text-decoration: none;
    font-weight: bold;
    color: black;
}

.dash-btn.farmer { background-color: #a8d0ff; }
.dash-btn.vendor { background-color: #f7b2d9; }
.dash-btn.report { background-color: #fff59d; }
.dash-btn.logout { background-color: #ffab91; }

/* ================= Farmer/Vendor/item List page ================ */
.farmer-list-container {
    width: 800px;
    margin: 10px auto;
    text-align: left;
}

.farmer-list-container h2 {
    text-align: center;
    margin-top: 0;
    margin-bottom: 10px;
}

.vendor-list-container {
    width: 800px;
    margin: 10px auto;
    text-align: left;
}

.vendor-list-container h2 {
    text-align: center;
    margin-top: 0;
    margin-bottom: 10px;
}

.item-list-container {
    margin: 10px auto;
}

.item-list-container h2 {
    margin: 0;
    margin-bottom: 10px;
}

/* ================= Sticky Header for List Pages ================= */
.list-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #D6D5F7;        /* same panel color */
    padding-top: 6px;
    padding-bottom: 10px;
}

.farmer-list-container th {
    position: static;
}

.vendor-list-container th {
    position: static;
}

/* Farmer/Vendor list table layout */
.dashboard-container table {
    table-layout: fixed;
    width: 100%;
}

/* Farmer/Vendor Name column */
.dashboard-container table th:nth-child(1),
.dashboard-container table td:nth-child(1) {
    width: 45%;               /* 🔥 BIGGER column */
}

/* Other columns tighter */
.dashboard-container table th:nth-child(2),
.dashboard-container table td:nth-child(2) {
    width: 15%;
}

.dashboard-container table th:nth-child(3),
.dashboard-container table td:nth-child(3) {
    width: 15%;
}

.dashboard-container table th:nth-child(4),
.dashboard-container table td:nth-child(4) {
    width: 10%;
}

.dashboard-container table th:nth-child(5),
.dashboard-container table td:nth-child(5) {
    width: 15%;
}

.dashboard-container table td:nth-child(1) {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ================= Sticky Table Columns ================= */
.table-scroll {
    max-height: calc(100vh - 180px); /* header + search */
    overflow-y: auto;
    scrollbar-gutter: stable;
}

.table-scroll thead th {
    position: sticky;
    top: 0;
    z-index: 10;
    color: #FFFFFF;
    background: #7A7894;      /* MUST be solid */
    white-space: nowrap;
    box-shadow: 0 2px 0 #aaa; /* visual separation */
}

.table-scroll table {
    border-collapse: separate;
    border-spacing: 0;
}

/* ================= FARMER / VENDOR TRANSACTIONS ================= */
.farmer-main-grid {
    display: grid;
    grid-template-columns: 2.2fr 1fr;
    height: 100vh;
    max-height: 100vh;
    gap: 10px;
    padding: 10px;
    background: #dbe9ff;
    box-sizing: border-box;
    overflow: hidden;
    margin: 0;
}

.vendor-main-grid {
    display: grid;
    grid-template-columns: 2.2fr 1fr;
    height: 100vh;
    max-height: 100vh;
    gap: 10px;
    padding: 10px;
    background: #dbe9ff;
    box-sizing: border-box;
    overflow: hidden;
    margin: 0;
}

.lhs-panel {
    display: grid;
    grid-template-rows: auto 1fr;
    gap: 10px;
}

.lhs-top-grid {
    display: grid;
    grid-template-columns: 1.6fr 0.8fr;
    gap: 10px;
}

/* Panels */
.panel {
    background: #e6e6e6;
    padding: 10px;
    border-radius: 10px;
}

.panel h3 {
    margin-top: 0;
    padding: 6px 8px;
    margin-bottom: 6px;
    font-size: 15px;
    color: #0b3c5d;
    background: linear-gradient(to right, #eef5ff, #e0ecff);
    border-bottom: 1px solid #b6cff5;
    border-radius: 8px 8px 0 0;
}

.panel.panel-bordered {
    border: 2px solid #70BBD4;
}

.rhs-panel.panel-bordered {
    border-color: #1f3d5c;
}

/* ===== Add to Bill Button ===== */
#addItemBtn {
    background-color: #2ecc71;      /* Green */
    color: white;
    border: none;
    padding: 8px 14px;
    font-weight: bold;
    border-radius: 6px;
    cursor: pointer;
}

#addItemBtn:hover {
    background-color: #27ae60;
}

/* ===== Remove from Bill Button ===== */
#removeItemBtn {
    background-color: #e74c3c;      /* Red */
    color: white;
    border: none;
    padding: 8px 14px;
    font-weight: bold;
    border-radius: 6px;
    cursor: pointer;
}

#removeItemBtn:disabled {
    background-color: #f5b7b1;      /* Light red (disabled) */
    cursor: not-allowed;
}

#removeItemBtn:hover:not(:disabled) {
    background-color: #c0392b;
}

.links-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;   /* 2 columns */
    gap: 8px;
    margin-top: 6px;
}

.links-grid a {
    font-size: 15px;
    font-weight: 500;
    padding: 6px 4px;
}
/* -------- BILL DETAILS (CRITICAL SECTION) -------- */

.bill-panel {
    font-size: 13px;
}

.bill-panel input,
.bill-panel select {
    margin-bottom: 0;        /* 🔥 IMPORTANT */
    padding: 5px;
    height: 30px;
    font-size: 13px;
    border-radius: 8px;
}

.bill-no {
    width: 90px;
}

/* Inline layout */
.inline-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.inline-row.two-cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.inline-pair {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
}

.inline-pair label {
    white-space: nowrap;
    line-height: 1;
    font-size: 13px;
}

/* -------- ITEM DETAILS -------- */

.item-panel table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.item-panel th,
.item-panel td {
    border: 1px solid #aaa;
    padding: 4px;
    text-align: center;
}

.charges-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 8px;
    font-size: 13px;
}

.totals-row {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
}

#grossAmount,
#netAmount {
    background-color: #f3f3f3;
    font-weight: bold;
    color: #2c3e50;
    cursor: not-allowed;
}

/* -------- RHS / PREVIEW -------- */

.rhs-panel {
    background: #ffffff;
    border-radius: 10px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ===== Bill Preview Header ===== */
.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.panel-header h3 {
     margin: 0;
     flex: 1;
}
/* ===== Icon Buttons Print and Send to Whatsapp ===== */
.preview-actions {
    display: flex;
    gap: 8px;
    margin-left: 10px;
}

.icon-btn {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: 1px solid #aaa;
    background: #f5f5f5;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: allowed 0.15s ease;
}

/* Hover */
.icon-btn:hover:not(:disabled) {
    background: #d7ddff;
    border-color: #4a6cf7;
    transform: scale(1.08);
}

.icon-btn:active:not(:disabled) {
    transform: scale(0.96);
}

/* Disabled */
.icon-btn:disabled,
.icon-btn.disabled {
    opacity: 0.45;
    cursor: not-allowed;
    background: #e0e0e0;
}

.icon-btn[title] {
    position: relative;
}

#printThermalBtn:not(:disabled) {
    background: #d9f7df;
    box-shadow: 0 0 0 0 rgba(40, 167, 69, 0.6);
    animation: pulseGlow 1.8s infinite;
}

@keyframes pulseGlow {
    0% {
        box-shadow: 0 0 0 0 rgba(40, 167, 69, 0.5);
    }
    70% {
        box-shadow: 0 0 0 6px rgba(40, 167, 69, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(40, 167, 69, 0);
    }
}

.tooltip-wrapper {
    display: inline-flex;
}

.pdf-preview {
    flex: 1;
    border: 1px dashed #aaa;
    margin: 10px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    overflow: hidden;
}

/* ===== BILL PREVIEW IFRAME ===== */
#billPreviewFrame {
    width: 100%;
    height: 100%;
    border: none;
    overflow: auto;
}

/* ===== PREVIEW MODE (iframe & browser) ===== */
body {
    font-family: Arial, sans-serif;
    font-size: 12px;
    margin: 0;
    padding: 0;
}

.bill-container {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
}

/* ===== PRINT MODE ONLY ===== */
@media print {

    @page {
        size: auto;
        margin: 5mm;
    }

    body.paper-80 .bill-container {
        width: 80mm;
        font-size: 13px;
    }

    body.paper-58 .bill-container {
        width: 58mm;
        font-size: 11px;
    }
}

/* Bottom buttons */
.bottom-buttons {
    display: flex;
    justify-content: space-between;
}

.btn-success {
    background: #4caf50;
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    border: none;
}

.btn-danger {
    background: #e53935;
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    border: none;
}

.help-text {
    font-size: 12px;
    color: #666;
}

/* === Global Label & Input Uniformity === */
label {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;      /* Prevent label wrapping */
}

input,
select {
    font-size: 14px;
}

/* Inline layouts */
.inline-row label,
.inline-pair label {
    flex-shrink: 0;           /* Keep label on single line */
}

.wrap-label {
    white-space: normal;
}

/* === INLINE FORMS INSIDE login-container (Farmer / Vendor / Item Add) === */
/* Restore flex behavior */
.login-container .inline-row.two-cols {
    display: flex;          /* 🔥 override grid */
    gap: 12px;
}

/* Remove auth-page spacing for inline inputs */
.login-container .inline-row input,
.login-container .inline-row select {
    margin-bottom: 0;       /* 🔥 critical */
}

/* Ensure perfect vertical centering */
.login-container .inline-row,
.login-container .inline-pair {
    display: flex;
    align-items: center;
}

/* ===== ITEM DETAILS SECTION ===== */
.item-panel {
    display: flex;
    flex-direction: column;
}

.item-toolbar {
    display: flex;
    gap: 12px;
    margin-bottom: 8px;
}

.item-content {
    display: grid;
    grid-template-columns: 3fr 1.2fr;
    gap: 12px;
    flex: 1;
}

.item-table-wrapper {
    border: 1px solid #aaa;
    height: 360px;
    overflow-y: auto;
    background: white;
}

.item-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.item-table th,
.item-table td {
    border-bottom: 1px solid #ddd;
    padding: 4px 6px;
    text-align: center;
}

.item-table th {
    position: sticky;
    top: 0;
    background: #f0f0f0;
}

.charges-panel {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Default item footer (Farmer) */
.item-footer {
    display: grid;
    grid-template-columns: 1fr 1fr;
    margin-top: auto;
    gap: 20px;
/*    display: flex;
    flex-direction: column;
    gap: 6px;*/
}

/* ===== FIX: Vendor bottom totals full width ===== */
/* Override item-footer grid for totals row */
/* Vendor-specific footer layout */
.vendor-main-grid .item-footer {
    display: block;     /* override farmer behavior */
}

/* Keep three inputs in one row */
.inline-row.three-cols {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    width: 100%;
}

/* Ensure children stretch */
.inline-row.three-cols .inline-pair {
    width: 100%;
    flex: unset;             /* 🔥 cancel flex behavior */
}

/* Force inputs to occupy full column width */
.inline-row.three-cols input {
    width: 100% !important;
    max-width: none !important;
    box-sizing: border-box;
}

/* ===== RIGHT CHARGES PANEL REFINEMENTS ===== */
.charges-panel .inline-row {
    justify-content: flex-end;
}

.charges-panel label {
    text-align: right;
    width: 90px;           /* fixed label width */
}

.charges-panel input {
    width: 90px;           /* ~8 digits */
    text-align: right;
    padding: 4px 6px;
}

/* ===== ITEM LIST TABLE – FINAL COLUMN WIDTHS ===== */

/* Base width for Qty / Rate (fits "वजन / नग" in one line) */
:root {
    --qty-col-width: 9ch;        /* tuned for Marathi heading */
}

/* ===== HEADER ALIGNMENT (FORCED) ===== */
.item-table thead th {
    text-align: center !important;
    white-space: nowrap;
}

/* Sr No – unchanged */
.item-table th:nth-child(1),
.item-table td:nth-child(1) {
    width: 4ch;
    text-align: center;
}

/* Item Name – flexible */
.item-table th:nth-child(2),
.item-table td:nth-child(2) {
    width: auto;
    text-align: left;
}

/* Weight / Qty */
.item-table th:nth-child(3),
.item-table td:nth-child(3) {
    width: var(--qty-col-width);
    text-align: right;
    white-space: nowrap;         /* 🔥 prevent wrap */
}

/* Rate – same as Qty */
.item-table th:nth-child(4),
.item-table td:nth-child(4) {
    width: var(--qty-col-width);
    text-align: right;
    white-space: nowrap;
}

/* Price – 1.6 × Qty width */
.item-table th:nth-child(5),
.item-table td:nth-child(5) {
    width: calc(var(--qty-col-width) * 1.6);
    text-align: right;
    white-space: nowrap;
}

.row-selected {
    background-color: #cce5ff;
}

/* ================= FINAL BILL BUTTONS ================= */
.btn-final {
    background: linear-gradient(135deg, #1b8f3b, #28c76f);
    color: white;
    font-weight: bold;
    padding: 12px 22px;
    font-size: 16px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.btn-final:hover {
    background: linear-gradient(135deg, #148233, #22b35f);
    transform: scale(1.03);
}

/* Cancel button */
.btn-cancel {
    background: linear-gradient(135deg, #c0392b, #e74c3c);
    color: white;
    font-weight: bold;
    padding: 12px 22px;
    font-size: 16px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    margin-left: 10px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.btn-cancel:hover {
    background: linear-gradient(135deg, #a93226, #c0392b);
    transform: scale(1.03);
}

/* ===== Farmer / Vendor List – Name Column Handling ===== */
table {
    table-layout: fixed;   /* 🔥 critical for ellipsis */
}

.farmer-name {
    max-width: 220px;     /* adjust as you like */
    width: 100%;
    white-space: nowrap;   /* prevent wrapping */
    overflow: hidden;      /* hide overflow */
    text-overflow: ellipsis; /* show ... */
    vertical-align: middle;
}

.vendor-name {
    max-width: 220px;     /* adjust as you like */
    width: 100%;
    white-space: nowrap;   /* prevent wrapping */
    overflow: hidden;      /* hide overflow */
    text-overflow: ellipsis; /* show ... */
    vertical-align: middle;
}

table th:last-child,
table td:last-child {
    width: 80px;
    text-align: center;
    white-space: nowrap;
}

/* ========= SEARCH BOX ========== */
.search-box{
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 10px;
}

.search-box input{
    flex: 1;
}

#clearSearch {
    cursor: pointer;
    font-size: 16px;
    opacity: 0.6;
}

#clearSearch:hover {
    opacity: 1;
}

.top-actions {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
}

.top-actions a {
    font-weight: bold;
    font-size: 15px;
    text-decoration: none;
    color: #003366;
}

/* ================= SELECT2 – EXACT MATCH WITH INPUTS ================= */
.select2-container {
    width: 100% !important;
    font-size: 13px;
}

/* Main selection box */
.select2-container--default .select2-selection--single {
    height: var(--control-height);
    min-height: var(--control-height);

    border: 1px solid #ccc;
    border-radius: var(--control-radius);
    background-color: #fff;

    padding: 0 var(--control-padding-x);
    box-sizing: border-box;

    display: flex;
    align-items: center;
}

/* Selected text */
.select2-container--default
.select2-selection--single
.select2-selection__rendered {
    padding: 0;
    line-height: var(--control-height);
    font-size: 13px;
    color: #333;
}

/* Dropdown arrow */
.select2-container--default
.select2-selection--single
.select2-selection__arrow {
    height: var(--control-height);
    width: 24px;
    right: 4px;
}

/* Clear (×) button */
.select2-selection__clear {
    font-size: 16px;
    margin-right: 6px;
    line-height: var(--control-height);
    color: #999;
}

.select2-selection__clear:hover {
    color: #333;
}

/* Disabled state */
.select2-container--default.select2-container--disabled
.select2-selection--single {
    background-color: #f3f3f3;
    cursor: not-allowed;
}

/* ================= DROPDOWN ================= */

.select2-dropdown {
    border-radius: var(--control-radius);
    border: 1px solid #bbb;
    box-shadow: 0 4px 10px rgba(0,0,0,0.12);
}

/* Search box inside dropdown */
.select2-container--default
.select2-search--dropdown
.select2-search__field {
    height: var(--control-height);
    padding: 4px 6px;
    border-radius: 6px;
    border: 1px solid #ccc;
    font-size: 13px;
    box-sizing: border-box;
}

/* Options */
.select2-results__option {
    font-size: 13px;
    padding: 6px 8px;
}

.select2-results__option--highlighted {
    background-color: #cce5ff !important;
    color: #003366;
}

.select2-results__option--selected {
    background-color: #e6f0ff;
}

/* ===== FORCE PERFECT ROUNDING FOR SELECT2 ===== */

.select2-container--default .select2-selection--single {
    overflow: hidden; /* 🔥 THIS IS THE KEY */
}

/* Arrow must not affect curvature */
.select2-container--default
.select2-selection--single
.select2-selection__arrow {
    right: 6px;
    width: 22px;
}

/* Ensure inner text never changes shape */
.select2-container--default
.select2-selection--single
.select2-selection__rendered {
    padding-left: 4px;
    padding-right: 4px;
}

input,
select,
.select2-selection--single {
    box-shadow: inset 0 1px 1px rgba(0,0,0,0.04);
}

/* ===== PERFECT CONTROL NORMALIZATION ===== */
input,
select,
.select2-selection--single {
    height: var(--control-height) !important;
    border-radius: var(--control-radius) !important;
    box-sizing: border-box !important;
}

/* Remove native number input styling differences */
input[type="number"] {
    appearance: textfield;
    -moz-appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.select2-results__option--highlighted {
    color: #1f2d3d !important;
}

.success-popup {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #28a745;
    color: white;
    padding: 12px 18px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: bold;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    z-index: 9999;
    opacity: 1;
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.success-popup.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(-10px);
}

/* ========== Common Action Button Size ================== */
.btn-action {
    height: 36px;
    min-height: 36px;
    padding: 0 18px;
    font-size: 15px;
    font-weight: bold;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

.hidden {
    display: none !important;
}

input[readonly] {
    background-color: #f3f3f3;
    cursor: not-allowed;
    color: #555
}