:root {
    /* MODO CLARO */
    --bg-gradient: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    --glass-bg: rgba(255, 255, 255, 0.35);
    --glass-border: rgba(255, 255, 255, 0.45);
    --text-color: #2c3e50;
    --text-muted: #607d8b;
    --input-bg: rgba(255, 255, 255, 0.6);
    --primary-color: #3498db;
    --text-blue: #2980b9;
    --secondary-color: rgba(0, 0, 0, 0.05);
    --secondary-text: #546e7a;
    --shadow: rgba(31, 38, 135, 0.1);
}

@media (prefers-color-scheme: dark) {
    :root {
        /* MODO OSCURO AUTOMÁTICO */
        --bg-gradient: linear-gradient(135deg, #141419 0%, #08080a 100%);
        --glass-bg: rgba(22, 22, 28, 0.6);
        --glass-border: rgba(255, 255, 255, 0.08);
        --text-color: #f5f6fa;
        --text-muted: #9aa0a6;
        --input-bg: rgba(0, 0, 0, 0.35);
        --primary-color: #2980b9;
        --text-blue: #5bb0ff;
        --secondary-color: rgba(255, 255, 255, 0.05);
        --secondary-text: #b0bec5;
        --shadow: rgba(0, 0, 0, 0.4);
    }
}

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

body {
    background: var(--bg-gradient);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.app-container {
    width: 100%;
    max-width: 420px;
    padding: 16px;
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 24px;
    box-shadow: 0 12px 40px 0 var(--shadow);
    overflow: hidden; 
}

/* Tipografía */
h1 { font-size: 26px; text-align: center; font-weight: 700; letter-spacing: -0.5px; }
h2 { font-size: 20px; font-weight: 600; margin-bottom: 16px; color: var(--text-color); }
h3 { font-size: 15px; font-weight: 600; margin-bottom: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.subtitle { text-align: center; color: var(--text-muted); font-size: 14px; margin-bottom: 24px; }

/* Controles de Formulario */
form { display: flex; flex-direction: column; gap: 16px; }

input, select {
    width: 100%;
    min-height: 46px;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    background: var(--input-bg);
    color: var(--text-color);
    font-size: 16px;
    outline: none;
    transition: background 0.2s, border 0.2s;
}

/* FIX CRÍTICO PARA IPHONE */
.ios-date-wrapper {
    display: flex;
    flex-direction: column;
    width: 100%;
}
.ios-date-wrapper label {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 4px;
    padding-left: 4px;
}
input[type="date"], input[type="time"] {
    -webkit-appearance: none;
    appearance: none;
    box-sizing: border-box;
    width: 100% !important;
    max-width: 100%;
}

.input-row {
    display: flex;
    gap: 12px;
    width: 100%;
}
.flex-item {
    flex: 1 1 0%;
    min-width: 0; 
}

/* Botones */
button {
    font-size: 16px;
    font-weight: 600;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}
.btn-primary {
    background: var(--primary-color);
    color: #ffffff;
    padding: 14px;
}
.btn-primary:active { transform: scale(0.98); opacity: 0.9; }
.btn-secondary {
    background: var(--secondary-color);
    color: var(--secondary-text);
    padding: 14px;
    width: 100%;
    margin-top: 12px;
}

/* Cabecera de Perfil Centrada */
.profile-header {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 56px;
    margin-bottom: 24px;
}
.btn-back {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    color: var(--primary-color);
    padding: 8px 4px;
    font-size: 24px;
    font-weight: 700;
    line-height: 1;
}
.profile-title-container {
    text-align: center;
    width: 100%;
    padding: 0 40px;
}
#active-user-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-blue);
    margin-bottom: 2px;
}
.profile-meta {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
    letter-spacing: 0.2px;
}

/* Gestión de Vistas */
.view-section { animation: fadeIn 0.3s ease-in-out; }
.hidden { display: none !important; }

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

/* Dashboard Grid con Swipe-Actions a la Izquierda */
.user-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
    max-height: 280px;
    overflow-y: auto;
}
.user-card {
    position: relative;
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    overflow: hidden;
    min-height: 54px;
    background: var(--input-bg);
}
.user-card-data {
    display: flex;
    width: 100%;
    height: 100%;
    background: var(--input-bg);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 2;
}

/* Zonas táctiles divididas equitativamente al 50% */
.zone-left {
    flex: 1;
    padding: 16px;
    display: flex;
    align-items: center;
    font-weight: 600;
    font-size: 16px;
    color: var(--text-color);
    border-right: 1px dashed var(--glass-border);
    cursor: pointer;
}
.zone-right {
    flex: 1;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    color: var(--primary-color);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}
.zone-right:active, .zone-left:active {
    background: rgba(0, 0, 0, 0.03);
}

/* Contenedor de acciones del Dashboard (Oculto a la izquierda) */
.user-actions-left {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 150px;
    display: flex;
    z-index: 1;
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Desplazamiento reactivo del Dashboard */
.user-card.show-user-actions .user-card-data {
    transform: translateX(150px);
}
.user-card.show-user-actions .user-actions-left {
    transform: translateX(0);
}

/* Vista Perfil e Historial (Swipe a la Derecha) */
.weight-entry-box, .history-box {
    margin-bottom: 24px;
}
.glass-list { list-style: none; }
.history-item {
    background: var(--input-bg);
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    margin-bottom: 10px;
    position: relative;
    overflow: hidden; 
    min-height: 60px;
}
.history-data {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    width: 100%;
    background: var(--input-bg);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 2;
}
.history-date-group { display: flex; flex-direction: column; }
.h-date { font-size: 14px; font-weight: 600; }
.h-time { font-size: 11px; color: var(--text-muted); }
.history-weight-group { font-size: 16px; font-weight: 700; text-align: right; }
.h-lbs { font-size: 12px; color: var(--text-muted); font-weight: 400; display: block; }

.history-actions {
    position: absolute;
    right: 0;
    top: 0;
    height: 100%;
    width: 150px; 
    display: flex;
    z-index: 1;
    transform: translateX(100%); 
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.btn-action {
    flex: 1;
    height: 100%;
    border-radius: 0;
    border: none;
    color: white;
    font-size: 13px;
    font-weight: 600;
}
.btn-edit { background: #f39c12; }
.btn-delete { background: #e74c3c; }

.history-item.show-actions .history-data {
    transform: translateX(-150px);
}
.history-item.show-actions .history-actions {
    transform: translateX(0); 
}
