/**
 * AI Smart Content - Products Page
 * Estilos para la página de gestión de productos
 */

/* ============================================
   HEADER
   ============================================ */
.products-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
    /* backdrop-filter removido para mejor rendimiento */
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-left {
    display: flex;
    align-items: center;
}

.logo-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 1.1rem;
    transition: var(--transition);
}

.logo-link:hover {
    color: var(--primary-color);
}

.logo-link i {
    font-size: 1.25rem;
    color: var(--primary-color);
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Estilos de navegación movidos a navigation.css para unificación */

.btn-logout {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.95rem;
}

.btn-logout:hover {
    border-color: var(--error-color);
    color: var(--error-color);
    background: rgba(239, 68, 68, 0.1);
}

/* ============================================
   MAIN CONTAINER
   ============================================ */
.products-container {
    width: 100%;
    height: 100vh;
    min-height: 100vh;
    display: flex;
    position: relative;
    padding-top: var(--app-header-height, 45.8px); /* Espacio para header fijo; #app-container no aplica padding en esta vista */
    padding-left: 3rem;
    padding-right: 2rem;
    padding-bottom: 0;
    background: var(--living-bg-deep, var(--bg-primary));
    box-sizing: border-box;
}

/* En móvil, el sidebar se oculta y el contenido ocupa todo el ancho */
@media (max-width: 768px) {
    .products-container {
        padding-top: var(--app-header-height, 45.8px);
        padding-left: 1rem;
        padding-right: 1rem;
    }
}

.products-main {
    flex: 1;
    padding: 0;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    transition: margin-right 0.3s ease;
    display: flex;
    flex-direction: column;
    min-height: 0;
    box-sizing: border-box;
}


/* ============================================
   PAGE HEADER
   ============================================ */
.page-header {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-bottom: 2rem;
    padding-top: 0;
    width: 100%;
}

.page-header-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    width: 100%;
    gap: 1rem;
}

.page-header-top .category-tabs {
    flex: 1;
    min-width: 0;
}

.page-header .btn-add-product {
    flex-shrink: 0;
}

/* ============================================
   CATEGORY TABS
   ============================================ */
.category-tabs {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    width: 100%;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(236, 235, 218, 0.2);
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(236, 235, 218, 0.3) transparent;
}

.category-tabs::-webkit-scrollbar {
    height: 4px;
}

.category-tabs::-webkit-scrollbar-track {
    background: transparent;
}

.category-tabs::-webkit-scrollbar-thumb {
    background: rgba(236, 235, 218, 0.3);
    border-radius: 2px;
}

.category-tabs::-webkit-scrollbar-thumb:hover {
    background: rgba(236, 235, 218, 0.5);
}

.category-tab {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    background: transparent;
    border: 1px solid rgba(236, 235, 218, 0.2);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.category-tab:hover {
    background: rgba(236, 235, 218, 0.1);
    border-color: rgba(236, 235, 218, 0.4);
    color: var(--text-primary);
}

.category-tab.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: var(--bg-black);
    font-weight: 600;
}

.category-tab i {
    font-size: 0.875rem;
}

.btn-add-product {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--bg-interactive);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    height: fit-content;
    width: auto;
    max-width: fit-content;
}

.btn-add-product:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

/* ============================================
   PRODUCTS GALLERY
   ============================================ */
