/**
 * Chatbot Widget CSS - Phase 3
 * Styles complets pour widget assistant multi-spécialité
 *
 * Features:
 * - Design moderne et responsive
 * - Animations fluides
 * - Thème adaptable (light/dark)
 * - Accessibilité (ARIA, keyboard navigation)
 */

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

.chatbot-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 420px;
    max-width: calc(100vw - 40px);
    max-height: 680px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.chatbot-widget[data-widget-state="minimized"] {
    max-height: 64px;
}

.chatbot-widget[data-widget-state="hidden"] {
    display: none;
}

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

.chatbot-widget-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px 20px;
    border-radius: 16px 16px 0 0;
    cursor: pointer;
    user-select: none;
    flex-shrink: 0;
}

.chatbot-header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chatbot-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chatbot-icon {
    font-size: 24px;
    animation: chatbot-wave 2s ease-in-out infinite;
}

@keyframes chatbot-wave {
    0%, 100% { transform: rotate(0deg); }
    10%, 30% { transform: rotate(14deg); }
    20%, 40% { transform: rotate(-8deg); }
    50% { transform: rotate(0deg); }
}

.chatbot-title {
    font-weight: 600;
    font-size: 16px;
}

.chatbot-specialty-badge {
    background: rgba(255, 255, 255, 0.2);
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    transition: background 0.2s;
}

.chatbot-header-actions {
    display: flex;
    gap: 8px;
}

.chatbot-btn-icon {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.2s;
    font-size: 16px;
    line-height: 1;
}

.chatbot-btn-icon:hover {
    background: rgba(255, 255, 255, 0.2);
}

.chatbot-btn-icon:active {
    transform: scale(0.95);
}

/* ==================== */
/* BODY                 */
/* ==================== */

.chatbot-widget-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f9fafb;
}

/* Custom scrollbar */
.chatbot-widget-body::-webkit-scrollbar {
    width: 6px;
}

.chatbot-widget-body::-webkit-scrollbar-track {
    background: transparent;
}

.chatbot-widget-body::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

.chatbot-widget-body::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* ==================== */
/* SPECIALTY SELECTOR   */
/* ==================== */

.chatbot-specialty-selector {
    text-align: center;
    padding: 8px;
}

.chatbot-selector-title {
    font-size: 18px;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 8px;
}

.chatbot-selector-subtitle {
    font-size: 13px;
    color: #6b7280;
    margin-bottom: 20px;
}

.chatbot-specialties-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

.chatbot-specialty-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: white;
    border: 2px solid #e5e7eb;
    border-left: 4px solid #667eea;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.chatbot-specialty-card:hover {
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
    transform: translateY(-2px);
}

.chatbot-specialty-icon {
    font-size: 32px;
    flex-shrink: 0;
}

.chatbot-specialty-info {
    flex: 1;
}

.chatbot-specialty-name {
    font-weight: 600;
    font-size: 14px;
    color: #1f2937;
    margin-bottom: 4px;
}

.chatbot-specialty-desc {
    font-size: 12px;
    color: #6b7280;
}

.chatbot-or-divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 20px 0;
}

.chatbot-or-divider::before,
.chatbot-or-divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid #e5e7eb;
}

.chatbot-or-divider span {
    padding: 0 12px;
    font-size: 12px;
    color: #9ca3af;
    text-transform: uppercase;
    font-weight: 500;
}

