/* =========================================================
   BASE
========================================================= */

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family:
        Inter,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
    background: #f5f6f8;
    color: #1f2937;
}

.hidden {
    display: none !important;
}


/* =========================================================
   LAYOUT
========================================================= */

.layout {
    min-height: 100vh;
    display: flex;
}


/* =========================================================
   SIDEBAR
========================================================= */

.sidebar {
    width: 270px;
    flex: 0 0 270px;
    background: #111827;
    color: white;
    padding: 24px 16px;
    overflow-y: auto;
}

.sidebar-brand {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: 0.15em;
    margin: 4px 8px 24px;
}


/* =========================================================
   BOTÓN NUEVA CONVERSACIÓN
========================================================= */

.new-chat {
    width: 100%;
    border: 1px solid #374151;
    background: #1f2937;
    color: white;
    border-radius: 10px;
    padding: 12px;
    cursor: pointer;
    text-align: left;
    font-weight: 600;
    transition:
        background 0.2s ease,
        border-color 0.2s ease;
}

.new-chat:hover {
    background: #374151;
}


/* =========================================================
   BOTÓN MI APRENDIZAJE
========================================================= */

.learning-profile-button {
    width: 100%;
    margin-top: 10px;
    border: 1px solid #374151;
    background: transparent;
    color: #e5e7eb;
    border-radius: 10px;
    padding: 12px;
    cursor: pointer;
    text-align: left;
    font-weight: 600;
    transition:
        background 0.2s ease,
        border-color 0.2s ease,
        color 0.2s ease;
}

.learning-profile-button:hover {
    background: #1f2937;
    border-color: #4b5563;
    color: white;
}


/* =========================================================
   HISTORIAL
========================================================= */

.history-title {
    margin: 28px 8px 10px;
    color: #9ca3af;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.session-item {
    padding: 10px 12px;
    margin-bottom: 4px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.session-item:hover {
    background: #1f2937;
}

.session-item.active {
    background: #374151;
}


/* =========================================================
   APP
========================================================= */

.app {
    flex: 1;
    width: auto;
    min-width: 0;
    min-height: 100vh;
    margin: 0;
    background: white;
    display: flex;
    flex-direction: column;
}


/* =========================================================
   HEADER
========================================================= */

.header {
    padding: 28px 32px 20px;
    border-bottom: 1px solid #e5e7eb;
}

.header h1 {
    margin: 6px 0 2px;
    font-size: 26px;
}

.header p {
    margin: 0;
    color: #6b7280;
}


/* =========================================================
   MODOS
========================================================= */

.modes {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    padding: 16px 24px;
    border-bottom: 1px solid #e5e7eb;
}

.mode {
    border: 1px solid #d1d5db;
    background: white;
    border-radius: 12px;
    padding: 12px 8px;
    cursor: pointer;
    font-size: 14px;
    transition:
        background 0.2s ease,
        border-color 0.2s ease,
        color 0.2s ease;
}

.mode span {
    margin-right: 4px;
}

.mode:hover {
    border-color: #9ca3af;
}

.mode.active {
    border-color: #111827;
    background: #111827;
    color: white;
}


/* =========================================================
   CONVERSACIÓN
========================================================= */

.conversation {
    flex: 1;
    padding: 28px;
    overflow-y: auto;
}

.message {
    display: flex;
    margin-bottom: 24px;
}

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

.avatar {
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    border-radius: 50%;
    background: #111827;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    margin-right: 12px;
}

.bubble {
    max-width: 75%;
    background: #f3f4f6;
    border-radius: 16px;
    padding: 14px 16px;
    line-height: 1.55;
}

.message.user .bubble {
    background: #111827;
    color: white;
}

.bubble p {
    margin: 6px 0 0;
    white-space: pre-wrap;
}

.sources {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid #d1d5db;
    font-size: 12px;
    color: #6b7280;
}


/* =========================================================
   COMPOSITOR
========================================================= */

.composer {
    display: flex;
    gap: 12px;
    padding: 20px 24px;
    border-top: 1px solid #e5e7eb;
    background: white;
}

.composer textarea {
    flex: 1;
    resize: none;
    border: 1px solid #d1d5db;
    border-radius: 14px;
    padding: 13px 15px;
    font: inherit;
    outline: none;
}

.composer textarea:focus {
    border-color: #111827;
}

.composer button {
    border: 0;
    border-radius: 14px;
    padding: 0 20px;
    background: #111827;
    color: white;
    cursor: pointer;
    font-weight: 600;
}

.composer button:disabled {
    opacity: 0.5;
    cursor: wait;
}


/* =========================================================
   MI APRENDIZAJE
========================================================= */

.learning-profile-panel {
    flex: 1;
    overflow-y: auto;
    padding: 32px;
    background: #f8f9fb;
}


/* =========================================================
   CABECERA DEL PERFIL
========================================================= */

.learning-profile-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    max-width: 900px;
    margin: 0 auto 28px;
}

