/* ==========================================================================
   TU REFUGIO - COMPONENTES INTERACTIVOS, MODALES Y EXPERIENCIAS
   ========================================================================== */

/* Capa Base de Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 12, 20, 0.65);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-top: max(20px, env(safe-area-inset-top));
    padding-bottom: max(20px, env(safe-area-inset-bottom));
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-sheet {
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.4);
    width: 100%;
    max-width: 580px;
    max-height: 88vh;
    max-height: 88dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translate3d(0, 25px, 0);
    -webkit-transform: translate3d(0, 25px, 0);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
}

.modal-overlay.active .modal-sheet {
    transform: translate3d(0, 0, 0);
    -webkit-transform: translate3d(0, 0, 0);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-subtle);
}

.modal-title-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-title {
    font-family: var(--font-serif);
    font-size: 1.35rem;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close-btn {
    background: transparent;
    border: none;
    font-size: 1.3rem;
    color: var(--text-muted);
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

.modal-close-btn:hover {
    background: var(--bg-surface);
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* ==========================================================================
   EXPERIENCIA: "NECESITO UN ABRAZO" (PANTALLA COMPLETA DE CALMA)
   ========================================================================== */
.hug-overlay {
    position: fixed;
    inset: 0;
    background: radial-gradient(circle at center, #261f2f 0%, #120e17 100%);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
    padding-top: max(30px, env(safe-area-inset-top));
    padding-left: max(20px, env(safe-area-inset-left));
    padding-right: max(20px, env(safe-area-inset-right));
    padding-bottom: max(30px, calc(env(safe-area-inset-bottom) + 20px));
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.8s ease;
    color: #f7f3ec;
    text-align: center;
}

.hug-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.hug-content-box {
    max-width: 480px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    position: relative;
    z-index: 2;
}

/* Círculo de Respiración y Pulso Cálido */
.breathing-sanctuary {
    position: relative;
    width: 170px;
    height: 170px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 6px;
}

.breathing-circle-outer {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(217, 125, 145, 0.3) 0%, rgba(157, 141, 241, 0.08) 70%, transparent 100%);
    animation: breathing-halo 6s ease-in-out infinite;
}

.breathing-circle-inner {
    width: 105px;
    height: 105px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(217, 125, 145, 0.75) 0%, rgba(212, 139, 112, 0.75) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 40px rgba(217, 125, 145, 0.45);
    cursor: pointer;
    animation: heart-beat 2.4s ease-in-out infinite;
    transition: transform 0.3s ease;
}

.breathing-circle-inner:hover {
    transform: scale(1.06);
}

.hug-heart-icon {
    font-size: 2.6rem;
    filter: drop-shadow(0 2px 8px rgba(0,0,0,0.25));
}

.hug-prompt {
    font-family: var(--font-serif);
    font-size: 1.6rem;
    font-weight: 500;
    color: #fff;
    line-height: 1.3;
}

.hug-affirmation {
    font-size: 1rem;
    color: #ded7ce;
    line-height: 1.6;
    font-weight: 300;
    max-width: 400px;
}

.hug-breathing-guide {
    font-size: 0.84rem;
    letter-spacing: 0.05em;
    color: #f7b29a;
    background: rgba(247, 178, 154, 0.1);
    padding: 5px 16px;
    border-radius: var(--radius-full);
    border: 1px solid rgba(247, 178, 154, 0.2);
    font-weight: 400;
}

.hug-exit-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: #f7f3ec;
    padding: 8px 22px;
    border-radius: var(--radius-full);
    font-size: 0.88rem;
    cursor: pointer;
    transition: var(--transition-fast);
    margin-top: 6px;
}

.hug-exit-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

@keyframes breathing-halo {
    0%, 100% { transform: scale(0.9); opacity: 0.4; }
    50% { transform: scale(1.4); opacity: 0.9; }
}

@keyframes heart-beat {
    0%, 100% { transform: scale(1); }
    15% { transform: scale(1.08); }
    30% { transform: scale(1); }
    45% { transform: scale(1.05); }
}

@keyframes pulse-guide {
    0%, 40% { opacity: 1; content: "Inhala despacio..."; }
    50%, 100% { opacity: 0.8; }
}

/* ==========================================================================
   MINI-CARTA PARA NAYE
   ========================================================================== */
