/* inventory.css — Estilos para la vista de inventario con tarjetas */

:root {
    --inv-primary: #667eea;
    --inv-primary-end: #764ba2;
    --inv-success: #10b981;
    --inv-warning: #f59e0b;
    --inv-danger: #ef4444;
    --inv-info: #3b82f6;
    --inv-gray: #64748b;
    --inv-bg: #f0f2f5;
    --inv-card-bg: #ffffff;
    --inv-shadow: 0 4px 16px rgba(0,0,0,0.06);
    --inv-radius: 14px;
}

/* === Header === */
.inv-header {
    background: linear-gradient(135deg, var(--inv-primary), var(--inv-primary-end));
    color: white;
    padding: 1.25rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}
.inv-header h1 { margin: 0; font-size: 1.4rem; font-weight: 700; display: flex; align-items: center; gap: 0.5rem; }
.inv-header .subtitle { opacity: 0.8; font-size: 0.85rem; }
.inv-header-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.inv-header-actions .btn-h {
    background: rgba(255,255,255,0.18);
    border: 1px solid rgba(255,255,255,0.3);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}
.inv-header-actions .btn-h:hover { background: rgba(255,255,255,0.3); }
.inv-header-actions .btn-h.solid { background: white; color: var(--inv-primary); font-weight: 600; }

/* === KPI Stats Row === */
.inv-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}
.inv-stat {
    background: var(--inv-card-bg);
    border-radius: 12px;
    padding: 1rem;
    box-shadow: var(--inv-shadow);
    position: relative;
    overflow: hidden;
    transition: transform 0.2s;
}
.inv-stat:hover { transform: translateY(-3px); }
.inv-stat::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--stat-color, var(--inv-primary));
}
.inv-stat-icon {
    width: 38px; height: 38px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    color: white;
    font-size: 1.1rem;
    margin-bottom: 0.6rem;
    background: var(--stat-color, var(--inv-primary));
}
.inv-stat-val { font-size: 1.6rem; font-weight: 700; color: #1a1a2e; line-height: 1; }
.inv-stat-label { color: #6c757d; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.5px; margin-top: 0.2rem; }

/* === Tabs === */
.inv-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
    border-bottom: 2px solid #e2e8f0;
    overflow-x: auto;
}
.inv-tab {
    padding: 0.65rem 1.15rem;
    color: var(--inv-gray);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.88rem;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
}
.inv-tab:hover { color: var(--inv-primary); }
.inv-tab.active { color: var(--inv-primary); border-bottom-color: var(--inv-primary); }

/* === Search/Filter Bar === */
.inv-toolbar {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    align-items: center;
}
.inv-search {
    flex: 1;
    min-width: 240px;
    padding: 0.65rem 1rem 0.65rem 2.5rem;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    font-size: 0.9rem;
    background: white url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%239ca3af' viewBox='0 0 20 20'%3E%3Cpath d='M8 4a4 4 0 100 8 4 4 0 000-8zM2 8a6 6 0 1110.89 3.476l4.817 4.817a1 1 0 01-1.414 1.414l-4.816-4.816A6 6 0 012 8z'/%3E%3C/svg%3E") no-repeat 0.75rem center;
    background-size: 16px;
    transition: border-color 0.2s;
}
.inv-search:focus { outline: none; border-color: var(--inv-primary); box-shadow: 0 0 0 3px rgba(102,126,234,0.1); }

.inv-filter-stock {
    padding: 0.65rem 0.85rem;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    font-size: 0.88rem;
    background: white;
    cursor: pointer;
    min-width: 140px;
}
.inv-filter-stock:focus { outline: none; border-color: var(--inv-primary); }

.inv-view-toggle {
    display: flex;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
}
.inv-view-btn {
    padding: 0.55rem 0.85rem;
    border: none;
    background: white;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--inv-gray);
    transition: all 0.15s;
}
.inv-view-btn.active { background: var(--inv-primary); color: white; }

/* === Product Cards Grid === */
.inv-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
}
@media (min-width: 1400px) {
    .inv-cards { grid-template-columns: repeat(4, 1fr); }
}

.product-card {
    background: var(--inv-card-bg);
    border-radius: var(--inv-radius);
    box-shadow: var(--inv-shadow);
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
    position: relative;
}
.product-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 28px rgba(0,0,0,0.1);
}
.product-card.out-of-stock { opacity: 0.6; }
.product-card.out-of-stock:hover { opacity: 0.85; }

/* Card Image */
.product-card-img {
    height: 160px;
    background: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}
