:root {
    --bg-primary: #f4f6f9;
    --bg-container: #ffffff;
    --sidebar-bg: #2c3e50;
    --sidebar-hover: #34495e;
    --text-main: #333333;
    --text-muted: #718096;
    --color-accent: #3182ce;
    --color-accent-hover: #2b6cb0;
    --color-success: #38a169;
    --color-success-hover: #2f855a;
    --color-danger: #e53e3e;
    --color-danger-hover: #c53030;
    --border-color: #e2e8f0;
}

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

body {
    background-color: var(--bg-primary);
    color: var(--text-main);
    overflow-x: hidden;
}

/* --- Menú de Hamburguesa GATILLO LATERAL VERTICAL --- */
.menu-btn {
    position: fixed;
    top: 0;
    left: 0;
    width: 35px; /* Estrecho y vertical */
    height: 100vh; /* Ocupa toda la altura visual de la pantalla */
    z-index: 100;
    background: var(--sidebar-bg);
    color: white;
    border: none;
    padding: 0;
    cursor: pointer;
    box-shadow: 2px 0 8px rgba(0,0,0,0.15);
    transition: left 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    writing-mode: vertical-rl; /* Gira el icono para alinearlo verticalmente */
    text-orientation: mixed;
    border-radius: 0 16px 16px 0; /* Bordes suaves hacia la derecha */
}

/* El gatillo se desplaza junto con el menú abierto */
.menu-btn.active {
    left: 260px;
    border-radius: 16px 0 0 16px; /* Bordes suaves hacia la izquierda cuando abre */
    width: 40px; /* Un poco más ancho para cerrarlo más fácil */
}

/* Transición para el icono hamburguesa girado */
.menu-btn .hamb-icon {
    font-size: 24px;
    transform: rotate(90deg); /* Asegura que las líneas estén verticales */
    display: inline-block;
}

/* --- Menú Lateral (Sidebar) --- */
.sidebar {
    position: fixed;
    top: 0;
    left: -260px; /* Escondido a la izquierda */
    width: 260px;
    height: 100%;
    background: var(--sidebar-bg);
    color: white;
    z-index: 99;
    transition: left 0.3s ease;
    padding-top: 30px;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
}

.sidebar.active {
    left: 0; /* Se desliza hacia la vista */
}

.sidebar .brand {
    font-size: 18px;
    font-weight: bold;
    padding: 0 25px 25px 25px;
    color: var(--color-accent);
    border-bottom: 1px solid var(--sidebar-hover);
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar a {
    display: block;
    padding: 15px 25px;
    color: #ecf0f1;
    text-decoration: none;
    font-size: 16px;
    font-weight: 500;
    transition: background 0.2s;
    cursor: pointer;
}

.sidebar a:hover, .sidebar a.active {
    background: var(--sidebar-hover);
    border-left: 4px solid var(--color-accent);
    color: white;
}

/* --- Contenedor Principal (Con margen táctil a la izquierda) --- */
.main-content {
    padding: 30px 15px 30px 50px; /* Margen extra a la izquierda para el gatillo */
    min-height: 100vh;
}

.container {
    max-width: 500px;
    margin: 0 auto;
    background: var(--bg-container);
    padding: 25px;
    border-radius: 16px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

/* --- Vistas --- */
.vista {
    display: none;
}

.vista.active {
    display: block;
}

h2 {
    text-align: center;
    margin-bottom: 25px;
    color: var(--sidebar-bg);
    font-size: 22px;
    font-weight: 700;
}

.campo {
    margin-bottom: 24px;
}

label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: #4a5568;
    font-size: 15px;
}

.fecha-actual {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 20px;
    text-align: center;
    background: #edf2f7;
    padding: 6px;
    border-radius: 8px;
    font-weight: 500;
}

/* Input Rango */
.range-container {
    display: flex;
    align-items: center;
    gap: 15px;
}

input[type="range"] {
    flex: 1;
    height: 8px;
    border-radius: 5px;
    background: var(--border-color);
    outline: none;
    -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--color-accent);
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.range-val {
    font-size: 18px;
    font-weight: bold;
    color: var(--color-accent);
    min-width: 40px;
    text-align: right;
}

/* Emojis */
.emoji-group {
    display: flex;
    justify-content: space-between;
    background: #f7fafc;
    padding: 10px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.emoji-option {
    flex: 1;
    text-align: center;
    position: relative;
}

.emoji-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    cursor: pointer;
    z-index: 2;
}

.emoji-label {
    font-size: 26px;
    display: inline-block;
    transition: transform 0.2s, filter 0.2s;
    cursor: pointer;
    padding: 5px;
    filter: grayscale(60%);
    opacity: 0.6;
}

.emoji-option input[type="radio"]:checked + .emoji-label {
    filter: grayscale(0%);
    opacity: 1;
    transform: scale(1.3);
}

.emoji-text {
    display: block;
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 2px;
}

textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #cbd5e0;
    border-radius: 10px;
    resize: vertical;
    font-size: 15px;
    outline: none;
}

textarea:focus {
    border-color: var(--color-accent);
}

