/* --- Native App Touch Optimizations --- */
html, body {
    overscroll-behavior-y: none; /* Bloquea el pull-to-refresh del navegador */
    -webkit-tap-highlight-color: transparent; /* Elimina el recuadro azul al tocar botones */
    -webkit-user-select: none; /* Previene la selección de texto accidental en toda la app */
    user-select: none;
}

/* Protegemos el área segura de iOS (Notch y barra inferior) */
.app-header {
    padding-top: max(15px, env(safe-area-inset-top));
}

main {
    padding-bottom: max(20px, env(safe-area-inset-bottom));
}

/* Devolvemos la capacidad de seleccionar texto ÚNICAMENTE al contenido del lector */
#readerContent {
    -webkit-user-select: text;
    user-select: text;
}

/* Scroll con inercia suave nativa de iOS */
.view {
    -webkit-overflow-scrolling: touch;
}


:root {
    --primary: #00a2e8; /* saVRee Blue */
    --primary-dark: #007bb5;
    --navy: #1a2942;
    --bg-color: #f4f7f6;
    --card-bg: #ffffff;
    --text-main: #2d3748;
    --text-muted: #718096;
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }

body { background-color: var(--bg-color); color: var(--text-main); -webkit-font-smoothing: antialiased; }

/* Header */
.app-header { background-color: var(--navy); color: white; padding: 15px 20px; display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; z-index: 100; box-shadow: 0 2px 10px rgba(0,0,0,0.1); }
.logo { font-size: 1.2rem; font-weight: bold; letter-spacing: 1px; }
.logo span { color: var(--primary); font-weight: 400; }
.app-header button { background: none; border: none; color: white; font-size: 1.2rem; cursor: pointer; }

/* Layout */
main { padding: 20px; max-width: 600px; margin: 0 auto; min-height: calc(100vh - 60px); }
.view { display: none; animation: fadeIn 0.3s ease-in-out; }
.view.active { display: block; }
.hidden { display: none !important; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Upload View */
.hero-text { text-align: center; margin-bottom: 30px; margin-top: 20px;}
.hero-text h1 { color: var(--navy); font-size: 1.5rem; margin-bottom: 10px; }
.hero-text p { color: var(--text-muted); font-size: 0.95rem; line-height: 1.5; }

.upload-card { background: var(--card-bg); border: 2px dashed #cbd5e0; border-radius: 16px; padding: 40px 20px; text-align: center; box-shadow: 0 4px 6px rgba(0,0,0,0.02); transition: 0.3s; }
.upload-icon { font-size: 3rem; color: var(--primary); margin-bottom: 15px; display: block; }
.upload-card h3 { margin-bottom: 5px; color: var(--navy); }
.upload-card p { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 20px; }

.primary-btn { background-color: var(--primary); color: white; border: none; padding: 12px 24px; border-radius: 8px; font-weight: 600; font-size: 1rem; cursor: pointer; width: 100%; box-shadow: 0 4px 10px rgba(0, 162, 232, 0.3); transition: 0.2s; }
.primary-btn:active { transform: scale(0.98); }

/* Loader */
#loadingState { text-align: center; margin-top: 40px; }
.spinner { border: 4px solid rgba(0, 162, 232, 0.2); border-left-color: var(--primary); border-radius: 50%; width: 40px; height: 40px; animation: spin 1s linear infinite; margin: 0 auto 15px; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* Library View */
.app-info { margin-bottom: 20px; padding-bottom: 15px; border-bottom: 1px solid #e2e8f0; }
.app-info h1 { color: var(--navy); font-size: 1.4rem; }
.app-info p { color: var(--text-muted); font-size: 0.9rem; margin-top: 5px; }

.article-card { background: var(--card-bg); padding: 16px; border-radius: 12px; margin-bottom: 12px; box-shadow: 0 2px 4px rgba(0,0,0,0.04); display: flex; justify-content: space-between; align-items: center; cursor: pointer; transition: 0.2s; }
.article-card:active { background: #f8fafc; }
.article-card h3 { font-size: 1.05rem; color: var(--navy); }
.article-card i { color: var(--primary); }

/* Reader View */
.back-btn { background: none; border: none; color: var(--primary); font-size: 1rem; font-weight: 600; display: flex; align-items: center; cursor: pointer; margin-bottom: 20px; }
.back-btn i { font-size: 1.2rem; margin-right: 5px; }

.reader-typography { background: var(--card-bg); padding: 25px 20px; border-radius: 16px; box-shadow: 0 4px 10px rgba(0,0,0,0.05); }
.reader-typography h1 { color: var(--navy); margin-bottom: 15px; font-size: 1.5rem;}
.reader-typography h3 { color: var(--navy); margin: 20px 0 10px; font-size: 1.2rem;}
.reader-typography p { font-size: 1.05rem; line-height: 1.6; color: #4a5568; margin-bottom: 15px; }
.reader-typography ul { margin-left: 20px; margin-bottom: 15px; line-height: 1.6; color: #4a5568; }

.reader-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.edit-actions { display: flex; gap: 10px; }

.secondary-btn {
    background: #e2e8f0;
    color: var(--navy);
    border: none;
    padding: 8px 15px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
}

/* Estilo cuando el contenido es editable */
[contenteditable="true"] {
    outline: 2px dashed var(--primary);
    padding: 10px;
    border-radius: 8px;
    background: #fffdf5; /* Color crema suave para indicar edición */
}

.header-actions {
    display: flex;
    gap: 15px;
    align-items: center;
}

.header-actions button {
    background: none;
    border: none;
    color: white;
    font-size: 1.4rem; /* Un poco más grande para facilitar el toque en móviles */
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.header-actions button:hover {
    opacity: 0.8;
}

