/**
 * EK Parts Catalog - Frontend Stylesheet
 */

:root {
    --ek-primary: #0038b8;
    --ek-primary-hover: #002c91;
    --ek-accent: #0066cc;
    --ek-text-dark: #1e293b;
    --ek-text-muted: #64748b;
    --ek-border: #e2e8f0;
    --ek-bg-light: #f8fafc;
    --ek-card-bg: #ffffff;
    --ek-radius: 8px;
    --ek-shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --ek-shadow-md: 0 4px 14px rgba(0,0,0,0.08);
    --ek-shadow-hover: 0 10px 25px rgba(0,0,0,0.12);
}

.ek-parts-container {
    max-width: 1440px;
    margin: 0 auto;
    padding: 24px 16px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--ek-text-dark);
    box-sizing: border-box;
}

.ek-parts-container * {
    box-sizing: border-box;
}

/* ==========================================================================
   Barra de Filtros Superior
   ========================================================================== */

.ek-filter-bar {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: var(--ek-radius);
    padding: 20px;
    margin-bottom: 24px;
    box-shadow: var(--ek-shadow-sm);
}

.ek-filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
}

.ek-filter-field {
    flex: 1 1 180px;
    min-width: 160px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ek-filter-search-box {
    flex: 1.8 1 240px;
}

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

.ek-select,
.ek-input-text {
    width: 100%;
    height: 42px;
    padding: 8px 12px;
    background-color: #ffffff;
    border: 1px solid #94a3b8;
    border-radius: 6px;
    font-size: 0.92rem;
    color: var(--ek-text-dark);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.ek-select:focus,
.ek-input-text:focus {
    border-color: var(--ek-primary);
    box-shadow: 0 0 0 3px rgba(0, 56, 184, 0.15);
}

.ek-filter-actions {
    display: flex;
    gap: 8px;
    height: 42px;
}

.ek-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 20px;
    height: 42px;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
    border: none;
    white-space: nowrap;
}

.ek-btn-primary {
    background: var(--ek-primary);
    color: #ffffff;
}

.ek-btn-primary:hover {
    background: var(--ek-primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 56, 184, 0.25);
}

.ek-btn-secondary {
    background: #f1f5f9;
    color: var(--ek-text-muted);
    border: 1px solid #cbd5e1;
}

.ek-btn-secondary:hover {
    background: #e2e8f0;
    color: var(--ek-text-dark);
}

.ek-filter-status-bar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid #f1f5f9;
    font-size: 0.85rem;
    color: var(--ek-text-muted);
}

.ek-total-badge strong {
    color: var(--ek-primary);
    font-weight: 700;
}

/* ==========================================================================
   Aviso para Invitados (No Logueados)
   ========================================================================== */

.ek-login-banner {
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
    border: 1px solid #fde68a;
    border-left: 5px solid #d97706;
    border-radius: var(--ek-radius);
    padding: 16px 20px;
    margin-bottom: 24px;
    box-shadow: var(--ek-shadow-sm);
}

.ek-login-banner-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
}

.ek-lock-icon {
    font-size: 2rem;
    flex-shrink: 0;
}

.ek-login-text {
    flex: 1 1 300px;
}

.ek-login-text strong {
    display: block;
    color: #92400e;
    font-size: 1.05rem;
    margin-bottom: 4px;
}

.ek-login-text p {
    margin: 0;
    color: #b45309;
    font-size: 0.92rem;
}

.ek-btn-login {
    background: #d97706;
    color: #ffffff;
    font-size: 0.9rem;
    padding: 0 18px;
    height: 38px;
    border-radius: 6px;
}

.ek-btn-login:hover {
    background: #b45309;
    color: #ffffff;
}

/* ==========================================================================
   Header del Catálogo
   ========================================================================== */

.ek-catalog-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid #e2e8f0;
    flex-wrap: wrap;
    gap: 12px;
}

.ek-catalog-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ek-catalog-title h3 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--ek-text-dark);
}

.ek-catalog-icon {
    font-size: 1.6rem;
}

.ek-catalog-meta {
    font-size: 0.92rem;
    color: var(--ek-text-muted);
}

.ek-catalog-meta strong {
    color: var(--ek-primary);
}

