/* ============================================================================
   Asistente de Proyectos — Full-page ChatGPT-like interface
   ============================================================================ */

/* Page override: asistente needs full viewport height */
#page-asistente-proyectos.page-content.active {
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 0;
    overflow: hidden;
}

/* Container: takes full page area */
.asistente-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
    padding: 0 16px;
    position: relative;
}

/* Header */
.asistente-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0 12px;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.asistente-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.asistente-header-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #1e293b;
}

.asistente-header-subtitle {
    font-size: 0.8rem;
    color: #64748b;
}

.asistente-header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.asistente-btn {
    padding: 6px 14px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    background: #fff;
    color: #475569;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.asistente-btn:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

.asistente-btn-primary {
    background: linear-gradient(135deg, #2563eb, #1e40af);
    color: #fff;
    border-color: transparent;
}

.asistente-btn-primary:hover {
    background: linear-gradient(135deg, #1d4ed8, #1e3a8a);
}

.asistente-btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.asistente-btn-success {
    background: #10b981;
    color: #fff;
    border-color: transparent;
}

.asistente-btn-success:hover {
    background: #059669;
}

/* Status badge */
.asistente-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 500;
    background: #f1f5f9;
    color: #64748b;
}

.asistente-status.has-results {
    background: #ecfdf5;
    color: #059669;
}

.asistente-status.evaluating {
    background: #eff6ff;
    color: #2563eb;
}

.asistente-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #94a3b8;
}

.asistente-status.has-results .asistente-status-dot {
    background: #10b981;
}

.asistente-status.evaluating .asistente-status-dot {
    background: #2563eb;
}

/* Messages area */
.asistente-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 0;
    display: flex;
    flex-direction: column;
    gap: 20px;
    scroll-behavior: smooth;
}

/* Empty state */
.asistente-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: #94a3b8;
    gap: 16px;
}

.asistente-empty-icon {
    font-size: 3rem;
    opacity: 0.5;
}

.asistente-empty-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #64748b;
}

.asistente-empty-text {
    font-size: 0.85rem;
    max-width: 400px;
    line-height: 1.5;
}

.asistente-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-top: 12px;
}

.asistente-suggestion {
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid #e2e8f0;
    background: #fff;
    color: #475569;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.15s;
}

.asistente-suggestion:hover {
    background: #f1f5f9;
    border-color: #2563eb;
    color: #2563eb;
}

.asistente-suggestions-top {
    display: flex;
    gap: 8px;
    width: 100%;
}

.asistente-suggestion-top {
    flex: 1;
    text-align: center;
    font-weight: 600;
}

/* Message bubbles */
.asistente-msg {
    display: flex;
    gap: 12px;
    max-width: 85%;
    animation: asistente-fade-in 0.3s ease;
}

@keyframes asistente-fade-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.asistente-msg.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.asistente-msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.asistente-msg.user .asistente-msg-avatar {
    background: linear-gradient(135deg, #2563eb, #1e40af);
    color: #fff;
}

.asistente-msg.assistant .asistente-msg-avatar {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #fff;
}

.asistente-msg-content {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 0.85rem;
    line-height: 1.6;
    word-wrap: break-word;
}

.asistente-msg.user .asistente-msg-content {
    background: linear-gradient(135deg, #2563eb, #1e40af);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.asistente-msg.assistant .asistente-msg-content {
    background: #f8fafc;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
}

/* Markdown rendering inside assistant messages */
.asistente-msg.assistant .asistente-msg-content h3 {
    font-size: 0.9rem;
    font-weight: 700;
    margin: 12px 0 6px;
    color: #1e293b;
}

.asistente-msg.assistant .asistente-msg-content h3:first-child {
    margin-top: 0;
}

.asistente-msg.assistant .asistente-msg-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0;
    font-size: 0.8rem;
}

.asistente-msg.assistant .asistente-msg-content th,
.asistente-msg.assistant .asistente-msg-content td {
    padding: 6px 10px;
    border: 1px solid #e2e8f0;
    text-align: left;
}

.asistente-msg.assistant .asistente-msg-content th {
    background: #f1f5f9;
    font-weight: 600;
}

.asistente-msg.assistant .asistente-msg-content ul,
.asistente-msg.assistant .asistente-msg-content ol {
    padding-left: 20px;
    margin: 6px 0;
}

.asistente-msg.assistant .asistente-msg-content li {
    margin: 3px 0;
}

.asistente-msg.assistant .asistente-msg-content strong {
    font-weight: 600;
    color: #0f172a;
}

.asistente-msg.assistant .asistente-msg-content code {
    background: #e2e8f0;
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 0.78rem;
}

/* Tool call indicator */
.asistente-tool-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: #fffbeb;
    border-radius: 8px;
    border: 1px solid #fde68a;
    font-size: 0.75rem;
    color: #92400e;
    align-self: flex-start;
    animation: asistente-fade-in 0.2s ease;
}

