/* ==========================================================================
   SANA - Arquitectura Visual: Apple Health (iOS 17+)
   ========================================================================== */

:root {
    --ios-bg: #F2F2F7;
    --ios-surface: #FFFFFF;
    --ios-text: #000000;
    --ios-text-muted: #8E8E93;
    --ios-border: #C6C6C8;
    
    --ios-blue: #007AFF;
    --ios-blue-light: #E5F1FF;
    --ios-green: #34C759;
    --ios-green-light: #EBFAE5;
    --ios-red: #FF3B30;
    --ios-red-light: #FFEBEA;
    --ios-orange: #FF9500;
    --ios-orange-light: #FFF4E5;
    --ios-gray: #8E8E93;
    --ios-gray-light: #F2F2F7;

    --font-stack: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
}

body.dark-mode {
    --ios-bg: #000000;
    --ios-surface: #1C1C1E;
    --ios-text: #FFFFFF;
    --ios-text-muted: #EBEBF599;
    --ios-border: #38383A;
    
    --ios-blue: #0A84FF;
    --ios-blue-light: rgba(10, 132, 255, 0.15);
    --ios-green: #30D158;
    --ios-green-light: rgba(48, 209, 88, 0.15);
    --ios-red: #FF453A;
    --ios-red-light: rgba(255, 69, 58, 0.15);
    --ios-orange: #FF9F0A;
    --ios-orange-light: rgba(255, 159, 10, 0.15);
    --ios-gray: #98989D;
    --ios-gray-light: rgba(142, 142, 147, 0.18);
}

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

body { background-color: var(--ios-bg); color: var(--ios-text); font-family: var(--font-stack); overscroll-behavior-y: none; line-height: 1.3; transition: background-color 0.2s, color 0.2s; }

.view { display: none; opacity: 0; transition: opacity 0.2s; }
.view.active { display: flex; flex-direction: column; opacity: 1; min-height: 100vh; }
.hidden { display: none !important; }

/* --- Headers iOS --- */
.ios-header { padding: 16px 20px 8px; background: var(--ios-bg); position: sticky; top: 0; z-index: 10; }
.ios-header-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.ios-large-title { font-size: 2.2rem; font-weight: 800; letter-spacing: -0.03em; }

.ios-header-nav { display: flex; justify-content: space-between; align-items: center; padding: 16px; background: var(--ios-surface); border-bottom: 1px solid var(--ios-border); position: sticky; top: 0; z-index: 10; }
.ios-nav-title { font-size: 1.1rem; font-weight: 600; text-align: center; flex: 1; }

.btn-text { background: none; border: none; color: var(--ios-blue); font-size: 1.05rem; cursor: pointer; font-family: inherit; }
.btn-text.bold { font-weight: 600; }

.btn-icon { background: none; border: none; color: var(--ios-blue); display: flex; justify-content: center; align-items: center; cursor: pointer; padding: 6px; }
.btn-icon svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* --- Contenedor Principal --- */
.dashboard-content { padding: 16px 20px 100px; max-width: 600px; margin: 0 auto; width: 100%; }

/* --- GRUPOS ESTILO APPLE HEALTH --- */
.treatment-group { margin-bottom: 32px; }
.treatment-group.completed-group { opacity: 0.5; }

/* Encabezado del grupo (fuera de la tarjeta blanca) */
.ios-group-header { padding: 0 4px 8px 4px; display: flex; justify-content: space-between; align-items: flex-end; cursor: pointer; }
.ios-gh-text { flex: 1; }
.ios-gh-text h3 { font-size: 1.4rem; font-weight: 700; color: var(--ios-text); letter-spacing: -0.02em; margin-bottom: 4px; }
.ios-gh-text .doc { display: flex; align-items: center; gap: 6px; font-size: 0.9rem; color: var(--ios-text-muted); font-weight: 500; }
.ios-gh-text .doc svg { width: 16px; height: 16px; flex-shrink: 0; }
.ios-group-header .arrow { color: var(--ios-text-muted); font-size: 1.4rem; padding-bottom: 4px; }

/* Contenedor blanco continuo para los remedios */
.ios-list-container { background: var(--ios-surface); border-radius: 12px; overflow: hidden; }

/* Tarjeta individual del medicamento */
.ios-card { display: flex; align-items: center; padding: 14px 16px; gap: 14px; border-bottom: 1px solid var(--ios-border); background: var(--ios-surface); }
.ios-card:last-child { border-bottom: none; }

.ios-med-icon { width: 44px; height: 44px; border-radius: 22px; display: flex; justify-content: center; align-items: center; flex-shrink: 0; }
.ios-med-icon svg { width: 24px; height: 24px; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; fill: none; }