.letter-paper {
    background: #fffdf9;
    border: 1px solid #f0e6d8;
    border-radius: var(--radius-md);
    padding: 32px 28px;
    position: relative;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .letter-paper {
    background: #1f1b29;
    border-color: rgba(255, 255, 255, 0.1);
}

.letter-stamp {
    position: absolute;
    top: 24px;
    right: 24px;
    border: 2px dashed var(--accent-rose);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 0.72rem;
    color: var(--accent-rose);
    text-transform: uppercase;
    font-weight: 700;
    transform: rotate(5deg);
}

.letter-date {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.letter-text {
    font-family: var(--font-serif);
    font-size: 1.05rem;
    line-height: 1.8;
    color: var(--text-primary);
    white-space: pre-line;
    margin-bottom: 24px;
}

.letter-sign {
    font-family: var(--font-hand);
    font-size: 1.7rem;
    color: var(--accent-primary);
    text-align: right;
    margin-top: 10px;
}

/* ==========================================================================
   MIS FAVORITAS (DRAWER / LISTADO)
   ========================================================================== */
.favorites-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.empty-heart-icon {
    font-size: 3rem;
    margin-bottom: 12px;
    opacity: 0.5;
}

.favorites-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.favorite-item {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 16px;
    position: relative;
    transition: var(--transition-fast);
}

.favorite-item:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
}

.fav-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.fav-mood-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    color: var(--accent-primary);
}

.fav-content {
    font-family: var(--font-serif);
    font-size: 0.98rem;
    color: var(--text-primary);
    line-height: 1.5;
    margin-bottom: 10px;
}

.fav-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.fav-delete-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.8rem;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
}

.fav-delete-btn:hover {
    color: var(--accent-rose);
    background: rgba(217, 125, 145, 0.1);
}

/* ==========================================================================
   EL RINCÓN DE CELEBRAR MIS LOGROS
   ========================================================================== */
.achievement-form-box {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 18px;
    margin-bottom: 22px;
}

.achievement-input-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.achievement-textarea {
    width: 100%;
    height: 75px;
    background: var(--bg-base);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 12px;
    font-family: var(--font-main);
    font-size: 16px; /* 16px exactos previene zoom no deseado en iOS Safari */
    color: var(--text-primary);
    resize: none;
    outline: none;
    transition: var(--transition-fast);
    -webkit-appearance: none;
    appearance: none;
}

.achievement-textarea:focus {
    border-color: var(--accent-gold);
    box-shadow: 0 0 0 3px rgba(226, 168, 74, 0.2);
}

.achievement-btn-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.achievement-cat-select {
    background: var(--bg-base);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
    padding: 8px 14px;
    font-size: 16px; /* 16px exactos previene zoom no deseado en iOS Safari */
    color: var(--text-secondary);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
}

.btn-celebrate {
    background: linear-gradient(135deg, #e2a84a 0%, #f6ad55 100%);
    color: white;
    border: none;
    padding: 8px 18px;
    border-radius: var(--radius-full);
    font-weight: 600;
    font-size: 0.88rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 4px 12px rgba(226, 168, 74, 0.35);
    transition: var(--transition-fast);
}

.btn-celebrate:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(226, 168, 74, 0.45);
}

.achievements-timeline {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.achievement-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    animation: slide-in-top 0.4s ease;
}

.ach-content-wrap {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ach-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.72rem;
    font-weight: 600;
    color: #b7791f;
    background: rgba(226, 168, 74, 0.15);
    padding: 2px 8px;
    border-radius: var(--radius-full);
    width: fit-content;
}

[data-theme="dark"] .ach-tag {
    color: #f6e05e;
}

.ach-text {
    font-size: 0.92rem;
    color: var(--text-primary);
    line-height: 1.4;
}

.ach-date {
    font-size: 0.74rem;
    color: var(--text-muted);
}

/* ==========================================================================
   SORPRESA SECRETA MODAL
   ========================================================================== */
.surprise-card-box {
    text-align: center;
    padding: 20px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.surprise-star-icon {
    font-size: 3.5rem;
    animation: gentle-float 3s ease-in-out infinite;
}

.surprise-title {
    font-family: var(--font-serif);
    font-size: 1.4rem;
    color: var(--accent-primary);
}

.surprise-message {
    font-family: var(--font-serif);
    font-size: 1.15rem;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-surface);
    padding: 18px 22px;
    border-radius: var(--radius-md);
    border: 1px dashed var(--accent-primary);
}

/* Toast de Alerta Flotante */
.toast-notice {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(-60px);
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    padding: 10px 20px;
    border-radius: var(--radius-full);
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    z-index: 3000;
    font-size: 0.88rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
    pointer-events: none;
    opacity: 0;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s ease;
}

.toast-notice.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* Canvas Confetti / Destellos de Logro */
#confetti-canvas {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 2500;
}

@keyframes slide-in-top {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}
