/* css/stock_adj.css */
/* Matches the "Excellux Tally-inspired" compact theme */

/* --- 1. Root Variables & Global Reset --- */
:root {
    --color-primary: #007bff;
    --color-primary-dark: #0056b3;
    --color-danger: #dc3545;
    --color-danger-dark: #a71d2a;
    --color-success: #28a745; /* Added for positive stock diff */
    --color-warning: #ffc107; /* Added for negative stock diff */
    --color-bg-light: #f8f9fa;
    --color-bg-dark: #e9ecef;
    --color-border: #ced4da;
    --color-text-dark: #212529;
    --color-text-light: #495057;
    --color-text-white: #ffffff;
    --font-family-sans: Arial, sans-serif;
    --shadow-light: 0 1px 3px rgba(0,0,0,0.1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; }

body {
    font-family: var(--font-family-sans);
    font-size: 13px;
    line-height: 1.4;
    background-color: var(--color-bg-dark);
    color: var(--color-text-dark);
}

/* --- 2. Header --- */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 15px;
    background-color: var(--color-text-white);
    border-bottom: 2px solid var(--color-primary);
    box-shadow: var(--shadow-light);
    position: sticky;
    top: 0;
    z-index: 100;
}

.app-header h1 { font-size: 1.2rem; color: var(--color-primary); }
.user-display { font-size: 0.8rem; color: var(--color-text-light); }
.header-actions { display: flex; gap: 6px; }

/* Buttons */
button, .header-button, .action-btn {
    font-family: var(--font-family-sans);
    font-size: 12px;
    padding: 6px 10px;
    border: 1px solid var(--color-border);
    border-radius: 3px;
    background-color: var(--color-bg-light);
    color: var(--color-text-dark);
    cursor: pointer;
    transition: background-color 0.2s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
button:hover, .header-button:hover, .action-btn:hover {
    background-color: var(--color-bg-dark);
    border-color: #adb5bd;
}

/* Primary Button */
#saveAdjBtn, .action-btn.primary {
    background-color: var(--color-primary);
    border-color: var(--color-primary);
    color: var(--color-text-white);
    font-weight: bold;
}
#saveAdjBtn:hover, .action-btn.primary:hover {
    background-color: var(--color-primary-dark);
    border-color: var(--color-primary-dark);
}

/* Delete Button */
.delete-item-btn {
    background: none;
    border: none;
    color: var(--color-danger);
    font-size: 14px;
    padding: 2px 4px;
    cursor: pointer;
}
.delete-item-btn:hover { color: var(--color-danger-dark); }

/* --- 3. Layout Containers --- */
.po-container {
    padding: 10px;
    max-width: 1200px; /* Slightly narrower than Invoice is okay */
    margin: 10px auto;
}

fieldset {
    border: 1px solid var(--color-border);
    border-radius: 3px;
    padding: 10px 15px;
    margin-bottom: 10px;
    background-color: var(--color-text-white);
    box-shadow: var(--shadow-light);
}

legend {
    font-size: 1rem;
    font-weight: bold;
    color: var(--color-primary);
    padding: 0 5px;
    margin-left: -5px;
}

