/* Viewer - custom styles */

body {
    font-family: 'Segoe UI', Tahoma, Arial, sans-serif;
    min-height: 100vh;
    padding-bottom: 80px;
}

.navbar-brand {
    font-weight: 600;
    letter-spacing: .3px;
}

#warehouseSelect,
#categorySelect {
    display: block;
    width: 100%;
    min-height: 38px;
}

#inventoryTable thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    white-space: nowrap;
    vertical-align: middle;
}

#inventoryTable tbody td {
    vertical-align: middle;
}

.qty-input {
    transition: background-color .15s ease, border-color .15s ease;
    font-variant-numeric: tabular-nums;
    font-weight: 500;
}

.name-input {
    border: 1px solid transparent;
    background: transparent;
    font-weight: 600;
    transition: background-color .15s ease, border-color .15s ease;
    width: 100%;
}

.name-input:focus {
    border-color: #86b7fe;
    background: #fff;
    box-shadow: 0 0 0 .2rem rgba(13, 110, 253, .15);
}

.name-input.bg-warning-subtle {
    background-color: #fff3cd !important;
    border-color: #ffda6a !important;
}

.name-input.bg-success-subtle {
    background-color: #d1e7dd !important;
    border-color: #a3cfbb !important;
    transition: background-color 1s ease;
}

.price-input {
    border: 1px solid transparent;
    background: transparent;
    font-weight: 500;
    font-size: .85rem;
    transition: background-color .15s ease, border-color .15s ease;
    width: 100%;
}

.price-input:focus {
    border-color: #86b7fe;
    background: #fff;
    box-shadow: 0 0 0 .2rem rgba(13, 110, 253, .15);
}

.price-input.bg-warning-subtle {
    background-color: #fff3cd !important;
    border-color: #ffda6a !important;
}

.price-input.bg-success-subtle {
    background-color: #d1e7dd !important;
    border-color: #a3cfbb !important;
    transition: background-color 1s ease;
}

.price-input::-webkit-outer-spin-button,
.price-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.price-input {
    -moz-appearance: textfield;
}

/* PDF modal warehouse list */
#pdfWarehouseList .form-check {
    margin-bottom: .25rem;
}

.qty-input:focus {
    box-shadow: 0 0 0 .2rem rgba(13, 110, 253, .15);
}

.qty-input.bg-warning-subtle {
    background-color: #fff3cd !important;
    border-color: #ffda6a !important;
}

.qty-input.bg-success-subtle {
    background-color: #d1e7dd !important;
    border-color: #a3cfbb !important;
    transition: background-color 1s ease;
}

.qty-input.is-invalid {
    border-color: #dc3545;
    background-color: #f8d7da !important;
}

#inventoryTable tbody td:first-child {
    position: sticky;
    right: 0;
    background: #fff;
    z-index: 1;
    border-left: 1px solid #dee2e6;
}

#inventoryTable thead th:first-child {
    position: sticky;
    right: 0;
    z-index: 3;
}

.qty-input::-webkit-outer-spin-button,
.qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.qty-input {
    -moz-appearance: textfield;
}

#searchBox:focus {
    box-shadow: 0 0 0 .2rem rgba(13, 110, 253, .15);
}

#statusBar {
    font-size: .85rem;
}

.card {
    border: none;
    border-radius: .75rem;
    overflow: hidden;
}

.toast {
    min-width: 260px;
}

/* Fixed bottom save bar */
#saveBar {
    transition: opacity .2s ease;
}

#saveBar .btn {
    font-size: 1.1rem;
    font-weight: 600;
}

.delete-btn {
    opacity: .6;
    transition: opacity .15s;
}
.delete-btn:hover {
    opacity: 1;
}

/* ============================================================ */
/* Login screen                                                */
/* ============================================================ */
.login-screen {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, #f0f6ff 0%, #ffffff 50%, #fff8f0 100%);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.login-bg-circle {
    position: absolute;
    border-radius: 50%;
    opacity: .5;
    pointer-events: none;
}
.login-bg-circle-tl {
    width: 320px;
    height: 320px;
    top: -120px;
    left: -100px;
    background: #cfe2ff;
}
.login-bg-circle-br {
    width: 360px;
    height: 360px;
    bottom: -160px;
    right: -110px;
    background: #fde2c5;
}