.product-card-img img {
    max-width: 85%;
    max-height: 140px;
    object-fit: contain;
    transition: transform 0.3s;
}
.product-card:hover .product-card-img img { transform: scale(1.08); }

/* Stock Badge (top-right) */
.product-stock-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 0.25rem 0.6rem;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 700;
    color: white;
    z-index: 2;
}
.product-stock-badge.high { background: var(--inv-success); }
.product-stock-badge.low { background: var(--inv-warning); }
.product-stock-badge.out { background: var(--inv-danger); }

/* Usage Badge (top-left) */
.product-type-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    padding: 0.2rem 0.55rem;
    border-radius: 6px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    z-index: 2;
}
.product-type-badge.venta { background: #ede9fe; color: #7c3aed; }
.product-type-badge.interno { background: #fce7f3; color: #db2777; }
.product-type-badge.servicio { background: #e0f2fe; color: #0284c7; }

/* Card Body */
.product-card-body {
    padding: 1rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.product-card-name {
    font-weight: 600;
    font-size: 0.92rem;
    color: #1e293b;
    line-height: 1.3;
    /* Truncate 2 lines */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.product-card-sku {
    font-size: 0.78rem;
    color: #94a3b8;
    font-family: 'SF Mono', 'Cascadia Code', monospace;
}
.product-card-sku .extra-codes {
    background: #e0e7ff;
    color: #4338ca;
    padding: 0.1rem 0.4rem;
    border-radius: 10px;
    font-size: 0.68rem;
    margin-left: 4px;
    font-family: inherit;
}

/* Stock Bar */
.stock-bar-wrap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.stock-bar {
    flex: 1;
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    overflow: hidden;
}
.stock-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
}
.stock-bar-fill.high { background: linear-gradient(90deg, var(--inv-success), #34d399); }
.stock-bar-fill.low { background: linear-gradient(90deg, var(--inv-warning), #fbbf24); }
.stock-bar-fill.out { background: var(--inv-danger); }
.stock-bar-count {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--inv-gray);
    white-space: nowrap;
}

/* Price + Info Row */
.product-card-price {
    font-size: 1.15rem;
    font-weight: 700;
    color: #1e293b;
}
.product-card-price .price-range {
    font-size: 0.7rem;
    color: #94a3b8;
    font-weight: 400;
    display: block;
}

/* Card Footer / Actions */
.product-card-actions {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid #f1f5f9;
    margin-top: auto;
}
.product-card-actions .btn-card {
    flex: 1;
    padding: 0.45rem;
    border: none;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    transition: all 0.2s;
    text-decoration: none;
}
.btn-card.btn-view {
    background: #f1f5f9;
    color: #475569;
}
.btn-card.btn-view:hover { background: #e2e8f0; }
.btn-card.btn-sell {
    background: linear-gradient(135deg, #10b981, #34d399);
    color: white;
}
.btn-card.btn-sell:hover { box-shadow: 0 4px 12px rgba(16,185,129,0.3); transform: translateY(-1px); }

/* === Sidebar Widgets (collapsible) === */
.inv-widgets {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.25rem;
}
@media (max-width: 768px) {
    .inv-widgets { grid-template-columns: 1fr; }
}
.inv-widget {
    background: var(--inv-card-bg);
    border-radius: var(--inv-radius);
    box-shadow: var(--inv-shadow);
    overflow: hidden;
}
.inv-widget-header {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}
.inv-widget-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.inv-widget-title i { color: var(--inv-primary); }
.inv-widget-body { padding: 1rem; }
.inv-widget .chart-container { height: 180px; }

/* Alert List */
.inv-alert-list { max-height: 180px; overflow-y: auto; }
.inv-alert-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid #f8fafc;
}
.inv-alert-item:last-child { border-bottom: none; }
.inv-alert-item .name { font-size: 0.82rem; color: #334155; }
.inv-alert-qty {
    font-size: 0.72rem;
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    font-weight: 600;
}
.inv-alert-qty.critical { background: #fee2e2; color: #dc2626; }
.inv-alert-qty.low { background: #fef3c7; color: #d97706; }

/* === Footer === */
.inv-footer {
    padding: 0.8rem 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    color: var(--inv-gray);
    border-top: 1px solid #e2e8f0;
    margin-top: 1rem;
}

/* === Retirar Button === */
.inv-btn-retirar {
    background: linear-gradient(135deg, var(--inv-primary), var(--inv-primary-end));
    border: none;
    color: white;
    padding: 0.65rem 1.2rem;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.88rem;
    transition: all 0.2s;
}
.inv-btn-retirar:hover { box-shadow: 0 4px 15px rgba(102,126,234,0.4); transform: translateY(-2px); }

/* === Modals (reutilizar del original) === */
.modal { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); z-index: 1100; align-items: center; justify-content: center; }
.modal.active { display: flex; }
.modal-content { background: white; border-radius: var(--inv-radius); width: 95%; max-width: 600px; max-height: 90vh; overflow: auto; }
.modal-retiro { max-width: 920px; }
.modal-header { background: linear-gradient(135deg, var(--inv-primary), var(--inv-primary-end)); color: white; padding: 1rem 1.5rem; display: flex; justify-content: space-between; align-items: center; }
.modal-header h3 { margin: 0; font-size: 1.1rem; }
.modal-close { background: none; border: none; color: white; font-size: 1.5rem; cursor: pointer; opacity: 0.8; }
.modal-close:hover { opacity: 1; }
.modal-body { padding: 1.5rem; }
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 0.4rem; font-size: 0.85rem; font-weight: 500; color: #374151; }
.form-group input, .form-group select { width: 100%; padding: 0.6rem 0.8rem; border: 1px solid #e0e0e0; border-radius: 8px; font-size: 0.9rem; }
.form-group input:focus, .form-group select:focus { outline: none; border-color: var(--inv-primary); box-shadow: 0 0 0 3px rgba(102,126,234,0.1); }

/* Autocomplete */
.autocomplete-wrap { position: relative; }
.autocomplete-list { position: absolute; top: calc(100% + 6px); left: 0; right: 0; max-height: 240px; overflow-y: auto; border: 1px solid #e5e7eb; border-radius: 10px; background: #fff; box-shadow: 0 10px 30px rgba(0,0,0,0.08); z-index: 1200; display: none; }
.autocomplete-item { width: 100%; border: 0; background: #fff; text-align: left; padding: 0.65rem 0.8rem; border-bottom: 1px solid #f3f4f6; cursor: pointer; font-size: 0.86rem; display: flex; align-items: flex-start; gap: 0.55rem; }
.autocomplete-item:last-child { border-bottom: 0; }
.autocomplete-item:hover, .autocomplete-item.active { background: #f5f7ff; }
.autocomplete-meta { display: block; font-size: 0.75rem; color: #6b7280; margin-top: 2px; }
.autocomplete-item input[type="checkbox"] { margin-top: 0.2rem; width: 15px; height: 15px; accent-color: var(--inv-primary); cursor: pointer; flex-shrink: 0; }
.autocomplete-main { flex: 1; }
.autocomplete-group { border-bottom: 1px solid #f3f4f6; }
.autocomplete-group:last-child { border-bottom: 0; }
.autocomplete-group-header { width: 100%; border: 0; background: #fff; text-align: left; cursor: pointer; padding: 0.65rem 0.8rem; display: flex; align-items: center; justify-content: space-between; gap: 0.7rem; font-size: 0.85rem; }
.autocomplete-group-header:hover { background: #f5f7ff; }
.group-left { display: inline-flex; align-items: center; gap: 0.5rem; min-width: 0; }
.group-caret { color: var(--inv-gray); transition: transform 0.15s ease; }
.autocomplete-group.open .group-caret { transform: rotate(90deg); }
.group-count { font-size: 0.75rem; color: #6b7280; background: #f3f4f6; padding: 0.15rem 0.5rem; border-radius: 999px; white-space: nowrap; }
.autocomplete-group-list { display: none; border-top: 1px solid #f8fafc; background: #fcfdff; }
.autocomplete-subitem { padding-left: 1.65rem; border-bottom: 1px solid #eef2ff; }
.autocomplete-subitem:last-child { border-bottom: 0; }
.autocomplete-hint { margin-top: 0.4rem; font-size: 0.76rem; color: #6b7280; }
.autocomplete-actions { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 0.5rem; }

/* Action button */
.btn-action { background: linear-gradient(135deg, var(--inv-primary), var(--inv-primary-end)); border: none; color: white; padding: 0.7rem 1.2rem; border-radius: 10px; font-weight: 600; width: 100%; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 0.5rem; font-size: 0.9rem; transition: all 0.2s; }
.btn-action:hover { box-shadow: 0 4px 15px rgba(102,126,234,0.4); transform: translateY(-2px); }

/* Loading */
.loading { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(255,255,255,0.9); display: flex; align-items: center; justify-content: center; z-index: 9999; }
.spinner { width: 40px; height: 40px; border: 3px solid #e0e0e0; border-top-color: var(--inv-primary); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Empty state */
.inv-empty { text-align: center; padding: 3rem 2rem; color: #94a3b8; }
.inv-empty i { font-size: 2.5rem; margin-bottom: 0.75rem; display: block; }
