/* ===================================================
   UDD Medicina — Asistente para el levantamiento de información de nuevos proyectos
   Light glossy theme
   =================================================== */

@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&family=Ubuntu:wght@300;400;500;700&display=swap');

:root {
    --primary: #20263F;
    --accent: #009A7A;
    --accent-hover: #00805f;
    --bg: #F5F7FA;
    --surface: #FFFFFF;
    --surface-glass: rgba(255, 255, 255, 0.72);
    --text-primary: #20263F;
    --text-secondary: #5A6278;
    --text-accent: #009A7A;
    --border: rgba(32, 38, 63, 0.08);
    --border-strong: rgba(32, 38, 63, 0.12);
    --shadow-sm: 0 1px 3px rgba(32, 38, 63, 0.06);
    --shadow-md: 0 4px 16px rgba(32, 38, 63, 0.08);
    --shadow-lg: 0 8px 32px rgba(32, 38, 63, 0.10);
    --shadow-glow: 0 0 24px rgba(0, 154, 122, 0.12);
    --font-heading: 'Roboto', sans-serif;
    --font-body: 'Ubuntu', -apple-system, 'Roboto', Helvetica, Arial, sans-serif;
    --radius: 5px;
    --radius-lg: 10px;
    --radius-pill: 24px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background: var(--bg);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 14px;
    height: 100vh;
    display: flex;
    justify-content: center;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ── App Container ── */
.app-container {
    width: 100%;
    max-width: 640px;
    height: 100%;
    background: var(--surface);
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: var(--shadow-lg);
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
}

/* ── Top Branding Bar (always visible) ── */
.header-top-bar {
    background: var(--primary);
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    flex-shrink: 0;
}

.header-logo {
    height: 28px;
    filter: brightness(0) invert(1);
    transition: opacity 0.2s;
}

.header-logo:hover {
    opacity: 0.85;
}

.header-title {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 15px;
    color: #FFFFFF;
    letter-spacing: 0.02em;
}

/* ═══════════════════════════════════════════
   REGISTRATION FORM
   ═══════════════════════════════════════════ */

.registration-section {
    flex: 1;
    overflow-y: auto;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 24px 16px 40px;
    background:
        radial-gradient(ellipse at 50% 0%, rgba(0, 154, 122, 0.04) 0%, transparent 60%),
        var(--bg);
}

.registration-card {
    width: 100%;
    max-width: 480px;
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-strong);
    padding: 32px 28px;
    box-shadow:
        var(--shadow-md),
        inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.registration-heading {
    font-family: var(--font-heading);
    font-size: 22px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 6px;
}

.registration-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 28px;
    line-height: 1.5;
}

/* Form Layout */
.register-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.form-row {
    display: flex;
    gap: 14px;
}

.form-row .form-group {
    flex: 1;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    font-family: var(--font-heading);
}

.required {
    color: #e05252;
}

.form-group input,
.form-group select {
    padding: 10px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--border-strong);
    font-size: 14px;
    font-family: var(--font-body);
    color: var(--text-primary);
    background: var(--surface);
    transition: all 0.2s ease;
    outline: none;
    width: 100%;
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--accent);
    box-shadow: var(--shadow-glow);
}

.form-group input::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

.form-group select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%235A6278' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
    cursor: pointer;
}

.form-error {
    padding: 10px 14px;
    background: rgba(224, 82, 82, 0.06);
    border: 1px solid rgba(224, 82, 82, 0.2);
    border-radius: var(--radius);
    color: #c0392b;
    font-size: 13px;
    text-align: center;
}