/* ==========================================================================
   Grid de 4 Columnas Responsiva
   ========================================================================== */

.ek-parts-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
    margin-bottom: 36px;
}

/* Responsive Breakpoints */
@media (max-width: 1200px) {
    .ek-parts-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 20px;
    }
}

@media (max-width: 860px) {
    .ek-parts-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }
    .ek-filter-row {
        gap: 10px;
    }
}

@media (max-width: 520px) {
    .ek-parts-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    .ek-filter-field,
    .ek-filter-actions {
        width: 100%;
        flex: 1 1 100%;
    }
    .ek-filter-actions {
        margin-top: 6px;
    }
    .ek-btn {
        flex: 1;
    }
}

/* ==========================================================================
   Tarjeta de Producto (Card)
   ========================================================================== */

.ek-part-card {
    background: var(--ek-card-bg);
    border: 1px solid var(--ek-border);
    border-radius: var(--ek-radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100%;
    box-shadow: var(--ek-shadow-sm);
    transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1), 
                box-shadow 0.22s cubic-bezier(0.4, 0, 0.2, 1),
                border-color 0.22s;
}

.ek-part-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--ek-shadow-hover);
    border-color: #cbd5e1;
}

/* Contenedor de Imagen Cuadrada */
.ek-card-image-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    background: #fbfbfb;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 16px;
}

.ek-card-image-wrap img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    transition: transform 0.3s ease;
}

.ek-part-card:hover .ek-card-image-wrap img {
    transform: scale(1.05);
}

/* Badge de bloqueo para visitantes */
.ek-card-lock-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(0,0,0,0.06);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

/* Cuerpo de la Tarjeta */
.ek-card-body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.ek-card-sku-badge {
    margin-bottom: 10px;
}

.ek-card-sku-badge code {
    background: #f1f5f9;
    color: #334155;
    padding: 4px 8px;
    border-radius: 4px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.83rem;
    font-weight: 600;
    border: 1px solid #e2e8f0;
    display: inline-block;
}

.ek-card-title {
    margin: 0 0 14px 0;
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1.4;
    color: var(--ek-text-dark);
    text-transform: uppercase;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.8em;
    flex-grow: 1;
}

/* Metadatos (Marca, Modelo, Categoría) */
.ek-card-meta {
    margin: 0;
    padding-top: 12px;
    border-top: 1px solid #f1f5f9;
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.84rem;
}

.ek-meta-row {
    display: grid;
    grid-template-columns: 80px 1fr;
    gap: 8px;
    align-items: baseline;
}

.ek-meta-row dt {
    color: var(--ek-text-muted);
    font-weight: 600;
    margin: 0;
}

.ek-meta-row dd {
    margin: 0;
    color: var(--ek-text-dark);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ==========================================================================
   Paginación Fluida & Carga
   ========================================================================== */

.ek-pagination-wrapper {
    text-align: center;
    margin: 30px 0 20px;
}

.ek-btn-load-more {
    background: var(--ek-primary);
    color: #ffffff;
    padding: 0 32px;
    height: 48px;
    font-size: 1rem;
    box-shadow: 0 4px 14px rgba(0, 56, 184, 0.2);
}

.ek-btn-load-more:hover {
    background: var(--ek-primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 56, 184, 0.3);
}

.ek-btn-load-more:disabled {
    background: #94a3b8;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.ek-infinite-scroll-trigger {
    height: 20px;
}

.ek-no-more-banner {
    text-align: center;
    padding: 16px;
    margin: 20px 0;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: var(--ek-radius);
    color: #166534;
    font-weight: 600;
    font-size: 0.95rem;
}

.ek-loading-overlay {
    text-align: center;
    padding: 40px 20px;
}

.ek-spinner {
    width: 38px;
    height: 38px;
    margin: 0 auto 14px;
    border: 3px solid #e2e8f0;
    border-top-color: var(--ek-primary);
    border-radius: 50%;
    animation: ek-spin 0.8s linear infinite;
}

@keyframes ek-spin {
    to { transform: rotate(360deg); }
}

.ek-no-items {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    background: #f8fafc;
    border: 2px dashed #cbd5e1;
    border-radius: var(--ek-radius);
    color: var(--ek-text-muted);
    font-size: 1.05rem;
}
