/* GesGat Lite — Estils principals */

:root {
    --color-primari:    #6b7c2e;
    --color-primari-f:  #556324;
    --color-perill:     #dc2626;
    --color-ok:         #16a34a;
    --color-avis:       #d97706;
    --color-info:       #0891b2;
    --color-fons:       #f8fafc;
    --color-superficia: #ffffff;
    --color-vora:       #e2e8f0;
    --color-text:       #1e293b;
    --color-text-suau:  #64748b;
    --font:             'Segoe UI', system-ui, sans-serif;
    --radi:             6px;
    --ombra:            0 1px 3px rgba(0,0,0,.1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font);
    font-size: 14px;
    color: var(--color-text);
    background: var(--color-fons);
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.hidden { display: none !important; }

/* ── Login ── */
#pantalla-login {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background: linear-gradient(135deg, #2c3a10 0%, #6b7c2e 100%);
}
.login-caixa {
    background: white;
    border-radius: 12px;
    padding: 2.5rem 2rem;
    width: 360px;
    box-shadow: 0 8px 32px rgba(0,0,0,.2);
}
.login-caixa h1 { font-size: 1.5rem; color: var(--color-primari); margin-bottom: .25rem; font-weight: 700; }
.login-caixa p  { color: var(--color-text-suau); margin-bottom: 1.5rem; font-size: .9rem; }

/* ── App shell ── */
#pantalla-app { display: flex; flex-direction: column; height: 100vh; }

/* ── Capçalera ── */
.capçalera {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: .4rem 1rem;
    background: var(--color-primari);
    color: white;
    flex-shrink: 0;
}
.capçalera h1 { font-size: 1rem; font-weight: 700; white-space: nowrap; }
.info-usuari {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.3;
}
.info-ajuntament { font-size: .8rem; font-weight: 600; opacity: .95; }
.info-nom-usuari  { font-size: .75rem; opacity: .75; }
.separador-cap { flex: 1; }
.capçalera select {
    font-size: .85rem;
    padding: .25rem .4rem;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    width: auto;
}
.btn-logout { background: rgba(255,255,255,.15); border: 1px solid rgba(255,255,255,.3); color: white; padding: .3rem .75rem; border-radius: var(--radi); cursor: pointer; font-size: .85rem; white-space: nowrap; }
.btn-logout:hover { background: rgba(255,255,255,.25); }

/* ── Cos: nav lateral + contingut ── */
.cos-app { display: flex; flex: 1; overflow: hidden; }

/* ── Nav lateral ── */
.nav-lateral {
    width: 180px;
    background: var(--color-superficia);
    border-right: 1px solid var(--color-vora);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}
.nav-logo {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem .75rem .75rem;
    border-bottom: 1px solid var(--color-vora);
}
.nav-logo img {
    max-width: 120px;
    max-height: 64px;
    width: auto;
    height: auto;
    object-fit: contain;
}
.nav-btn {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .65rem 1rem;
    border: none;
    background: none;
    cursor: pointer;
    color: var(--color-text);
    font-size: .9rem;
    text-align: left;
    border-left: 3px solid transparent;
    transition: background .15s;
}
.nav-btn:hover  { background: #f1f5f9; }
.nav-btn.actiu  { background: #f3f5ec; color: var(--color-primari); border-left-color: var(--color-primari); font-weight: 600; }
.nav-icona { width: 1.25rem; height: 1.25rem; flex-shrink: 0; }

/* ── Contingut principal ── */
.contingut { flex: 1; overflow-y: auto; padding: 1.25rem; }

/* ── Capçalera de mòdul ── */
.modul-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    gap: 1rem;
    flex-wrap: wrap;
}
.modul-header h2 { font-size: 1.2rem; }
.modul-filtres { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* ── Formularis ── */
.form-grup { margin-bottom: 1rem; }
.form-grup label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .3rem; color: var(--color-text-suau); }
input[type=text], input[type=email], input[type=password], input[type=date],
input[type=number], select, textarea {
    width: 100%;
    padding: .5rem .75rem;
    border: 1px solid var(--color-vora);
    border-radius: var(--radi);
    font-size: .9rem;
    font-family: var(--font);
    background: white;
    color: var(--color-text);
    transition: border-color .15s;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--color-primari);
    box-shadow: 0 0 0 2px rgba(107,124,46,.15);
}
textarea { min-height: 80px; resize: vertical; }

