/* ================================================================
   Agenda Salud — Portal del Paciente v3.1.1
   Diseño: Split layout con panel decorativo + formulario limpio
   ================================================================ */

/* ── Reset y base ────────────────────────────────────────────── */
:root {
    --portal-blue:      #2563eb;
    --portal-blue-dark: #1d4ed8;
    --portal-blue-pale: #eff6ff;
    --portal-teal:      #0891b2;
    --portal-text:      #1e293b;
    --portal-muted:     #64748b;
    --portal-border:    #e2e8f0;
    --portal-bg:        #f8fafc;
    --portal-white:     #ffffff;
    --portal-success:   #059669;
    --portal-error:     #dc2626;
    --portal-radius:    14px;
    --portal-shadow:    0 20px 60px rgba(37,99,235,.12);
}

#app-patient-portal *,
#app-patient-portal *::before,
#app-patient-portal *::after { box-sizing: border-box; }

#app-patient-portal {
    font-family: 'Roboto', sans-serif;
    color: var(--portal-text);
    min-height: 100%;
    width: 100%;
    /* Sin max-width aquí — el theme ya limita el ancho del contenido */
}

#app-patient-portal h1,
#app-patient-portal h2,
#app-patient-portal h3,
#app-patient-portal h4 {
    font-family: 'Lora', serif;
}

/* ══════════════════════════════════════════════════════════════
   VISTAS DE AUTENTICACIÓN (login, register, forgot, reset)
   Layout: panel izquierdo decorativo + panel derecho formulario
══════════════════════════════════════════════════════════════ */
.app-view {
    display: block;
}

/* Wrapper externo de todas las vistas de auth */
#app-view-rut,
#app-view-login,
#app-view-register,
#app-view-forgot,
#app-view-reset {
    min-height: 500px;
    display: flex;
    align-items: stretch;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: var(--portal-shadow);
    margin: 24px 0;
    width: 100%;
    max-width: 100%;
    background: var(--portal-white);
    border: 1px solid var(--portal-border);
}

/* Panel izquierdo: usa .app-auth-panel-left div — no pseudo-elements en el wrapper */

/* Contenido sobre el panel izquierdo — usamos un elemento interno */
.app-auth-panel-left {
    width: 40%;
    max-width: 340px;
    flex-shrink: 0;
    background:
        radial-gradient(ellipse at 20% 20%, rgba(255,255,255,.18) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 80%, rgba(8,145,178,.25) 0%, transparent 60%),
        linear-gradient(145deg, #1d4ed8 0%, #2563eb 45%, #0891b2 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    padding: 44px 36px;
    position: relative;
    overflow: hidden;
    color: #fff;
}

/* Círculos decorativos en el panel */
.app-auth-panel-left::before {
    content: '';
    position: absolute;
    width: 260px;
    height: 260px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,.12);
    top: -60px;
    right: -80px;
}

.app-auth-panel-left::after {
    content: '';
    position: absolute;
    width: 160px;
    height: 160px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,.1);
    bottom: 40px;
    right: 30px;
}

.app-panel-logo {
    font-size: 44px;
    margin-bottom: 24px;
    line-height: 1;
    position: relative;
    z-index: 1;
}

.app-panel-title {
    font-family: 'Lora', serif;
    font-size: 24px;
    font-weight: 700;
    color: #fff;
    margin: 0 0 12px;
    line-height: 1.3;
    position: relative;
    z-index: 1;
}

.app-panel-subtitle {
    font-size: 14px;
    color: rgba(255,255,255,.75);
    line-height: 1.6;
    margin: 0 0 32px;
    position: relative;
    z-index: 1;
}

.app-panel-features {
    list-style: none;
    padding: 0;
    margin: 0;
    position: relative;
    z-index: 1;
}

.app-panel-features li {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: rgba(255,255,255,.85);
    margin-bottom: 12px;
    font-weight: 500;
}

