/* admin-bodegas.css — Tech Elite Theme */
/* Paleta: --solvix-navy, navy-light, cyan, glass, silver, silver-dark, metal */

/* ── Tab background transparent ── */
#admin-bodegas-content {
    background-color: transparent !important;
}

/* ── Container ── */
.ab-module-container {
    margin-top: 0;
    padding: 0;
    font-family: 'Inter', system-ui, sans-serif;
    color: var(--solvix-silver);
    width: 100%;
    min-height: calc(100vh - 100px);
    box-sizing: border-box;
    animation: fadeInPage 0.3s ease-in-out;
}

@keyframes fadeInPage {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* --- Header — Metal Pulido --- */
.ab-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 15px 20px;
    background: var(--solvix-metal);
    color: var(--solvix-navy);
    border-radius: 12px;
    border: 1px solid var(--solvix-metal-border);
    box-shadow: var(--solvix-metal-shadow);
}

.ab-title {
    font-size: 1.8rem;
    font-weight: 700;
    margin: 0;
    color: var(--solvix-navy);
}

.ab-subtitle {
    font-size: 0.9rem;
    color: var(--solvix-navy);
    margin-top: 4px;
    opacity: 0.7;
}

/* --- Botones --- */
.ab-btn-primary {
    background: var(--solvix-glass);
    color: var(--solvix-cyan);
    border: 1px solid rgba(0, 242, 255, 0.2);
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.ab-btn-primary:hover {
    border-color: var(--solvix-cyan);
    box-shadow: 0 0 12px var(--solvix-cyan-glow);
    transform: translateY(-1px);
}

.ab-btn-ghost {
    background: var(--solvix-glass);
    color: var(--solvix-cyan);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
}

.ab-btn-ghost:hover {
    
    box-shadow: 0 0 12px var(--solvix-cyan-glow);
    color: var(--solvix-cyan);
    transform: translateY(-1px);
}

/* --- KPI Grid --- */
.ab-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.ab-kpi-card {
    background: var(--solvix-glass);
    padding: 20px;
    border-radius: 16px;
    box-shadow: 
        0 4px 20px rgba(0, 0, 0, 0.3),
        inset 0 1px 1px rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: 16px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

/* Efecto de Brillo Cristal Permanente */
.ab-kpi-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg,
        transparent 0%,
        rgba(255, 255, 255, 0.02) 40%,
        rgba(255, 255, 255, 0.08) 50%,
        rgba(255, 255, 255, 0.02) 60%,
        transparent 100%
    );
    transform: rotate(-15deg);
    pointer-events: none;
    z-index: 1;
}

/* Barrido de luz al Hover */
.ab-kpi-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: -150%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(0, 242, 255, 0.15),
        transparent
    );
    transition: left 0.6s ease-in-out;
    z-index: 2;
}

.ab-kpi-card:hover {
    border-color: rgba(0, 242, 255, 0.4);
    transform: translateY(-3px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
}

.ab-kpi-card:hover::after {
    left: 150%;
}


.ab-kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Material Icons';
    font-size: 24px;
}

.ab-kpi-icon.blue  { background: rgba(0, 123, 255, 0.1); color: #3b82f6; }
.ab-kpi-icon.green { background: rgba(16, 185, 129, 0.1); color: #10b981; }
.ab-kpi-icon.orange { background: rgba(245, 158, 11, 0.1); color: #f59e0b; }

.ab-kpi-info {
    display: flex;
    flex-direction: column;
}

.ab-kpi-label {
    font-size: 0.85rem;
    color: var(--solvix-silver-dark);
    font-weight: 500;
}

.ab-kpi-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--solvix-silver);
}

/* --- Barra de Controles --- */
.ab-controls-bar {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
    background: var(--solvix-glass);
    padding: 10px 16px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.ab-search-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.05);
    padding: 8px 12px;
    border-radius: 8px;
    width: 300px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.ab-search-wrapper input {
    border: none;
    background: transparent;
    outline: none;
    width: 100%;
    color: var(--solvix-silver);
}

.ab-search-wrapper input::placeholder {
    color: var(--solvix-silver-dark);
    opacity: 0.5;
}

.ab-view-btn {
    background: transparent;
    border: none;
    color: var(--solvix-silver-dark);
    cursor: pointer;
    padding: 5px;
}

.ab-view-btn.active {
    color: var(--solvix-cyan);
}

/* --- Grid de Tarjetas de Bodega --- */
.ab-grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
}

/* --- Tarjeta Individual --- */
.ab-card {
    background: var(--solvix-glass);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    position: relative;
    overflow: hidden;
}

.ab-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 25px rgba(0, 0, 0, 0.3);
    border-color: rgba(255, 255, 255, 0.1);
}

