.chat-page {
    position: relative;
    height: 100dvh;
    overflow: hidden;
    background-color: transparent !important;
    width: 100%;
    margin: 0 auto;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.chat-messages {
    width: 100%;
    max-width: 780px;
    padding: 8px;
    padding-top: 85px;
    margin-bottom: 160px;
    margin-left: auto;
    margin-right: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: hidden;
}

@media (max-width: 650px) {
    .chat-messages {
        padding-top: 115px;
    }
}

.chat-spacer {
    height: 0;
    /* This ensures smooth scrolling */
    height: 0;
    /* This ensures smooth scrolling */
}

.chat-loading-screen {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 10px;
    align-items: center;
    font-size: 1.3rem;
    font-weight: bold;
}

.check-answers-floating {
    position: absolute;
    bottom: 0;
    width: 100%;

    display: flex;
    flex-direction: column;
    align-items: center;
}

.check-answers-advice {
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    background:
        color-mix(in srgb, var(--mud-palette-background) 85%, transparent);
    height: 2rem;
    border-radius: var(--app-border-radius-lg);
    padding: 0.5rem 2rem;

    width: auto;
    overflow: hidden;
    margin: 3px auto;

    display: flex;
    align-items: center;
}

.check-answers-text {
    text-align: center;
}

.bubble {
    max-width: 65%;
    word-wrap: break-word;
    border: 1px solid var(--mud-palette-lines-default);
    background-color: transparent;
    border: transparent;
}

.bubble-content {
    padding: 10px 14px;
}

.own {
    align-self: flex-end;
}

.own .bubble-content {
    background-color: var(--mud-palette-primary);
    color: white;
    border-radius: 16px 16px 4px 16px;
    border-color: var(--mud-palette-primary-darken);
}

.own .bubble-attachment-item {
    margin-left: auto;
}

.own .bubble-attachment-item {
    background-color: rgba(0, 0, 0, 0.15) !important;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.other {
    align-self: flex-start;
    margin-right: auto;
}

.other .bubble-content,
.other.bubble-content {
    background-color: var(--mud-palette-surface);
    color: var(--mud-palette-text-primary);
    border-radius: 16px 16px 16px 4px;
    border-color: var(--mud-palette-lines-default);
    margin-right: auto;
    transition: background-color 0.3s ease, max-width 0.3s ease;
}

@media (max-width: 850px) {

    .other .bubble-content,
    .other.bubble-content {
        border: transparent !important;
        background-color: transparent;
        box-shadow: none !important;
        max-width: 90%;
    }
}

.other .bubble-attachment-item {
    background-color: transparent !important;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.other .bubble-attachment-info {
    color: var(--mud-palette-text-primary);
}

.time {
    display: block;
    margin-top: 4px;
    font-size: 0.7rem;
    opacity: 0.7;
    text-align: right;
}

.input-wrapper {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    background: color-mix(in srgb, var(--mud-palette-surface) 85%, transparent);
    z-index: 10;
    border-radius: var(--app-border-radius-lg);
    width: calc(100% - 2rem);
    max-width: 800px;
    flex-shrink: 0;
    margin-bottom: calc(2.5rem + env(safe-area-inset-bottom, 0px));
    padding: 15px;
}

/* Mobile: adjust padding */
@media (max-width: 780px) {
    .input-wrapper {
        width: calc(100% - 1rem);
        border-radius: var(--app-border-radius);
    }
}


.input-field {
    flex-shrink: 0;
    min-height: 50px;
    padding: 0 10px;
    border-radius: var(--app-border-radius);
    background-color: transparent;
    color: var(--mud-palette-text-primary);
}

.send-button {
    border-radius: var(--app-border-radius);
    background-color: var(--mud-palette-primary);
    color: white;
}

.chat-container {
    height: 100%;
    overflow-y: auto;
    position: relative;
    background-color: transparent !important;
    scrollbar-gutter: stable both-edges;
}


.titulo-mostrado {
    font-size: 1.2rem;
    font-style: italic;
    margin-bottom: 8px;
    border-bottom: 1px dashed var(--mud-palette-text-primary);
}

/* RAG Badge */
.ai-response {
    position: relative;
}

.rag-badge {
    position: absolute;
    top: -8px;
    right: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: linear-gradient(135deg, #4ade80 0%, #22c55e 100%);
    color: #052e16;
    font-size: 0.65rem;
    font-weight: 600;
    border-radius: var(--app-border-radius);
    box-shadow: 0 2px 8px rgba(34, 197, 94, 0.4);
    white-space: nowrap;
}

.rag-badge .mud-icon-root {
    font-size: 0.85rem !important;
    width: 14px !important;
    height: 14px !important;
}

.explicacion-title {
    margin-bottom: 5px;
}

.explicacion-item {
    font-size: 0.9rem;
    margin-bottom: 12px;
    margin-left: 5px;
    padding-left: 5px;
    border-left: 1px solid gray;
}

.more-options {
    background-color: transparent !important;
    gap: 10px;
    align-items: center;
    padding: 0 10px;
}

.attach-button {
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    padding: 10px;
    border-radius: var(--app-border-radius);
}

.attach-button.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.processing-indicator {
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

/* Video Generation Indicator */
.video-generation-indicator {
    background: linear-gradient(135deg, rgba(156, 39, 176, 0.15) 0%, rgba(103, 58, 183, 0.15) 100%) !important;
    border: 1px solid rgba(156, 39, 176, 0.3) !important;
    min-width: 280px;
    max-width: 350px;
    animation: video-pulse 2s ease-in-out infinite;
}

.video-generation-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 4px;
}

.video-icon-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #9c27b0 0%, #673ab7 100%);
    border-radius: 50%;
    animation: icon-bounce 1.5s ease-in-out infinite;
}

.video-icon {
    color: white !important;
}

.video-generation-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.video-title {
    font-weight: 600 !important;
    color: var(--mud-palette-text-primary) !important;
}

.video-subtitle {
    color: var(--mud-palette-text-secondary) !important;
}

.video-progress-wrapper {
    width: 100%;
}

.video-progress {
    border-radius: 4px;
    height: 6px !important;
}

@keyframes video-pulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(156, 39, 176, 0.4);
    }

    50% {
        box-shadow: 0 0 0 8px rgba(156, 39, 176, 0);
    }
}

@keyframes icon-bounce {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

.attachment-row {
    display: flex;
    gap: 8px;
    flex-wrap: nowrap;
}

.attachment-item {
    min-width: 80px;
    max-width: 100px;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: var(--app-border-radius-sm);
    position: relative;
    background-color: var(--mud-palette-surface);
}

@media (hover: hover) {
    .attachment-item:hover {
        background-color: rgba(102, 179, 255, 0.1);
    }
}

.hidden {
    display: none;
}

.notification-banner {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    min-width: 300px;
    max-width: 600px;
    border-radius: var(--app-border-radius-sm);
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.banner-content {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
}

.banner-text {
    flex: 1;
    font-weight: 500;
}

.banner-close {
    margin-left: auto;
}

.notification-error {
    background-color: #f44336 !important;
    color: white;
    border: 2px solid #d32f2f;
}

.notification-success {
    background-color: #4caf50 !important;
    color: white;
    border: 2px solid #388e3c;
}

.notification-warning {
    background-color: #ff9800 !important;
    color: white;
    border: 2px solid #f57c00;
}

.notification-info {
    background-color: #2196f3 !important;
    color: white;
    border: 2px solid #1976d2;
}

/* Bubble attachments styling */
.bubble-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}

.bubble-attachment-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: var(--app-border-radius-sm);
    background-color: transparent !important;
    max-width: 500px;
}


.bubble-attachment-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
    color: white;
}


