:root {
    --creme: #FDFBF7;
    --sage: #7C9082;
    --clay: #6D5C53;
    --petal: #EAC9C1;
    --amber-soft: #F4E4D4;
    --midnight: #1A1A1A;
    --safe-area-bottom: env(safe-area-inset-bottom, 20px);
    --lavender: #9B5DE5;
    --lavender-soft: #D8B4FE;
}

/* ===== MODO OSCURO ===== */
body.dark-mode {
    --creme: #1A1A2E;
    --sage: #9BB5A2;
    --clay: #E0D5CE;
    --petal: #C4908A;
    --amber-soft: #2A2A3E;
    --midnight: #0D0D1A;
    --lavender: #D8B4FE;
    background-color: var(--creme);
    color: var(--clay);
    color-scheme: dark;
}

body.dark-mode .app-bg {
    background: radial-gradient(circle at 0% 0%, #2A2A3E 0%, transparent 40%),
                radial-gradient(circle at 100% 100%, #3D1F1F 0%, transparent 40%);
}

body.dark-mode .glass-card {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.12);
}

body.dark-mode .bottom-nav {
    background: rgba(10, 10, 20, 0.97);
}

body.dark-mode textarea.modern-input {
    background: rgba(255, 255, 255, 0.06);
    color: #E0D5CE;
    border-color: rgba(255, 255, 255, 0.12);
}

body.dark-mode textarea.modern-input:focus {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(196, 144, 138, 0.5);
}

body.dark-mode .afirmacion-hero {
    background: linear-gradient(135deg, #2D1F2E 0%, #0D0D1A 100%);
}

body.dark-mode .journal-module {
    background: rgba(255,255,255,0.04);
}

body.dark-mode #welcome-screen {
    background: var(--creme);
}

/* Animaciones de "El Jardín del Ser" */
@keyframes flutter {
    0%, 100% { transform: translateY(0) rotate(-5deg); }
    50% { transform: translateY(-10px) rotate(5deg); }
}

@keyframes sunPulse {
    0%, 100% { opacity: 0.6; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.1); }
}

@keyframes grassWave {
    0%, 100% { transform: skewX(-2deg); }
    50% { transform: skewX(2deg); }
}

.butterfly {
    animation: flutter 3s ease-in-out infinite;
    transform-origin: center;
}

.sun-ray {
    animation: sunPulse 4s ease-in-out infinite;
    transform-origin: center;
}

.grass-blade {
    animation: grassWave 4s ease-in-out infinite;
    transform-origin: bottom center;
}