.app-panel-features li span.icon {
    width: 28px;
    height: 28px;
    background: rgba(255,255,255,.15);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

/* ── Panel derecho: formulario ────────────────────────────── */
.app-auth-panel-right {
    flex: 1;
    min-width: 0;          /* crucial: permite que flex child se encoja */
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 44px 40px;
    background: var(--portal-white);
    overflow-y: auto;
    max-height: 90vh;
}

.app-auth-heading {
    font-family: 'Lora', serif;
    font-size: 26px;
    font-weight: 700;
    color: var(--portal-text);
    margin: 0 0 6px;
}

.app-auth-subheading {
    font-size: 14px;
    color: var(--portal-muted);
    margin: 0 0 32px;
    line-height: 1.5;
}

/* ── Inputs ───────────────────────────────────────────────── */
.app-form-group {
    margin-bottom: 20px;
}

.app-form-group label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: var(--portal-muted);
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-bottom: 8px;
}

.app-input {
    width: 100%;
    padding: 13px 16px;
    border: 1.5px solid var(--portal-border);
    border-radius: 10px;
    font-size: 15px;
    font-family: 'Roboto', sans-serif;
    background: var(--portal-bg);
    color: var(--portal-text);
    transition: border-color .2s, box-shadow .2s, background .2s;
    box-sizing: border-box;
    appearance: none;
    -webkit-appearance: none;
}

.app-input:focus {
    outline: none;
    border-color: var(--portal-blue);
    background: var(--portal-white);
    box-shadow: 0 0 0 4px rgba(37,99,235,.1);
}

.app-input::placeholder { color: #b0bac7; }

/* ── Botón principal ──────────────────────────────────────── */
.app-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 13px 24px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 700;
    font-family: 'Roboto', sans-serif;
    border: none;
    cursor: pointer;
    transition: all .2s;
    text-decoration: none;
    letter-spacing: .2px;
}

.app-btn-primary {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #fff;
    width: 100%;
    padding: 14px;
    box-shadow: 0 4px 14px rgba(37,99,235,.35);
}

.app-btn-primary:hover {
    background: linear-gradient(135deg, #1d4ed8, #1e40af);
    box-shadow: 0 6px 20px rgba(37,99,235,.45);
    transform: translateY(-1px);
}

.app-btn-primary:active { transform: translateY(0); box-shadow: none; }
.app-btn-primary:disabled { opacity: .6; cursor: not-allowed; transform: none; box-shadow: none; }

.app-btn-secondary {
    background: var(--portal-bg);
    color: var(--portal-muted);
    border: 1.5px solid var(--portal-border);
}

.app-btn-secondary:hover {
    background: var(--portal-border);
    color: var(--portal-text);
}

/* ── Links de auth ────────────────────────────────────────── */
.app-auth-links {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 20px;
    font-size: 13px;
    flex-wrap: wrap;
    color: var(--portal-muted);
}

.app-auth-links a {
    color: var(--portal-blue);
    text-decoration: none;
    font-weight: 600;
}

.app-auth-links a:hover { text-decoration: underline; }
.app-auth-links span    { color: #cbd5e1; }

/* ── Divider con RUT mostrado ─────────────────────────────── */
.app-rut-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--portal-blue-pale);
    color: var(--portal-blue);
    font-weight: 700;
    font-size: 14px;
    padding: 8px 16px;
    border-radius: 30px;
    border: 1px solid #bfdbfe;
    margin-bottom: 24px;
}

.app-rut-chip .icon { font-size: 16px; }

/* ── Password toggle ─────────────────────────────────────── */
.app-pass-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.app-pass-wrap .app-input { padding-right: 46px; }

.app-eye-btn {
    position: absolute;
    right: 13px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 17px;
    color: #94a3b8;
    padding: 0;
    line-height: 1;
    transition: color .15s;
}

.app-eye-btn:hover { color: var(--portal-blue); }

