/* Estilos del Chatbot Legal - Rediseño v2 */
#legal-ai-chatbot-wrapper {
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    display: flex;
    flex-direction: row;
    width: 100%;
    max-width: 1200px;
    height: 700px;
    background-color: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
    overflow: hidden;
    margin: 20px auto;
}

/* Info card (outside chat) */
.lac-info-card {
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    width: 100%;
    max-width: 1200px;
    margin: 20px auto 0 auto;
    background: linear-gradient(180deg, #ffffff 0%, #fbfbfb 100%);
    border: 1px solid #eaeaea;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.04);
    overflow: hidden;
}

.lac-info-card-header {
    padding: 16px 20px;
    border-bottom: 1px solid #ededed;
}

.lac-info-card-title {
    font-weight: 800;
    color: #1a1a1a;
    font-size: 14px;
    letter-spacing: 0.2px;
}

.lac-info-card-subtitle {
    margin-top: 6px;
    color: #666;
    font-size: 13px;
}

.lac-info-card-body {
    padding: 16px 20px 18px 20px;
}

.lac-info-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.lac-info-item {
    background: #fff;
    border: 1px solid #efefef;
    border-radius: 10px;
    padding: 12px 14px;
}

.lac-info-item-title {
    font-weight: 800;
    font-size: 13px;
    color: #1a1a1a;
    margin-bottom: 6px;
}

.lac-info-item-text {
    font-size: 13px;
    color: #555;
    line-height: 1.5;
}

@media (max-width: 900px) {
    .lac-info-grid {
        grid-template-columns: 1fr;
    }
}

/* Sidebar */
#lac-sidebar {
    width: 280px;
    background-color: #fcfcfc;
    border-right: 1px solid #eee;
    padding: 20px;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.lac-sidebar-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
}

.lac-btn-primary, .lac-btn-secondary {
    flex: 1;
    border: none;
    padding: 10px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    text-align: center;
    transition: background 0.3s;
}

.lac-btn-primary {
    background-color: #1a1a1a;
    color: #fff;
}
.lac-btn-primary:hover {
    background-color: #333;
}

.lac-btn-secondary {
    background-color: #e0e0e0;
    color: #333;
}
.lac-btn-secondary:hover {
    background-color: #d0d0d0;
}

/* Antiguo ID por compatibilidad si cachea */
#lac-new-chat-btn {
    /* Resetear estilos viejos si aplican por ID */
    margin-bottom: 0;
    width: auto;
}

#lac-sidebar h3 {
    font-size: 18px;
    margin-bottom: 15px;
    color: #1a1a1a;
    font-weight: 700;
}

.lac-history-list {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow-y: auto;
    flex: 1; /* Ocupar el resto del alto */
}

.lac-history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    margin-bottom: 6px;
    border-radius: 6px;
    cursor: pointer;
    background-color: #f8f8f8;
    color: #555;
    font-size: 13px;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.lac-history-item:hover {
    background-color: #f0f0f0;
    border-color: #ddd;
}

.lac-history-item.active {
    background-color: #1a1a1a;
    color: #fff;
    border-color: #1a1a1a;
}

.lac-history-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    margin-right: 8px;
}

.lac-history-delete {
    opacity: 0.5;
    font-weight: bold;
    font-size: 16px;
    line-height: 1;
    padding: 0 4px;
}

.lac-history-delete:hover {
    opacity: 1;
    color: #d00;
}

.lac-history-item.active .lac-history-delete:hover {
    color: #ff6b6b;
}

.lac-empty-history {
    font-size: 13px;
    color: #999;
    text-align: center;
    padding: 20px 0;
    font-style: italic;
}

/* Área Principal */
#lac-main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: #fff;
    position: relative;
}

.lac-header-main {
    padding: 25px 40px;
    border-bottom: 1px solid #f0f0f0;
}

.lac-header-main h2 {
    margin: 0 0 8px 0;
    font-size: 22px;
    color: #1a1a1a;
    font-weight: 700;
}

.lac-header-main p {
    margin: 0;
    color: #777;
    font-size: 14px;
}

/* Mensajes */
.lac-chat-messages {
    flex: 1;
    padding: 30px 40px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.lac-message {
    max-width: 85%;
    line-height: 1.6;
    font-size: 15px;
    position: relative;
    display: flex;
    flex-direction: column;
}

.lac-message strong {
    display: block;
    margin-bottom: 8px;
    font-size: 12px;
    color: #999;
    font-weight: 600;
}

.bot-message {
    align-self: flex-start;
}

.bot-message .lac-msg-content {
    background-color: #f7f7f7;
    color: #333;
    padding: 20px 25px;
    border-radius: 8px;
    border-top-left-radius: 0;
}

.user-message {
    align-self: flex-end;
    align-items: flex-end; /* Alinear el strong a la derecha */
}

.user-message strong {
    text-align: right;
}

.user-message .lac-msg-content {
    background-color: #1a1a1a;
    color: #fff;
    padding: 15px 25px;
    border-radius: 8px;
    border-top-right-radius: 0;
    text-align: left;
}

/* Input Area */
.lac-input-container {
    padding: 20px 40px;
    border-top: 1px solid #f0f0f0;
    background-color: #fff;
}

.lac-input-wrapper {
    display: flex;
    gap: 15px;
    align-items: flex-start; /* Alinear arriba para textarea */
    margin-bottom: 15px;
}

#lac-user-input {
    flex: 1;
    padding: 15px 20px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    font-size: 15px;
    resize: none;
    height: 50px;
    min-height: 50px;
    font-family: inherit;
    transition: border-color 0.3s;
    background-color: #fff;
}

