/* Demo - Estilos */

/* Loading indicator (dentro del dashboard) */
.loading-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: #7f8c8d;
    min-height: 400px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #e0e6ed;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Login Screen */
.demo-login-overlay {
    position: fixed;
    z-index: 9999;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.demo-login-card {
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    padding: 40px 32px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 350px;
    max-width: 95vw;
    animation: fadeIn 0.3s ease-in-out;
}

.login-logo {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    margin-bottom: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.demo-login-card h2 {
    margin-bottom: 10px;
    font-weight: 700;
    font-size: 1.8rem;
    text-align: center;
    color: #333;
}

.login-subtitle {
    color: #666;
    font-size: 0.95rem;
    margin-bottom: 25px;
    text-align: center;
}

.demo-password-input {
    padding: 12px 18px;
    border-radius: 30px;
    border: 1px solid #ddd;
    width: 100%;
    margin-bottom: 20px;
    font-size: 1.1rem;
    transition: border-color 0.3s;
}

.demo-password-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.demo-login-btn {
    background: #667eea;
    color: white;
    padding: 12px 36px;
    border: none;
    border-radius: 30px;
    font-size: 1.1rem;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    cursor: pointer;
    transition: all 0.3s;
    width: 100%;
}

.demo-login-btn:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

.login-error {
    color: #d32f2f;
    margin-top: 12px;
    font-size: 0.9rem;
    animation: shake 0.3s;
}

.session-info {
    margin-top: 15px;
    font-size: 12px;
    color: #666;
    text-align: center;
}

.back-to-chat {
    margin-top: 20px;
    color: #667eea;
    text-decoration: none;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: color 0.3s;
}

.back-to-chat:hover {
    color: #5568d3;
}

/* Dashboard */
.demo-dashboard {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.demo-main-content {
    width: calc(100% - 70px);
    margin-left: 70px;
    display: flex;
    flex-direction: column;
    background: #f5f7fa;
    overflow: hidden;
}

/* Header */
.demo-header {
    background: white;
    padding: 20px 30px;
    border-bottom: 1px solid #e0e6ed;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    z-index: 10;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.header-title h1 {
    font-size: 1.8rem;
    color: #2c3e50;
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 0 8px 0;
}

.header-title h1 i {
    color: #667eea;
}

.demo-user-info {
    display: flex;
    gap: 12px;
    align-items: center;
}

.demo-badge {
    background: #ffd93d;
    color: #333;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.demo-phone {
    color: #667eea;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: 'Courier New', monospace;
}

.header-actions {
    display: flex;
    gap: 10px;
}

.header-btn {
    background: #667eea;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.3s;
}

.header-btn:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.header-btn.active {
    background: #5568d3;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.4);
}

/* Chat Container */
.demo-chat-container {
    display: flex;
    flex: 1;
    gap: 20px;
    padding: 20px 30px;
    overflow: hidden;
}

.chat-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #e5ddd5;
}

.welcome-message {
    text-align: center;
    padding: 40px 20px;
    color: #555;
}

.welcome-message i {
    font-size: 3rem;
    color: #667eea;
    margin-bottom: 15px;
}

.welcome-message h3 {
    margin: 0 0 10px 0;
    color: #2c3e50;
}

.welcome-message p {
    margin: 8px 0;
    line-height: 1.6;
}

.welcome-message .info-text {
    font-size: 0.9rem;
    color: #888;
    margin-top: 15px;
    font-style: italic;
}

/* Messages */
.message {
    max-width: 70%;
    margin-bottom: 12px;
    animation: fadeInUp 0.3s;
    position: relative;
}

.message.user {
    align-self: flex-start;
}

.message.model {
    align-self: flex-end;
    padding-right: 30px; /* Espacio para el icono del robot */
    margin-left: auto;
}

/* Icono de robot para mensajes del modelo */
.message.model::before {
    content: '\f544'; /* Código del icono fa-robot */
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    position: absolute;
    right: 0;
    top: 0;
    width: 24px;
    height: 24px;
    background: #25d366;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.message-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    position: relative;
    word-wrap: break-word;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    line-height: 1.5;
}

/* Usuario tiene fondo blanco con punta inferior izquierda */
.message.user .message-bubble {
    background: white;
    color: #333;
    border-bottom-left-radius: 4px;
    border: 1px solid #ccc;
}

/* ProChat (model) tiene el fondo verde con punta inferior derecha */
.message.model .message-bubble {
    background: #dcf8c6;
    color: #333;
    border-bottom-right-radius: 4px;
    border-right: 3px solid #25d366;
}

.message-time {
    font-size: 0.75rem;
    color: #999;
    margin-top: 5px;
    text-align: right;
}

.typing-indicator {
    background: white;
    padding: 12px 16px;
    border-radius: 12px;
    border-bottom-right-radius: 4px;
    max-width: 60px;
    margin-left: auto;
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-10px);
    }
}

/* Chat Input */
.chat-input-container {
    padding: 15px;
    background: #f0f2f5;
    border-top: 1px solid #e0e6ed;
}

.chat-form {
    display: flex;
    gap: 10px;
    align-items: center;
}

.message-input {
    flex: 1;
    padding: 12px 20px;
    border: 1px solid #ddd;
    border-radius: 30px;
    font-size: 0.95rem;
    outline: none;
    transition: all 0.3s;
}

.message-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.input-btn {
    width: 45px;
    height: 45px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: all 0.3s;
}

.send-btn {
    background: #667eea;
    color: white;
}

.send-btn:hover {
    background: #5568d3;
    transform: scale(1.1);
}

.record-btn {
    background: #25d366;
    color: white;
}