.products-gallery {
    position: relative;
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-secondary);
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.empty-state i {
    font-size: 4rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.empty-state h3 {
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.products-grid {
    column-count: 4;
    column-gap: 1.5rem;
    padding: 2rem 0;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(236, 235, 218, 0.3) transparent;
}

.products-grid.rendering .product-card {
    opacity: 0;
    transform: translateY(20px);
}

.products-grid::-webkit-scrollbar {
    width: 8px;
}

.products-grid::-webkit-scrollbar-track {
    background: transparent;
}

.products-grid::-webkit-scrollbar-thumb {
    background: rgba(236, 235, 218, 0.3);
    border-radius: 4px;
}

.products-grid::-webkit-scrollbar-thumb:hover {
    background: rgba(236, 235, 218, 0.5);
}

/* ============================================
   PRODUCT CARD
   ============================================ */
.product-card {
    background: transparent;
    border: none;
    border-radius: 16px;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    position: relative;
    break-inside: avoid;
    margin-bottom: 1.5rem;
    display: inline-block;
    width: 100%;
    box-shadow: none;
}

.product-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
}

.product-card-image {
    width: 100%;
    aspect-ratio: 1;
    background: var(--bg-hover);
    position: relative;
    overflow: hidden;
    border-radius: 16px;
    transition: transform 0.3s ease;
}

.product-card:hover .product-card-image {
    transform: scale(1.02);
}

.product-card-image img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.product-card-image .no-image {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: #9CA3AF;
    font-size: 3rem;
    background: var(--bg-hover);
    gap: 0.5rem;
}

.product-card-image .no-image span {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Estilos removidos - cards ahora solo muestran imágenes */

.btn-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.btn-icon:hover {
    background: var(--bg-tertiary);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.btn-icon.delete:hover {
    border-color: var(--error-color);
    color: var(--error-color);
    background: rgba(239, 68, 68, 0.1);
}

/* ============================================
   FORM (para modales u otros usos)
   ============================================ */
.sidebar-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    color: var(--text-primary);
    font-weight: 500;
    font-size: 0.9rem;
}

.form-group .required {
    color: var(--error-color);
}

/* Estilos de inputs heredan de base.css - sin duplicación */
/* Eliminadas transiciones - usar reglas base unificadas */

/* Override específico solo para border en products */
.form-input,
.form-textarea,
.form-select {
    border: 1px solid rgba(236, 235, 218, 0.3);
    border-radius: 6px;
    transition: none !important;
    -webkit-transition: none !important;
    -moz-transition: none !important;
    -o-transition: none !important;
    transform: none !important;
    scale: 1 !important;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
    outline: none;
}

.form-textarea {
    resize: vertical;
    min-height: 100px;
}

.form-select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%23ecebda' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 12px center;
    background-repeat: no-repeat;
    background-size: 16px;
    padding-right: 40px;
}

.form-actions {
    display: flex;
    gap: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.btn-secondary {
    flex: 1;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid rgba(236, 235, 218, 0.3);
    border-radius: 6px;
    color: var(--text-primary);
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.btn-secondary:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.btn-primary {
    flex: 1;
    padding: 0.75rem;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    border: none;
    border-radius: 6px;
    color: var(--bg-black);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ============================================
   PRODUCT IMAGES SECTION
   ============================================ */
.product-images-section {
    margin-top: 1rem;
}

.images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
    margin-top: 0.75rem;
}

.image-item {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.image-item:hover {
    border-color: var(--accent-warm);
    transform: translateY(-2px);
}

.image-item[draggable="true"] {
    cursor: move;
}

.image-wrapper {
    position: relative;
    width: 100%;
    height: 150px;
    overflow: hidden;
}

.image-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.image-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.image-item:hover .image-overlay {
    opacity: 1;
}

.image-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-image-action {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(4px);
}

.btn-image-action:hover {
    background: var(--border-light);
    transform: scale(1.1);
}

.btn-image-action.active {
    background: var(--accent-warm);
    border-color: var(--accent-warm);
}

.image-badge {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    background: var(--accent-warm);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.image-order-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: #121416;
    border-top: 1px solid #1B1D1F;
}

.btn-order {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.75rem;
}

.btn-order:hover:not(:disabled) {
    border-color: var(--accent-warm);
    color: var(--accent-warm);
    background: var(--bg-hover);
}

.btn-order:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.order-number {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    min-width: 24px;
    text-align: center;
}

.image-item .no-image {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 150px;
    color: var(--text-muted);
    font-size: 1.5rem;
}

.btn-remove-image {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(239, 68, 68, 0.9);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.85rem;
    z-index: 10;
}

.btn-remove-image:hover {
    background: var(--error-color);
    transform: scale(1.1);
}

.upload-zone-small {
    border: 2px dashed #1B1D1F;
    border-radius: 8px;
    padding: 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #121416;
}

.upload-zone-small:hover {
    border-color: var(--accent-warm);
    background: var(--bg-hover);
}

/* ============================================
   NEW PRODUCT MODAL
   ============================================ */
.new-product-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.new-product-modal.active {
    opacity: 1;
    visibility: visible;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-overlay);
}

.modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    background: var(--bg-card);
    border: 1px solid rgba(236, 235, 218, 0.3);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    overflow: hidden;
}

.new-product-modal.active .modal-content {
    transform: translate(-50%, -50%) scale(1);
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(236, 235, 218, 0.3);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.modal-close {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border: 1px solid rgba(236, 235, 218, 0.3);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--bg-tertiary);
    border-color: var(--error-color);
    color: var(--error-color);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1400px) {
    .products-grid {
        column-count: 3;
    }
}

@media (max-width: 1024px) {
    .page-header-top {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .products-grid {
        column-count: 2;
    }
}

@media (max-width: 768px) {
    .products-header {
        padding: 1rem;
    }

    .header-nav {
        gap: 0.5rem;
    }

    /* Solo afecta a nav-links dentro de header-nav, no al sidebar */
    .header-nav .nav-link span {
        display: none;
    }

    .products-main {
        padding: 1rem;
    }
    
    .products-grid {
        column-count: 1;
        column-gap: 1rem;
    }

}