/* Estado SELECCIONADO con Brillo Cian y Pulso */
.ab-card.selected {
    border-color: var(--solvix-cyan);
    transform: translateY(-2px);
    background: rgba(0, 242, 255, 0.05);
    animation: cyanPulse 2s infinite ease-in-out;
}

@keyframes cyanPulse {
    0% { 
        box-shadow: 0 0 15px rgba(0, 242, 255, 0.2), inset 0 0 5px rgba(0, 242, 255, 0.1);
        border-color: rgba(0, 242, 255, 0.5);
    }
    50% { 
        box-shadow: 0 0 35px rgba(0, 242, 255, 0.5), inset 0 0 15px rgba(0, 242, 255, 0.2);
        border-color: rgba(0, 242, 255, 1);
    }
    100% { 
        box-shadow: 0 0 15px rgba(0, 242, 255, 0.2), inset 0 0 5px rgba(0, 242, 255, 0.1);
        border-color: rgba(0, 242, 255, 0.5);
    }
}


.ab-card-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
}

.ab-card-icon {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--solvix-silver-dark);
    font-weight: bold;
}

.ab-card-status {
    font-size: 0.75rem;
    padding: 4px 8px;
    border-radius: 99px;
    font-weight: 600;
}

.ab-dot {

}

.status-active {
    
    color: #4ade80;
}

.status-full {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
}

.ab-card-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--solvix-silver);
    margin-bottom: 4px;
}

.ab-card-code {
    font-size: 0.85rem;
    color: var(--solvix-silver-dark);
    margin-bottom: 15px;
    display: block;
}

/* --- Barra de Progreso --- */
.ab-progress-wrapper {
    margin-bottom: 15px;
}

.ab-progress-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    margin-bottom: 5px;
    color: var(--solvix-silver-dark);
}

.ab-progress-bar {
    height: 8px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    overflow: hidden;
}

.ab-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6 0%, #2563eb 100%);
    border-radius: 4px;
    transition: width 0.5s ease;
}

.ab-progress-fill.warning { background: #f59e0b; }
.ab-progress-fill.danger  { background: #ef4444; }

.ab-card-meta {
    display: flex;
    gap: 15px;
    font-size: 0.85rem;
    color: var(--solvix-silver-dark);
    margin-bottom: 20px;
    padding-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.ab-card-actions {
    display: flex;
    gap: 10px;
}

.ab-action-btn {
    flex: 1;
    padding: 8px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    background: var(--solvix-metal);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--solvix-silver-dark);
    transition: all 0.2s;
}

.ab-action-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.15);
    color: var(--solvix-silver);
}

.btn-delete:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #f87171;
    border-color: rgba(239, 68, 68, 0.3);
}

/* --- Modal --- */
.ab-modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ab-modal-overlay.hidden { display: none; }

.ab-modal-content {
    background: var(--solvix-navy-light);
    width: 500px;
    max-height: 85vh;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
}

.ab-modal-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.ab-modal-header h2 {
    color: var(--solvix-silver);
    font-weight: 700;
}

.ab-close-modal {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--solvix-silver-dark);
}

.ab-close-modal:hover {
    color: var(--solvix-silver);
}

.ab-modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.ab-form-group {
    margin-bottom: 15px;
}

.ab-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.ab-form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--solvix-silver-dark);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.ab-form-group input,
.ab-form-group select {
    width: 100%;
    padding: 10px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    outline: none;
    font-family: inherit;
    box-sizing: border-box;
    background: rgba(255, 255, 255, 0.05);
    color: var(--solvix-silver);
}

.ab-form-group input::placeholder {
    color: var(--solvix-silver-dark);
    opacity: 0.5;
}

.ab-form-group input:focus,
.ab-form-group select:focus {
    border-color: var(--solvix-cyan);
    box-shadow: 0 0 0 3px var(--solvix-cyan-glow);
}

.ab-form-group select option {
    background: var(--solvix-navy-light);
    color: var(--solvix-silver);
}

.ab-modal-footer {
    padding: 20px;
    background: var(--solvix-metal);
    flex-shrink: 0;
}

