/* ==========================================================================
   VANES — UX POLISH
   Micro-animations, transitions, premium details
   ========================================================================== */

/* Smooth scrolling global */
html { scroll-behavior: smooth; }

/* Page entry animation */
.app-main {
    animation: fadeSlideIn .4s ease-out;
}
@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ======== SIDEBAR POLISH ======== */

/* Active nav item glow + accent bar */
.sidebar .nav-item.active .nav-link,
.sidebar a.active {
    background: rgba(0, 230, 118, 0.06) !important;
    border: 1px solid rgba(0, 230, 118, 0.15) !important;
    color: #fff !important;
    box-shadow: 0 0 20px rgba(0, 230, 118, 0.06);
    position: relative;
}
.sidebar .nav-item.active .nav-link::before,
.sidebar a.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 25%;
    height: 50%;
    width: 3px;
    background: #00e676;
    border-radius: 0 4px 4px 0;
    box-shadow: 0 0 10px rgba(0, 230, 118, .5);
}

/* Nav icon bump on hover */
.sidebar .nav-link:hover .nav-icon {
    transform: scale(1.1);
    transition: transform .15s ease;
}

/* Subtle sidebar separator */
.sidebar-nav {
    position: relative;
}
.sidebar-nav::after {
    content: '';
    display: block;
    height: 1px;
    margin: 8px 16px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.06), transparent);
}

/* ======== CARDS — GLASS + DEPTH ======== */

.dash-card,
.descargas-card,
.card {
    transition: border-color .2s, box-shadow .25s, transform .15s;
}
.dash-card:hover,
.card:hover {
    border-color: rgba(255,255,255,0.12);
    box-shadow: 0 20px 50px rgba(0,0,0,0.35);
    transform: translateY(-1px);
}

/* Header accents */
.dash-card-header h3,
.page-title-row h1 {
    background: linear-gradient(135deg, #fff, rgba(255,255,255,0.7));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ======== INPUTS — GLOW FOCUS ======== */

.ui-input:focus,
.ui-select:focus,
.prod-qty-input:focus,
.prec-price-input:focus {
    border-color: rgba(0, 230, 118, 0.3) !important;
    box-shadow: 0 0 0 4px rgba(0, 230, 118, 0.08) !important;
    background: rgba(0, 230, 118, 0.03) !important;
}

/* ======== BUTTONS — MICRO-INTERACTIONS ======== */

.btn-primary {
    transition: transform .08s, box-shadow .2s, background .2s, filter .2s;
    position: relative;
    overflow: hidden;
}
.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 35px rgba(0, 230, 118, 0.2);
}
.btn-primary:active {
    transform: translateY(1px) scale(0.98);
    box-shadow: 0 4px 12px rgba(0, 230, 118, 0.1);
}

/* Shimmer on primary buttons */
.btn-primary::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        to right,
        transparent 0%,
        rgba(255,255,255,0.08) 50%,
        transparent 100%
    );
    transform: rotate(30deg) translateX(-100%);
    transition: transform .5s;
    pointer-events: none;
}
.btn-primary:hover::after {
    transform: rotate(30deg) translateX(30%);
}

/* ======== TABLE ROWS — SMOOTH ======== */

.prod-row,
.prec-row,
.hist-row,
.mov-row,
.client-item,
.fila-producto,
.top10-fila {
    transition: background .15s, transform .08s;
}
.prod-row:hover,
.prec-row:hover,
.hist-row:hover,
.mov-row:hover,
.client-item:hover {
    transform: translateX(2px);
}

/* Alternating row subtle tint */
.prod-row:nth-child(even),
.prec-row:nth-child(even),
.hist-row:nth-child(even),
.mov-row:nth-child(even) {
    background: rgba(255,255,255,0.01);
}

/* ======== KPI CARDS — GLOW BORDERS ======== */