.record-btn:hover {
    background: #1fb855;
    transform: scale(1.1);
}

.record-btn.recording {
    background: #ff4444;
    animation: pulse 1s infinite;
}

.qa-btn {
    background: #f59e0b;
    color: white;
}

.qa-btn:hover {
    background: #d97706;
    transform: scale(1.1);
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.15);
    }
}

/* Context Panel - Igual que conversaciones */
.context-panel {
    width: 350px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.context-panel.hidden {
    display: none;
}

.context-panel.visible {
    display: flex;
}

/* Ocultar botón de cerrar en desktop */
.mobile-close-context-btn {
    display: none;
}

.context-header {
    padding: 20px 25px;
    border-bottom: 2px solid #f0f2f5;
    position: sticky;
    top: 0;
    background: white;
    z-index: 10;
}

.context-header h3 {
    margin: 0;
    color: #2c3e50;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1rem;
}

.context-header h3 i {
    color: #667eea;
}

.context-content {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.context-section {
    padding: 20px 25px;
    border-bottom: 1px solid #f0f2f5;
}

.context-section:last-child {
    border-bottom: none;
}

.context-section-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.context-section-header i {
    color: #667eea;
    font-size: 1.1rem;
}

.context-section-header h4 {
    margin: 0;
    color: #34495e;
    font-size: 1rem;
    font-weight: 600;
}

.context-section-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.context-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.field-label {
    color: #7f8c8d;
    font-size: 0.85rem;
    font-weight: 500;
    text-transform: capitalize;
}

.field-value {
    color: #2c3e50;
    font-size: 0.95rem;
    font-weight: 400;
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 6px;
    border-left: 3px solid #667eea;
}

.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    color: #95a5a6;
}

.loading-container p {
    margin: 0;
    font-size: 0.9rem;
}

.context-actions {
    position: sticky;
    bottom: 0;
    background: white;
    border-top: 1px solid #e0e0e0;
}

.action-btn {
    width: 100%;
    padding: 12px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.3s;
}

.action-btn:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}


/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

/* Responsive */
@media (max-width: 1024px) {
    .context-panel {
        width: 300px;
    }
}

@media (max-width: 768px) {
    .demo-main-content {
        width: calc(100% - 60px);
        margin-left: 60px;
    }

    .demo-header {
        padding: 15px 20px;
    }

    .header-title h1 {
        font-size: 1.4rem;
    }

    .header-btn span {
        display: none;
    }

    .demo-chat-container {
        flex-direction: column;
        padding: 15px;
        position: relative;
    }

    .chat-wrapper {
        min-height: 500px;
        width: 100%;
        max-width: 100%;
    }

    /* Panel de contexto en móvil - overlay tipo modal */
    .context-panel {
        position: absolute;
        top: 0;
        right: 0;
        height: 100%;
        width: 100%;
        max-width: 100%;
        z-index: 30;
        box-shadow: -2px 0 10px rgba(0,0,0,0.1);
        transform: translateX(100%);
        transition: transform 0.3s ease;
        order: 0;
        margin-bottom: 0;
    }
    
    .context-panel.visible {
        transform: translateX(0);
    }
    
    .context-panel.hidden {
        transform: translateX(100%);
    }
    
    /* Botón de cerrar en móvil */
    .mobile-close-context-btn {
        display: block;
        position: absolute;
        left: 15px;
        top: 50%;
        transform: translateY(-50%);
        background: none;
        border: none;
        color: white;
        font-size: 1.3rem;
        cursor: pointer;
        padding: 8px;
        border-radius: 50%;
        transition: all 0.3s;
        z-index: 150;
    }
    
    .mobile-close-context-btn:hover {
        background: rgba(255,255,255,0.2);
    }
    
    /* Ajustar header del contexto para el botón de cerrar */
    .context-panel .context-header {
        position: relative;
        padding-left: 60px;
    }

    /* Ajustar input y botones en tablets */
    .chat-form {
        gap: 8px;
    }

    .message-input {
        padding: 10px 16px;
        font-size: 0.9rem;
    }

    .input-btn {
        width: 42px;
        height: 42px;
        font-size: 1rem;
        flex-shrink: 0; /* Evitar que se compriman */
    }
}

@media (max-width: 480px) {
    .demo-main-content {
        width: calc(100% - 50px);
        margin-left: 50px;
    }

    .demo-login-card {
        padding: 30px 24px;
        min-width: 300px;
    }

    .message {
        max-width: 85%;
    }

    /* Ajustes específicos para móviles */
    .demo-chat-container {
        padding: 10px;
    }

    .chat-input-container {
        padding: 10px;
    }

    .chat-form {
        gap: 6px;
        max-width: 100%;
    }

    .message-input {
        padding: 10px 12px;
        font-size: 0.9rem;
        min-width: 0;
        flex: 1;
    }

    .input-btn {
        width: 38px;
        height: 38px;
        min-width: 38px;
        min-height: 38px;
        font-size: 0.9rem;
        flex-shrink: 0;
    }

    .send-btn:hover,
    .record-btn:hover {
        transform: none;
    }

    /* Ajustar panel de contexto */
    .context-panel {
        padding: 15px;
    }
    
    .context-panel .context-header h3 {
        font-size: 1rem;
    }

    .stat-value {
        font-size: 1.8rem;
    }
    
    /* Ajustar header del demo */
    .demo-header {
        padding: 12px 15px;
    }
    
    .header-title h1 {
        font-size: 1.2rem;
    }
    
    .demo-badge {
        font-size: 0.65rem;
        padding: 3px 8px;
    }
    
    .demo-phone {
        font-size: 0.85rem;
    }
}