/* Submit Button */
.register-submit-btn {
    margin-top: 8px;
    padding: 14px 28px;
    background: linear-gradient(135deg, var(--accent), #00b88d);
    color: #FFFFFF;
    border: none;
    border-radius: 0px;
    font-size: 15px;
    font-weight: 600;
    font-family: var(--font-heading);
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow:
        0 2px 12px rgba(0, 154, 122, 0.25),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
    letter-spacing: 0.02em;
}

.register-submit-btn:hover {
    background: linear-gradient(135deg, var(--accent-hover), var(--accent));
    transform: translateY(-1px);
    box-shadow:
        0 4px 18px rgba(0, 154, 122, 0.35),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.register-submit-btn:active {
    transform: translateY(0);
}

.register-submit-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

/* ═══════════════════════════════════════════
   CHAT SECTION
   ═══════════════════════════════════════════ */

.chat-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* ── Chat Header ── */
.chat-header {
    padding: 0;
    background: var(--surface-glass);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid var(--border-strong);
    z-index: 10;
    position: sticky;
    top: 0;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}

.header-content {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px 20px 14px;
}

.current-task {
    font-size: 13px;
    color: var(--text-secondary);
    background: var(--bg);
    padding: 6px 12px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border-strong);
    display: inline-flex;
    align-items: center;
    gap: 4px;
    width: fit-content;
}

.current-task .value {
    color: var(--text-primary);
    font-weight: 500;
    margin-left: 4px;
}

/* ── Record Detail ── */
.record-detail {
    margin-top: 4px;
    padding: 10px 14px;
    background: linear-gradient(135deg, rgba(0, 154, 122, 0.04), rgba(0, 154, 122, 0.02));
    border-radius: var(--radius);
    border: 1px solid rgba(0, 154, 122, 0.12);
    width: 100%;
    font-size: 15px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    transition: all 0.3s ease;
}

.record-detail.hidden {
    display: none;
}

.detail-label {
    color: var(--accent);
    font-weight: 700;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-family: var(--font-heading);
}

.detail-text {
    color: var(--text-secondary);
    line-height: 1.45;
    white-space: pre-wrap;
}

/* ── Chat Area ── */
.chat-area {
    flex: 1;
    padding: 20px 20px 100px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 18px;
    scroll-behavior: smooth;
    background:
        radial-gradient(ellipse at 50% 0%, rgba(0, 154, 122, 0.03) 0%, transparent 50%),
        var(--bg);
}

.message {
    display: flex;
    margin-bottom: 4px;
    opacity: 0;
    animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.message.user {
    justify-content: flex-end;
}

.message.ai {
    justify-content: flex-start;
}

.message.system {
    justify-content: center;
    margin-top: 16px;
    margin-bottom: 16px;
}

.bubble {
    padding: 14px 18px;
    border-radius: var(--radius-lg);
    font-size: 14px;
    line-height: 1.6;
    max-width: 82%;
    word-wrap: break-word;
    letter-spacing: 0.01em;
}

.message.user .bubble {
    background: linear-gradient(135deg, var(--accent), #00b88d);
    color: #FFFFFF;
    border-bottom-right-radius: 2px;
    font-weight: 500;
    box-shadow:
        0 2px 8px rgba(0, 154, 122, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.message.ai .bubble {
    background: var(--surface);
    color: var(--text-primary);
    border: 1px solid var(--border-strong);
    border-bottom-left-radius: 2px;
    box-shadow:
        var(--shadow-sm),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.message.system .bubble {
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    box-shadow: none;
    text-align: center;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-pill);
}

/* ── Input Area ── */
.input-area {
    padding: 16px 20px;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, var(--surface) 65%, transparent);
}

.suggestion-container {
    display: flex;
    justify-content: center;
    margin-bottom: 10px;
}

.suggestion-btn {
    background: rgba(0, 154, 122, 0.08);
    color: var(--accent);
    border: 1px solid rgba(0, 154, 122, 0.2);
    padding: 8px 16px;
    border-radius: var(--radius-pill);
    font-size: 13px;
    font-family: var(--font-body);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

.suggestion-btn:hover {
    background: rgba(0, 154, 122, 0.15);
    border-color: rgba(0, 154, 122, 0.3);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 154, 122, 0.15);
}

.suggestion-btn:active {
    transform: translateY(0);
}

.suggestion-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.input-container {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface);
    padding: 6px 6px 6px 18px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border-strong);
    box-shadow:
        var(--shadow-md),
        inset 0 1px 0 rgba(255, 255, 255, 0.9);
    transition: all 0.25s ease;
}

.input-container:focus-within {
    border-color: var(--accent);
    box-shadow:
        var(--shadow-glow),
        inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.input-container input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 14px;
    font-family: var(--font-body);
    outline: none;
}

.input-container input::placeholder {
    color: var(--text-secondary);
    opacity: 0.7;
}

/* ── Send Button ── */
#send-btn {
    background: linear-gradient(135deg, var(--accent), #00b88d);
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    color: #FFFFFF;
    box-shadow:
        0 2px 8px rgba(0, 154, 122, 0.25),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

#send-btn svg path {
    stroke: #FFFFFF;
}

#send-btn:hover {
    background: linear-gradient(135deg, var(--accent-hover), var(--accent));
    transform: scale(1.08);
    box-shadow:
        0 4px 14px rgba(0, 154, 122, 0.35),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

#send-btn:active {
    transform: scale(0.95);
}

#send-btn:disabled {
    background: var(--bg);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

#send-btn:disabled svg path {
    stroke: var(--text-secondary);
}