.chatbot-btn-primary {
    width: 100%;
    padding: 12px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.chatbot-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.chatbot-btn-primary:active {
    transform: translateY(0);
}

/* ==================== */
/* MESSAGES             */
/* ==================== */

.chatbot-messages-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chatbot-messages-scroll {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 4px;
}

.chatbot-message {
    display: flex;
    gap: 12px;
    animation: chatbot-message-enter 0.3s ease;
}

@keyframes chatbot-message-enter {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chatbot-message-user {
    flex-direction: row-reverse;
}

.chatbot-message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.chatbot-message-user .chatbot-message-avatar {
    background: #10b981;
}

.chatbot-message-content {
    flex: 1;
    max-width: 75%;
}

.chatbot-message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.chatbot-message-role {
    font-size: 12px;
    font-weight: 600;
    color: #667eea;
}

.chatbot-message-user .chatbot-message-role {
    color: #10b981;
}

.chatbot-message-time {
    font-size: 11px;
    color: #9ca3af;
}

.chatbot-message-text {
    background: white;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    color: #1f2937;
    line-height: 1.6;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.chatbot-message-user .chatbot-message-text {
    background: #10b981;
    color: white;
}

.chatbot-message-tools {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    font-size: 11px;
    color: #6b7280;
}

.chatbot-tools-icon {
    font-size: 14px;
}

/* ==================== */
/* CHAIN OF THOUGHT     */
/* ==================== */

.chatbot-cot-steps {
    background: white;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    animation: chatbot-slide-in 0.3s ease;
}

@keyframes chatbot-slide-in {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.chatbot-cot-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.chatbot-cot-icon {
    font-size: 20px;
}

.chatbot-cot-title {
    font-weight: 600;
    font-size: 14px;
    color: #1f2937;
}

.chatbot-cot-steps-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chatbot-cot-step {
    display: flex;
    gap: 12px;
    padding: 12px;
    background: #f9fafb;
    border-radius: 8px;
    border-left: 3px solid #10b981;
}

.chatbot-cot-step.error {
    border-left-color: #ef4444;
}

.chatbot-cot-step-number {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #10b981;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
}

.chatbot-cot-step.error .chatbot-cot-step-number {
    background: #ef4444;
}

.chatbot-cot-step-content {
    flex: 1;
}

.chatbot-cot-step-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    color: #1f2937;
    margin-bottom: 4px;
}

.chatbot-cot-step-tool {
    font-size: 11px;
    color: #6b7280;
    font-style: italic;
}

.chatbot-cot-step-time {
    font-size: 10px;
    color: #9ca3af;
    margin-top: 4px;
}

/* ==================== */
/* SUGGESTIONS          */
/* ==================== */

.chatbot-suggestions {
    background: white;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.chatbot-suggestions-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.chatbot-suggestions-icon {
    font-size: 18px;
}

.chatbot-suggestions-title {
    font-weight: 600;
    font-size: 13px;
    color: #1f2937;
}

.chatbot-suggestions-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chatbot-suggestion-btn {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    padding: 10px 14px;
    border-radius: 8px;
    text-align: left;
    font-size: 13px;
    color: #1f2937;
    cursor: pointer;
    transition: all 0.2s;
}

.chatbot-suggestion-btn:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
    transform: translateX(4px);
}

/* ==================== */
/* INPUT AREA           */
/* ==================== */

.chatbot-input-area {
    background: white;
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05);
}

.chatbot-input-wrapper {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.chatbot-input {
    flex: 1;
    min-height: 40px;
    max-height: 120px;
    padding: 10px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    color: #1f2937;
    resize: none;
    transition: border-color 0.2s;
}

.chatbot-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.chatbot-input::placeholder {
    color: #9ca3af;
}

.chatbot-input-actions {
    display: flex;
    gap: 4px;
}

.chatbot-btn-send {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chatbot-btn-send:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.chatbot-btn-send:active {
    transform: scale(0.95);
}

.chatbot-btn-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.chatbot-char-counter {
    font-size: 11px;
    color: #9ca3af;
    text-align: right;
    margin-top: 4px;
}

/* ==================== */
/* FEEDBACK             */
/* ==================== */

.chatbot-feedback-panel {
    background: white;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    text-align: center;
}

.chatbot-feedback-title {
    font-size: 13px;
    font-weight: 500;
    color: #1f2937;
    margin-bottom: 12px;
}

.chatbot-feedback-stars {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 12px;
}

.chatbot-star {
    background: none;
    border: none;
    font-size: 32px;
    cursor: pointer;
    transition: all 0.2s;
    filter: grayscale(100%);
    opacity: 0.3;
}

.chatbot-star:hover,
.chatbot-star.hover {
    filter: grayscale(0%);
    opacity: 1;
    transform: scale(1.2);
}

.chatbot-star.selected {
    filter: grayscale(0%);
    opacity: 1;
}

.chatbot-feedback-comment {
    margin-top: 12px;
}

.chatbot-feedback-comment textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    color: #1f2937;
    resize: vertical;
    margin-bottom: 12px;
}

.chatbot-btn-secondary {
    background: #f3f4f6;
    color: #1f2937;
    border: 1px solid #e5e7eb;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.chatbot-btn-secondary:hover {
    background: #e5e7eb;
}

/* ==================== */
/* HISTORY              */
/* ==================== */

.chatbot-history-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.chatbot-history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.chatbot-history-title {
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
}

.chatbot-history-filters {
    margin-bottom: 16px;
}

.chatbot-select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 13px;
    color: #1f2937;
    background: white;
}

.chatbot-history-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chatbot-history-item {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.chatbot-history-item:hover {
    border-color: #667eea;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.15);
}

.chatbot-history-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.chatbot-history-specialty {
    font-size: 11px;
    font-weight: 600;
    color: #667eea;
    text-transform: uppercase;
}

.chatbot-history-date {
    font-size: 11px;
    color: #9ca3af;
}

.chatbot-history-item-title {
    font-size: 13px;
    font-weight: 500;
    color: #1f2937;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chatbot-history-item-meta {
    font-size: 11px;
    color: #6b7280;
}

.chatbot-history-empty {
    text-align: center;
    padding: 40px 20px;
}

.chatbot-empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.chatbot-empty-text {
    font-size: 14px;
    color: #6b7280;
}

/* ==================== */
/* LOADING              */
/* ==================== */

.chatbot-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 24px;
}

.chatbot-loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: chatbot-spin 1s linear infinite;
}

@keyframes chatbot-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.chatbot-loading-text {
    font-size: 13px;
    color: #6b7280;
}

/* ==================== */
/* ERROR                */
/* ==================== */

.chatbot-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 24px;
    background: #fef2f2;
    border-radius: 12px;
    text-align: center;
}