.learning-profile-header h2 {
    margin: 0;
    font-size: 28px;
    letter-spacing: -0.02em;
}

.learning-profile-header p {
    margin: 7px 0 0;
    color: #6b7280;
    font-size: 14px;
}


/* =========================================================
   BOTÓN CERRAR PERFIL
========================================================= */

.learning-profile-close {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    border: 1px solid #d1d5db;
    border-radius: 50%;
    background: white;
    color: #374151;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition:
        background 0.2s ease,
        border-color 0.2s ease,
        color 0.2s ease;
}

.learning-profile-close:hover {
    background: #111827;
    border-color: #111827;
    color: white;
}


/* =========================================================
   SECCIONES DEL PERFIL
========================================================= */

.learning-profile-section {
    max-width: 900px;
    margin: 0 auto 22px;
    padding: 24px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
}

.learning-profile-section h3 {
    margin: 0 0 18px;
    font-size: 16px;
    color: #111827;
}


/* =========================================================
   EVIDENCIA ACUMULADA
========================================================= */

.learning-evidence-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 14px 0;
    border-bottom: 1px solid #f0f1f3;
}

.learning-evidence-item:first-child {
    padding-top: 2px;
}

.learning-evidence-item:last-child {
    padding-bottom: 2px;
    border-bottom: 0;
}

.learning-concept {
    font-weight: 600;
    color: #1f2937;
}

.learning-count {
    flex: 0 0 auto;
    color: #6b7280;
    font-size: 13px;
    background: #f3f4f6;
    border-radius: 999px;
    padding: 6px 10px;
}


/* =========================================================
   PATRONES DE APRENDIZAJE
========================================================= */

.learning-pattern-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 14px 0;
    border-bottom: 1px solid #f0f1f3;
}

.learning-pattern-item:first-child {
    padding-top: 2px;
}

.learning-pattern-item:last-child {
    padding-bottom: 2px;
    border-bottom: 0;
}

.learning-pattern-meta {
    flex: 0 0 auto;
    color: #4b5563;
    font-size: 13px;
    font-weight: 600;
    background: #f3f4f6;
    border-radius: 999px;
    padding: 6px 10px;
}


/* =========================================================
   PRÓXIMO RETO
========================================================= */

.learning-profile-next-step {
    position: relative;
    padding: 18px 20px 18px 24px;
    background: #f3f4f6;
    border-radius: 12px;
    color: #374151;
    line-height: 1.6;
    font-size: 15px;
}

.learning-profile-next-step::before {
    content: "";
    position: absolute;
    top: 14px;
    bottom: 14px;
    left: 0;
    width: 4px;
    background: #111827;
    border-radius: 0 4px 4px 0;
}


/* =========================================================
   RESPONSIVE
========================================================= */

@media (max-width: 750px) {

    .sidebar {
        display: none;
    }

    .app {
        width: 100%;
    }

    .modes {
        grid-template-columns: repeat(2, 1fr);
    }

    .bubble {
        max-width: 88%;
    }

    .learning-profile-panel {
        padding: 24px 18px;
    }

    .learning-profile-header h2 {
        font-size: 24px;
    }

    .learning-profile-section {
        padding: 20px;
    }

    .learning-evidence-item,
    .learning-pattern-item {
        align-items: flex-start;
        flex-direction: column;
        gap: 8px;
    }
}