/* ── Animations ── */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
    width: 5px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* ── Modal ── */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(32, 38, 63, 0.4);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal.visible {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: var(--surface);
    width: 90%;
    max-width: 420px;
    max-height: 80vh;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-strong);
    box-shadow:
        0 20px 60px rgba(32, 38, 63, 0.18),
        inset 0 1px 0 rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(20px);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal.visible .modal-content {
    transform: translateY(0);
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(to bottom, rgba(0, 154, 122, 0.03), transparent);
}

.modal-header h3 {
    font-family: var(--font-heading);
    font-size: 16px;
    font-weight: 700;
    color: var(--primary);
}

#close-modal-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    transition: all 0.2s;
}

#close-modal-btn:hover {
    color: var(--text-primary);
    background: var(--bg);
    transform: none;
}

.record-list {
    overflow-y: auto;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.record-item {
    padding: 10px 14px;
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
    font-size: 14px;
    border: 1px solid transparent;
}

.record-item:hover {
    background: var(--bg);
    color: var(--text-primary);
    border-color: var(--border);
}

.record-item.active {
    background: rgba(0, 154, 122, 0.06);
    color: var(--accent);
    border-color: rgba(0, 154, 122, 0.2);
    font-weight: 500;
}

/* ── Record Name Button ── */
.value-btn {
    background: transparent;
    border: none;
    color: var(--accent);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    padding: 0 4px;
    margin: 0;
    width: auto;
    height: auto;
    border-radius: 2px;
    display: inline-block;
    text-align: left;
    text-decoration: underline;
    text-decoration-color: rgba(0, 154, 122, 0.35);
    text-underline-offset: 3px;
    font-family: var(--font-body);
    transition: all 0.2s;
}

.value-btn:hover {
    background: rgba(0, 154, 122, 0.06);
    transform: none;
    text-decoration-color: var(--accent);
}

/* ── Loading / Status ── */
.loading-records {
    text-align: center;
    color: var(--text-secondary);
    padding: 24px;
    font-size: 13px;
}

/* ── Typing Indicator ── */
.typing-bubble {
    display: flex;
    gap: 5px;
    padding: 12px 18px;
    align-items: center;
}

.typing-bubble .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    opacity: 0.4;
    animation: typingDot 1.4s ease-in-out infinite;
}

.typing-bubble .dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-bubble .dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingDot {

    0%,
    60%,
    100% {
        opacity: 0.3;
        transform: translateY(0);
    }

    30% {
        opacity: 1;
        transform: translateY(-4px);
    }
}

/* ── New Project Button ── */
.new-project-btn {
    background: none;
    border: 1px solid rgba(0, 154, 122, 0.2);
    color: var(--accent);
    font-size: 12px;
    padding: 5px 12px;
    border-radius: var(--radius);
    cursor: pointer;
    font-family: var(--font-body);
    transition: all 0.2s;
    margin-top: 6px;
    align-self: flex-start;
}

.new-project-btn:hover {
    background: rgba(0, 154, 122, 0.08);
    border-color: var(--accent);
}

/* ── Record Status Icons ── */
.record-status-icon {
    font-size: 14px;
    margin-right: 4px;
}

/* ── Mobile Responsive ── */
@media (max-width: 600px) {
    .header-top-bar {
        padding: 10px 12px;
        gap: 8px;
    }

    .header-title {
        font-size: 13px;
    }

    .header-logo {
        height: 24px;
    }

    .chat-header {
        padding: 10px 12px;
    }

    .chat-area {
        padding: 12px 12px 90px;
    }

    .bubble {
        max-width: 92%;
        font-size: 14px;
    }

    .input-container {
        margin: 0 8px 8px;
    }

    .input-container input {
        font-size: 15px;
        padding: 12px 14px;
    }

    .registration-card {
        margin: 12px;
        padding: 24px 18px;
    }

    .form-row {
        flex-direction: column;
    }

    .record-detail {
        font-size: 14px;
    }
}