.chatbot-error-icon {
    font-size: 48px;
}

.chatbot-error-message {
    font-size: 14px;
    color: #991b1b;
    font-weight: 500;
}

/* ==================== */
/* FOOTER               */
/* ==================== */

.chatbot-widget-footer {
    background: white;
    border-top: 1px solid #e5e7eb;
    padding: 12px 20px;
    border-radius: 0 0 16px 16px;
    flex-shrink: 0;
}

.chatbot-footer-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 11px;
    color: #9ca3af;
}

.chatbot-footer-link {
    color: #667eea;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.chatbot-footer-link:hover {
    color: #764ba2;
    text-decoration: underline;
}

.chatbot-footer-separator {
    color: #d1d5db;
}

/* ==================== */
/* FLOATING BUTTON      */
/* ==================== */

.chatbot-floating-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    font-size: 28px;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chatbot-floating-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.chatbot-floating-btn:active {
    transform: scale(1.05);
}

.chatbot-floating-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    animation: chatbot-pulse 2s ease-in-out infinite;
}

@keyframes chatbot-pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
}

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

@media (max-width: 768px) {
    .chatbot-widget {
        width: 100%;
        max-width: 100%;
        height: 100vh;
        max-height: 100vh;
        bottom: 0;
        right: 0;
        border-radius: 0;
    }

    .chatbot-floating-btn {
        bottom: 16px;
        right: 16px;
        width: 56px;
        height: 56px;
        font-size: 24px;
    }
}

/* ==================== */
/* ACCESSIBILITY        */
/* ==================== */

.chatbot-widget *:focus-visible {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* Reduce motion for users with preference */
@media (prefers-reduced-motion: reduce) {
    .chatbot-widget,
    .chatbot-widget *,
    .chatbot-floating-btn {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