.login-card-wrap {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 420px;
    padding: 0 16px;
}

.login-card {
    border: none;
    border-radius: 1rem;
}

.login-avatar {
    width: 70px;
    height: 70px;
    margin: 0 auto;
    border-radius: 50%;
    background: #e7f1ff;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #0d6efd;
    font-size: 2rem;
}

/* ============================================================ */
/* Add Product modal sections                                  */
/* ============================================================ */
.form-section-title {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin: 1rem 0 .5rem;
    font-weight: 700;
    color: #b46e00;
}
.form-section-title .bar {
    display: inline-block;
    width: 4px;
    height: 16px;
    background: #fd7e14;
    border-radius: 2px;
}
.form-section-title small {
    font-weight: 400;
}

.ap-warehouse-card {
    border: 1px solid #dee2e6;
    border-radius: .5rem;
    padding: .75rem;
    margin-bottom: .5rem;
    background: #fff;
}

/* User info bar */
#userInfoBar {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
}

/* ============================================================ */
/* Responsive: tablets (≤ 992px)                                */
/* ============================================================ */
@media (max-width: 991.98px) {
    .toolbar-actions {
        margin-top: .5rem;
    }
}

/* ============================================================ */
/* Responsive: mobile (≤ 768px)                                */
/* ============================================================ */
@media (max-width: 768px) {
    .table-responsive {
        font-size: .85rem;
    }
    body {
        padding-bottom: 100px;
    }

    /* Navbar: shrink the brand and stack status below */
    .navbar > .container-fluid {
        flex-wrap: wrap;
    }
    .navbar-brand {
        font-size: .95rem;
        max-width: 70%;
    }

    /* Toolbar: bigger tap targets, icons-only on small screens */
    .toolbar-actions .btn {
        min-width: 40px;
        min-height: 38px;
        padding: .375rem .55rem;
    }

    /* Table: smaller font and slightly tighter cells */
    #inventoryTable th,
    #inventoryTable td {
        padding: .35rem .4rem;
        font-size: .82rem;
    }
    .qty-input {
        max-width: 70px !important;
        font-size: .95rem;
        min-height: 38px;
    }
    .price-input {
        max-width: 75px !important;
        font-size: .8rem;
    }

    /* Hide non-essential text in summary card */
    #summaryCard .text-muted.ms-2 {
        display: block;
        margin-top: .25rem;
    }
}

/* ============================================================ */
/* Responsive: very small phones (≤ 480px)                     */
/* ============================================================ */
@media (max-width: 480px) {
    .login-bg-circle-tl {
        width: 220px;
        height: 220px;
        top: -90px;
        left: -70px;
    }
    .login-bg-circle-br {
        width: 240px;
        height: 240px;
        bottom: -110px;
        right: -80px;
    }
    .login-card-wrap {
        padding: 0 12px;
    }
    .login-card .card-body {
        padding: 1.25rem !important;
    }
    .login-avatar {
        width: 56px;
        height: 56px;
        font-size: 1.5rem;
    }

    /* Toolbar: drop to icon-only buttons */
    .toolbar-actions .btn {
        font-size: .85rem;
        padding: .35rem .5rem;
    }

    /* Add Product modal: full-width on tiny screens */
    #addProductModal .modal-dialog {
        margin: .5rem;
        max-width: none;
    }

    /* Inventory table: aggressive shrink */
    #inventoryTable th,
    #inventoryTable td {
        padding: .3rem .3rem;
        font-size: .78rem;
    }
    .qty-input {
        max-width: 60px !important;
        font-size: .9rem;
    }
    .price-input {
        max-width: 65px !important;
        font-size: .75rem;
    }
    .price-col {
        min-width: 60px !important;
    }
}

/* ============================================================ */
/* Landscape phone fixes                                       */
/* ============================================================ */
@media (max-height: 500px) and (orientation: landscape) {
    .login-screen {
        align-items: flex-start;
        padding-top: 1rem;
    }
    .login-bg-circle-tl {
        width: 180px;
        height: 180px;
        top: -70px;
        left: -50px;
    }
    .login-bg-circle-br {
        width: 200px;
        height: 200px;
        bottom: -80px;
        right: -60px;
    }
}