/* Reset básico */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Body y fondo */
body {
    background-color: #f4f7f8;
    color: #333;
    line-height: 1.6;
}

/* Encabezado y navegación */
header {
    background-color: #4CAF50;
    color: white;
    padding: 15px 20px;
    text-align: center;
}

header h1 {
    margin-bottom: 10px;
}

nav a {
    color: white;
    margin: 0 15px;
    text-decoration: none;
    font-weight: bold;
}

nav a:hover {
    text-decoration: underline;
}

/* Contenedor principal */
main {
    max-width: 900px;
    margin: 30px auto;
    background: white;
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

/* Títulos */
h2 {
    margin-bottom: 20px;
    color: #4CAF50;
}

/* Formularios */
form input, form select, form button {
    width: 100%;
    padding: 10px 12px;
    margin: 8px 0;
    border-radius: 5px;
    border: 1px solid #ccc;
    font-size: 1rem;
}

form input:focus, form select:focus {
    border-color: #4CAF50;
    outline: none;
}

form button {
    background-color: #4CAF50;
    color: white;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.3s;
}

form button:hover {
    background-color: #45a049;
}

/* Tablas */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

table, th, td {
    border: 1px solid #ddd;
}

th, td {
    padding: 12px;
    text-align: left;
}

th {
    background-color: #f2f2f2;
    font-weight: bold;
}

/* Botón eliminar en rojo (excepto acciones específicas) */
button[type="submit"]:not(.btn-accion) {
    background-color: #e74c3c;
}

button[type="submit"]:not(.btn-accion):hover {
    background-color: #c0392b;
}

/* Footer */
footer {
    text-align: center;
    margin-top: 40px;
    padding: 15px;
    background-color: #f2f2f2;
    color: #555;
    border-top: 1px solid #ddd;
}

/* Responsivo */
@media (max-width: 600px) {
    nav a {
        display: block;
        margin: 5px 0;
    }

    main {
        margin: 20px;
        padding: 20px;
    }
}

/* Cards de mascotas (listados simples) */
.mascota-card {
    background-color: #fff;
    border-radius: 10px;
    box-shadow: 0 3px 6px rgba(0,0,0,0.1);
    padding: 15px 20px;
    margin-bottom: 15px;
    display: block;
    transition: transform 0.2s;
}

.mascota-card:hover {
    transform: translateY(-3px);
}

.mascota-info {
    display: flex;
    flex-direction: column;
}

.mascota-info span {
    margin-bottom: 4px;
    font-size: 0.95rem;
}

.mascota-info span b {
    color: #4CAF50;
}

.mascota-actions form {
    display: inline;
}

.mascota-actions button {
    padding: 6px 12px;
    margin-left: 5px;
}

/* =========================
   Componentes compartidos
   (para buscar/modificar)
   ========================= */

/* Cabecera compacta con botón volver a la derecha */
.header-bar {
    position: relative;
    display: block;
    margin-bottom: 6px;
    background: transparent; /* los templates ya llevan su layout */
    padding: 0;
}
.header-bar h1 {
    text-align: center;
    margin: 8px 0 4px 0;
    line-height: 1.2;
    color: #333;
}
.btn-volver {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    background-color: #555;
    color: #fff;
    padding: 6px 10px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}
.btn-volver:hover { background-color: #333; }

/* Fila de filtros compacta y centrada */
.form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 15px;
    justify-content: center;
}
.form-row input,
.form-row select {
    flex: 1 1 120px;
    max-width: 170px;
    padding: 8px;
}
.form-row input[name="propietario_email"] {
    max-width: 320px;
}

/* Botón de buscar: forzar verde (sobre rule global de submit rojo) */
.btn-buscar {
    flex: 0 0 auto;
    background-color: #4CAF50 !important;
    color: white !important;
    border: none;
    padding: 10px 15px !important;
    border-radius: 5px;
    cursor: pointer;
}
.btn-buscar:hover { background-color: #45a049 !important; }

/* Mensajes e indicaciones */
.mensaje { text-align: center; color: #c0392b; font-weight: bold; margin-top: 10px; }
.hint { text-align: center; color: #666; margin-bottom: 10px; }

/* Disposición de info dentro de las tarjetas de resultados */
.mascota-info-grid {
    display: grid;
    gap: 10px 24px;
    grid-template-columns: repeat(3, minmax(180px, 1fr));
}

.mascota-info-grid .info-col span {
    display: block;
    margin: 2px 0;
    font-size: 0.93rem;
}

/* Ajustes responsivos */
@media (max-width: 900px) {
    .mascota-info-grid {
        grid-template-columns: repeat(2, minmax(180px, 1fr));
    }
}

@media (max-width: 600px) {
    .mascota-info-grid {
        grid-template-columns: 1fr;
    }
}

/* Bloque de fotos y miniaturas */
.foto-info {
    margin-top: 8px;
    margin-left: 4px;
    font-size: 0.9em;
    color: #444;
}
.foto-info b { color: #000; }

.foto-thumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}
.thumb { width: 90px; text-align: center; }
.thumb img {
    width: 90px;
    height: 90px;
    object-fit: cover;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #fff;
    cursor: zoom-in;
}
.thumb .cap {
    font-size: 0.78em;
    color: #333;
    margin-top: 4px;
    line-height: 1.1em;
}

/* Botón eliminar miniaturas existente */
.foto-item {
    position: relative;
    display: inline-block;
    overflow: visible;
}
.btn-remove-foto {
    position: absolute;
    top: -12px;
    right: -12px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: none;
    background: rgba(231, 76, 60, 0.95);
    color: #fff;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.18);
    transition: transform 0.2s ease, background-color 0.2s ease;
}
.btn-remove-foto:hover,
.btn-remove-foto:focus {
    background: rgba(192, 57, 43, 0.95);
    transform: scale(1.07);
    outline: none;
}

/* Lightbox común */
.lb-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.8);
    display: none; align-items: center; justify-content: center;
    z-index: 9999; padding: 20px;
}
.lb-overlay.show { display: flex; }
.lb-inner { position: relative; max-width: 95vw; max-height: 95vh; }
.lb-img {
    max-width: 95vw; max-height: 85vh; display: block; margin: 0 auto; border-radius: 6px;
    box-shadow: 0 6px 16px rgba(0,0,0,0.5); background: #fff;
}
.lb-caption {
    color: #fff; text-align: center; margin-top: 8px; font-size: 0.95rem;
}
.lb-close {
    position: absolute; top: -12px; right: -12px;
    width: 36px; height: 36px; border-radius: 50%;
    border: none; background: #fff; color: #333; cursor: pointer;
    font-size: 20px; line-height: 36px; box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.lb-close:hover { background: #eee; }

/* Acciones dentro de las tarjetas (modo modificar) */
.card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
    justify-content: flex-end;
}
.card-actions form {
    margin: 0;
}
.btn-accion {
    width: auto;
    padding: 8px 16px;
    border-radius: 5px;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    color: #fff;
    transition: background-color 0.2s ease;
}
.btn-accion-primario {
    background-color: #3498db;
}
.btn-accion-primario:hover {
    background-color: #2d7fb6;
}
.btn-accion-peligro {
    background-color: #e74c3c;
}
.btn-accion-peligro:hover {
    background-color: #c0392b;
}