/* Premium Modern SaaS Design - "15+ Year Experience" UI/UX */
/* Inter is already self-hosted via billing-css/inter.css (loaded by every
   page that also loads this file) - this used to also pull the same font
   from Google Fonts, an unnecessary external request on every page load
   (billing screens included) that just fails silently offline. */

:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --secondary-color: #10b981;
    --secondary-hover: #059669;
    --background-color: #f3f4f6;
    --surface-color: #ffffff;
    --text-main: #111827;
    --text-muted: #6b7280;
    --border-color: #e5e7eb;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--background-color);
    color: var(--text-main);
    -webkit-font-smoothing: antialiased;
}

/* Page Header & Container */
.page-wrapper {
    padding: 1.5rem;
    max-width: 1600px;
    margin: 0 auto;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 0;
    letter-spacing: -0.025em;
}

/* Cards & Surfaces */
.card, .iw-card, .panel {
    background: var(--surface-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
    overflow: hidden;
    transition: var(--transition);
}

.card-header, .iw-card-header {
    background: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    padding: 1.25rem 1.5rem;
    font-weight: 600;
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-body, .iw-card-body {
    padding: 1.5rem;
}

/* Inputs & Form Controls */
.form-control, .form-select, input[type="text"], input[type="number"], input[type="date"] {
    background-color: #f9fafb;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    color: var(--text-main);
    transition: var(--transition);
    width: 100%;
}

.form-control:focus, .form-select:focus, input:focus {
    background-color: var(--surface-color);
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
    outline: none;
}

label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 0.375rem;
    display: block;
}

/* Buttons */
.btn, .iw-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.btn-primary, .iw-btn-primary {
    background-color: var(--primary-color);
    color: white;
}
.btn-primary:hover, .iw-btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-success, .iw-btn-success {
    background-color: var(--secondary-color);
    color: white;
}
.btn-success:hover, .iw-btn-success:hover {
    background-color: var(--secondary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* Data Tables
   overflow: hidden (shorthand = both axes) was meant only to clip content to
   the rounded corners below, but .table-responsive's entire reason to exist
   is Bootstrap's own overflow-x: auto — this silently killed it everywhere
   the class is used without a more specific override. Pages using
   .tablefixhead were rescued by own.css's !important overflow-x:auto; any
   page with a plain .table-responsive (e.g. exist-po.html's list grid) had
   no such rescue: wide tables were hard-clipped with no scrollbar and no way
   to reach the hidden columns at all.

   overflow-y was then left as hidden "to keep the rounded-corner clipping
   intent" — which turned out to be the same bug on the other axis. A page
   that sets its own `max-height` + `overflow-y: auto` on .table-responsive
   (process-card-list.html does exactly that, at 70vh) had that auto silently
   replaced by hidden, because this rule loads later at equal specificity.
   The result: 1451px of rows inside a 754px box with no scrollbar — roughly
   700px of the list simply unreachable, on a screen tall enough that the
   page itself did not scroll either.

   Neither axis is declared hidden now. Per CSS Overflow, a `visible` axis
   paired with a non-visible one computes to `auto`, so vertical scrolling
   appears only when a page has actually constrained the height, and stays
   absent otherwise. The rounded-corner clipping is unaffected: overflow-x:
   auto already establishes a scroll container that clips to the border box
   on both axes. */
.table-responsive {
    border-radius: var(--radius-md);
    overflow-x: auto;
    border: 1px solid var(--border-color);
}

.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-bottom: 0;
}

.table thead th {
    background-color: #f9fafb;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

.table tbody td {
    padding: 0.875rem 1rem;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
    vertical-align: middle;
}

.table tbody tr {
    background-color: var(--surface-color);
    transition: var(--transition);
}

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

/* Summary / Totals block */
.totals-block {
    background: linear-gradient(135deg, #f9fafb 0%, #f3f4f6 100%);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
}
.totals-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}
.totals-row.grand-total {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--primary-color);
    border-top: 1px solid var(--border-color);
    padding-top: 0.75rem;
    margin-top: 0.75rem;
    margin-bottom: 0;
}
/* Global Customer Details Toggle Panel */
.customer-details {
    background-color: #f8fafc !important;
    border-radius: 8px !important;
    padding: 16px !important;
    border: 1px solid #e2e8f0 !important;
    margin-bottom: 12px !important;
}
.customer-details .form-heading {
    font-size: 14px !important;
    font-weight: 700 !important;
    color: #1e293b !important;
    border-bottom: 2px solid #cbd5e1 !important;
    padding-bottom: 8px !important;
    margin-bottom: 12px !important;
}
.customer-details .detail {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 6px 0 !important;
    border-bottom: 1px dashed #cbd5e1 !important;
    font-size: 13px !important;
}
.customer-details .detail:last-child {
    border-bottom: none !important;
}
.customer-details .detail .label {
    color: #475569 !important;
    font-weight: 600 !important;
}
.customer-details .detail span:not(.label) {
    color: #0f172a !important;
    font-weight: 600 !important;
    text-align: right !important;
    max-width: 60% !important;
    word-break: break-word !important;
}

/* --- Sales Order Footer Compact Layout (Label Left, Value Right) --- */
.iw-card .row.align-items-top > div > div[class^="sec_"] {
    display: grid !important;
    grid-template-columns: 1fr auto !important;
    align-items: center !important;
    gap: 4px 12px !important;
    padding: 8px 12px !important;
    background: #f8fafc !important;
    border-radius: 6px !important;
    border: 1px solid #e2e8f0 !important;
    margin-bottom: 8px !important;
}

/* Override the previous flex layout if it's there */
.iw-card .row.align-items-top.justify-content-end > div > div {
    display: grid !important;
}

/* ...but not when that div is itself a Bootstrap .row.
   The blanket rule above declares no grid-template-columns, so it produces a
   SINGLE-COLUMN grid. That is what the sec_* stat cards want, but several
   footers (stock_in, edit_stock_in, purchase_order, purchase_order_fixed,
   dispatch-packing-list) nest a real .row at exactly this depth to place the
   TDS/Other-Charges panel beside the Round Off / Net Amount card. Collapsing
   that row to one column pushed the Net Amount card underneath the panel,
   leaving the footer visibly misaligned with a large empty gap to its left.
   A nested .row must stay a flex row so its columns sit side by side. */
.iw-card .row.align-items-top.justify-content-end > div > div.row {
    display: flex !important;
}

.iw-card .row.align-items-top > div > div[class^="sec_"] p {
    margin: 0 !important;
    font-size: 12px !important;
    color: #475569 !important;
    border: none !important;
    text-align: left !important;
}

.iw-card .row.align-items-top > div > div[class^="sec_"] h3,
.iw-card .row.align-items-top > div > div[class^="sec_"] h2 {
    margin: 0 !important;
    font-size: 14px !important;
    font-weight: 700 !important;
    color: #0f172a !important;
    border: none !important;
    text-align: right !important;
}

.iw-card .row.align-items-top > div > div[class^="sec_"] input {
    margin: 0 !important;
    height: 28px !important;
    width: 80px !important;
    padding: 2px 6px !important;
    font-size: 13px !important;
    text-align: right !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 4px !important;
}

/* Specifically for sec_green Net Amount */
.iw-card .row.align-items-top > div > div.sec_green {
    background: #ecfdf5 !important;
    border-color: #a7f3d0 !important;
}
.iw-card .row.align-items-top > div > div.sec_green h2 {
    color: #059669 !important;
    font-size: 18px !important;
}

/* --- Tender Modes (TDS DIV) Compact Styling --- */
.iw-card .tds-div {
    background: #f8fafc !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 6px !important;
    padding: 8px !important;
    margin-bottom: 8px !important;
}
.iw-card .tds-div .iw-btn {
    height: 26px !important;
    padding: 2px 8px !important;
    font-size: 11px !important;
    line-height: 1 !important;
    margin-bottom: 4px !important;
    font-weight: 600 !important;
}
.iw-card .tds-div input.tab-input,
.iw-card .tds-div select.tds-sel,
.iw-card .tds-div select#serviceTax {
    height: 26px !important;
    padding: 2px 6px !important;
    font-size: 12px !important;
    margin-bottom: 4px !important;
}
/* Reduce padding between columns inside tds-div */
.iw-card .tds-div .row > .col-6 {
    padding-left: 2px !important;
    padding-right: 2px !important;
}
.iw-card .tds-div h4 {
    font-size: 13px !important;
    margin: 0 !important;
    padding: 4px !important;
}

/* --- Transaction Page Unified Layout (25% / 60% / 15%) --- */
.transaction-layout {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 120px);
    overflow: hidden;
}
.transaction-header {
    flex: 0 0 25%;
    height: 25%;
    overflow-y: auto;
    padding: 4px 8px;
    background: #fff;
}
.transaction-product-bar {
    flex: 0 0 auto;
    background: #fff;
    z-index: 5;
}
.transaction-grid {
    flex: 0 0 60%;
    height: 60%;
    overflow-y: hidden;
    background: #fff;
    border-top: 2px solid #e2e8f0;
    border-bottom: 2px solid #e2e8f0;
    display: flex;
    flex-direction: column;
}
/* Force grid children to expand */
.transaction-grid > .box-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.transaction-grid .box-body > .row {
    flex: 1;
    margin: 0;
}
.transaction-grid .box-body > .row > .col-xl-12 {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0;
}
.transaction-grid .table-responsive {
    flex: 1;
    display: flex;
    flex-direction: column;
}
.transaction-grid .tablefixhead {
    flex: 1;
    height: auto !important; /* Override 40vh from meat.css */
    overflow-y: auto;
}
.transaction-footer {
    flex: 0 0 15%;
    height: 15%;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 4px 8px;
    background: #f8fafc;
}

/* Compact spacing for transaction header to fit 6 rows */
.transaction-header .row {
    margin-bottom: 4px !important;
}
.transaction-header .form-group {
    margin-bottom: 0 !important;
}
.transaction-header label {
    font-size: 11px !important;
    margin-bottom: 1px !important;
    color: #475569;
    text-transform: uppercase;
    font-weight: 600;
}
.transaction-header input.form-control,
.transaction-header select.form-control,
.transaction-header select.form-select,
.transaction-header .input-group .form-control {
    height: 26px !important;
    padding: 2px 6px !important;
    font-size: 12px !important;
    border-radius: 4px !important;
}
.transaction-header .iw-btn {
    height: 26px !important;
    padding: 2px 10px !important;
    font-size: 11px !important;
    line-height: 1.5 !important;
}


/* Override for Round Off sec_green */
.iw-card .row.align-items-top > div > div.sec_green {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    justify-content: center !important;
    background: #ecfdf5 !important;
    border-color: #a7f3d0 !important;
    padding: 4px 6px !important;
    gap: 2px !important;
}
.iw-card .row.align-items-top > div > div.sec_green input {
    width: 100% !important;
    height: 24px !important;
    font-size: 12px !important;
    padding: 2px 4px !important;
    text-align: right !important;
}
.iw-card .row.align-items-top > div > div.sec_green p {
    text-align: center !important;
    margin-bottom: 2px !important;
}

/* ==========================================================================
   MODERN POLISH & PREMIUM AESTHETICS 
   ========================================================================== */

/* 1. Elevation & Depth (Shadows) */
.iw-card, .iw-side-panel, .autocomplete-list {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03) !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 8px !important;
    background-color: #ffffff !important;
}
.iw-side-panel {
    height: 100%;
}