.asistente-tool-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid #fde68a;
    border-top-color: #f59e0b;
    border-radius: 50%;
    animation: asistente-spin 0.8s linear infinite;
}

@keyframes asistente-spin {
    to { transform: rotate(360deg); }
}

/* Typing indicator */
.asistente-typing {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    align-self: flex-start;
}

.asistente-typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #94a3b8;
    animation: asistente-typing-bounce 1.4s infinite;
}

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

@keyframes asistente-typing-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* Excel download card */
.asistente-excel-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: linear-gradient(135deg, #ecfdf5, #d1fae5);
    border: 1px solid #6ee7b7;
    border-radius: 12px;
    margin-top: 8px;
    cursor: pointer;
    transition: all 0.15s;
}

.asistente-excel-card:hover {
    background: linear-gradient(135deg, #d1fae5, #a7f3d0);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.2);
}

.asistente-excel-icon {
    font-size: 1.5rem;
}

.asistente-excel-info {
    flex: 1;
}

.asistente-excel-title {
    font-weight: 600;
    font-size: 0.85rem;
    color: #065f46;
}

.asistente-excel-desc {
    font-size: 0.75rem;
    color: #047857;
}

/* Input area */
.asistente-input-area {
    padding: 12px 0 16px;
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.asistente-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: #fff;
    border: 2px solid #e2e8f0;
    border-radius: 16px;
    padding: 8px 12px;
    transition: border-color 0.2s;
}

.asistente-input-wrapper:focus-within {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.asistente-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 0.9rem;
    resize: none;
    max-height: 120px;
    min-height: 24px;
    line-height: 1.5;
    background: transparent;
    font-family: inherit;
    color: #1e293b;
}

.asistente-input::placeholder {
    color: #94a3b8;
}

.asistente-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #2563eb, #1e40af);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    flex-shrink: 0;
}

.asistente-send-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #1d4ed8, #1e3a8a);
    transform: scale(1.05);
}

.asistente-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.asistente-send-btn svg {
    width: 18px;
    height: 18px;
}

/* Map widget inside messages */
.asistente-map-container {
    margin: 10px 0;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
}

.asistente-map-canvas {
    width: 100%;
    height: 320px;
}

.asistente-map-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: #f0fdf4;
    border-top: 1px solid #bbf7d0;
    font-size: 0.8rem;
    font-weight: 600;
    color: #166534;
}

.asistente-map-confirm {
    padding: 6px 16px;
    background: linear-gradient(135deg, #10b981, #059669);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.asistente-map-confirm:hover:not(:disabled) {
    background: linear-gradient(135deg, #059669, #047857);
    transform: translateY(-1px);
}

.asistente-map-confirm:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.asistente-map-instructions {
    padding: 6px 12px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    font-size: 0.75rem;
    color: #64748b;
    text-align: center;
}

/* Chart container inside messages */
.asistente-chart-container {
    margin: 10px 0;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px;
}

.asistente-chart-container canvas {
    max-height: 300px;
}

/* Responsive */
@media (max-width: 768px) {
    .asistente-container {
        padding: 0 8px;
    }

    .asistente-msg {
        max-width: 95%;
    }

    .asistente-header {
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
    }

    .asistente-suggestions {
        flex-direction: column;
    }

    .asistente-suggestion {
        text-align: center;
    }

    .asistente-suggestions-top {
        flex-direction: column;
    }

    .asistente-map-canvas {
        height: 260px;
    }
}
