@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap');

:root {
    --bg-dark: #030712;
    --bg-card: rgba(10, 20, 42, 0.4);
    --border-card: rgba(56, 189, 248, 0.15);
    --color-primary: #38bdf8;
    --color-primary-glow: rgba(56, 189, 248, 0.3);
    --color-accent: #f43f5e;
    --color-accent-glow: rgba(244, 63, 94, 0.3);
    --color-success: #22c55e;
    --color-text-main: #f8fafc;
    --color-text-muted: #94a3b8;
    --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
    background-color: var(--bg-dark);
}

body {
    font-family: var(--font-sans);
    background: radial-gradient(circle at 50% 50%, #071530 0%, #020612 100%);
    color: var(--color-text-main);
    display: flex;
    flex-direction: column;
}

#barcode-input {
    position: absolute;
    left: -9999px;
    opacity: 0;
}

.layout {
    height: 100vh;
    width: 100vw;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

/* Header */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2.5vh 4vw;
    background: rgba(3, 7, 18, 0.4);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-text {
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: 2px;
    background: linear-gradient(135deg, #ffffff 0%, #cbd5e1 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.topbar-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    color: #94a3b8;
}

.status-dot {
    width: 8px;
    height: 8px;
    background-color: var(--color-success);
    border-radius: 50%;
    position: relative;
}

.status-dot::after {
    content: '';
    position: absolute;
    top: -2.5px;
    left: -2.5px;
    right: -2.5px;
    bottom: -2.5px;
    border-radius: 50%;
    border: 2px solid var(--color-success);
    opacity: 0.8;
    animation: status-pulse 2s infinite ease-in-out;
}

@keyframes status-pulse {
    0% { transform: scale(1); opacity: 0.8; }
    100% { transform: scale(2.5); opacity: 0; }
}

/* Main Content */
.content {
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4vh 5vw;
}

.content-active {
    display: grid;
    grid-template-columns: 1.3fr 1px 1fr;
    gap: 4vw;
    width: 100%;
    height: 100%;
    align-items: center;
}

/* Divider styling */
.middle-divider {
    width: 1px;
    height: 75%;
    background: linear-gradient(to bottom, rgba(56, 189, 248, 0) 0%, rgba(56, 189, 248, 0.25) 50%, rgba(56, 189, 248, 0) 100%);
    position: relative;
    justify-self: center;
}

.middle-divider::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 2px;
    height: 40px;
    background: var(--color-primary);
    box-shadow: 0 0 15px var(--color-primary), 0 0 30px var(--color-primary);
    border-radius: 4px;
}

/* Product Info Column */
.col-producto {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2.2vh;
}

.producto-codigo {
    color: var(--color-primary);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.95rem;
    letter-spacing: 1px;
}

.producto-nombre {
    font-size: clamp(1.8rem, 3.4vw, 2.8rem);
    font-weight: 800;
    line-height: 1.25;
    color: #ffffff;
}

.precio-box {
    background: linear-gradient(135deg, rgba(8, 22, 51, 0.6) 0%, rgba(3, 7, 20, 0.8) 100%);
    border: 1px solid rgba(56, 189, 248, 0.4);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.4), 
                inset 0 0 20px rgba(56, 189, 248, 0.15), 
                0 0 25px rgba(56, 189, 248, 0.1);
    border-radius: 20px;
    padding: 3.5vh 3vw;
    display: flex;
    flex-direction: column;
    gap: 0.8vh;
    max-width: 100%;
}

.precio-label {
    text-transform: uppercase;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--color-text-muted);
    letter-spacing: 1px;
}

.precio-valor {
    font-size: clamp(3.5rem, 8vw, 6.2rem);
    font-weight: 800;
    color: #ffffff;
    line-height: 1;
    text-shadow: 0 0 25px rgba(56, 189, 248, 0.45);
}

.precios-secundarios {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5vw;
    margin-top: 1vh;
}

.precio-secundario-card {
    background: rgba(10, 20, 42, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 14px;
    padding: 1.8vh 1.5vw;
    display: flex;
    flex-direction: column;
    gap: 0.5vh;
    transition: all 0.3s ease;
}

.precio-secundario-card:hover {
    border-color: rgba(56, 189, 248, 0.2);
    background: rgba(10, 20, 42, 0.5);
}

.precio-secundario-label {
    text-transform: uppercase;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-text-muted);
    letter-spacing: 0.5px;
}

.precio-secundario-valor {
    font-size: clamp(1.2rem, 2.2vw, 1.8rem);
    font-weight: 700;
    color: #ffffff;
}

/* Promotions Column */
.col-promociones {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    height: 100%;
    padding-top: 1vh;
}

.promociones-header {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--color-accent);
    margin-bottom: 2.5vh;
}

.promociones-header svg {
    color: var(--color-accent);
    filter: drop-shadow(0 0 8px var(--color-accent-glow));
}

.promociones-header h2 {
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-size: 1.2rem;
    font-weight: 700;
}

.sin-promos-container {
    background: rgba(15, 23, 42, 0.2);
    border: 1px dashed rgba(255, 255, 255, 0.06);
    border-radius: 16px;
    padding: 4vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5vh;
    text-align: center;
    color: var(--color-text-muted);
}

.sin-promos-icon {
    opacity: 0.3;
}

.sin-promos-container p {
    font-style: italic;
    font-size: 0.95rem;
}

.promo-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 2vh;
    overflow-y: auto;
    max-height: 48vh;
    padding-right: 8px;
}

/* Custom scrollbar for promo list */
.promo-list::-webkit-scrollbar {
    width: 6px;
}
.promo-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
    border-radius: 3px;
}
.promo-list::-webkit-scrollbar-thumb {
    background: rgba(244, 63, 94, 0.25);
    border-radius: 3px;
}
.promo-list::-webkit-scrollbar-thumb:hover {
    background: rgba(244, 63, 94, 0.45);
}

