/* ============================================
   RESET + BASE
   ============================================ */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Segoe UI', sans-serif;
    background: #f5f0e8;
    position: relative;
    min-height: 100vh;
}

/* ============================================
   MARCA DE AGUA
   ============================================ */
body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('../img/logobf.png');
    background-repeat: no-repeat;
    background-position: center center;
    background-size: 40%;
    opacity: 0.06;
    pointer-events: none;
    z-index: -1;
}

/* ============================================
   HEADER
   ============================================ */
.header {
    background: linear-gradient(135deg, #5d3a1a, #a9744f);
    color: white;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    position: relative;
    z-index: 999;
}
.header .brand { font-weight: bold; letter-spacing: 2px; }

.btn-volver {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: white;
    text-decoration: none;
    background: rgba(255,255,255,0.2);
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    transition: 0.25s;
    white-space: nowrap;
    margin-left: auto;
}
.btn-volver:hover {
    background: rgba(255,255,255,0.35);
    transform: translateX(-2px);
}

/* ============================================
   CONTENEDOR
   ============================================ */
.container {
    max-width: 1000px;
    margin: 30px auto;
    padding: 0 20px;
    position: relative;
    z-index: 1;
}

h2 {
    color: #5d3a1a;
    margin-bottom: 20px;
    font-size: 1.4rem;
}

/* ============================================
   TABS
   ============================================ */
.tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 20px;
    border-bottom: 2px solid #d4a373;
    flex-wrap: wrap;
}
.tabs a {
    padding: 12px 20px;
    text-decoration: none;
    color: #5d3a1a;
    font-weight: 600;
    border-radius: 8px 8px 0 0;
    font-size: 14px;
}
.tabs a.activo { background: #5d3a1a; color: white; }
.tabs a:hover:not(.activo) { background: #f0e8dc; }

/* ============================================
   CARDS
   ============================================ */
.card {
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    margin-bottom: 25px;
}

.seccion-titulo {
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 2px solid #f0e8dc;
    padding-bottom: 10px;
    margin-bottom: 20px;
    margin-top: 25px;
}
.seccion-titulo:first-child { margin-top: 0; }
.seccion-titulo .icono-seccion { font-size: 1.4rem; }
.seccion-titulo h3 {
    color: #5d3a1a;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.subseccion-titulo {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #a9744f;
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 15px;
    margin-top: 20px;
    padding-bottom: 6px;
    border-bottom: 1px dashed #e8d5b7;
}
.subseccion-titulo:first-of-type { margin-top: 0; }

/* ============================================
   FORMULARIOS
   ============================================ */
.grid { display: grid; gap: 15px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }

.campo { display: flex; flex-direction: column; gap: 5px; }
.campo.full { grid-column: 1 / -1; }
.campo label {
    font-size: 11px;
    color: #5d3a1a;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

input, select, textarea {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid #d4a373;
    border-radius: 6px;
    font-family: inherit;
    font-size: 14px;
    background: white;
    transition: 0.2s;
}

input[type="text"], textarea, select { text-transform: uppercase; }
input[type="text"]::placeholder, textarea::placeholder { text-transform: none; }

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: #5d3a1a;
    box-shadow: 0 0 0 3px rgba(169,116,79,0.15);
}

/* Foto */
.bloque-foto {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 25px;
    align-items: start;
}
.foto-container { text-align: center; }
.foto-preview-box {
    width: 100%;
    aspect-ratio: 1;
    max-width: 180px;
    margin: 0 auto 12px;
    border-radius: 12px;
    border: 3px dashed #d4a373;
    background: #faf5ee;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    cursor: pointer;
    transition: 0.3s;
}
.foto-preview-box:hover { border-color: #5d3a1a; background: #f0e8dc; }
.foto-preview-box img { width: 100%; height: 100%; object-fit: cover; }
.foto-preview-box .placeholder { color: #a9744f; font-size: 48px; }
.foto-btn {
    display: inline-block;
    background: #5d3a1a;
    color: white;
    padding: 8px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    margin-top: 5px;
}
.foto-hint { font-size: 11px; color: #a9744f; margin-top: 8px; }
#inputFoto { display: none; }

/* Contactos emergencia */
.contacto-emergencia {
    background: #faf5ee;
    border: 2px solid #e8d5b7;
    border-radius: 10px;
    padding: 18px;
    margin-bottom: 15px;
}
.contacto-emergencia .num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #a9744f;
    color: white;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    font-size: 13px;
    font-weight: bold;
    margin-right: 8px;
}
.contacto-emergencia-titulo {
    color: #5d3a1a;
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
}

/* ============================================
   BOTONES
   ============================================ */
.acciones {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 2px solid #f0e8dc;
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}
button.guardar {
    background: #5d3a1a;
    color: white;
    padding: 16px 70px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    transition: 0.3s;
    font-family: inherit;
}
button.guardar:hover {
    background: #3e2610;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(93,58,26,0.3);
}
button.guardar:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.btn-cancelar, .btn-cancelar-edit {
    background: #999;
    color: white;
    padding: 16px 40px;
    border: none;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 700;
    display: inline-block;
    transition: 0.3s;
    font-family: inherit;
    font-size: 1rem;
    cursor: pointer;
}
.btn-cancelar:hover, .btn-cancelar-edit:hover { background: #777; }

/* ============================================
   BADGES
   ============================================ */
.badge {
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: bold;
    text-transform: uppercase;
}
.badge.activo      { background: #d4edda; color: #155724; }
.badge.inactivo    { background: #f8d7da; color: #721c24; }
.badge.vacaciones  { background: #fff3cd; color: #856404; }
.badge.incapacidad { background: #ffe4cc; color: #8a4b00; }
.badge.baja        { background: #e2e3e5; color: #383d41; }

/* ============================================
   MENSAJES
   ============================================ */
.err {
    background: #f8d7da;
    color: #721c24;
    padding: 14px 18px;
    border-radius: 8px;
    margin-bottom: 20px;
    border-left: 4px solid #dc3545;
}
.vacio {
    background: white;
    text-align: center;
    padding: 40px 20px;
    border-radius: 10px;
    color: #999;
    box-shadow: 0 2px 5px rgba(0,0,0,0.06);
}
.vacio .icono { font-size: 3rem; margin-bottom: 10px; }

.resultados-info {
    padding: 6px 4px;
    margin-bottom: 10px;
    color: #5d3a1a;
    font-size: 12px;
    font-weight: 600;
}

/* ============================================
   TOASTS
   ============================================ */
.toast, .toast-pdf {
    position: fixed;
    top: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    background: #28a745;
    color: white;
    padding: 16px 35px;
    border-radius: 50px;
    font-size: 15px;
    font-weight: 600;
    box-shadow: 0 10px 30px rgba(0,0,0,0.25);
    z-index: 99999;
    opacity: 0;
    transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    white-space: nowrap;
}
.toast.mostrar, .toast-pdf.mostrar {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}
.toast.del  { background: #dc3545; }
.toast.warn { background: #ffc107; color: #5d3a1a; }
.toast.err  { background: #dc3545; }

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 900px) {
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .header { padding: 12px 15px; gap: 10px; }
    .header .brand { font-size: 1.1rem; letter-spacing: 1.5px; }

    .container { padding: 0 12px; margin: 15px auto; max-width: 100%; }

    h2 { font-size: 1.2rem; margin-bottom: 15px; }

    .tabs a { flex: 1; padding: 12px 8px; font-size: 12.5px; text-align: center; }

    .card { padding: 18px 15px; border-radius: 10px; margin-bottom: 15px; }
    .seccion-titulo { margin-top: 20px; margin-bottom: 15px; padding-bottom: 8px; }
    .seccion-titulo h3 { font-size: 0.9rem; letter-spacing: 0.5px; }
    .seccion-titulo .icono-seccion { font-size: 1.2rem; }
    .subseccion-titulo { font-size: 0.8rem; }
    .campo label { font-size: 11px; }

    input, select, textarea { padding: 12px; font-size: 16px; min-height: 44px; }

    .bloque-foto { grid-template-columns: 1fr; gap: 18px; }
    .foto-preview-box { max-width: 140px; margin: 0 auto 10px; }

    .acciones {
        flex-direction: column-reverse;
        gap: 10px;
        margin-top: 20px;
        padding-top: 15px;
    }
    button.guardar,
    .btn-cancelar,
    .btn-cancelar-edit,
    button[type="submit"] {
        width: 100%;
        padding: 15px 20px;
        font-size: 1rem;
        min-height: 48px;
        justify-content: center;
        text-align: center;
    }

    .contacto-emergencia { padding: 14px; }
    .btn-volver { font-size: 12px; padding: 7px 12px; gap: 4px; }

    .toast, .toast-pdf {
        top: auto;
        bottom: 20px;
        left: 15px;
        right: 15px;
        transform: translateY(150%);
        white-space: normal;
        text-align: center;
        padding: 14px 20px;
        font-size: 13px;
        border-radius: 12px;
    }
    .toast.mostrar, .toast-pdf.mostrar { transform: translateY(0); }
}

@media (max-width: 600px) {
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* Táctil */
@media (hover: none) and (pointer: coarse) {
    button, .btn-editar, .btn-eliminar-ficha,
    .btn-eliminar, .item, .tabs a, .chip {
        min-height: 44px;
    }
}