/* Animaciones de Flor de Progreso */
@keyframes growIn {
    0% { transform: scale(0); opacity: 0; }
    70% { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

.animate-grow {
    animation: growIn 1.2s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    transform-box: fill-box;
    transform-origin: center;
}

.flower-container {
    transition: transform 1.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    transform-origin: bottom center;
}

.petal-path {
    transform-origin: center bottom;
    transform-box: fill-box;
}

/* --- Sobreescrituras de colores de texto de Tailwind en modo oscuro --- */
/* Textos de piedra (grises) → versiones claras para fondo oscuro */
body.dark-mode .text-stone-600,
body.dark-mode .text-stone-700,
body.dark-mode .text-stone-800,
body.dark-mode .text-stone-900 {
    color: #C8BDB8 !important;
}

body.dark-mode .text-stone-500 {
    color: #B0A8A4 !important;
}

body.dark-mode .text-stone-400,
body.dark-mode .text-stone-300 {
    color: #8A8380 !important;
}

/* Texto principal clay → claro */
body.dark-mode .text-clay {
    color: #E0D5CE !important;
}

/* Fondos claros → versiones oscuras */
body.dark-mode .bg-creme,
body.dark-mode .bg-white\/40,
body.dark-mode .bg-white\/30 {
    background: rgba(255,255,255,0.06) !important;
}

body.dark-mode .bg-white\/80,
body.dark-mode .bg-white\/60 {
    background: rgba(255,255,255,0.1) !important;
}

/* Badges y fondos de chips */
body.dark-mode .bg-emerald-100 {
    background: rgba(52, 211, 153, 0.15) !important;
}

body.dark-mode .bg-emerald-50 {
    background: rgba(52, 211, 153, 0.1) !important;
}

body.dark-mode .bg-rose-50\/50 {
    background: rgba(254, 228, 220, 0.05) !important;
}

/* Bordes */
body.dark-mode .border-rose-100,
body.dark-mode .border-white\/60,
body.dark-mode .border-white\/50 {
    border-color: rgba(255, 255, 255, 0.1) !important;
}

/* History items */
body.dark-mode .history-item {
    border-left-color: var(--petal);
}

body.dark-mode .history-item::before {
    background: var(--creme);
    border-color: var(--petal);
}

/* Toggle de Modo Oscuro */
.dark-toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    gap: 10px;
}

.dark-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.dark-toggle-track {
    width: 48px;
    height: 26px;
    background: rgba(0,0,0,0.1);
    border-radius: 999px;
    transition: all 0.3s;
    position: relative;
    border: 1px solid rgba(0,0,0,0.08);
}

.dark-toggle-track::after {
    content: '';
    position: absolute;
    left: 3px;
    top: 3px;
    width: 18px;
    height: 18px;
    background: white;
    border-radius: 50%;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.dark-toggle input:checked + .dark-toggle-track {
    background: var(--clay);
}

.dark-toggle input:checked + .dark-toggle-track::after {
    left: calc(100% - 21px);
}

* {
    -webkit-tap-highlight-color: transparent;
    box-sizing: border-box;
}

body {
    background-color: #f2eeea; /* Color de fondo exterior para resaltar el contenedor */
    font-family: 'Outfit', sans-serif;
    color: var(--clay);
    overflow-x: hidden;
    margin: 0;
    min-height: 100vh;
    display: flex;
    justify-content: center;
}

#app-content, #login-screen, #welcome-screen {
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
    background-color: var(--creme);
    min-height: 100vh;
    position: relative;
    box-shadow: 0 0 60px rgba(0,0,0,0.05);
}

body.dark-mode {
    background-color: #0d0d1a;
}

/* Fondo Inmersivo */
.app-bg {
    position: fixed;
    inset: 0;
    z-index: -1;
    background: radial-gradient(circle at 0% 0%, var(--amber-soft) 0%, transparent 40%),
                radial-gradient(circle at 100% 100%, var(--petal) 0%, transparent 40%);
    background-attachment: fixed;
}

.app-bg::after {
    content: '';
    position: fixed;
    inset: 0;
    background-image: url('https://www.transparenttextures.com/patterns/natural-paper.png');
    opacity: 0.1;
    pointer-events: none;
}

/* Contenedor Principal con Padding para Nav */
.view-container {
    padding-bottom: calc(85px + var(--safe-area-bottom));
    min-height: 100vh;
}

/* Glassmorphism */
.glass-card {
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 32px;
}

/* Animaciones de Entrada */
@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.animate-up {
    animation: slideUp 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

/* Pantalla de Bienvenida Re-imaginada */
#welcome-screen {
    background: var(--creme);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem;
}

.hero-flower {
    width: 120px;
    height: 120px;
    background: var(--petal);
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    margin-bottom: 2rem;
    position: relative;
    box-shadow: 0 20px 40px rgba(234, 201, 193, 0.4);
}

.hero-flower::before {
    content: '';
    position: absolute;
    inset: 15px;
    background: white;
    border-radius: 50%;
    opacity: 0.3;
}

/* Nav Inferior */
/* Nav Inferior Full-Width */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 500px;
    height: calc(75px + var(--safe-area-bottom));
    background: rgba(26, 26, 26, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding-bottom: var(--safe-area-bottom);
    z-index: 100;
    box-shadow: 0 -10px 30px rgba(0,0,0,0.1);
}

.nav-item {
    color: #888;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
}

.nav-item.active {
    color: var(--petal);
    transform: translateY(-8px);
}

.nav-item span {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.5;
    transform: translateY(0);
    transition: all 0.3s;
}

.nav-item.active span {
    opacity: 1;
    transform: translateY(0);
}

/* Tarjetas de Contenido */
.section-header {
    margin-top: 2rem;
    margin-bottom: 2rem;
}

.afirmacion-hero {
    padding: 3rem 2rem;
    border-radius: 40px;
    background: linear-gradient(135deg, var(--clay) 0%, var(--midnight) 100%);
    color: white;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.ensenanza-card {
    line-height: 1.8;
    font-size: 1.05rem;
    color: var(--clay);
    padding: 2.5rem;
}

.daily-check {
    padding: 2rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    border-radius: 30px;
}

/* Diario */
.journal-module {
    background: white;
    border-radius: 35px;
    padding: 2rem;
}

textarea.modern-input {
    width: 100%;
    background: var(--creme);
    border: 1px solid rgba(0,0,0,0.05);
    border-radius: 24px;
    padding: 1.5rem;
    font-size: 1rem;
    resize: none;
    min-height: 120px;
    transition: all 0.3s;
}

textarea.modern-input:focus {
    outline: none;
    background: white;
    border-color: var(--sage);
    box-shadow: 0 10px 20px rgba(124, 144, 130, 0.1);
}

/* Otros */
.btn-primary-app {
    background: var(--sage);
    color: white;
    padding: 1rem 2rem;
    border-radius: 20px;
    font-weight: 600;
    transition: all 0.3s;
}

.custom-checkbox {
    width: 28px;
    height: 28px;
    border: 2px solid var(--petal);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    cursor: pointer;
    background: white;
    flex-shrink: 0;
}

.custom-checkbox i {
    width: 16px;
    height: 16px;
    color: white;
    opacity: 0;
    transform: scale(0.5);
    transition: all 0.3s;
}

.custom-checkbox.checked {
    background: var(--sage);
    border-color: var(--sage);
    transform: scale(1.1);
    box-shadow: 0 0 15px rgba(124, 144, 130, 0.3);
}

.custom-checkbox.checked i {
    opacity: 1;
    transform: scale(1);
}

.commitment-card {
    cursor: pointer;
    transition: all 0.3s;
    border: 2px solid transparent;
}

.commitment-card:hover {
    background: rgba(255, 255, 255, 0.6);
}

.commitment-card.active-state {
    border-color: rgba(124, 144, 130, 0.3);
    background: rgba(124, 144, 130, 0.05);
}

.pulse-attention {
    animation: pulse-border 1.5s infinite;
}

@keyframes pulse-border {
    0% { border-color: rgba(234, 201, 193, 0.3); box-shadow: 0 0 0 0 rgba(234, 201, 193, 0.4); }
    70% { border-color: rgba(234, 201, 193, 0.6); box-shadow: 0 0 0 10px rgba(234, 201, 193, 0); }
    100% { border-color: rgba(234, 201, 193, 0.3); box-shadow: 0 0 0 0 rgba(234, 201, 193, 0); }
}

.hidden { display: none !important; }

/* Progreso Circular */
.progress-container {
    position: relative;
    width: 120px;
    height: 120px;
    margin: 0 auto 2rem;
}

.progress-ring {
    transform: rotate(-90deg);
}

.progress-ring__circle {
    transition: stroke-dashoffset 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    stroke: var(--petal);
    stroke-linecap: round;
}

.progress-text {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Historial del Diario */
.history-item {
    border-left: 2px solid var(--petal);
    padding-left: 1.5rem;
    position: relative;
}

.history-item::before {
    content: '';
    position: absolute;
    left: -7px;
    top: 0;
    width: 12px;
    height: 12px;
    background: var(--creme);
    border: 2px solid var(--petal);
    border-radius: 50%;
}

.journal-header-badge {
    background: var(--petal);
    color: var(--clay);
    padding: 0.2rem 0.6rem;
    border-radius: 8px;
    font-size: 10px;
    font-weight: 700;
}

.btn-toggle-journal {
    background: white;
    padding: 0.8rem 1.5rem;
    border-radius: 12px;
    border: 1px solid rgba(0,0,0,0.05);
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s;
}

.btn-toggle-journal:active {
    transform: scale(0.95);
}

.btn-toggle-journal.active {
    background: var(--clay);
    color: white;
    border-color: var(--clay);
}

/* ===== PANTALLA DE PIN ===== */
#pin-screen {
    background: var(--creme);
}

.pin-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid var(--petal);
    background: transparent;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.pin-dot.filled {
    background: var(--clay);
    border-color: var(--clay);
    transform: scale(1.15);
}

.pin-dot.error {
    background: #f43f5e;
    border-color: #f43f5e;
    animation: shake 0.4s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}

.pin-keyboard {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    max-width: 240px;
    margin: 0 auto;
}

.pin-key {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(0,0,0,0.06);
    font-size: 1.4rem;
    font-weight: 500;
    font-family: 'Outfit', sans-serif;
    color: var(--clay);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s;
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.pin-key:active {
    transform: scale(0.88);
    background: var(--petal);
    color: white;
}

.pin-key-ghost {
    background: transparent;
    border-color: transparent;
    box-shadow: none;
    opacity: 0.6;
}

.pin-key-ghost:active {
    background: rgba(0,0,0,0.05);
}

body.dark-mode #pin-screen {
    background: var(--creme);
}

body.dark-mode .pin-key {
    background: rgba(255,255,255,0.08);
    border-color: rgba(255,255,255,0.1);
    color: var(--clay);
}

body.dark-mode .pin-key:active {
    background: var(--petal);
}

/* ===== ESTILOS DE IMPRESIÓN (PDF) ===== */
@media print {
    /* Ocultar elementos de la interfaz */
    .bottom-nav, 
    button, 
    .hero-flower, 
    .app-bg,
    .dark-toggle,
    nav,
    #welcome-screen,
    .btn-toggle-journal,
    #pin-screen {
        display: none !important;
    }

    body {
        background: white !important;
        color: #1a1a1a !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    .view-container {
        padding: 0 !important;
        margin: 0 !important;
    }

    /* Formato del Diario */
    .history-item {
        page-break-inside: avoid;
        border-left: 3px solid #EAC9C1 !important;
        margin-bottom: 2rem !important;
        padding-left: 2rem !important;
    }

    .journal-header-badge {
        background: #f8f8f8 !important;
        border: 1px solid #ddd !important;
        color: #666 !important;
        print-color-adjust: exact;
    }

    h2 {
        font-size: 28pt !important;
        color: #444 !important;
        margin-bottom: 30pt !important;
    }

    h3 {
        color: #1a1a1a !important;
    }

    p {
        font-size: 11pt !important;
        line-height: 1.6 !important;
    }

    .glass-card {
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        backdrop-filter: none !important;
        padding: 0 !important;
    }

    /* Cabecera personalizada para el PDF */
    .print-header {
        display: block !important;
        text-align: center;
        margin-bottom: 50pt;
        border-bottom: 1px solid #eee;
        padding-bottom: 20pt;
    }
}

/* ===== REPRODUCTOR DE AUDIO MEJORADO ===== */
.audio-player-container {
    padding: 1.5rem !important;
    border: 1px solid rgba(234, 201, 193, 0.3) !important;
    background: rgba(255, 255, 255, 0.5) !important;
    box-shadow: 0 15px 35px rgba(234, 201, 193, 0.15) !important;
}

body.dark-mode .audio-player-container {
    background: rgba(255, 255, 255, 0.05) !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2) !important;
}

