/* css/inventory.css - INDUSTRIAL LEDGER REVAMP */
@import url('https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@400;700&display=swap');

/* --- 1. CORE SYSTEM RULES --- */
:root {
    --ledger-font: 'Roboto Mono', monospace;
    --ledger-bg: #f2f2f2;         /* Workspace Grey */
    --paper-white: #ffffff;       /* Paper White */
    --ink-black: #000000;         /* Primary Ink */
    --border-grey: #333333;       /* Rigid Grid Line */
    --active-blue: #004085;       /* Highlight Blue */
    --danger-red: #d32f2f;
    --font-size-clerical: 11px;
    --row-height-strict: 22px;    /* Clerical height */
}

* {
    box-sizing: border-box;
    text-transform: uppercase;    /* Force All-Caps globally */
    letter-spacing: 0.5px;
}

body {
    font-family: var(--ledger-font);
    font-size: var(--font-size-clerical);
    background-color: var(--ledger-bg);
    color: var(--ink-black);
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Remove Number Input Spinners */
input[type=number]::-webkit-inner-spin-button, 
input[type=number]::-webkit-outer-spin-button { 
  -webkit-appearance: none; 
  margin: 0; 
}
input[type=number] {
  -moz-appearance: textfield;
}

/* --- 2. HEADER & TOOLBAR --- */
.app-header {
    background-color: #2c3e50;
    color: white;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 15px;
    border-bottom: 2px solid var(--ink-black);
    position: sticky;
    top: 0;
    z-index: 100;
    flex-shrink: 0;
}

.app-header h1 { 
    font-size: 16px; 
    margin: 0; 
}

.user-display {
    font-size: 10px;
    color: #aeb6bf;
    margin-left: 15px;
}

.header-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

.header-actions button, .header-button {
    background: transparent;
    border: 1px solid #ffffff44;
    color: white;
    padding: 2px 8px;
    font-size: 10px;
    cursor: pointer;
    height: 24px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    transition: all 0.2s;
}

.header-actions button:hover, .header-button:hover {
    background-color: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.6);
}

#logoutBtn {
    border-color: rgba(220, 53, 69, 0.4);
    color: #ffcccc;
}

#logoutBtn:hover {
    background-color: rgba(220, 53, 69, 0.2);
    border-color: #dc3545;
    color: white;
}

/* --- 3. MAIN LAYOUT & KPI PANELS --- */
.po-container {
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    padding: 0 10px;
    flex-grow: 1;
}

.ledger-details-panel {
    background: var(--paper-white);
    padding: 10px;
    border: 1px solid var(--ink-black);
    margin-bottom: 10px;
    box-shadow: 2px 2px 0px #000; /* Industrial shadow */
}

.ledger-header-table {
    width: 100%;
    border-collapse: collapse;
}

.ledger-label {
    width: 140px;
    font-weight: 700;
    font-size: 10px;
    padding: 4px 5px;
    background: #e9ecef;
    border: 1px solid var(--border-grey);
    vertical-align: middle;
}

.ledger-input-cell {
    border: 1px solid var(--border-grey);
    padding: 0;
    height: 24px;
    vertical-align: middle;
}

.ledger-input {
    width: 100%;
    height: 100%;
    border: none;
    padding: 0 5px;
    font-family: var(--ledger-font);
    font-size: 11px;
    outline: none;
    background: transparent;
    color: var(--ink-black);
}

.ledger-input:focus { 
    background: #fffbe6; 
}

.ledger-input[readonly], .ledger-input:disabled {
    background-color: #f8f9fa;
    color: #555;
    font-weight: bold;
}

.grand-val {
    font-size: 14px;
    font-weight: bold;
}

/* --- 4. ITEM GRID (EXCEL STYLE) --- */
.item-table-wrapper {
    background: var(--paper-white);
    border: 2px solid var(--ink-black);
    overflow-y: auto;
    max-height: 65vh;
}