#lac-user-input:focus {
    border-color: #d4af37;
    outline: none;
    box-shadow: 0 0 0 2px rgba(212, 175, 55, 0.1);
}

#lac-send-btn {
    background-color: #1a1a1a;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 0 30px;
    height: 50px; /* Igualar altura inicial input */
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.3s;
}

#lac-send-btn:hover {
    background-color: #333;
}

/* Footer Credits */
.lac-footer-credits {
    text-align: center;
    font-size: 11px;
    color: #aaa;
    margin-top: 5px;
}

.lac-footer-credits p {
    margin: 2px 0;
}

.lac-footer-credits a {
    color: #d4af37;
    text-decoration: none;
    font-weight: 600;
}

.lac-footer-credits a:hover {
    text-decoration: underline;
}

/* Estilos Markdown Content */
.lac-msg-content.markdown-body {
    line-height: 1.6;
}

.lac-msg-content.markdown-body p {
    margin: 0 0 10px 0;
}
.lac-msg-content.markdown-body p:last-child {
    margin-bottom: 0;
}

.lac-msg-content.markdown-body ul, .lac-msg-content.markdown-body ol {
    margin: 8px 0 8px 20px;
    padding: 0;
}

.lac-msg-content.markdown-body li {
    margin-bottom: 4px;
}

.lac-msg-content.markdown-body strong {
    font-weight: 700;
    color: inherit; /* Heredar color (blanco en user, negro en bot) */
}

.lac-msg-content.markdown-body em {
    font-style: italic;
}

.lac-msg-content.markdown-body code {
    background-color: rgba(0,0,0,0.1);
    padding: 2px 4px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.9em;
}

.user-message .lac-msg-content.markdown-body code {
    background-color: rgba(255,255,255,0.2);
}

.lac-msg-content.markdown-body pre {
    background-color: #2d2d2d;
    color: #f8f8f2;
    padding: 10px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 10px 0;
    font-size: 0.9em;
}

.lac-msg-content.markdown-body blockquote {
    border-left: 3px solid #d4af37;
    margin: 10px 0;
    padding-left: 10px;
    color: #666;
    font-style: italic;
}
.user-message .lac-msg-content.markdown-body blockquote {
    border-left-color: rgba(255,255,255,0.5);
    color: #ddd;
}

/* Typing Indicator */
.lac-typing-indicator {
    padding: 15px 20px;
    background-color: #f7f7f7;
    border-radius: 8px;
    border-top-left-radius: 0;
    display: inline-flex;
    gap: 4px;
    width: fit-content;
}

.lac-typing-dot {
    width: 6px;
    height: 6px;
    background-color: #bbb;
    border-radius: 50%;
    animation: lac-bounce 1.4s infinite ease-in-out;
}
.lac-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.lac-typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes lac-bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Modal Styles */
.lac-modal {
    display: none; 
    position: fixed; 
    z-index: 9999; 
    left: 0;
    top: 0;
    width: 100%; 
    height: 100%; 
    overflow: auto; 
    background-color: rgba(0,0,0,0.5); 
    backdrop-filter: blur(2px);
    animation: fadeIn 0.3s;
}

.lac-modal-content {
    background-color: #fefefe;
    margin: 15% auto; 
    padding: 30px;
    border: 1px solid #888;
    width: 90%;
    max-width: 450px;
    border-radius: 10px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.2);
    position: relative;
    animation: slideIn 0.3s;
}

.lac-close-modal {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.lac-close-modal:hover,
.lac-close-modal:focus {
    color: #000;
    text-decoration: none;
    cursor: pointer;
}

.lac-modal h3 {
    margin-top: 0;
    font-size: 20px;
    color: #333;
}

.lac-modal p {
    color: #666;
    font-size: 14px;
    margin-bottom: 20px;
}

#lac-chat-title-input {
    width: 100%;
    padding: 12px;
    margin-bottom: 20px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 15px;
    box-sizing: border-box;
}

.lac-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

@keyframes fadeIn {
    from {opacity: 0;}
    to {opacity: 1;}
}

@keyframes slideIn {
    from {transform: translateY(-20px); opacity: 0;}
    to {transform: translateY(0); opacity: 1;}
}

/* Responsive */
@media (max-width: 768px) {
    #legal-ai-chatbot-wrapper {
        flex-direction: column;
        height: auto;
        min-height: 700px;
        margin: 10px;
        width: auto;
    }

    #lac-sidebar {
        width: 100%;
        padding: 15px;
        border-right: none;
        border-bottom: 1px solid #eee;
    }
    
    .lac-history-list {
        display: flex;
        overflow-x: auto;
        padding-bottom: 5px;
        gap: 10px;
    }
    
    .lac-history-list li {
        margin-bottom: 0;
        flex: 0 0 auto;
        width: auto;
        max-width: 200px;
    }

    .lac-header-main, .lac-chat-messages, .lac-input-container {
        padding: 20px;
    }
    
    .lac-message {
        max-width: 95%;
    }
}
