﻿/* =========================================
   DNC PORTAL PACIENTE - STYLESHEET
   Mobile First, Dark Mode Premium, Design System
========================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Outfit:wght@500;600;700;800&display=swap');

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--surface-base);
    color: var(--text-primary);
    font-family: var(--font-sans);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    padding-bottom: 80px; /* Space for bottom nav */
}

/* --- TIPO Y ENCABEZADOS GLOBALES --- */
h1, h2, h3, h4, h5, h6 { font-family: var(--font-heading); line-height: 1.2; letter-spacing: -0.02em; }
h2 { font-size: var(--text-2xl); margin-bottom: var(--spacing-2); font-weight: 700; }
p.subtitle { color: var(--text-muted); font-size: var(--text-sm); margin-bottom: var(--spacing-6); }




/* --- BARRA DE PROGRESO --- */
.progress-container {
    position: sticky;
    top: 0;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    padding: 1rem var(--app-padding);
    z-index: 50;
    border-bottom: 1px solid var(--color-border);
}
.progress-bar-wrapper {
    display: flex;
    gap: 4px;
    height: 6px;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}
.progress-segment {
    flex: 1;
    background-color: rgba(255, 255, 255, 0.1);
    transition: background-color 0.3s ease;
}
.progress-segment.active {
    background-color: var(--color-primary);
}
.progress-text {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* --- WIZARD STEPS --- */
.wizard-container {
    flex: 1;
    padding: var(--app-padding);
    padding-bottom: 6rem; /* Espacio para botones inferiores */
}

.wizard-step {
    display: none;
    animation: fadeIn 0.4s ease forwards;
}
.wizard-step.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- INPUTS Y FORMULARIOS --- */
.form-group {
    margin-bottom: 1.25rem;
}

label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--color-text-muted);
}

input[type="text"],
input[type="number"],
input[type="time"],
input[type="date"],
select,
textarea {
    width: 100%;
    background: var(--color-bg-input);
    border: 1px solid var(--color-border);
    color: var(--color-text-main);
    padding: 0.875rem 1rem;
    border-radius: var(--border-radius-sm);
    font-size: 1rem;
    transition: all 0.2s ease;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

/* --- CHECKBOX & RADIO GLASSMORPHISM --- */
.radio-group, .checkbox-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.radio-card {
    position: relative;
    cursor: pointer;
}
.radio-card input {
    position: absolute;
    opacity: 0;
}
.radio-card .card-content {
    background: var(--color-bg-input);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-sm);
    padding: 1rem;
    text-align: center;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
}
.radio-card input:checked ~ .card-content {
    background: rgba(16, 185, 129, 0.1);
    border-color: var(--color-primary);
    color: var(--color-primary);
}

/* --- TOGGLE SWITCH --- */
.toggle-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--color-bg-card);
    padding: 1rem;
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--color-border);
}
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 28px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: var(--color-bg-input);
    transition: .4s;
    border-radius: 34px;
    border: 1px solid var(--color-border);
}
.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 3px;
    background-color: var(--color-text-muted);
    transition: .4s;
    border-radius: 50%;
}
input:checked + .slider {
    background-color: var(--color-primary);
    border-color: var(--color-primary);
}
input:checked + .slider:before {
    transform: translateX(22px);
    background-color: #fff;
}

/* --- FOTOGRAFÃAS --- */
.photo-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}
.photo-upload-box {
    position: relative;
    background: var(--color-bg-input);
    border: 1px dashed var(--color-border);
    border-radius: var(--border-radius-sm);
    height: 180px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    overflow: hidden;
    transition: border-color 0.2s ease;
}
.photo-upload-box:hover {
    border-color: var(--color-primary);
}
.photo-upload-box input[type="file"] {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}
.photo-placeholder {
    text-align: center;
    color: var(--color-text-muted);
}
.photo-placeholder i {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}
.photo-preview {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    object-fit: cover;
    display: none;
    z-index: 10;
}

/* --- BOTONES DE NAVEGACIÃ“N INFERIOR --- */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-top: 1px solid var(--color-border);
    padding: 1rem var(--app-padding);
    display: flex;
    gap: 1rem;
    z-index: 50;
}

.btn {
    flex: 1;
    padding: 0.875rem 1.5rem;
    border-radius: var(--border-radius-sm);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    text-align: center;
    border: none;
    transition: all 0.2s ease;
}

.btn-primary {
    background-color: var(--color-primary);
    color: #fff;
}
.btn-primary:active {
    background-color: var(--color-primary-hover);
}

