/* ===== ENTERPRISE FORM SYSTEM ===== */

/* Field Error */
.field-error { display: block; font-size: 10px; color: var(--danger); margin-top: 3px; font-weight: 500; animation: slideDown 0.15s ease; }
.form-group.has-error input,
.form-group.has-error select { border-color: var(--danger); background: var(--danger-light); }

/* Form Layout */
.compact-form { width: 100%; }
.form-row {
    display: flex;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-md);
    flex-wrap: wrap;
}
.form-row:last-child { margin-bottom: 0; }
.form-row.two-col > .form-group { flex: 0 0 calc(50% - var(--spacing-md) / 2); }
.form-group {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}
.form-group label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
    letter-spacing: 0.2px;
    display: flex;
    align-items: center;
    gap: 5px;
}
.form-group label i {
    font-size: 13px;
    color: var(--primary);
}
.required { color: var(--danger); margin-left: 2px; }

.form-input {
    width: 100%;
    padding: 7px 12px;
    font-size: 13px;
    font-family: var(--font);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s;
    line-height: 1.4;
    height: 36px;
}
.form-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); background: #fff; }
.form-input::placeholder { color: var(--text-muted); }
select.form-input { cursor: pointer; appearance: auto; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%239eaab8'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 30px; }
textarea.form-input { resize: vertical; min-height: 60px; height: auto; }

/* Input variants */
.form-input-sm { height: 30px; padding: 4px 10px; font-size: 12px; }
.form-input-lg { height: 40px; padding: 8px 14px; font-size: 14px; }
.form-input[readonly] { background: var(--bg-secondary); cursor: default; }
.help-text { display: block; font-size: 10px; color: var(--text-muted); margin-top: 3px; }
.form-input.text-right { text-align: right; }
input[type="number"].form-input { -moz-appearance: textfield; }
input[type="number"].form-input::-webkit-outer-spin-button,
input[type="number"].form-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.form-actions {
    display: flex; align-items: center; gap: 8px;
    padding-top: var(--spacing-md);
    border-top: 1px solid var(--border);
    margin-top: var(--spacing-md);
}

/* Column widths */
.col-1 { width: calc(8.333% - 11px); }
.col-2 { width: calc(16.666% - 10px); }
.col-3 { width: calc(25% - 9px); }
.col-4 { width: calc(33.333% - 8px); }
.col-5 { width: calc(41.666% - 7px); }
.col-6 { width: calc(50% - 6px); }
.col-7 { width: calc(58.333% - 5px); }
.col-8 { width: calc(66.666% - 4px); }
.col-9 { width: calc(75% - 3px); }
.col-10 { width: calc(83.333% - 2px); }
.col-11 { width: calc(91.666% - 1px); }
.col-12 { width: 100%; }

/* ===== ENTERPRISE SECTION CARDS ===== */
.form-section {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-md);
    animation: slideUp 0.15s ease;
    box-shadow: var(--shadow);
}
.section-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: var(--spacing-md);
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: 0.2px;
}
.section-title i { font-size: 16px; color: var(--primary); }

/* Section color variants */
.section-info { border-left: 4px solid var(--primary); }
.section-info .section-title { color: var(--primary); }
.section-info .section-title i { color: var(--primary); }