.ledger-grid {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.ledger-grid th {
    background: #333;
    color: white;
    font-size: 10px;
    height: 24px;
    border: 1px solid var(--paper-white);
    padding: 0 8px;
    text-align: left;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 10;
}

.ledger-grid td {
    border: 1px solid var(--border-grey);
    height: var(--row-height-strict);
    padding: 4px 8px; 
    vertical-align: middle;
    font-size: 11px;
}

.ledger-grid tr:hover {
    background-color: #f1f1f1;
}

.col-action, .col-check {
    width: 60px;
    text-align: center;
}

/* --- 5. MODALS & FORMS --- */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    display: none; /* Controlled by JS */
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.modal-content, .modal-content-small {
    background: var(--paper-white);
    border: 2px solid var(--ink-black);
    padding: 20px;
    box-shadow: 10px 10px 0px var(--ink-black);
    max-height: 85vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.modal-content {
    width: 800px;
    max-width: 95vw;
}

.modal-content-small {
    width: 450px;
    max-width: 90vw;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    border-bottom: 2px solid var(--border-grey);
    padding-bottom: 10px;
}

.modal-header h2 {
    margin: 0;
    font-size: 14px;
    color: var(--ink-black);
    font-weight: bold;
}

.modal-close {
    background: none;
    border: none;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
    color: #555;
}

.modal-close:hover {
    color: var(--danger-red);
}

.modal-body {
    flex-grow: 1;
    overflow-y: auto;
}

.modal-footer {
    margin-top: 20px;
    display: flex;
    justify-content: flex-end;
    border-top: 1px solid var(--border-grey);
    padding-top: 15px;
}

/* Form Layouts */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.form-column {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-size: 10px;
    font-weight: bold;
    color: var(--ink-black);
    margin-bottom: 4px;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="date"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 6px;
    border: 1px solid var(--border-grey);
    font-family: var(--ledger-font);
    font-size: 11px;
    outline: none;
    background: #fff;
    color: var(--ink-black);
}

.form-group input:focus, 
.form-group select:focus, 
.form-group textarea:focus {
    background-color: #fffbe6;
}

.form-group input:disabled, 
.form-group input[readonly] {
    background-color: #f8f9fa;
    color: #555;
    font-weight: bold;
}

.form-group-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background: #e9ecef;
    border: 1px solid var(--border-grey);
    margin-top: 5px;
}

.form-group-checkbox label {
    margin: 0;
    cursor: pointer;
}

/* Internal Modal Tables (Update/Delete/Groups) */
.modal-list-wrapper {
    border: 1px solid var(--border-grey);
    margin-top: 15px;
    max-height: 40vh;
    overflow-y: auto;
}

.modal-table {
    width: 100%;
    border-collapse: collapse;
}

.modal-table th {
    background: #444;
    color: white;
    padding: 6px 8px;
    font-size: 10px;
    text-align: left;
    position: sticky;
    top: 0;
}

.modal-table td {
    border: 1px solid var(--border-grey);
    padding: 6px 8px;
    font-size: 11px;
}

/* --- 6. UTILITIES & BUTTONS --- */
.action-btn {
    background-color: var(--ledger-bg);
    color: var(--ink-black);
    border: 1px solid var(--border-grey);
    padding: 4px 10px;
    font-family: var(--ledger-font);
    font-size: 10px;
    cursor: pointer;
    font-weight: bold;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.action-btn:hover {
    background-color: #e2e6ea;
}

.action-btn.primary {
    background-color: var(--active-blue);
    color: white;
    border-color: var(--ink-black);
}

.action-btn.primary:hover {
    background-color: #002752;
}

.action-btn.danger {
    background-color: var(--danger-red);
    color: white;
    border-color: var(--ink-black);
}

.action-btn.danger:hover {
    background-color: #b71c1c;
}

.edit-icon-btn {
    background: none;
    border: none;
    color: var(--active-blue);
    cursor: pointer;
    font-size: 12px;
}

.edit-icon-btn:hover {
    color: #002752;
}

#bulkUploadData {
    font-family: var(--ledger-font);
    font-size: 11px;
    white-space: pre;
    border: 1px solid var(--border-grey);
    padding: 10px;
    background: #fff;
    width: 100%;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(255, 255, 255, 0.85);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.loading-overlay p {
    font-family: var(--ledger-font);
    font-weight: bold;
    margin-top: 10px;
    color: var(--ink-black);
}

.spinner {
    border: 4px solid rgba(0,0,0,0.1);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border-left-color: var(--active-blue);
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}