.btn-secondary {
    background-color: transparent;
    border: 1px solid var(--color-border);
    color: var(--color-text-main);
}
.btn-secondary:active {
    background-color: rgba(255, 255, 255, 0.05);
}

/* Condicionales Ocultos */
.hidden {
    display: none !important;
}

/* Success Screen */
.success-screen {
    text-align: center;
    padding-top: 4rem;
}
.success-icon {
    font-size: 4rem;
    color: var(--color-primary);
    margin-bottom: 1.5rem;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--color-primary);
    color: white;
    padding: 12px 24px;
    border-radius: 50px;
    font-size: 0.875rem;
    font-weight: 500;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
    white-space: nowrap;
}
.toast.show {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* --- UX FASE 1: SEGUIMIENTO MENSUAL --- */
.step-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    color: var(--color-text-muted);
}
.step-meta-left {
    font-weight: 500;
    color: var(--color-primary);
}
.clinical-card {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    margin-bottom: 2rem;
}
.form-control, .draft-input {
    min-height: 48px;
    padding: 12px 16px;
    font-size: 16px;
    border-radius: var(--border-radius-sm);
}
input[type='range'].range-slider {
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    outline: none;
    -webkit-appearance: none;
}
input[type='range'].range-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--color-primary);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(239, 68, 68, 0.4);
}
.form-group {
    margin-bottom: 1.5rem;
}

/* UX POLISH */
.clinical-card .photo-upload-box {
    border: 1px dashed rgba(255, 255, 255, 0.1);
    background: transparent;
    margin-bottom: 1rem;
}
.range-value {
    margin-top: 8px;
    font-size: 0.9rem;
    color: var(--color-text-muted);
    text-align: right;
}
textarea.form-control {
    min-height: 80px;
    resize: vertical;
}

/* --- UX FASE 2: PROGRESS CENTER --- */
.section-heading {
    font-size: 1rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 1rem;
}

/* Logro Reciente (Hero) */
.hero-logro {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(15, 23, 42, 0.8));
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: 16px;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
}
.logro-icon {
    font-size: 2.5rem;
}
.logro-title {
    font-size: 0.9rem;
    color: var(--color-text-muted);
    margin: 0 0 0.25rem 0;
    font-weight: 500;
}
.logro-text {
    font-size: 1.25rem;
    font-weight: 700;
    color: #10b981; /* Verde Ã©xito */
    margin: 0;
}