.section-success { border-left: 4px solid var(--accent); }
.section-success .section-title { color: #6A8F20; }
.section-success .section-title i { color: var(--accent); }

.section-indigo { border-left: 4px solid #6366F1; }
.section-indigo .section-title { color: #6366F1; }
.section-indigo .section-title i { color: #6366F1; }

.section-warning { border-left: 4px solid var(--warning); }
.section-warning .section-title { color: var(--warning); }
.section-warning .section-title i { color: var(--warning); }
.section-warning .section-title { color: #B87D10; }
.section-warning .section-title i { color: var(--warning); }

.section-danger { border-left: 4px solid var(--danger); }
.section-danger .section-title { color: var(--danger); }
.section-danger .section-title i { color: var(--danger); }

.section-dark { border-left: 4px solid var(--primary-dark); }
.section-dark .section-title { color: var(--primary-dark); }
.section-dark .section-title i { color: var(--primary-dark); }

.section-gray { border-left: 4px solid var(--text-muted); }
.section-gray .section-title { color: var(--text-secondary); }
.section-gray .section-title i { color: var(--text-muted); }

/* ===== SUMMARY PANEL ===== */
.summary-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--spacing-lg);
    border-left: 4px solid var(--primary-dark);
    box-shadow: var(--shadow);
}
.summary-panel .section-title { color: var(--primary-dark); margin-bottom: 10px; }
.summary-panel .section-title i { color: var(--primary-dark); }
.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid var(--border-light);
    font-size: 12px;
}
.summary-row:last-child { border-bottom: none; }
.summary-label { color: var(--text-secondary); font-weight: 500; }
.summary-value { font-weight: 600; color: var(--text); }
.summary-value.text-right { text-align: right; }
.summary-grand {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary);
    padding-top: 10px;
    margin-top: 6px;
    border-top: 2px solid var(--primary);
}
.summary-grand .summary-label { color: var(--primary); }
.summary-grand .summary-value { color: var(--primary); font-size: 18px; }

/* ===== INFO PANEL ===== */
.info-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px var(--spacing-lg);
    border-left: 4px solid var(--primary);
    margin-bottom: var(--spacing-md);
}
.info-panel .section-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--primary);
    margin-bottom: 8px;
    padding-bottom: 6px;
}
.info-panel .section-title i { font-size: 13px; }
.info-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 12px;
    border-bottom: 1px solid var(--border-light);
}
.info-row:last-child { border-bottom: none; }
.info-label { color: var(--text-secondary); font-weight: 500; }
.info-value { font-weight: 600; color: var(--text); }
.info-value.highlight { color: var(--primary); }
.info-value.danger { color: var(--danger); }
.info-value.success { color: var(--success); }

/* ===== ACTION BARS ===== */
.action-bar-top {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0 14px 0;
    flex-wrap: wrap;
}
.action-bar-top .btn { height: 30px; }
.action-bar-bottom {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px var(--spacing-lg);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-top: var(--spacing-md);
    position: sticky;
    bottom: 28px;
    z-index: 50;
    box-shadow: var(--shadow-md);
}
.action-bar-bottom .btn { height: 34px; padding: 5px 20px; font-size: 13px; }

/* Hide action bar inside modals — modal footer handles buttons */
.modal-body .action-bar-bottom { display: none; }

/* Prevent sticky action bar from overlapping last form fields */
.form-section:last-child { padding-bottom: 28px; }