/* --- Vista de Lista --- */
.ab-grid-container.list-view {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ab-grid-container.list-view .ab-card {
    display: grid;
    grid-template-columns: 60px 2fr 3fr 1.5fr 150px;
    align-items: center;
    padding: 12px 20px;
    gap: 20px;
    height: auto;
}

.ab-grid-container.list-view .ab-card-header {
    display: contents;
    margin-bottom: 0;
}

.ab-grid-container.list-view .ab-card-icon {
    grid-column: 1;
    width: 48px;
    height: 48px;
}

.ab-grid-container.list-view .ab-card-title {
    grid-column: 2;
    margin: 0;
    font-size: 1rem;
    display: flex;
    flex-direction: column;
}

.ab-grid-container.list-view .ab-card-title::after {
    content: attr(data-code);
    font-size: 0.8rem;
    color: var(--solvix-silver-dark);
    font-weight: 400;
    margin-top: 2px;
}

.ab-grid-container.list-view .ab-card-code { display: none; }

.ab-grid-container.list-view .ab-card-status {
    grid-column: 2;
    width: fit-content;
    margin-left: auto;
    position: relative;
    top: -15px;
}

.ab-grid-container.list-view .ab-progress-wrapper {
    grid-column: 3;
    margin-bottom: 0;
    width: 100%;
}

.ab-grid-container.list-view .ab-card-meta {
    grid-column: 4;
    border-top: none;
    padding-top: 0;
    margin-bottom: 0;
    flex-direction: column;
    gap: 4px;
    font-size: 0.8rem;
}

.ab-grid-container.list-view .ab-card-actions {
    grid-column: 5;
    justify-content: flex-end;
}

@media (max-width: 900px) {
    .ab-grid-container.list-view .ab-card {
        display: flex;
        flex-direction: column;
        align-items: stretch;
    }
    .ab-grid-container.list-view .ab-card-header {
        display: flex;
    }
}

/* ── Estructura de Tarjeta con Panel Lateral Oculto ── */
.ab-card-wrapper {
    position: relative;
    z-index: 1;
    /* Mantiene las dimensiones de la tarjeta base en el grid */
    height: 100%;
}

.ab-card-wrapper.open {
    z-index: 50; /* Elevar cuando está abierto para flotar sobre las demás */
}

@keyframes pulseGlowTab {
    0% { box-shadow: 0 0 15px rgba(0, 242, 255, 0.15), 0 0 30px rgba(0, 242, 255, 0.05); border-color: rgba(0, 242, 255, 0.5); }
    50% { box-shadow: 0 0 25px rgba(0, 242, 255, 0.4), 0 0 60px rgba(0, 242, 255, 0.2); border-color: var(--solvix-cyan); }
    100% { box-shadow: 0 0 15px rgba(0, 242, 255, 0.15), 0 0 30px rgba(0, 242, 255, 0.05); border-color: rgba(0, 242, 255, 0.5); }
}

.ab-card {
    /* La tarjeta principal tiene un z-index superior para tapar el panel */
    z-index: 5;
    transition: all 0.3s ease;
}

.ab-card.selected {
    border-color: var(--solvix-cyan);
    animation: pulseGlowTab 2s infinite;
    overflow: visible;
}

@keyframes pulseGlowRed {
    0% { box-shadow: 0 0 15px rgba(239, 68, 68, 0.2), 0 0 30px rgba(239, 68, 68, 0.1); border-color: rgba(239, 68, 68, 0.5); }
    50% { box-shadow: 0 0 25px rgba(239, 68, 68, 0.5), 0 0 60px rgba(239, 68, 68, 0.3); border-color: #ef4444; }
    100% { box-shadow: 0 0 15px rgba(239, 68, 68, 0.2), 0 0 30px rgba(239, 68, 68, 0.1); border-color: rgba(239, 68, 68, 0.5); }
}

.ab-card.critical {
    border-color: rgba(239, 68, 68, 0.5);
    animation: pulseGlowRed 2s infinite !important;
}

/* Quitarle el foco a la tarjeta principal si el panel lateral está abierto */
.ab-card-wrapper.open .ab-card {
    border-color: rgba(0, 242, 255, 0.2) !important;
    animation: none !important;
    box-shadow: none !important;
}

.ab-card-wrapper.open .ab-card.critical {
    border-color: rgba(239, 68, 68, 0.2) !important;
}

/* --- Expansión Vertical Original --- */
.ab-card-expanded {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: var(--solvix-navy);
    border: 1px solid var(--solvix-cyan);
    border-top: none;
    border-radius: 0 0 16px 16px;
    padding: 15px;
    box-sizing: border-box;
    z-index: 100;
    box-shadow: 0 20px 50px rgba(0,0,0,0.6);
    transform-origin: top;
    animation: dropDownExpand 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes dropDownExpand {
    from { opacity: 0; transform: translateY(-10px); pointer-events: none; }
    to { opacity: 1; transform: translateY(0); pointer-events: auto; }
}

/* --- Solapa Lateral (Tab) --- */
.ab-side-tab-btn {
    position: absolute;
    top: 50%;
    right: -36px; 
    transform: translateY(-50%);
    width: 40px;
    height: 85px;
    background: var(--solvix-glass);
    border: 1px solid var(--solvix-cyan);
    border-left: none;
    border-radius: 0 12px 12px 0;
    backdrop-filter: blur(12px);
    z-index: 4; /* Detrás de ab-card (5) y delante del panel (3) */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--solvix-silver);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 4px 0 15px rgba(0,0,0,0.2);
    /* Siempre visible para poder abrir y cargar el CSV */
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.ab-side-tab-btn:hover {
    background: rgba(0, 242, 255, 0.15);
    width: 45px;
    right: -41px;
}

.ab-side-tab-btn i.fa-list {
    font-size: 1.1rem;
    margin-bottom: 3px;
}

.ab-side-tab-btn .tab-arrow {
    font-size: 0.8rem;
    margin-bottom: 4px;
    transition: transform 0.3s ease;
}

.ab-card-wrapper.open .tab-arrow {
    transform: rotate(180deg);
}

.ab-side-tab-btn .tab-badge {
    background: rgba(0, 0, 0, 0.5);
    color: var(--solvix-cyan);
    font-size: 0.65rem;
    padding: 2px 5px;
    border-radius: 8px;
    font-weight: bold;
    border: 1px solid rgba(0,242,255,0.2);
}

/* --- Panel Lateral Flotante --- */
.ab-side-panel {
    position: absolute;
    top: 10px;
    /* Se elimina bottom fijo para que pueda crecer según su contenido */
    min-height: calc(100% - 20px);
    left: 20px; 
    width: 650px; /* Tabla aún más ancha */
    background: var(--solvix-navy);
    border: 1px solid var(--solvix-cyan);
    border-left: none; /* Ocultar el borde que se vería bajo el glassmorphism */
    border-radius: 0 12px 12px 0;
    padding: 15px;
    box-shadow: 15px 0 40px rgba(0,0,0,0.7);
    z-index: 3; /* Detrás de solapa y tarjeta */
    opacity: 0;
    visibility: hidden;
    transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
}

.ab-card-wrapper.open .ab-side-panel {
    opacity: 1;
    visibility: visible;
    /* Mover el panel anclándolo al lado derecho de la tarjeta (100%) menos 15px para que se solape y no se note separación */
    left: calc(100% - 15px);
    animation: pulseGlowTab 2s infinite;
}

/* Modificamos las pestañas internas del panel para que combinen con la nueva apariencia */
.ab-expand-tab {
    padding: 6px 14px;
    font-size: 0.75rem;
    border-radius: 6px;
    border: 1px solid rgba(0,242,255,0.15);
    background: rgba(0,242,255,0.05);
    color: var(--solvix-silver);
    cursor: pointer;
    font-weight: 600;
    transition: 0.2s;
}
.ab-expand-tab.active {
    background: rgba(0,242,255,0.15);
    border-color: var(--solvix-cyan);
    color: var(--solvix-cyan);
}
.ab-expand-tab:hover {
    background: rgba(0,242,255,0.1);
}

/* ── Gemelo Digital ── */
#ab-gemelo-digital-modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 1000001;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}
#ab-gemelo-digital-modal .gemelo-content {
    background: #0f172a;
    border: 1px solid rgba(0,242,255,0.15);
    border-radius: 16px;
    padding: 20px;
    width: 90%;
    max-width: 800px;
    max-height: 85vh;
    overflow: auto;
    box-shadow: 0 0 50px rgba(0,242,255,0.1);
}
.gemelo-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}
.gemelo-header h3 {
    color: var(--solvix-cyan);
    margin: 0;
    font-size: 1rem;
}
.gemelo-close {
    background: none;
    border: none;
    color: rgba(255,255,255,0.4);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 4px 8px;
}
.gemelo-close:hover { color: white; }

/* ── inventory-flow table style ── */
.inventario-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}
.inventario-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 10px 12px;
    text-align: left;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.inventario-table thead th:first-child { border-radius: 8px 0 0 8px; }
.inventario-table thead th:last-child { border-radius: 0 8px 8px 0; }
.inventario-table tbody tr:hover {
    background: rgba(0, 242, 255, 0.03);
}

.ab-expand-tab.active {
    background: rgba(0,242,255,0.15) !important;
    border-color: var(--solvix-cyan) !important;
    color: var(--solvix-cyan) !important;
}

.ab-gemelo-canvas:hover {
    box-shadow: 0 0 20px rgba(0,242,255,0.08);
}

#ab-layout-plano {
    color-scheme: dark;
}
#ab-layout-plano::-webkit-file-upload-button {
    background: rgba(0,242,255,0.1);
    border: 1px solid rgba(0,242,255,0.2);
    color: var(--solvix-cyan);
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.75rem;
}