/* Botones */
button {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    margin-top: 10px;
}

.btn-guardar { background-color: var(--color-accent); color: white; }
.btn-guardar:hover { background-color: var(--color-accent-hover); }
.btn-exportar { background-color: var(--color-success); color: white; margin-bottom: 15px; }
.btn-exportar:hover { background-color: var(--color-success-hover); }
.btn-importar { background-color: #4a5568; color: white; }
.btn-importar:hover { background-color: #2d3748; }
.btn-peligro { background-color: var(--color-danger); color: white; margin-top: 25px; }
.btn-peligro:hover { background-color: var(--color-danger-hover); }

.file-input-wrapper {
    position: relative;
    overflow: hidden;
    display: inline-block;
    width: 100%;
}

.file-input-wrapper input[type=file] {
    font-size: 100px;
    position: absolute;
    left: 0;
    top: 0;
    opacity: 0;
    cursor: pointer;
}

.registros-count {
    text-align: center;
    font-size: 13px;
    color: #a0aec0;
    margin-top: 15px;
}

/* Tablas */
.tabla-container {
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--bg-container);
    margin-top: 10px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    text-align: left;
}

th {
    background-color: #edf2f7;
    color: #4a5568;
    padding: 12px;
    font-weight: 600;
    border-bottom: 2px solid var(--border-color);
}

td {
    padding: 12px;
    border-bottom: 1px solid #edf2f7;
    color: #2d3748;
    max-width: 140px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Capas de Bloqueo Táctil */
.overlay {
    position: fixed;
    display: none;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0,0,0,0.4);
    z-index: 98;
}
.overlay.active { display: block; }

/* Info Boxes */
.info-box {
    background: #ebf8ff;
    border-left: 4px solid var(--color-accent);
    color: #2b6cb0;
    padding: 12px;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 20px;
    line-height: 1.4;
}
.box-warning { background:#fffaf0; border-left-color:#dd6b20; color:#dd6b20; }
.box-muted { background: #f7fafc; border-left-color: #4a5568; color: #4a5568; }

.fecha-actual {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px; /* Espacio entre la fecha y el indicador */
}

.status-badge {
    display: inline-block;
    padding: 4px 12px;
    font-size: 12px;
    font-weight: bold;
    text-transform: uppercase;
    border-radius: 20px;
    letter-spacing: 0.5px;
    transition: all 0.3s ease;
}

.status-pendiente {
    background-color: #edf2f7;
    color: #4a5568;
    border: 1px solid #cbd5e0;
}

.status-guardado {
    background-color: #c6f6d5;
    color: #22543d;
    border: 1px solid #9ae6b4;
    box-shadow: 0 0 8px rgba(56, 161, 105, 0.2);
}

.habitos-container {
    display: flex;
    gap: 15px;
    margin-top: 5px;
}

.toggle-button {
    flex: 1;
    cursor: pointer;
    display: block;
    margin-bottom: 0 !important; /* Resetea el margen de las labels comunes */
}

.toggle-button input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-label {
    display: block;
    text-align: center;
    padding: 12px;
    background-color: #f7fafc;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-muted);
    transition: all 0.2s ease;
}

/* Cuando el checkbox oculto está marcado, el botón se vuelve azul/verde profesional */
.toggle-button input[type="checkbox"]:checked + .toggle-label {
    background-color: #ebf8ff;
    border-color: var(--color-accent);
    color: var(--color-accent);
    transform: scale(1.02);
    box-shadow: 0 2px 8px rgba(49, 130, 206, 0.15);
}

/* --- NUEVO: Distribución en dos columnas para ahorrar scroll --- */
.fila-compacta {
    display: flex;
    gap: 12px;
    margin-bottom: 12px; /* Reducido de 24px */
}

.fila-compacta .columna {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Reducción general de espacios verticales en todo el formulario */
.campo {
    margin-bottom: 12px; /* Reducido a la mitad para evitar scroll */
}

.container {
    max-width: 480px;
    margin: 0 auto;
    padding: 15px; /* Reducido de 25px */
}

h2 {
    margin-bottom: 15px;
}

/* Diseño moderno y editable para el input de ubicación */
.input-ubicacion-compacto {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-main);
    background-color: #ffffff;
    outline: none;
    transition: border-color 0.2s;
    height: 42px; /* Alineado con los botones de hábitos */
}

.input-ubicacion-compacto:focus {
    border-color: var(--color-accent);
}

/* Ajustes compactos para los botones de hábitos */
.toggle-label {
    padding: 10px 5px; /* Más compacto */
    font-size: 14px;
    border-radius: 12px;
}

/* Compactar el área de texto de notas */
textarea {
    padding: 10px;
    font-size: 14px;
    height: 60px; /* Altura inicial reducida para ahorrar pantalla */
}

button {
    padding: 12px; /* Más estilizado y compacto */
}

/* --- NUEVO: Alerta de copia de seguridad con transición suave --- */
.alerta-backup {
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 8px;
    margin-top: 4px;
    color: #ffffff; /* Texto blanco para que contraste con los fondos de colores */
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: background 0.5s ease;
    display: inline-block;
}