.bubble-attachment-name {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
}

.bubble-attachment-size {
    opacity: 0.7;
    font-size: 0.65rem !important;
}

.bubble-attachment-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100px;
    height: 80px;
    gap: 8px;
    opacity: 0.7;
}

/* Manual load button for heavy media */
.bubble-attachment-manual-load {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 140px;
    height: 100px;
    gap: 6px;
    padding: 12px;
    cursor: pointer;
    border-radius: var(--app-border-radius-sm);
    background: rgba(102, 179, 255, 0.1);
    border: 2px dashed rgba(102, 179, 255, 0.4);
    transition: all 0.2s ease;
}

@media (hover: hover) {
    .bubble-attachment-manual-load:hover {
        background: rgba(102, 179, 255, 0.2);
        border-color: rgba(102, 179, 255, 0.6);
        transform: scale(1.02);
    }
}

.bubble-attachment-manual-load .manual-load-icon {
    color: #66b3ff;
    opacity: 0.8;
}

.bubble-attachment-manual-load .manual-load-text {
    color: #66b3ff;
    font-weight: 500;
    text-align: center;
    font-size: 0.7rem !important;
}

.bubble-attachment-manual-load .manual-load-size {
    opacity: 0.6;
    font-size: 0.65rem !important;
}

/* User message variant */
.own .bubble-attachment-manual-load {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.4);
}

@media (hover: hover) {
    .own .bubble-attachment-manual-load:hover {
        background: rgba(255, 255, 255, 0.2);
        border-color: rgba(255, 255, 255, 0.6);
    }
}

.own .bubble-attachment-manual-load .manual-load-icon,
.own .bubble-attachment-manual-load .manual-load-text {
    color: white;
}

