/* ===== FUENTES DE GOOGLE ===== */
@import url('https://fonts.googleapis.com/css2?family=Caveat:wght@400;700&family=Indie+Flower&family=Quicksand:wght@300;400;500;600;700&display=swap');

/* ===== RESET Y BASE ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --crema: #FEF9EF;
    --papel: #FFF8E7;
    --terracota: #C17A74;
    --terracota-oscuro: #a5635d;
    --oliva: #8B9A6B;
    --mostaza: #D4A853;
    --tinta: #4A3728;
    --gris: #999;
    --gris-claro: #e8e0d5;
    --blanco: #ffffff;
    --sombra: 0 2px 10px rgba(0,0,0,0.08);
    --sombra-fuerte: 0 4px 20px rgba(0,0,0,0.15);
    --borde-redondo: 16px;
    --borde-redondo-sm: 10px;
    
    /* Alturas de elementos fijos */
    --header-height: 56px;
    --navbar-height: 60px;
}

body {
    background-color: var(--crema);
    font-family: 'Quicksand', sans-serif;
    color: var(--tinta);
    min-height: 100vh;
    min-height: 100dvh; /* Para móviles modernos */
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
}

/* ===== TIPOGRAFÍAS ===== */
.handwritten {
    font-family: 'Caveat', cursive;
}

.notebook {
    font-family: 'Indie Flower', cursive;
}

/* ===== LAYOUT PRINCIPAL TIPO APP ===== */
.app-container {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--crema);
    position: relative;
    display: flex;
    flex-direction: column;
}

/* En pantallas grandes, centrar como app */
@media (min-width: 481px) {
    body {
        background: #f0e6d3;
    }
    .app-container {
        box-shadow: var(--sombra-fuerte);
        min-height: 100vh;
        border-left: 1px solid #e0d5c0;
        border-right: 1px solid #e0d5c0;
    }
}

/* ===== HEADER FIJO ===== */
.app-header {
    background: var(--papel);
    padding: 12px 20px;
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--gris-claro);
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: var(--header-height);
    backdrop-filter: blur(10px);
}

