/**
 * Vangärtt Inventory System - Componentes UI (iOS Style)
 */

/* ================== BOTONES Y HAPTIC FEEDBACK ================== */
.btn {
    appearance: none;
    background: var(--system-gray-5);
    color: var(--label-primary);
    border: none;
    border-radius: var(--radius-md);
    padding: 16px 20px;
    font-size: 17px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    width: 100%;
    transition: transform var(--transition-fast), background var(--transition-fast), opacity var(--transition-fast);
}

/* Efecto de presión física (Haptic simulation) */
.btn:active {
    transform: scale(0.96);
    opacity: 0.8;
}

.btn-primary {
    background: var(--label-primary);
    color: var(--system-background);
}

/* ================== PANTALLA DE LOGIN (NUMPAD) ================== */
.login-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.pin-display {
    display: flex;
    gap: 16px;
    margin-bottom: 50px;
}

.pin-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid var(--system-gray-5);
    transition: background-color var(--transition-fast), border-color var(--transition-fast);
}

.pin-dot.filled {
    background-color: var(--label-primary);
    border-color: var(--label-primary);
}

.numpad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    width: 100%;
    max-width: 300px;
}

.num-key {
    background: var(--system-gray-6);
    color: var(--label-primary);
    border: none;
    border-radius: 50%;
    width: 80px;
    height: 80px;
    font-size: 32px;
    font-weight: 400;
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
}

.num-key:active {
    background: var(--system-gray-5);
}

/* ================== GRID DE INVENTARIO ================== */
.product-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    padding: 16px;
    align-items: start; /* Crucial: Evita que las tarjetas hermanas se estiren cuando una se despliega */
}

.product-card {
    background: var(--system-gray-6);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: transform var(--transition-fast), background var(--transition-fast);
}

.product-card:active {
    transform: scale(0.97);
}

.product-image {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    background: var(--system-gray-5);
    display: block;
    color: transparent;
}

.product-info {
    padding: 12px;
}

.product-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.product-price {
    font-size: 14px;
    color: var(--label-secondary);
}

/* === Menú Desplegable de Stock === */
.product-expansion {
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--transition-fast), padding var(--transition-fast);
    padding: 0 12px;
    background: rgba(0, 0, 0, 0.2); /* Sutil oscurecimiento tipo cajón interior */
}

.product-card.expanded .product-expansion {
    max-height: 150px;
    padding: 0 12px 12px 12px;
}

.stock-list {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
    margin-top: 12px;
    font-size: 12px;
}

.stock-list span.in-stock {
    color: var(--label-primary);
    font-weight: 600;
}

.stock-list span.out-stock {
    color: var(--system-red);
    opacity: 0.6;
}

.btn-register-sale {
    background: var(--label-primary);
    color: var(--system-background);
    border: none;
    border-radius: var(--radius-md);
    padding: 10px;
    width: 100%;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s, opacity 0.1s;
}

.btn-register-sale:active {
    transform: scale(0.95);
    opacity: 0.8;
}

.btn-register-sale:disabled {
    background: var(--system-gray-5);
    color: var(--label-secondary);
    pointer-events: none;
}
/* ================== ESTRUCTURA BASE MODALES ================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-modal);
}

.modal-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-top: 1px solid var(--glass-border);
    border-radius: 32px 32px 0 0;
    padding: 24px 20px calc(var(--safe-bottom) + 20px);
    transform: translateY(100%);
    transition: transform var(--transition-modal);
    display: flex;
    flex-direction: column;
}

/* ================== SEPARACIÓN DE CASOS DE APERTURA ================== */

/* Apertura Modal 1: Ventas */
body.sale-modal-open #saleModalOverlay {
    opacity: 1;
    pointer-events: auto;
}
body.sale-modal-open #saleModalSheet {
    transform: translateY(0);
}

/* Apertura Modal 2: Administración CRUD */
body.admin-modal-open #adminModalOverlay {
    opacity: 1;
    pointer-events: auto;
}
body.admin-modal-open #adminModalSheet {
    transform: translateY(0);
}

/* Segmented Control para Tallas */
.size-selector {
    display: flex;
    background: var(--system-gray-5);
    border-radius: var(--radius-md);
    padding: 4px;
    margin: 20px 0;
}

.size-btn {
    flex: 1;
    padding: 12px 0;
    text-align: center;
    font-size: 15px;
    font-weight: 600;
    border-radius: 10px;
    color: var(--label-primary);
    transition: background 0.2s, color 0.2s;
    background: transparent;
    border: none;
}

.size-btn.active {
    background: var(--label-primary);
    color: var(--system-background);
}

.size-btn.disabled {
    opacity: 0.15;
    pointer-events: none;
}

/* ================== BARRA SUPERIOR GLOBAL ================== */
.global-top-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background: rgba(28, 28, 30, 0.85);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.tab-btn {
    background: none;
    border: none;
    color: var(--label-secondary);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    font-weight: 500;
    cursor: pointer;
    transition: color var(--transition-fast), transform var(--transition-fast);
    width: 33%;
}

.tab-btn:active {
    transform: scale(0.9);
}

.tab-btn i {
    font-size: 24px;
}

.tab-btn.active {
    color: var(--label-primary);
}

.view {
    /* Empujamos el contenido hacia abajo para que el nuevo bloque doble no lo tape */
    padding-top: calc(var(--safe-top) + 125px); 
    padding-bottom: var(--safe-bottom);
}