/* 2. Modern Table Headers */
.table thead th, .table-responsive thead th {
    background-color: #f8fafc !important;
    color: #475569 !important;
    font-size: 11px !important;
    font-weight: 600 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
    border-bottom: 2px solid #e2e8f0 !important;
    border-top: none !important;
    padding: 10px 12px !important;
}

/* 3. Softer, Premium Colors */
/* Refined Danger (Red) for Balance Amount */
.text-danger, h2.text-danger {
    color: #ef4444 !important; /* Modern crimson/rose instead of pure red */
}
/* Refined Primary (Blue) for Headings */
h6.text-primary, .text-primary {
    color: #2563eb !important; /* Rich modern indigo/blue */
}

/* 4. Input Focus States & Styling */
input.form-control, select.form-select, select.form-control, textarea.form-control, .iw-side-panel input {
    border-radius: 6px !important;
    border: 1px solid #cbd5e1 !important;
    transition: all 0.2s ease-in-out !important;
}
input.form-control:focus, select.form-select:focus, select.form-control:focus, textarea.form-control:focus, .iw-side-panel input:focus {
    border-color: #3b82f6 !important;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2) !important;
    outline: none !important;
}

/* 5. Modern Buttons */
.btn-primary, .iw-btn-primary {
    background-color: #2563eb !important;
    border-color: #2563eb !important;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05) !important;
    border-radius: 6px !important;
    transition: all 0.2s ease-in-out !important;
}
.btn-primary:hover, .iw-btn-primary:hover {
    background-color: #1d4ed8 !important;
    border-color: #1d4ed8 !important;
    box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.2), 0 2px 4px -1px rgba(37, 99, 235, 0.1) !important;
}