.ios-med-content { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.ios-med-content h4 { font-size: 1.1rem; font-weight: 600; color: var(--ios-text); margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ios-med-time { font-size: 0.9rem; color: var(--ios-text); font-weight: 500; margin-bottom: 4px; }

.ios-med-meta { font-size: 0.8rem; display: flex; align-items: center; gap: 6px; font-weight: 500; }
.ios-dot-sep { font-size: 0.8rem; color: var(--ios-text-muted); }

/* --- Botones de Acción (Píldoras y Checks) --- */
.ios-action-col { display: flex; align-items: center; justify-content: flex-end; min-width: 75px; }
.ios-btn-pill { padding: 6px 16px; border-radius: 16px; font-size: 0.9rem; font-weight: 700; border: none; cursor: pointer; transition: transform 0.1s; text-transform: uppercase; letter-spacing: 0.02em; }
.ios-btn-pill:active { transform: scale(0.95); }

.ios-btn-primary { background: var(--ios-blue-light); color: var(--ios-blue); }
.ios-btn-urgent { background: var(--ios-red-light); color: var(--ios-red); animation: pulse 2s infinite; }
.ios-btn-warning { background: var(--ios-orange-light); color: var(--ios-orange); }

.ios-check-circle { width: 34px; height: 34px; border-radius: 17px; background: var(--ios-green); color: white; display: flex; align-items: center; justify-content: center; margin-right: 6px; }
.ios-check-circle svg { width: 20px; height: 20px; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; fill: none; }

/* --- Formularios y Botones Globales --- */
.ios-section-title { font-size: 0.85rem; color: var(--ios-text-muted); text-transform: uppercase; margin: 0 0 8px 12px; font-weight: 600; letter-spacing: 0.05em; }

.ios-form-group { background: var(--ios-surface); border-radius: 12px; overflow: hidden; margin-bottom: 24px; }
.ios-form-group input, .ios-form-group select { width: 100%; padding: 14px 16px; border: none; border-bottom: 1px solid var(--ios-border); background: transparent; color: var(--ios-text); font-size: 1rem; appearance: none; }
.ios-form-group input:last-child, .ios-form-group select:last-child { border-bottom: none; }
.ios-form-group input:focus { outline: none; background: var(--ios-blue-light); }
.input-row-half { display: flex; }
.input-row-half input, .input-row-half select { flex: 1; border-right: 1px solid var(--ios-border); }
.input-row-half input:last-child { border-right: none; }
.border-top { border-top: 1px solid var(--ios-border); }

.ios-floating-btn { position: fixed; bottom: 32px; right: 24px; background: var(--ios-blue); color: white; border: none; border-radius: 28px; width: 56px; height: 56px; font-size: 2rem; font-weight: 300; cursor: pointer; box-shadow: 0 4px 12px rgba(0, 122, 255, 0.4); display: flex; align-items: center; justify-content: center; z-index: 10; }
.ios-btn-primary-large { width: 100%; padding: 16px; background: var(--ios-blue); color: white; font-size: 1.05rem; font-weight: 600; border: none; border-radius: 12px; cursor: pointer; }
.ios-btn-secondary { width: 100%; padding: 14px; background: transparent; color: var(--ios-blue); border: none; font-size: 1rem; font-weight: 500; cursor: pointer; }
.ios-btn-danger-large { width: 100%; padding: 16px; background: var(--ios-surface); color: var(--ios-red); font-size: 1.05rem; font-weight: 600; border: none; border-radius: 12px; cursor: pointer; margin-top: 12px; }

/* Auth */
#auth-view { justify-content: center; align-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 340px; text-align: center; }
.auth-icon { font-size: 4rem; margin-bottom: 16px; }

/* Detalle */
.detail-doctor-card { padding: 16px; border-bottom: none; }
.doc-icon { font-size: 2rem; margin-right: 8px; }
.doc-info .label { font-size: 0.75rem; color: var(--ios-text-muted); text-transform: uppercase; font-weight: 600; }
.doc-info h3 { font-size: 1.15rem; font-weight: 600; }
.detail-actions { display: flex; border-top: 1px solid var(--ios-border); width: 100%; }
.detail-actions button { flex: 1; padding: 12px; background: transparent; border: none; border-right: 1px solid var(--ios-border); font-size: 0.95rem; font-weight: 500; cursor: pointer; color: var(--ios-blue); }
.detail-actions button:last-child { border-right: none; color: var(--ios-red); }

@keyframes pulse { 0% { opacity: 1; } 50% { opacity: 0.6; } 100% { opacity: 1; } }