/* ── Mensajes ─────────────────────────────────────────────── */
.app-error-box {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #b91c1c;
    border-radius: 10px;
    padding: 12px 16px;
    font-size: 13px;
    margin-bottom: 18px;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.app-error-box::before { content: '⚠️'; flex-shrink: 0; }

.app-ok-box {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
    border-radius: 10px;
    padding: 12px 16px;
    font-size: 13px;
    margin-bottom: 18px;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.app-ok-box::before { content: '✅'; flex-shrink: 0; }

/* ── T&C ──────────────────────────────────────────────────── */
.app-tc-wrap { margin-bottom: 20px; }

.app-tc-label {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    font-size: 13px;
    color: #374151;
    cursor: pointer;
    line-height: 1.5;
    background: #fffbeb;
    border: 1px solid #fde68a;
    padding: 12px 14px;
    border-radius: 10px;
}

.app-tc-label input[type="checkbox"] {
    margin-top: 2px;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    accent-color: var(--portal-blue);
}

.app-tc-label a { color: var(--portal-blue); text-decoration: underline; }

.app-tc-box {
    background: var(--portal-bg);
    border: 1px solid var(--portal-border);
    border-radius: 8px;
    padding: 16px;
    font-size: 12px;
    color: var(--portal-muted);
    line-height: 1.6;
    margin-top: 10px;
}

.app-tc-box p { margin: 0 0 8px; }
.app-tc-box p:last-child { margin-bottom: 0; }

.app-rut-display { font-weight: 700; color: var(--portal-blue); }

/* Compatibilidad: card-center ya no se usa en auth principal */
.app-card-center { display: contents; }
.app-card-logo   { display: none; }

/* ══════════════════════════════════════════════════════════════
   DASHBOARD
══════════════════════════════════════════════════════════════ */
.app-dashboard {
    background: var(--portal-white);
    border-radius: 20px;
    border: 1px solid var(--portal-border);
    box-shadow: 0 4px 24px rgba(0,0,0,.06);
    overflow: hidden;
    margin: 24px 0;
    width: 100%;
}

.app-dash-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 28px 32px;
    background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 50%, #0891b2 100%);
    color: #fff;
}

.app-dash-greeting h2 {
    margin: 0 0 4px;
    font-size: 22px;
    color: #fff;
    font-family: 'Lora', serif;
}

.app-muted { color: rgba(255,255,255,.7); font-size: 13px; margin: 0; }

#app-logout-btn {
    background: rgba(255,255,255,.15);
    color: #fff;
    border: 1px solid rgba(255,255,255,.25);
    backdrop-filter: blur(4px);
}

#app-logout-btn:hover {
    background: rgba(255,255,255,.25);
    color: #fff;
}

/* ── Tabs ───────────────────────────────────────────────────── */
.app-tabs {
    display: flex;
    border-bottom: 1px solid var(--portal-border);
    padding: 0 24px;
    gap: 0;
    background: var(--portal-white);
    overflow-x: auto;
    scrollbar-width: none;
}

.app-tabs::-webkit-scrollbar { display: none; }

.app-tab {
    padding: 16px 20px;
    border: none;
    background: none;
    font-size: 13px;
    font-weight: 600;
    font-family: 'Roboto', sans-serif;
    color: var(--portal-muted);
    cursor: pointer;
    border-bottom: 3px solid transparent;
    margin-bottom: -1px;
    white-space: nowrap;
    transition: all .2s;
    position: relative;
}

.app-tab:hover { color: var(--portal-blue); }

.app-tab.active {
    color: var(--portal-blue);
    border-bottom-color: var(--portal-blue);
}

.app-tab-content { display: none; padding: 28px 32px; }
.app-tab-content.active { display: block; }

/* ── Cards de cita ──────────────────────────────────────────── */
.app-appt-card {
    border: 1px solid var(--portal-border);
    border-radius: 14px;
    padding: 20px;
    margin-bottom: 14px;
    display: grid;
    grid-template-columns: 72px 1fr auto;
    gap: 18px;
    align-items: start;
    background: var(--portal-white);
    transition: box-shadow .2s, transform .15s;
}

.app-appt-card:hover {
    box-shadow: 0 6px 20px rgba(37,99,235,.09);
    transform: translateY(-1px);
}

.app-appt-card.is-upcoming  { border-left: 4px solid var(--portal-blue); }
.app-appt-card.is-completed { border-left: 4px solid var(--portal-success); opacity: .88; }
.app-appt-card.is-cancelled { border-left: 4px solid var(--portal-error);  opacity: .7; }

.app-appt-date-block {
    text-align: center;
    background: var(--portal-blue-pale);
    border-radius: 12px;
    padding: 12px 8px;
    min-width: 64px;
}

.app-appt-date-day {
    font-family: 'Lora', serif;
    font-size: 30px;
    font-weight: 700;
    color: var(--portal-blue);
    line-height: 1;
}

.app-appt-date-month {
    font-size: 11px;
    font-weight: 700;
    color: var(--portal-muted);
    text-transform: uppercase;
    margin-top: 3px;
    letter-spacing: .5px;
}

.app-appt-info h4 { margin: 0 0 6px; font-size: 15px; color: var(--portal-text); }