.kpi-card {
    transition: border-color .2s, box-shadow .25s, transform .15s;
    position: relative;
    overflow: hidden;
}
.kpi-card:hover {
    transform: translateY(-2px);
    border-color: rgba(255,255,255,0.1);
    box-shadow: 0 16px 40px rgba(0,0,0,0.3);
}
/* Subtle gradient shimmer at top */
.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(0,230,118,0.3), transparent);
    opacity: 0;
    transition: opacity .25s;
}
.kpi-card:hover::before {
    opacity: 1;
}

/* Deuda pulsing glow */
.kpi-card.deuda {
    animation: pulseDeuda 2s ease-in-out infinite;
}
@keyframes pulseDeuda {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255,82,82,0); }
    50% { box-shadow: 0 0 20px rgba(255,82,82,0.1); }
}

/* ======== BADGE PILL — ANIMATE ======== */

.badge-pill,
.dash-badge {
    transition: background .15s, transform .1s;
}
.badge-pill:hover,
.dash-badge:hover {
    background: rgba(255,255,255,0.08);
    transform: scale(1.05);
}

/* ======== MODAL — SMOOTH ENTRY ======== */

.modal-overlay {
    animation: modalFadeIn .2s ease-out;
}
@keyframes modalFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
.modal-box {
    animation: modalSlideUp .25s ease-out;
}
@keyframes modalSlideUp {
    from { opacity: 0; transform: translateY(20px) scale(0.95); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ======== TOAST — UPGRADE ======== */

.toast {
    font-weight: 600;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

/* ======== SCROLL ======== */

/* Custom scrollbar (webkit) */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.08);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.14);
}

/* Firefox scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.08) transparent;
}

/* ======== LOADING SKELETON ======== */

.skeleton {
    background: linear-gradient(90deg,
        rgba(255,255,255,0.03) 25%,
        rgba(255,255,255,0.06) 50%,
        rgba(255,255,255,0.03) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 8px;
}
@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ======== EMPTY STATES ======== */

.empty-msg,
.empty-state,
.chat-empty {
    position: relative;
    overflow: hidden;
}
.empty-msg::before,
.empty-state::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: radial-gradient(circle at 50% 0%, rgba(99,179,255,0.04), transparent 60%);
    pointer-events: none;
}

/* ======== VENTAS — ROW HIGHLIGHT ======== */

.prod-row.has-qty {
    background: rgba(0,230,118,0.04) !important;
    border-left: 3px solid rgba(0,230,118,0.3);
}

/* ======== TOTALES BOX — PREMIUM ======== */

.totales-box {
    background: linear-gradient(135deg, rgba(255,255,255,0.02), rgba(255,255,255,0.04)) !important;
    border: 1px solid rgba(255,255,255,0.08) !important;
    position: relative;
    overflow: hidden;
}
.totales-box::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(0,230,118,0.06), transparent 60%);
    pointer-events: none;
}
.total-final {
    text-shadow: 0 0 20px rgba(0,230,118,0.15);
}

/* ======== CUENTA CORRIENTE — SALDO ======== */

.mov-monto.pago { text-shadow: 0 0 10px rgba(0,230,118,0.2); }
.mov-monto.venta { text-shadow: 0 0 10px rgba(255,82,82,0.2); }

/* ======== AUMENTO CARD — ATTENTION ======== */

.aumento-card {
    position: relative;
    overflow: hidden;
}
.aumento-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(255,193,7,0.4), transparent);
}

/* ======== MOBILE POLISH ======== */

@media (max-width: 768px) {
    /* Bigger touch targets */
    .btn-primary,
    .btn-secondary,
    .btn-ghost {
        min-height: 48px;
        font-size: 16px;
    }
    
    /* Ventas table compact */
    .prod-head,
    .prod-row,
    .prec-head,
    .prec-row {
        padding: 10px 10px;
        font-size: 14px;
    }
    
    /* KPI cards stack nicely */
    .kpi-row {
        grid-template-columns: 1fr !important;
    }
    
    /* Modal full-width on mobile */
    .modal-box {
        width: 95% !important;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    /* Sidebar items bigger */
    .sidebar .nav-link {
        padding: 14px 12px;
        font-size: 16px;
    }
}

/* ======== PREFERS-REDUCED-MOTION ======== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