/* TransformaciÃ³n Visual (Before/After) */
.before-after-card {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: 16px;
    padding: 1rem;
    margin-bottom: 2rem;
}
.transform-col {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.transform-label {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    text-align: center;
    text-transform: uppercase;
    font-weight: 600;
}
.img-wrapper {
    aspect-ratio: 3/4;
    border-radius: 8px;
    overflow: hidden;
    background: rgba(0,0,0,0.2);
}
.transform-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Progreso Grid */
.progreso-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 2rem;
}
.progreso-card {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: 16px;
    padding: 1.5rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.progreso-icon {
    font-size: 2rem;
    margin-bottom: 0.25rem;
}
.progreso-label {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    font-weight: 600;
}
.progreso-diff {
    font-size: 1.75rem;
    font-weight: 800;
}
.progreso-diff.success { color: #10b981; }
.progreso-diff.neutral { color: var(--color-text-main); }
.progreso-diff.danger { color: var(--color-error); }
.progreso-current {
    font-size: 0.85rem;
    color: var(--color-text-main);
    opacity: 0.8;
}

/* Biofeedback */
.biofeedback-list {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: 16px;
    padding: 0.5rem 1.5rem;
    margin-bottom: 2rem;
}
.bio-item {
    display: flex;
    align-items: center;
    padding: 1rem 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.bio-item:last-child {
    border-bottom: none;
}
.bio-icon {
    font-size: 1.5rem;
    margin-right: 1rem;
}
.bio-label {
    flex: 1;
    font-weight: 500;
    color: var(--color-text-main);
}
.bio-val {
    font-weight: 700;
    color: var(--color-primary); /* Rojo DNC aquÃ­ estÃ¡ bien porque es un valor/score */
}

/* --- LOGROS TANGIBLES GRID --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: var(--spacing-3);
}

@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--spacing-2);
    }
    .card-stat {
        padding: var(--spacing-3) var(--spacing-2) !important;
        gap: var(--spacing-1) !important;
        border-radius: var(--radius-lg);
    }
    .card-stat .icon-container {
        font-size: 22px !important;
        margin-bottom: 0 !important;
    }
    .card-stat-label {
        font-size: 0.65rem !important;
        line-height: 1.1;
    }
    .progreso-diff {
        font-size: 1.25rem !important;
        margin-top: 4px;
    }
    .card-stat .text-xs {
        font-size: 0.65rem !important;
        line-height: 1.2;
    }
}

/* =========================================
   DRACO AI CHAT WINDOW (PATIENT)
========================================= */
#dracoChatWindow {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100vw;
    height: 65vh;
    background: #0A0A0C;
    border-top-left-radius: 28px;
    border-top-right-radius: 28px;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.7);
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    z-index: 100000;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform-origin: bottom center;
    padding-bottom: env(safe-area-inset-bottom);
}

.draco-chat-hidden {
    opacity: 0;
    transform: translateY(100%);
    pointer-events: none;
}

.draco-chat-visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.draco-overlay-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.draco-overlay-visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.draco-chat-header {
    background: transparent;
    padding: 20px;
    display: flex;
    align-items: center;
    border-bottom: none;
    position: relative;
}

.draco-chat-avatar {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    object-fit: cover;
    margin-right: 15px;
    border: 2px solid #FF1744;
}

.draco-chat-title-box {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.draco-chat-title {
    font-weight: 800;
    font-size: 1.4rem;
    color: #fff;
    line-height: 1;
}

.draco-chat-subtitle {
    font-size: 0.8rem;
    color: #9ca3af;
}

.draco-chat-close {
    background: none;
    border: none;
    color: #6b7280;
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    position: absolute;
    top: 20px;
    right: 20px;
}

.draco-chat-close:hover {
    color: #fff;
}

.draco-chat-body {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: transparent;
}

.draco-msg-draco, .draco-msg-user {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.draco-msg-user {
    align-items: flex-end;
}

.draco-msg-draco {
    align-items: flex-start;
}

.draco-msg-time {
    font-size: 0.65rem;
    color: #6b7280;
    margin-top: 4px;
}

.draco-msg-draco .draco-msg-time {
    margin-left: 4px;
}

.draco-msg-user .draco-msg-time {
    margin-right: 4px;
}

.draco-msg-bubble {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    line-height: 1.4;
}

.draco-msg-draco .draco-msg-bubble {
    background: #1C1C1E;
    color: #e5e7eb;
    border: none;
    border-bottom-left-radius: 4px;
}

.draco-msg-user .draco-msg-bubble {
    background: #FF1744;
    color: #fff;
    border-bottom-right-radius: 4px;
}

#dracoChatInput:focus {
    box-shadow: none !important;
    border: none !important;
    outline: none !important;
}

.draco-chat-footer {
    padding: 15px 20px 25px 20px;
    background: transparent;
    border-top: none;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    z-index: 10001;
}

/* Typing Indicator */
.draco-dot {
    width: 6px;
    height: 6px;
    background-color: #aaa;
    border-radius: 50%;
    animation: dracoTyping 1.4s infinite ease-in-out both;
}

.draco-dot:nth-child(1) { animation-delay: -0.32s; }
.draco-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes dracoTyping {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Tooltip Draco */
.draco-fab-tooltip {
    background: #FF1744;
    color: #fff;
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(255, 23, 68, 0.3);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    white-space: normal;
    word-break: break-word;
    max-width: calc(100vw - 110px);
    line-height: 1.3;
    text-align: right;
}

.draco-fab-tooltip::after {
    content: '';
    position: absolute;
    top: 50%;
    right: -6px;
    transform: translateY(-50%);
    border-width: 6px 0 6px 6px;
    border-style: solid;
    border-color: transparent transparent transparent #FF1744;
}

.draco-tooltip-hidden {
    opacity: 0;
    transform: translateX(20px);
    pointer-events: none;
}

.draco-tooltip-visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* =========================================
   MOBILE FIXES FOR NAV & DRACO
========================================= */
@media (max-width: 768px) {
    /* Prevent nav buttons text from truncating */
    .bottom-nav {
        padding: 0.8rem 0.5rem;
        gap: 0.5rem;
    }
    .bottom-nav .btn {
        padding: 0.5rem 0.2rem;
        font-size: 0.8rem;
    }

    /* Push Draco higher up on mobile to avoid nav collision - REMOVED for full screen mode */
}
/* Ensure SweetAlert modals sit on top of Draco Chat */
.swal2-container { z-index: 999999 !important; }