.app-appt-meta {
    font-size: 12px;
    color: var(--portal-muted);
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 4px;
}

.app-appt-meta span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--portal-bg);
    padding: 3px 8px;
    border-radius: 20px;
    border: 1px solid var(--portal-border);
}

/* ── Badges ─────────────────────────────────────────────────── */
.app-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .4px;
    white-space: nowrap;
}

.app-badge-agendada   { background: #dbeafe; color: #1d4ed8; }
.app-badge-confirmada { background: #d1fae5; color: #065f46; }
.app-badge-completada { background: #f3f4f6; color: #374151; }
.app-badge-cancelada  { background: #fee2e2; color: #991b1b; }
.app-badge-pendiente  { background: #fef3c7; color: #92400e; }

/* ── Ficha clínica ──────────────────────────────────────────── */
.app-ficha-card {
    background: linear-gradient(135deg, #f0fdf4, #ecfdf5);
    border: 1px solid #bbf7d0;
    border-radius: 14px;
    padding: 24px;
    margin-bottom: 20px;
}

.app-ficha-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 8px;
}

.app-ficha-header h4 { margin: 0; font-size: 15px; color: #065f46; }
.app-ficha-date { font-size: 12px; color: #6b7280; }

.app-ficha-notes {
    font-size: 14px;
    color: var(--portal-text);
    line-height: 1.75;
    background: var(--portal-white);
    border-radius: 8px;
    padding: 18px;
    border: 1px solid #d1fae5;
    white-space: pre-wrap;
}

/* ── Mi cuenta ──────────────────────────────────────────────── */
#app-tab-cuenta .app-section-title {
    font-size: 16px;
    font-family: 'Lora', serif;
    color: var(--portal-text);
    text-transform: none;
    letter-spacing: 0;
    font-weight: 700;
    margin-bottom: 20px;
}

/* ── Estados vacíos ─────────────────────────────────────────── */
.app-loading {
    text-align: center;
    color: var(--portal-muted);
    font-size: 14px;
    padding: 48px;
}

.app-empty-state {
    text-align: center;
    padding: 56px 24px;
    color: var(--portal-muted);
}

.app-empty-state .app-empty-icon {
    font-size: 52px;
    display: block;
    margin-bottom: 16px;
}

.app-empty-state p { font-size: 14px; margin: 0; line-height: 1.6; }

.app-section-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--portal-muted);
    text-transform: uppercase;
    letter-spacing: .6px;
    margin: 0 0 18px;
}

/* ── Botones de acción en citas ─────────────────────────────── */
.app-action-btn {
    padding: 7px 16px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all .15s;
    font-family: 'Roboto', sans-serif;
    border: none;
}

.app-confirm-btn { background: #059669; color: #fff; }
.app-confirm-btn:hover { background: #047857; }
.app-cancel-btn  { background: #fff; color: #dc2626; border: 2px solid #dc2626; }
.app-cancel-btn:hover  { background: #fef2f2; }
.app-action-btn:disabled { opacity: .5; cursor: not-allowed; }

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════════════════════════ */
/* En pantallas medianas: ocultar panel izquierdo para dar espacio al form */
@media (max-width: 640px) {
    #app-view-rut,
    #app-view-login,
    #app-view-register,
    #app-view-forgot,
    #app-view-reset {
        flex-direction: column;
        margin: 0;
        border-radius: 16px;
    }

    .app-auth-panel-left {
        width: 100%;
        max-width: 100%;
        padding: 28px 24px 24px;
        min-height: auto;
        flex-direction: row;
        align-items: center;
        gap: 14px;
    }

    .app-auth-panel-left::before,
    .app-auth-panel-left::after { display: none; }

    .app-panel-logo   { font-size: 32px; margin-bottom: 0; flex-shrink: 0; }
    .app-panel-title  { font-size: 17px; margin-bottom: 2px; }
    .app-panel-subtitle,
    .app-panel-features { display: none; }

    .app-auth-panel-right {
        padding: 28px 24px 32px;
        max-height: none;
    }

    .app-dash-header { flex-direction: column; gap: 16px; text-align: center; }
    .app-appt-card   { grid-template-columns: 1fr; }
    .app-appt-date-block { display: none; }
    .app-tabs  { padding: 0 16px; }
    .app-tab-content { padding: 20px 16px; }
    .app-dashboard { margin: 12px; border-radius: 16px; }
}