/* ===== PRODUCT GRID ===== */
.product-grid-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.product-grid {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    min-width: 1100px;
}
.product-grid thead { position: sticky; top: 0; z-index: 5; }
.product-grid th {
    background: var(--primary);
    color: #fff;
    padding: 8px 10px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.2px;
    text-align: left;
    white-space: nowrap;
    border-right: 1px solid rgba(255,255,255,0.15);
}
.product-grid th:last-child { border-right: none; }
.product-grid td {
    padding: 6px 10px;
    border-bottom: 1px solid var(--border-light);
    border-right: 1px solid var(--border-light);
    vertical-align: middle;
}
.product-grid td:last-child { border-right: none; }
.product-grid tbody tr:nth-child(even) { background: #F8FAFC; }
.product-grid tbody tr:hover { background: var(--primary-light); }

.product-grid .form-input {
    height: 30px;
    padding: 4px 8px;
    font-size: 12px;
}
.product-grid .form-input-sm {
    height: 28px;
    padding: 3px 7px;
    font-size: 11px;
}
.product-grid .text-right input { text-align: right; }

/* Compact sales POS product grid — tight rows, readable sizes */
.sales-panel-stretch .product-grid {
    min-width: 680px;
    font-size: 12px;
    border-collapse: collapse;
}
.sales-panel-stretch .product-grid th {
    padding: 4px 6px;
    font-size: 11px;
    letter-spacing: 0;
}
.sales-panel-stretch .product-grid td {
    padding: 2px 4px;
    font-size: 12px;
    line-height: 1.2;
}
.sales-panel-stretch .product-grid .form-input,
.sales-panel-stretch .product-grid input,
.sales-panel-stretch .product-grid textarea,
.sales-panel-stretch .product-grid select {
    height: 24px;
    min-height: 24px;
    padding: 2px 4px;
    font-size: 11px;
    line-height: 1.2;
    border-radius: 3px;
    box-sizing: border-box;
}
.sales-panel-stretch .product-grid textarea {
    min-height: 24px;
    resize: none;
}
.sales-panel-stretch .product-grid tbody tr:nth-child(even) { background: #F8FAFC; }
.sales-panel-stretch .product-grid tbody tr:hover { background: #E8F4FD; }

/* Excel-style compact grid for purchase */
.purchase-grid-compact .product-grid {
    min-width: 680px;
    font-size: 11px;
    border-collapse: collapse;
}
.purchase-grid-compact .product-grid th {
    padding: 2px 4px;
    font-size: 10px;
    letter-spacing: 0;
    line-height: 1.1;
}
.purchase-grid-compact .product-grid td {
    padding: 0 2px;
    font-size: 11px;
    line-height: 1;
    border-bottom: none;
    border-right: 1px solid #E2E8F0;
}
.purchase-grid-compact .product-grid td:last-child { border-right: none; }
.purchase-grid-compact .product-grid .form-input,
.purchase-grid-compact .product-grid input,
.purchase-grid-compact .product-grid textarea,
.purchase-grid-compact .product-grid select {
    height: 20px;
    min-height: 20px;
    padding: 1px 2px;
    font-size: 10px;
    line-height: 1;
    border-radius: 2px;
    box-sizing: border-box;
}
.purchase-grid-compact .product-grid textarea {
    min-height: 20px;
    resize: none;
}
.purchase-grid-compact .product-grid tbody tr:nth-child(even) { background: #F8FAFC; }
.purchase-grid-compact .product-grid tbody tr:hover { background: #E8F4FD; }

/* ===== PURCHASE PRODUCT GRID (Aligned) ===== */
.purchase-grid-wrap {
    overflow-x: auto;
    border: none;
    border-radius: 0;
}
.purchase-product-grid {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    table-layout: fixed;
}
.purchase-product-grid thead { position: sticky; top: 0; z-index: 5; }
.purchase-product-grid th {
    background: var(--primary);
    color: #fff;
    padding: 3px 4px;
    font-size: 10px;
    font-weight: 600;
    text-align: left;
    white-space: nowrap;
    border-right: 1px solid rgba(255,255,255,0.15);
}
.purchase-product-grid th:last-child { border-right: none; }
.purchase-product-grid td {
    padding: 2px 3px;
    border-bottom: 1px solid var(--border-light);
    border-right: 1px solid var(--border-light);
    vertical-align: middle;
    line-height: 1.3;
}
.purchase-product-grid td:last-child { border-right: none; }
.purchase-product-grid tbody tr:nth-child(even) { background: #F8FAFC; }
.purchase-product-grid tbody tr:hover { background: #E8F4FD; }
.purchase-product-grid .form-input,
.purchase-product-grid input[type="text"],
.purchase-product-grid input[type="number"],
.purchase-product-grid textarea {
    height: 24px;
    min-height: 24px;
    padding: 2px 5px;
    font-size: 11px;
    line-height: 1.3;
    border-radius: 3px;
    box-sizing: border-box;
    width: 100%;
    border: 1px solid var(--border);
    background: var(--bg);
    outline: none;
    transition: border-color 0.15s;
    font-family: var(--font);
}
.purchase-product-grid .form-input:focus,
.purchase-product-grid input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(54,155,202,0.12);
}
.purchase-product-grid textarea {
    min-height: 24px;
    overflow: hidden;
    resize: vertical;
}
.purchase-product-grid td.td-center { text-align: center; }
.purchase-product-grid td.td-num { color: var(--text-muted); font-size: 10px; padding: 2px 2px; }
.purchase-product-grid td.td-product { padding: 2px 3px; }
.purchase-product-grid td.td-qty,
.purchase-product-grid td.td-free { padding: 2px 2px; }
.purchase-product-grid td.td-rate,
.purchase-product-grid td.td-net { padding: 2px 2px; }
.purchase-product-grid td.td-serials { padding: 2px 2px; }
.purchase-product-grid td.td-comments { padding: 2px 2px; vertical-align: top; }
.purchase-product-grid td.td-machine-type,
.purchase-product-grid td.td-machine-volt { padding: 2px 2px; }
.purchase-product-grid td.td-machine-type select,
.purchase-product-grid td.td-machine-volt select { height: 24px; }
.purchase-product-grid td.td-del { padding: 2px 2px; }
.purchase-product-grid .del-row-btn {
    padding: 2px 4px;
    font-size: 13px;
    background: none;
    border: none;
    cursor: pointer;
    border-radius: 3px;
    transition: background 0.15s;
}
.purchase-product-grid .del-row-btn:hover { background: rgba(220,53,69,0.1); }
.purchase-product-grid .item-equiv {
    display: block;
    font-size: 8px;
    color: var(--text-muted);
    line-height: 1.2;
}
.purchase-product-grid .item-equiv:empty { line-height: 0; }
/* Product autocomplete dropdown */
.product-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    max-height: 220px;
    overflow-y: auto;
    z-index: 100;
    font-size: 11px;
    margin-top: 2px;
}
.product-dropdown-item {
    padding: 6px 8px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-light);
    line-height: 1.4;
}
.product-dropdown-item:last-child { border-bottom: none; }
.product-dropdown-item:hover,
.product-dropdown-item.active {
    background: var(--primary-light);
}
.product-dropdown-item .dd-code {
    font-weight: 600;
    color: var(--primary);
    font-size: 11px;
}
.product-dropdown-item .dd-name {
    color: var(--text);
    font-size: 11px;
}
.product-dropdown-item .dd-meta {
    font-size: 9px;
    color: var(--text-muted);
    margin-top: 1px;
}
.product-dropdown-empty {
    padding: 8px;
    color: var(--text-muted);
    font-size: 11px;
    text-align: center;
}

/* Ledger balance red bold */
.ledger-balance {
    color: var(--danger) !important;
    font-weight: 700;
}

/* Highlighting */
.row-edited { background: #FFF8E1 !important; }
.row-negative { background: #FFEBEE !important; }
.row-negative td { color: var(--danger); }
.row-lowstock { background: #FFF3E0 !important; }

/* ===== INFO DISPLAY (View mode label:value) ===== */
.info-display { display: flex; padding: 6px 0; border-bottom: 1px solid var(--border-light); }
.info-display:last-child { border-bottom: none; }
.info-display-label { width: 160px; font-weight: 600; color: var(--text-secondary); font-size: 12px; flex-shrink: 0; }
.info-display-value { flex: 1; color: var(--text); font-size: 12px; }

/* ===== STATUS BADGES ===== */
.status-badge {
    display: inline-block;
    padding: 3px 12px;
    font-size: 10px;
    font-weight: 700;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    line-height: 1.6;
}
.status-draft { background: #FFF8E1; color: #C77A00; }
.status-approved { background: var(--success-light); color: var(--success); }
.status-completed { background: var(--primary-light); color: var(--primary); }
.status-cancelled { background: var(--danger-light); color: var(--danger); }
.status-pending { background: #FFF3E0; color: #E68A00; }

/* ===== RESPONSIVE ===== */
@media (max-width: 1200px) {
    .col-2, .col-3 { width: calc(33.333% - 8px); }
    .col-4 { width: calc(50% - 6px); }
    .col-7, .col-8 { width: calc(50% - 6px); }
}
@media (max-width: 992px) {
    .form-row { gap: 10px; }
    .col-2, .col-3, .col-4, .col-5, .col-6, .col-7, .col-8 { width: calc(50% - 5px); }
}
@media (max-width: 768px) {
    .form-row { gap: 8px; }
    .col-1, .col-2, .col-3, .col-4, .col-5, .col-6, .col-7, .col-8,
    .col-9, .col-10, .col-11, .col-12 { width: 100%; }
}

/* ===== DETAIL CARD COLORS (for View pages) ===== */
.detail-card-info { border-left: 4px solid var(--primary) !important; }
.detail-card-info h4 i { color: var(--primary) !important; }
.detail-card-success { border-left: 4px solid var(--accent) !important; }
.detail-card-success h4 i { color: var(--accent) !important; }
.detail-card-warning { border-left: 4px solid var(--warning) !important; }
.detail-card-warning h4 i { color: var(--warning) !important; }
.detail-card-indigo { border-left: 4px solid #6366F1 !important; }
.detail-card-indigo h4 i { color: #6366F1 !important; }
.detail-card-dark { border-left: 4px solid var(--primary-dark) !important; }
.detail-card-dark h4 i { color: var(--primary-dark) !important; }
.detail-card-gray { border-left: 4px solid var(--text-muted) !important; }
.detail-card-gray h4 i { color: var(--text-muted) !important; }

/* ===== LOGIN FORM ===== */
.login-form .form-group { margin-bottom: 18px; }
.login-form label {
    font-size: 12px;
    font-weight: 600;
    color: #3a4a5e;
    margin-bottom: 5px;
    display: flex;
    align-items: center;
    gap: 5px;
}
.login-form label i {
    font-size: 13px;
    color: var(--primary);
}
.login-form .form-input {
    padding: 10px 14px;
    font-size: 13px;
    height: 40px;
    border: 1.5px solid #dce1e8;
    border-radius: 8px;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #f8fafc;
}
.login-form .form-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(54,155,202,0.12);
    background: #fff;
}
.login-form .form-input::placeholder {
    color: #a0aec0;
}
.login-form .form-group-remember {
    margin-bottom: 20px;
}
.login-form .checkbox-label {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 12px;
    color: #5a6878;
    cursor: pointer;
    font-weight: 400;
}
.login-form .checkbox-label input[type="checkbox"] {
    accent-color: var(--primary);
    width: 15px;
    height: 15px;
    cursor: pointer;
}
.login-form .btn-login {
    width: 100%;
    justify-content: center;
    padding: 10px;
    font-size: 14px;
    font-weight: 600;
    height: 42px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    border: none;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 0.3px;
}
.login-form .btn-login:hover {
    background: linear-gradient(135deg, var(--primary-hover), var(--primary-dark));
    box-shadow: 0 4px 16px rgba(54,155,202,0.35);
    transform: translateY(-1px);
}
.login-form .btn-login:active {
    transform: translateY(0);
}
.login-form .form-links {
    text-align: center;
    margin-top: 16px;
    font-size: 12px;
}
.login-form .form-links a {
    color: #6b7a8f;
    text-decoration: none;
    transition: color 0.2s;
}
.login-form .form-links a:hover {
    color: var(--primary);
    text-decoration: none;
}
.login-form .login-devby {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #e8ebf0;
}
.login-form .login-devby span {
    font-size: 11px;
    color: #94a3b8;
}
.login-form .login-devby a {
    font-size: 11px;
    font-weight: 600;
    color: var(--primary);
    text-decoration: none;
    transition: color 0.2s;
}
.login-form .login-devby a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

/* ===== DEVICE DYNAMIC ROWS ===== */
#device-dropdowns {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
#device-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
#device-table td {
    padding: 3px 4px;
    vertical-align: middle;
}
#device-table .form-input {
    font-size: 12px;
    height: 32px;
    box-sizing: border-box;
}
#device-table td:first-child { padding-left: 0; }
#device-table td:last-child { padding-right: 0; width: 32px; text-align: center; }
#device-table .remove-device {
    padding: 2px 6px;
    font-size: 11px;
}
.device-row-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
    min-width: 60px;
}
.device-row .device-select {
    flex: 1;
    height: 32px;
    font-size: 12px;
}