/* Grid Layout for Header Details */
.po-details-grid {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}
.details-column {
    flex: 1;
    min-width: 250px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* --- 4. Forms & Inputs --- */
.form-group { display: flex; flex-direction: column; }
.form-group label { margin-bottom: 3px; font-size: 12px; font-weight: bold; color: var(--color-text-light); }

input[type="text"], input[type="number"], input[type="date"], select, textarea {
    font-family: var(--font-family-sans);
    font-size: 13px;
    padding: 6px 8px;
    border: 1px solid var(--color-border);
    border-radius: 3px;
    background-color: #fff;
    width: 100%;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(0,123,255,0.25);
}
input:read-only, input:disabled {
    background-color: var(--color-bg-light);
    color: var(--color-text-light);
    cursor: not-allowed;
}

/* --- 5. Item Table --- */
.item-table-wrapper {
    width: 100%;
    max-height: 500px; /* Taller for heavy stock taking */
    overflow-y: auto;
    border: 1px solid var(--color-border);
    border-bottom: none;
}
.item-table { width: 100%; border-collapse: collapse; }

.item-table th, .item-table td {
    padding: 6px 8px;
    border-bottom: 1px solid var(--color-border);
    text-align: left;
    vertical-align: middle;
}
.item-table th {
    font-size: 11px;
    font-weight: bold;
    text-transform: uppercase;
    background-color: var(--color-bg-light);
    position: sticky;
    top: 0;
    z-index: 10;
}

/* Table Inputs */
.item-table input {
    font-size: 13px; 
    padding: 4px; 
    border: 1px solid transparent; /* Invisible border by default */
    background: transparent;
    text-align: right;
}
.item-table input:hover { border-color: #eee; }
.item-table input:focus {
    border-color: var(--color-primary);
    background-color: #fff;
    box-shadow: none;
}

/* Stock Adj Specific Columns */
.col-sno { width: 5%; text-align: center; }
.col-scode { width: 15%; font-weight: bold; }
.col-name { width: 35%; }
.col-system-qty { width: 12%; text-align: right; color: var(--color-text-light); }
.col-physical-qty { width: 12%; text-align: right; }
.col-diff { width: 12%; text-align: right; font-weight: bold; }
.col-action { width: 9%; text-align: center; }

/* Visual cues for difference */
.diff-positive { color: var(--color-success); } /* Surplus */
.diff-negative { color: var(--color-danger); }  /* Shortage */
.diff-neutral { color: var(--color-text-light); opacity: 0.5; }

/* Footer Search Bar */
.item-adder {
    display: flex;
    align-items: center;
    padding: 8px;
    background-color: var(--color-bg-light);
    border-top: 1px solid var(--color-border);
}
.item-adder label { font-weight: bold; margin-right: 10px; }
#itemSearchSCode { flex-grow: 1; }

/* --- 6. Autocomplete List --- */
.autocomplete-items {
    position: absolute;
    border: 1px solid #d4d4d4;
    border-bottom: none;
    border-top: none;
    z-index: 99;
    top: 100%;
    left: 0;
    right: 0;
    background-color: #fff;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    max-height: 300px;
    overflow-y: auto;
}
.autocomplete-items div {
    padding: 10px;
    cursor: pointer;
    background-color: #fff;
    border-bottom: 1px solid #d4d4d4;
}
.autocomplete-items div:hover {
    background-color: #e9e9e9;
}
.autocomplete-active {
    background-color: var(--color-primary) !important; 
    color: #ffffff; 
}

/* --- 7. Modals --- */
.modal-backdrop {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0,0,0,0.5);
    display: flex; justify-content: center; align-items: center; z-index: 1000;
}
.modal-content-small {
    background-color: var(--color-text-white); 
    border-radius: 4px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2); 
    width: 90%; 
    max-width: 400px;
    display: flex; flex-direction: column;
}
.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 15px; border-bottom: 1px solid var(--color-border);
}
.modal-header h2 { font-size: 1.1rem; margin: 0; }
.modal-close {
    font-size: 1.5rem; border: none; background: none; cursor: pointer; color: var(--color-text-light);
}
.modal-body { padding: 15px; }
.modal-footer {
    padding: 10px 15px; border-top: 1px solid var(--color-border);
    background-color: var(--color-bg-light); display: flex; justify-content: flex-end;
}

/* --- 8. Loading Overlay --- */
.loading-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(255, 255, 255, 0.8);
    display: flex; flex-direction: column; justify-content: center; align-items: center; z-index: 9999;
}
.spinner {
    border: 4px solid var(--color-bg-light); border-top: 4px solid var(--color-primary);
    border-radius: 50%; width: 40px; height: 40px; animation: spin 1s linear infinite;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
.loading-overlay p { margin-top: 10px; font-weight: bold; color: var(--color-primary); }