/* ============================================
   Estoque - Custom Stylesheet
   Mobile-first responsive design
   ============================================ */

/* --- Base / Typography --- */
:root {
    --primary: #4361ee;
    --primary-dark: #3a0ca3;
    --primary-light: #7b8fff;
    --success: #06d6a0;
    --danger: #ef476f;
    --warning: #ffd166;
    --bg: #f8f9fc;
    --card-bg: #ffffff;
    --text: #2b2d42;
    --text-muted: #8d99ae;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, .08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, .1);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all .2s ease;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

/* --- Gradient backgrounds --- */
.bg-primary-gradient {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%) !important;
}

/* --- Navbar --- */
.navbar {
    padding: .6rem 1rem;
    backdrop-filter: blur(10px);
}

.navbar-brand {
    font-size: 1.1rem;
    letter-spacing: -.02em;
}

/* --- Stat Cards --- */
.stat-card {
    background: var(--card-bg);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    border: 1px solid rgba(0, 0, 0, .04);
}

.stat-number {
    font-size: 1.4rem;
    letter-spacing: -.02em;
}

.stat-label {
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .04em;
}

/* --- Product Cards (Mobile) --- */
.product-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(0, 0, 0, .04);
    padding: .85rem;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.product-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    border-radius: var(--radius) 0 0 var(--radius);
    transition: var(--transition);
}

.product-card.status-ok::before {
    background: var(--success);
}

.product-card.status-low::before {
    background: var(--danger);
}

.product-card:active {
    transform: scale(.98);
}

.product-card .card-title {
    font-size: .95rem;
    font-weight: 600;
    margin-bottom: .15rem;
    color: var(--text);
}

.product-card .card-unit {
    font-size: .75rem;
    color: var(--text-muted);
}

.product-card .card-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: .25rem;
    margin-top: .55rem;
}

.product-card .card-stat {
    text-align: center;
}

.product-card .card-stat-value {
    font-size: .95rem;
    font-weight: 600;
}

.product-card .card-stat-label {
    font-size: .6rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: var(--text-muted);
}

.product-card .card-footer-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: .55rem;
    padding-top: .45rem;
    border-top: 1px solid rgba(0, 0, 0, .05);
}

/* --- Badges --- */
.badge-ok {
    background: rgba(6, 214, 160, .12);
    color: #059669;
    font-weight: 600;
    font-size: .7rem;
    padding: .3em .7em;
    border-radius: 20px;
}

.badge-low {
    background: rgba(239, 71, 111, .12);
    color: #dc2626;
    font-weight: 600;
    font-size: .7rem;
    padding: .3em .7em;
    border-radius: 20px;
    animation: pulse-badge 2s infinite;
}

@keyframes pulse-badge {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: .6;
    }
}

/* --- Table (Desktop) --- */
.product-table {
    font-size: .875rem;
}

.product-table thead {
    background: var(--bg);
}

.product-table thead th {
    font-weight: 600;
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-muted);
    border-bottom: 2px solid rgba(0, 0, 0, .06);
    padding: .65rem .5rem;
    white-space: nowrap;
}

.product-table tbody td {
    padding: .6rem .5rem;
    vertical-align: middle;
    border-bottom: 1px solid rgba(0, 0, 0, .04);
}

.product-table tbody tr {
    transition: var(--transition);
}

.product-table tbody tr:hover {
    background: rgba(67, 97, 238, .03);
}

.product-table .text-danger-emphasis {
    color: var(--danger) !important;
    font-weight: 600;
}

/* --- Action Buttons --- */
.btn-action {
    width: 30px;
    height: 30px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: none;
    font-size: .8rem;
    transition: var(--transition);
}

.btn-edit {
    background: rgba(67, 97, 238, .1);
    color: var(--primary);
}

.btn-edit:hover {
    background: var(--primary);
    color: #fff;
}

.btn-delete {
    background: rgba(239, 71, 111, .1);
    color: var(--danger);
}

.btn-delete:hover {
    background: var(--danger);
    color: #fff;
}

/* --- Search Input --- */
#searchInput:focus {
    box-shadow: 0 0 0 3px rgba(67, 97, 238, .15);
    border-color: var(--primary-light);
}

/* --- Modal --- */
.modal-content {
    border-radius: var(--radius);
}

.modal-header.bg-primary-gradient {
    border-radius: var(--radius) var(--radius) 0 0;
}

/* --- Faltam highlight --- */
.faltam-value {
    font-weight: 700;
}

.faltam-value.has-faltam {
    color: var(--danger);
}

/* --- Expiry --- */
.expiry-text {
    font-size: .75rem;
    color: var(--text-muted);
}

/* --- Alert Results Bar --- */
.alert-result-bar {
    border-radius: 0;
    font-size: .85rem;
    border-left: none;
    border-right: none;
}

/* --- Loading spinner --- */
.spinner-save {
    display: none;
}

.is-saving .spinner-save {
    display: inline-block;
}

.is-saving .save-text {
    display: none;
}

/* --- Empty state --- */
#emptyState i {
    opacity: .4;
}

/* --- Responsive tweaks --- */
@media (max-width: 767.98px) {
    .container-fluid {
        padding-left: .75rem;
        padding-right: .75rem;
    }

    .modal-dialog {
        margin: .5rem;
    }
}

@media (min-width: 768px) {
    .product-table {
        background: var(--card-bg);
        border-radius: var(--radius);
        box-shadow: var(--shadow-sm);
        overflow: hidden;
    }
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, .15);
    border-radius: 3px;
}

/* --- Transitions for entering cards --- */
.product-card,
.product-table tbody tr {
    animation: fadeIn .3s ease forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- Qty Adjust Buttons (▲▼) --- */
.qty-adjust-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.btn-qty {
    width: 22px;
    height: 22px;
    padding: 0;
    border: none;
    border-radius: 6px;
    font-size: .65rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}

.btn-qty-plus {
    background: rgba(6, 214, 160, .15);
    color: #059669;
}

.btn-qty-plus:hover {
    background: var(--success);
    color: #fff;
}

.btn-qty-minus {
    background: rgba(239, 71, 111, .15);
    color: #dc2626;
}

.btn-qty-minus:hover {
    background: var(--danger);
    color: #fff;
}

.btn-qty:active {
    transform: scale(.88);
}