/* 6. Fix Toggle Button Style */
#toggleCustomerDetails {
    background-color: #f8fafc;
    border: 1px solid #e2e8f0;
    color: #3b82f6;
    border-radius: 20px;
    padding: 4px 12px;
    font-weight: 600;
    font-size: 12px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    transition: all 0.2s ease;
}
#toggleCustomerDetails:hover {
    background-color: #eff6ff;
    border-color: #bfdbfe;
    color: #2563eb;
}

/* Clean up borders inside the main layout */
#salesQuotationtab {
    border-right: 1px solid #e2e8f0 !important;
}
#custCustomerDetailsSection {
    border-left: none !important;
}

/*
 * Item History modal - the tabs scroll on their own.
 *
 * Seventeen templates carry this modal and all of them load this stylesheet,
 * which is why the rule lives here rather than in each page. Their modal body
 * is height:auto, which was fine while /stockTracking/fetch/
 * salesAndPurchaseHistory returned five rows per category; it now returns every
 * movement for the product up to its ceiling, so without a cap the modal grows
 * taller than the screen and the tab strip scrolls off the top.
 *
 * view_product.html repeats these rules inline on purpose: it is the page the
 * history was reported against, and an inline copy still applies if a till is
 * holding a stale cached copy of this file.
 *
 * The sticky header needs an opaque background of its own - a transparent
 * sticky header lets the rows scroll through behind it.
 */
#salesHistory,
#purchaseHistory,
#overallHistory {
    max-height: 60vh;
    overflow-y: auto;
}

#salesHistoryTable thead th,
#purchaseHistoryTable thead th,
#overallHistoryTable thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background-color: #fff;
}
