/* ===== RESET BÁSICO ===== */
* {
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, sans-serif;
}

body {
    margin: 0;
    padding: 20px;
    background: #f4f6f9;
    color: #333;
}

/* ===== TÍTULO ===== */
h1 {
    text-align: center;
    margin-bottom: 20px;
}

/* ===== BUSCADOR ===== */
#buscar {
    width: 100%;
    max-width: 400px;
    padding: 10px;
    margin: 0 auto 20px;
    display: block;
    border-radius: 6px;
    border: 1px solid #ccc;
}

/* ===== FILTROS ===== */
.contenedor {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 15px;
    background: #fff;
    padding: 15px;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.05);
    margin-bottom: 20px;
}

.campo {
    display: flex;
    flex-direction: column;
}

.campo label {
    font-size: 13px;
    margin-bottom: 5px;
    color: #666;
}

.campo select {
    padding: 8px;
    border-radius: 6px;
    border: 1px solid #ccc;
}

/* ===== BOTÓN NUEVO ===== */
#btnNuevo {
    background: #4CAF50;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 6px;
    cursor: pointer;
    margin-bottom: 20px;
}

#btnNuevo:hover {
    background: #43a047;
}

/* ===== LISTADO DE ARTÍCULOS ===== */
#articulos {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

/* ===== CARD ARTÍCULO ===== */
article {
    background: #fff;
    padding: 15px;
    border-radius: 10px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.06);
    transition: transform 0.2s;
}

article:hover {
    transform: translateY(-3px);
}

article h3 {
    margin: 10px 0 5px;
}

article p {
    font-size: 14px;
    color: #555;
}

/* ===== GALERÍA ===== */
.galeria {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.galeria img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid #ddd;
}

/* ===== BOTONES ===== */
article button {
    margin-top: 10px;
    padding: 6px 10px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 13px;
}

article button:first-of-type {
    background: #2196F3;
    color: white;
}

article button:last-of-type {
    background: #f44336;
    color: white;
}

article button:hover {
    opacity: 0.9;
}

/* ===== MODAL ===== */
#modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

/* ===== CONTENIDO MODAL ===== */
#modal > * {
    background: #fff;
    padding: 20px;
    border-radius: 10px;
    width: 100%;
    max-width: 500px;
}

#modal input[type="text"],
#modal textarea {
    width: 100%;
    padding: 8px;
    margin-bottom: 10px;
    border-radius: 6px;
    border: 1px solid #ccc;
}

#modal textarea {
    min-height: 80px;
}

#modal input[type="file"] {
    margin-bottom: 15px;
}

#modal button {
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

#modal button:first-of-type {
    background: #4CAF50;
    color: white;
}

#modal button:last-of-type {
    /*background: #9e9e9e;*/
    color: black;
    /*margin-left: 10px;*/
}
/* GALERÍA EN MODAL DETALLE */
.galeria-detalle {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
}

.galeria-detalle img {
    width: 120px;          /* tamaño miniatura */
    height: 120px;
    object-fit: cover;     /* recorte prolijo */
    border-radius: 6px;
    cursor: zoom-in;
    transition: transform 0.2s ease;
}

.galeria-detalle img:hover {
    transform: scale(1.05);
}

/* ===== ZOOM IMAGEN ===== */
.zoom-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.85);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 3000;
}

.zoom-modal img {
    max-width: 90%;
    max-height: 90%;
    border-radius: 12px;
    animation: zoomIn 0.3s ease;
}

@keyframes zoomIn {
    from { transform: scale(0.6); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.galeria-detalle {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.galeria-detalle img {
    width: 130px;
    cursor: zoom-in;
    border-radius: 8px;
}
.preview-imagenes {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.img-preview {
    position: relative;
    width: 90px;
}

.img-preview img {
    width: 100%;
    height: 90px;
    object-fit: cover;
    border-radius: 6px;
}

.btn-delete-img {
    position: absolute;
    top: -6px;
    right: -6px;
    background: #e53935;
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    cursor: pointer;
    font-size: 12px;
}
/* ================== RESPONSIVE ================== */

/* ===== TABLETS ===== */
@media (max-width: 1024px) {

    #articulos {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    }

    .galeria img {
        width: 70px;
        height: 70px;
    }
}

/* ===== CELULARES ===== */
@media (max-width: 768px) {
    .campo select {
        font-size: 16px; /* evita zoom en iOS */
    }
    body {
        padding: 10px;
    }

    h1 {
        font-size: 20px;
    }

    /* Buscador */
    #buscar {
        width: 100%;
        max-width: none;
    }

    /* Filtros en una sola columna */
    .contenedor {
        grid-template-columns: 1fr;
        padding: 12px;
    }

    /* Botón nuevo */
    #btnNuevo {
        width: 100%;
        font-size: 16px;
        padding: 12px;
    }

    /* Artículos en columna */
    #articulos {
        grid-template-columns: 1fr;
    }

    article {
        padding: 12px;
    }

    article h3 {
        font-size: 16px;
    }

    article p {
        font-size: 14px;
    }

    /* Galería con scroll horizontal */
    .galeria {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 5px;
    }

    .galeria img {
        width: 90px;
        height: 90px;
        flex-shrink: 0;
    }

    /* Botones */
    article button {
        width: 100%;
        margin-top: 8px;
        font-size: 14px;
    }

    /* Modal */
    #modal > * {
        width: 95%;
        max-width: none;
        padding: 15px;
    }

    #modal textarea {
        min-height: 70px;
    }

    #modal button {
        width: 100%;
        margin-top: 10px;
    }

    #modal button:last-of-type {
        margin-left: 0;
    }
}

/* ===== CELULARES MUY CHICOS ===== */
@media (max-width: 400px) {

    h1 {
        font-size: 18px;
    }

    .galeria img {
        width: 75px;
        height: 75px;
    }
    .preview-imagenes .img-preview {
        width: 65px;
        height: 65px;
    }
}

/* ================= MODAL ================= */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.6);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 1000;
}

.modal {
    background: #fff;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    animation: modalIn .25s ease;
}

.modal h2 {
    margin: 0 0 8px;
}

.modal input,
.modal textarea {
    width: 100%;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #ccc;
    font-size: 15px;
}

.modal textarea {
    resize: vertical;
    min-height: 90px;
}

.acciones {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

@media (max-width: 480px) {
    .acciones {
        flex-direction: column;
    }
}

@keyframes modalIn {
    from { transform: scale(.95); opacity: 0 }
    to { transform: scale(1); opacity: 1 }
}
/* ===== PREVIEW IMÁGENES EN EDITAR ===== */
.preview-imagenes {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 10px;
}

.preview-imagenes .img-preview {
    width: 80px;
    height: 80px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #ddd;
    background: #fafafa;
}

.preview-imagenes img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* recorta sin deformar */
    cursor: pointer;
}
/* ================== SELECT RESPONSIVE ================== */

.campo {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.campo select {
    width: 100%;
    min-height: 44px; /* tamaño táctil recomendado */
    padding: 8px 12px;
    font-size: 15px;

    border-radius: 8px;
    border: 1px solid #ccc;
    background-color: #fff;

    /* elimina estilos nativos inconsistentes */
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;

    background-image: url("data:image/svg+xml;utf8,\
    <svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='gray'>\
    <path d='M7 10l5 5 5-5z'/>\
    </svg>");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 18px;
}

/* foco */
.campo select:focus {
    outline: none;
    border-color: #4f46e5;
    box-shadow: 0 0 0 2px rgba(79,70,229,.2);
}