/* Iconos de los Reproductores */
.player-icon-wrapper {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.music-icon-circle {
    background: var(--sage) !important;
}

.meditation-icon-circle {
    background: var(--lavender) !important;
}

body.dark-mode .player-icon-wrapper {
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.player-icon-wrapper i {
    width: 16px;
    height: 16px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

.music-icon-animation {
    animation: floating 3s ease-in-out infinite;
}

@keyframes floating {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

.audio-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 10px;
    outline: none;
    transition: background 0.3s;
}

body.dark-mode .audio-slider {
    background: rgba(255, 255, 255, 0.1);
}

.audio-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--sage);
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: all 0.2s;
}

.audio-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: var(--sage);
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.audio-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 4px 12px rgba(124, 144, 130, 0.3);
}

#music-play-btn i {
    filter: drop-shadow(0 4px 6px rgba(124, 144, 130, 0.2));
}

/* ===== REPRODUCTOR DE MEDITACIÓN (LAVANDA) ===== */
.meditation-player {
    border-color: rgba(155, 93, 229, 0.2) !important;
    box-shadow: 0 15px 35px rgba(155, 93, 229, 0.1) !important;
}

body.dark-mode .meditation-player {
    border-color: rgba(216, 180, 254, 0.1) !important;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2) !important;
}

.bg-lavender {
    background-color: var(--lavender) !important;
}

.meditation-slider::-webkit-slider-thumb {
    background: var(--lavender) !important;
}

.meditation-slider::-moz-range-thumb {
    background: var(--lavender) !important;
}

.meditation-player .music-icon-wrapper {
    background: var(--lavender) !important;
}

/* ===== TARJETA DE DESCARGA PDF ===== */
.download-card {
    background: rgba(155, 93, 229, 0.08);
    border: 1px solid rgba(155, 93, 229, 0.15);
    text-decoration: none !important;
}

body.dark-mode .download-card {
    background: rgba(216, 180, 254, 0.05);
    border-color: rgba(216, 180, 254, 0.1);
}

.download-card:hover {
    background: rgba(155, 93, 229, 0.12);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(155, 93, 229, 0.1);
}

body.dark-mode .download-card:hover {
    background: rgba(216, 180, 254, 0.08);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.text-lavender {
    color: var(--lavender) !important;
}

.text-lavender-dark\/60 {
    color: rgba(109, 40, 217, 0.6);
}

body.dark-mode .text-lavender-dark\/60 {
    color: rgba(216, 180, 254, 0.6);
}

.print-header {
    display: none;
}