.app-header h1 {
    font-family: 'Caveat', cursive;
    font-size: 1.6rem;
    color: var(--tinta);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-header .header-subtitle {
    font-family: 'Indie Flower', cursive;
    font-size: 0.85rem;
    color: var(--oliva);
    margin: 0;
}

.app-header .header-left {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.app-header .header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ===== CONTENIDO PRINCIPAL ===== */
.app-content {
    flex: 1;
    padding: 16px;
    padding-bottom: calc(var(--navbar-height) + 20px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* ===== BARRA DE NAVEGACIÓN INFERIOR ===== */
.app-navbar {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    background: var(--papel);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 8px 0;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    border-top: 1px solid var(--gris-claro);
    z-index: 100;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
    min-height: var(--navbar-height);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: var(--gris);
    font-size: 0.7rem;
    font-weight: 600;
    transition: all 0.2s ease;
    padding: 4px 12px;
    border-radius: 12px;
    gap: 4px;
    min-width: 56px;
    position: relative;
}

.nav-item .nav-icon {
    font-size: 1.4rem;
    transition: transform 0.2s ease;
}

.nav-item.activo {
    color: var(--terracota);
}

.nav-item.activo .nav-icon {
    transform: scale(1.1);
}

.nav-item.activo::before {
    content: '';
    position: absolute;
    top: -8px;
    width: 24px;
    height: 3px;
    background: var(--terracota);
    border-radius: 0 0 4px 4px;
}

.nav-item:active {
    transform: scale(0.95);
}

/* ===== TARJETAS DE RECUERDO (ESTILO COLLAGE) ===== */
.recuerdos-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

@media (min-width: 400px) {
    .recuerdos-grid {
        gap: 16px;
    }
}

.tarjeta-recuerdo {
    background: var(--papel);
    border-radius: var(--borde-redondo);
    box-shadow: var(--sombra);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    overflow: hidden;
    border: 1px solid var(--gris-claro);
    position: relative;
}

.tarjeta-recuerdo:active {
    transform: scale(0.97);
}

.tarjeta-recuerdo:nth-child(odd) {
    transform: rotate(0.5deg);
}

.tarjeta-recuerdo:nth-child(even) {
    transform: rotate(-0.5deg);
}

.tarjeta-recuerdo:nth-child(odd):active {
    transform: scale(0.97) rotate(0.5deg);
}

.tarjeta-recuerdo:nth-child(even):active {
    transform: scale(0.97) rotate(-0.5deg);
}

.tarjeta-recuerdo .foto {
    width: 100%;
    height: 150px;
    background: #e8e0d5;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    overflow: hidden;
    position: relative;
}

.tarjeta-recuerdo .foto img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.tarjeta-recuerdo .foto .foto-placeholder {
    opacity: 0.5;
}

.tarjeta-recuerdo .info {
    padding: 12px;
}

.tarjeta-recuerdo .titulo {
    font-family: 'Caveat', cursive;
    font-size: 1.3rem;
    color: var(--tinta);
    margin-bottom: 4px;
    line-height: 1.2;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.tarjeta-recuerdo .lugar {
    color: var(--oliva);
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 3px;
    margin-bottom: 2px;
}

.tarjeta-recuerdo .fecha {
    color: var(--gris);
    font-size: 0.7rem;
    margin-bottom: 6px;
}

.tarjeta-recuerdo .descripcion {
    font-family: 'Indie Flower', cursive;
    color: var(--tinta);
    opacity: 0.8;
    font-size: 0.85rem;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.tarjeta-recuerdo .etiquetas {
    display: flex;
    gap: 4px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.etiqueta {
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.65rem;
    color: white;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.etiqueta-recuerdo {
    background: var(--terracota);
}

.etiqueta-futuro {
    background: var(--mostaza);
}

.etiqueta-autor {
    background: var(--oliva);
}

/* ===== BOTÓN FLOTANTE ===== */
.fab {
    position: fixed;
    bottom: calc(var(--navbar-height) + 20px);
    right: 20px;
    width: 56px;
    height: 56px;
    background: var(--terracota);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    text-decoration: none;
    box-shadow: 0 4px 15px rgba(193, 122, 116, 0.4);
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
    z-index: 50;
    -webkit-tap-highlight-color: transparent;
}

.fab:active {
    transform: scale(0.9);
    background: var(--terracota-oscuro);
}

/* ===== MAPA ===== */
.mapa-container {
    height: calc(100vh - var(--header-height) - var(--navbar-height) - 40px);
    height: calc(100dvh - var(--header-height) - var(--navbar-height) - 40px);
    border-radius: var(--borde-redondo);
    overflow: hidden;
    box-shadow: var(--sombra);
    border: 2px solid white;
}

#mapa {
    height: 100%;
    width: 100%;
}

/* ===== FORMULARIOS ===== */
.formulario {
    background: var(--papel);
    padding: 20px;
    border-radius: var(--borde-redondo);
    box-shadow: var(--sombra);
    border: 1px solid var(--gris-claro);
}

.formulario h2 {
    font-family: 'Caveat', cursive;
    font-size: 2rem;
    color: var(--tinta);
    text-align: center;
    margin-bottom: 20px;
}

.campo {
    margin-bottom: 16px;
}

.campo label {
    display: block;
    margin-bottom: 6px;
    color: var(--tinta);
    font-weight: 600;
    font-size: 0.85rem;
}

.campo input,
.campo textarea,
.campo select {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid var(--gris-claro);
    border-radius: 12px;
    font-family: 'Quicksand', sans-serif;
    font-size: 0.95rem;
    background: white;
    transition: all 0.3s ease;
    color: var(--tinta);
    -webkit-appearance: none;
    appearance: none;
}

.campo input:focus,
.campo textarea:focus,
.campo select:focus {
    outline: none;
    border-color: var(--terracota);
    box-shadow: 0 0 0 3px rgba(193, 122, 116, 0.1);
}

.campo textarea {
    min-height: 100px;
    resize: vertical;
}

.campo select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M6 8L1 3h10z' fill='%234A3728'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}

.boton-submit {
    background: var(--terracota);
    color: white;
    padding: 14px 24px;
    border: none;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    width: 100%;
    font-family: 'Quicksand', sans-serif;
    transition: all 0.3s ease;
    letter-spacing: 0.5px;
    -webkit-tap-highlight-color: transparent;
}

.boton-submit:active {
    transform: scale(0.97);
    background: var(--terracota-oscuro);
}

.boton-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ===== LOGIN / REGISTRO ===== */
.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 20px;
}

.auth-box {
    background: var(--papel);
    padding: 32px 24px;
    border-radius: var(--borde-redondo);
    box-shadow: var(--sombra-fuerte);
    width: 100%;
    max-width: 380px;
    text-align: center;
    border: 1px solid var(--gris-claro);
}

.auth-box .auth-emoji {
    font-size: 4rem;
    margin-bottom: 12px;
}

.auth-box h1 {
    font-family: 'Caveat', cursive;
    font-size: 2.5rem;
    color: var(--tinta);
    margin: 0 0 4px;
}

.auth-box .auth-subtitle {
    font-family: 'Indie Flower', cursive;
    color: var(--oliva);
    margin-bottom: 24px;
    font-size: 1rem;
}

.auth-link {
    margin-top: 16px;
    font-size: 0.85rem;
    color: var(--gris);
}

.auth-link a {
    color: var(--terracota);
    text-decoration: none;
    font-weight: 700;
}

/* ===== MENSAJES ===== */
.mensaje-exito {
    background: #e8f5e9;
    color: #2e7d32;
    padding: 12px 16px;
    border-radius: 12px;
    margin-bottom: 16px;
    font-size: 0.9rem;
    font-weight: 600;
    text-align: center;
    border-left: 4px solid #2e7d32;
}

.mensaje-error {
    background: #fbe9e7;
    color: #c62828;
    padding: 12px 16px;
    border-radius: 12px;
    margin-bottom: 16px;
    font-size: 0.9rem;
    font-weight: 600;
    text-align: center;
    border-left: 4px solid #c62828;
}

/* ===== CÍRCULOS ===== */
.circulo-card {
    background: var(--papel);
    padding: 16px;
    border-radius: var(--borde-redondo);
    margin-bottom: 12px;
    border: 1px solid var(--gris-claro);
    box-shadow: var(--sombra);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    transition: transform 0.2s;
}

.circulo-card:active {
    transform: scale(0.98);
}

.circulo-card.activo {
    border-color: var(--oliva);
    background: #f5f7f0;
}

.circulo-nombre {
    font-family: 'Caveat', cursive;
    font-size: 1.4rem;
    color: var(--tinta);
}

.circulo-rol {
    font-size: 0.7rem;
    padding: 3px 10px;
    border-radius: 12px;
    color: white;
    font-weight: 700;
}

.rol-admin { background: var(--terracota); }
.rol-miembro { background: var(--oliva); }

.circulo-codigo {
    font-family: monospace;
    background: #f0e6d3;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.8rem;
    letter-spacing: 2px;
}

/* ===== UTILIDADES ===== */
.text-center { text-align: center; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }

/* ===== SCROLLBAR PERSONALIZADA ===== */
::-webkit-scrollbar {
    width: 4px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--gris-claro);
    border-radius: 4px;
}

/* ===== ANIMACIONES ===== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.3s ease;
}