/* ── Botons ── */
.btn, button[type=submit], button[type=button] {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .45rem 1rem;
    border: none;
    border-radius: var(--radi);
    cursor: pointer;
    font-size: .875rem;
    font-family: var(--font);
    font-weight: 500;
    transition: background .15s;
    background: var(--color-primari);
    color: white;
}
.btn:hover, button[type=submit]:hover, button[type=button]:hover { background: var(--color-primari-f); }
.btn-secundari, button[type=button].btn-secundari {
    background: var(--color-superficia);
    color: var(--color-text);
    border: 1px solid var(--color-vora);
}
.btn-secundari:hover, button[type=button].btn-secundari:hover { background: #f1f5f9; }
.btn-perill { background: var(--color-perill); }
.btn-perill:hover { background: #b91c1c; }
.btn-taula { background: #f1f5f9; color: var(--color-text); border: 1px solid var(--color-vora); padding: .25rem .6rem; font-size: .8rem; border-radius: 4px; }
.btn-taula:hover { background: #e2e8f0; }
.btn-taula.btn-perill { background: #fee2e2; color: var(--color-perill); border-color: #fecaca; }
.btn-taula.btn-perill:hover { background: #fecaca; }

/* ── Taules ── */
.taula-contenidor { background: white; border-radius: var(--radi); border: 1px solid var(--color-vora); overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
thead { background: #f8fafc; }
th { padding: .6rem 1rem; text-align: left; font-size: .8rem; font-weight: 600; color: var(--color-text-suau); text-transform: uppercase; letter-spacing: .03em; border-bottom: 1px solid var(--color-vora); }
td { padding: .65rem 1rem; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fafc; }
.accions { white-space: nowrap; display: flex; gap: .3rem; }
.buit { text-align: center; color: var(--color-text-suau); padding: 2rem !important; }
.taula-peu { padding: .5rem 1rem; font-size: .85rem; color: var(--color-text-suau); border-top: 1px solid var(--color-vora); background: #f8fafc; }

/* ── Badges ── */
.badge { display: inline-block; padding: .2rem .55rem; border-radius: 99px; font-size: .75rem; font-weight: 600; }
.badge-activa,  .badge-actiu  { background: #dcfce7; color: #166534; }
.badge-inactiva { background: #fef9c3; color: #854d0e; }
.badge-arxivada, .badge-arxivat { background: #f1f5f9; color: #64748b; }
.badge-mort     { background: #fee2e2; color: #991b1b; }
.badge-adoptat  { background: #dbeafe; color: #1e40af; }

/* ── Modals ── */
.modal-fons {
    position: fixed; inset: 0; background: rgba(0,0,0,.45);
    display: flex; align-items: center; justify-content: center;
    z-index: 100; padding: 1rem;
}
.modal-caixa {
    background: white; border-radius: 10px; padding: 1.5rem;
    width: 100%; max-width: 520px; max-height: 90vh;
    overflow-y: auto; box-shadow: 0 8px 32px rgba(0,0,0,.2);
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.25rem; }
.modal-header h3 { font-size: 1.1rem; }
.btn-tancar { background: none; border: none; font-size: 1.4rem; cursor: pointer; color: var(--color-text-suau); padding: 0 .25rem; }
.btn-tancar:hover { color: var(--color-text); }
.modal-accions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--color-vora); }

/* ── Fotos ── */
.foto-miniatura { width: 40px; height: 40px; object-fit: cover; border-radius: 50%; }
.foto-preview { max-width: 200px; max-height: 150px; border-radius: var(--radi); object-fit: cover; margin-top: .5rem; }

/* ── Mapa ── */
#mapa-leaflet { height: calc(100vh - 140px); border-radius: var(--radi); }
.btn-popup { margin-top: .4rem; padding: .3rem .65rem; background: var(--color-primari); color: white; border: none; border-radius: 4px; cursor: pointer; font-size: .8rem; }

/* ── Toasts ── */
#toast-contenidor { position: fixed; top: 1rem; right: 1rem; z-index: 9999; display: flex; flex-direction: column; gap: .5rem; }
.toast {
    padding: .75rem 1.1rem; border-radius: var(--radi);
    font-size: .875rem; font-weight: 500; max-width: 360px;
    box-shadow: 0 4px 12px rgba(0,0,0,.15);
    opacity: 0; transform: translateX(20px);
    transition: opacity .25s, transform .25s;
}
.toast-visible { opacity: 1; transform: translateX(0); }
.toast-ok    { background: #dcfce7; color: #166534; border-left: 4px solid var(--color-ok); }
.toast-error { background: #fee2e2; color: #991b1b; border-left: 4px solid var(--color-perill); }
.toast-avis  { background: #fef9c3; color: #854d0e; border-left: 4px solid var(--color-avis); }
.toast-info  { background: #e0f2fe; color: #0c4a6e; border-left: 4px solid var(--color-info); }