.promo-card {
    background: linear-gradient(135deg, rgba(244, 63, 94, 0.04) 0%, rgba(3, 7, 20, 0.75) 100%);
    border: 1px solid rgba(244, 63, 94, 0.25);
    box-shadow: 0 4px 20px rgba(244, 63, 94, 0.05);
    border-radius: 16px;
    padding: 2.2vh 2vw;
    display: flex;
    align-items: center;
    gap: 1.5vw;
}

.promo-icon-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #f43f5e 0%, #be185d 100%);
    color: #ffffff;
    box-shadow: 0 0 15px rgba(244, 63, 94, 0.4);
    flex-shrink: 0;
}

.promo-badge-icon {
    width: 22px;
    height: 22px;
}

.promo-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5vh;
}

.promo-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.2;
}

.promo-subtitle {
    font-size: 0.85rem;
    color: #fda4af;
    font-weight: 500;
}

.promo-card-divider {
    width: 1px;
    height: 40px;
    background: rgba(244, 63, 94, 0.2);
    margin: 0 1vw;
}

.promo-price-box {
    text-align: right;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.promo-price-value {
    font-size: clamp(1.4rem, 2.5vw, 2.1rem);
    font-weight: 800;
    color: var(--color-accent);
    line-height: 1;
    text-shadow: 0 0 10px rgba(244, 63, 94, 0.3);
}

.promo-price-unit {
    font-size: 0.85rem;
    color: var(--color-accent);
    font-weight: 600;
    margin-top: 2px;
}

/* States: Wait / Empty / Error / Not Found */
.estado {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3vh;
    text-align: center;
    padding: 6vh;
    background: linear-gradient(135deg, rgba(10, 20, 42, 0.3) 0%, rgba(3, 7, 20, 0.6) 100%);
    border: 1px solid var(--border-card);
    border-radius: 24px;
    backdrop-filter: blur(10px);
    max-width: 600px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
}

.estado h1 {
    font-size: clamp(1.8rem, 3.5vw, 2.8rem);
    font-weight: 800;
    color: #ffffff;
}

.estado p {
    color: var(--color-text-muted);
    font-size: clamp(1rem, 1.5vw, 1.25rem);
    line-height: 1.5;
    max-width: 450px;
}

.estado--error {
    border-color: rgba(239, 68, 68, 0.3);
    box-shadow: 0 20px 50px rgba(239, 68, 68, 0.1);
}
.estado--error h1 {
    color: #ef4444;
}

.estado--no-encontrado {
    border-color: rgba(245, 158, 11, 0.3);
    box-shadow: 0 20px 50px rgba(245, 158, 11, 0.1);
}
.estado--no-encontrado h1 {
    color: #f59e0b;
}

/* Scanning Barcode CSS Animation */
.barcode-anim-container {
    position: relative;
    width: 140px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.barcode-lines {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    height: 60px;
}

.barcode-lines span {
    background-color: var(--color-text-muted);
    width: 3px;
    height: 100%;
    border-radius: 1px;
}
.barcode-lines span:nth-child(even) {
    width: 6px;
}
.barcode-lines span:nth-child(3n) {
    width: 8px;
}
.barcode-lines span:nth-child(4n) {
    width: 2px;
}

.laser-line {
    position: absolute;
    width: 160px;
    height: 3px;
    background-color: #22c55e;
    box-shadow: 0 0 12px #22c55e, 0 0 24px #22c55e;
    top: 20px;
    animation: laser-move 2.5s infinite ease-in-out;
}

@keyframes laser-move {
    0% { top: 15px; opacity: 0.8; }
    50% { top: 85px; opacity: 1; }
    100% { top: 15px; opacity: 0.8; }
}

/* Footer */
.footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2.5vh 4vw;
    background: rgba(3, 7, 18, 0.6);
    border-top: 1px solid rgba(255, 255, 255, 0.03);
    font-size: 0.9rem;
    color: var(--color-text-muted);
}

.footer-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.footer-item svg {
    color: var(--color-text-muted);
    opacity: 0.7;
}

.footer-stocks {
    display: flex;
    align-items: center;
    gap: 24px;
    font-size: 1.15rem;
}

.footer-stocks .footer-item {
    gap: 10px;
}

.footer-stocks svg {
    width: 22px;
    height: 22px;
    color: var(--color-primary);
    opacity: 0.95;
}

.footer-stocks strong {
    color: #ffffff;
    font-weight: 700;
}

.stock-divider {
    width: 1px;
    height: 22px;
    background-color: rgba(255, 255, 255, 0.15);
}

/* Responsive grid/layout adjustments */
@media (max-width: 1024px) {
    .content-active {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
        gap: 3vh;
        overflow-y: auto;
    }

    .middle-divider {
        width: 100%;
        height: 1px;
        background: linear-gradient(to right, rgba(56, 189, 248, 0) 0%, rgba(56, 189, 248, 0.25) 50%, rgba(56, 189, 248, 0) 100%);
    }

    .middle-divider::after {
        width: 40px;
        height: 2px;
    }

    .precios-secundarios {
        gap: 2vw;
    }

    .col-promociones {
        padding-top: 0;
    }
}

@media (max-width: 640px) {
    .precios-secundarios {
        grid-template-columns: 1fr;
    }

    .footer {
        flex-direction: column;
        gap: 1.5vh;
        text-align: center;
        padding: 3vh 4vw;
    }

    .footer-stocks {
        flex-direction: column;
        gap: 1vh;
    }

    .stock-divider {
        display: none;
    }
}
