/* --- Estilos Base y Respaldo Profesional --- */
body {
    background-color: #f8fafc;
    color: #1e293b;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* --- Cabecera Adaptativa con Saludo Personalizado Abajo --- */
header {
    background-color: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    position: sticky;
    top: 0;
    z-index: 30;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    width: 100%;
    box-sizing: border-box;
}

.container-max {
    max-width: 64rem;
    margin: 0 auto;
    padding: 0.75rem 1rem 0.5rem 1rem;
    width: 100%;
    box-sizing: border-box;
}

.header-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    width: 100%;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-width: 0;
}

.header-logo {
    background-color: #4f46e5;
    color: white;
    padding: 0.55rem;
    border-radius: 0.75rem;
    font-weight: bold;
    flex-shrink: 0;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-titles h1 {
    font-size: 1.05rem;
    font-weight: bold;
    margin: 0;
    color: #0f172a;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Franja inferior dentro del fondo blanco para la bienvenida personalizada */
.header-user-footer {
    max-width: 64rem;
    margin: 0 auto;
    padding: 0.25rem 1rem 0.6rem 1rem;
    box-sizing: border-box;
}

.header-user-footer span {
    font-size: 0.7rem;
    color: #64748b;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}

.header-actions {
    display: flex;
    gap: 0.35rem;
    align-items: center;
    flex-shrink: 0;
}

/* Botones Principales adaptativos para móvil */
.btn-primary {
    background-color: #4f46e5;
    color: #ffffff;
    font-weight: 600;
    font-size: 0.7rem;
    padding: 0.35rem 0.5rem;
    border-radius: 0.5rem;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    transition: background-color 0.2s;
    box-sizing: border-box;
    height: 2.1rem;
    white-space: nowrap;
}

.btn-primary:hover {
    background-color: #4338ca;
}

.btn-logout {
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    color: #64748b;
    padding: 0.35rem 0.5rem;
    border-radius: 0.5rem;
    cursor: pointer;
    height: 2.1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Botones de Categoría Modernos */
.btn-category {
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid #cbd5e1;
    white-space: nowrap;
    transition: all 0.2s;
    box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}

.btn-category:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 8px -1px rgba(0, 0, 0, 0.15);
}

.btn-category.active {
    background-color: #4f46e5;
    color: white;
}

.btn-category.inactive {
    background-color: #ffffff;
    color: #475569;
    border: 1px solid #e2e8f0;
}

/* Tarjetas de Productos General */
.card {
    background-color: #ffffff;
    border-radius: 1rem;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: box-shadow 0.2s;
}
.card:hover {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* --- Estructura Ordenada de la Tarjeta de Publicación --- */
.product-card {
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    cursor: pointer;
    box-sizing: border-box;
    overflow-wrap: anywhere; /* Corrección para evitar cortes abruptos de palabras */
}

.product-card-body {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.product-badges {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.25rem;
}

.badge-tipo {
    background: #e0e7ff;
    color: #4f46e5;
    font-size: 0.55rem;
    font-weight: bold;
    padding: 0.2rem 0.35rem;
    border-radius: 9999px;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 65%;
}

.badge-cat {
    font-size: 0.6rem;
    color: #94a3b8;
    white-space: nowrap;
}

.product-info {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.product-title {
    font-size: 0.85rem;
    font-weight: bold;
    color: #0f172a;
    margin: 0;
    line-height: 1.2;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-desc {
    font-size: 0.7rem;
    color: #64748b;
    margin: 0;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-price-wrapper {
    padding-top: 0.15rem;
}

.product-price {
    color: #4f46e5;
    font-weight: 800;
    font-size: 0.95rem;
}

.product-footer {
    padding-top: 0.5rem;
    margin-top: 0.5rem;
    border-top: 1px solid #f1f5f9;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.btn-whatsapp {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    background: #10b981;
    color: #ffffff;
    padding: 0.4rem;
    border-radius: 0.5rem;
    font-size: 0.65rem;
    font-weight: 600;
    text-decoration: none;
    box-sizing: border-box;
}

.product-owner-actions {
    display: flex;
    gap: 0.25rem;
}

.btn-action {
    flex: 1;
    border: none;
    padding: 0.3rem;
    border-radius: 0.4rem;
    font-size: 0.6rem;
    font-weight: bold;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
}

.btn-edit {
    background: #e0e7ff;
    color: #4f46e5;
}

.btn-delete {
    background: #fee2e2;
    color: #991b1b;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.modal-box {
    background-color: #ffffff;
    border-radius: 1.5rem;
    max-width: 28rem;
    width: 100%;
    padding: 1.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    border: 1px solid #f1f5f9;
}

/* --- Cuadrícula responsiva --- */
.product-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}

/* --- Corrección exclusiva para la cabecera en Móvil (menor a 768px) --- */
@media (max-width: 767px) {
    .header-container {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .header-brand {
        width: 100%;
        justify-content: flex-start;
    }

    .header-titles h1 {
        font-size: 1.1rem;
        white-space: normal;
    }

    .header-actions {
        width: 100%;
        justify-content: space-between;
        gap: 0.3rem;
    }

    .btn-primary {
        flex: 1;
        justify-content: center;
        padding: 0.4rem 0.2rem;
        font-size: 0.65rem;
    }

    .btn-logout {
        flex-shrink: 0;
    }
}

/* --- En pantallas medianas y de escritorio (desde 768px) --- */
@media (min-width: 768px) {
    .container-max {
        padding: 1rem 1rem 0.75rem 1rem;
    }
    .header-user-footer {
        padding: 0 1rem 0.75rem 1rem;
    }
    .header-titles h1 {
        font-size: 1.125rem;
    }
    .header-user-footer span {
        font-size: 0.75rem;
    }
    .btn-primary {
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
        border-radius: 0.75rem;
        height: 2.375rem;
        gap: 0.5rem;
    }
    .btn-logout {
        padding: 0.5rem 0.75rem;
        border-radius: 0.75rem;
        height: 2.375rem;
    }
    .header-actions {
        gap: 0.5rem;
    }
    .product-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 1rem;
    }
    .product-card {
        padding: 1rem;
    }
    .badge-tipo {
        font-size: 0.65rem;
        padding: 0.25rem 0.5rem;
        max-width: none;
    }
    .product-title {
        font-size: 1rem;
    }
    .product-desc {
        font-size: 0.75rem;
        -webkit-line-clamp: 3;
        line-clamp: 3;
    }
    .product-price {
        font-size: 1.125rem;
    }
    .product-footer {
        padding-top: 1rem;
        margin-top: 1rem;
        gap: 0.5rem;
    }
    .btn-whatsapp {
        padding: 0.625rem;
        font-size: 0.75rem;
    }
    .btn-action {
        padding: 0.4rem;
        font-size: 0.75rem;
    }
}

/* --- Contenedor Global para Mostrar/Ocultar Contraseña --- */
.password-container {
    position: relative;
    width: 100%;
    display: block;
    box-sizing: border-box;
}

.password-input {
    width: 100%;
    padding: 0.625rem 2.5rem 0.625rem 0.625rem;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 0.75rem;
    font-size: 0.875rem;
    box-sizing: border-box;
    outline: none;
    color: #0f172a;
}

.password-toggle-btn {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #64748b;
    cursor: pointer;
    font-size: 0.875rem;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.password-toggle-btn:hover {
    color: #4f46e5;
}

/* Botón adaptable: ancho completo por defecto (móvil), y ajustado/centrado en escritorio */
@media (min-width: 768px) {
    .btn-actualizar-pass {
        width: auto !important;
        min-width: 16rem;
        margin-left: auto;
        margin-right: auto;
    }
}