.bubble-attachment-image {
    width: 100%;
    max-width: 180px;
    max-height: 120px;
    border-radius: 4px;
    object-fit: cover;
}

.bubble-attachment-video {
    max-width: 100%;
    max-height: 300px;
    border-radius: var(--app-border-radius-sm);
}

.bubble-attachment-audio {
    margin: 10px;
    width: 300px;
}

/* Attachment action buttons */
.bubble-attachment-actions {
    display: flex;
    gap: 2px;
    margin-left: auto;
}

.attachment-action-btn {
    padding: 4px !important;
    min-width: 28px !important;
    width: 28px !important;
    height: 28px !important;
}

.attachment-action-btn .mud-icon-root {
    font-size: 0.95rem !important;
}

.own .attachment-action-btn {
    color: rgba(255, 255, 255, 0.9) !important;
}

@media (hover: hover) {
    .own .attachment-action-btn:hover {
        background-color: rgba(255, 255, 255, 0.15) !important;
    }
}

.other .attachment-action-btn {
    color: var(--mud-palette-text-primary) !important;
}

@media (hover: hover) {
    .other .attachment-action-btn:hover {
        background-color: rgba(0, 0, 0, 0.1) !important;
    }
}

/* Chat Intro Component Styles */
.intro-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    height: auto;
    min-height: 400px;
    padding: 40px 20px;
    text-align: center;
    margin-bottom: 150px;
}

.intro-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-bottom: 40px;
}

.intro-icon {
    font-size: 48px !important;
    width: 48px !important;
    height: 48px !important;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.8;
        transform: scale(1.05);
    }
}

.intro-title {
    color: var(--mud-palette-text-primary);
    font-weight: 600;
}

.intro-subtitle {
    color: var(--mud-palette-text-secondary);
    max-width: 400px;
}

.intro-suggestions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    width: 100%;
    max-width: 600px;
}

.suggestions-label {
    color: var(--mud-palette-text-secondary);
    margin-bottom: 8px;
}

.suggestion-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 12px;
    width: 100%;
}

.suggestion-card {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
    background-color: var(--mud-palette-surface) !important;
    box-shadow: var(--app-box-shadow);
    border-radius: var(--app-border-radius);
    cursor: pointer;
    transition: all 0.2s ease;
}

@media (hover: hover) {
    .suggestion-card:hover {
        background-color: var(--mud-palette-action-default-hover) !important;
        border-color: var(--mud-palette-primary);
        transform: translateY(-2px);
    }
}

.suggestion-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
}

.suggestion-title {
    font-weight: 500;
    color: var(--mud-palette-text-primary);
}

.suggestion-card .mud-typography-caption {
    color: var(--mud-palette-text-secondary);
}

/* Respuesta libre text styling */
.respuesta-libre {
    font-size: 1rem;
    line-height: 1.7;
}

/* Explicacion text styling */
.explicacion-text {
    font-size: 0.875rem;
    line-height: 1.6;
}

.attachment-filename {
    max-width: 80px;
}

/* Lightweight Quote Feature Styles */

/* Enable text selection in bubbles */
.selectable-text {
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    cursor: text;
}

.selectable-text::selection {
    background-color: rgba(25, 118, 210, 0.3);
    color: inherit;
}

/* Message wrapper with hover actions */
.message-wrapper {
    position: relative;
    margin-bottom: 12px;
    display: flex;
    justify-content: flex-end;
}

.message-hover-actions {
    opacity: 0;
    position: absolute;
    top: 8px;
    right: 8px;
    transition: opacity 0.2s ease;
    z-index: 8;
}

.message-hover-actions.own {
    left: 8px;
}

@media (hover: hover) {
    .message-wrapper:hover .message-hover-actions {
        opacity: 1;
    }
}

.quote-btn {
    background: rgba(255, 255, 255, 0.95);
    box-shadow: var(--app-box-shadow-sm);
    border-radius: var(--app-border-radius-sm);
}

@media (hover: hover) {
    .quote-btn:hover {
        background: rgba(255, 255, 255, 1);
        transform: scale(1.05);
    }
}

.quoted-preview {
    margin: 8px 0;
    border-left: 4px solid #1976d2;
    border-radius: var(--app-border-radius-sm);
}

.quoted-text {
    color: var(--mud-palette-text-primary);
    font-style: italic;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-height: 50px;
    margin-top: auto;
    margin-bottom: auto;
}

/* Mobile responsiveness */
@media (max-width: 800px) {
    .message-hover-actions {
        opacity: 1;
        /* Always visible on mobile */
    }

    .quoted-preview-text {
        font-size: 0.875rem;
    }
}