/* ===================================================
   PROFESSOR CHAT - Styles pour le chat interactif
   =================================================== */

/* === FLOATING CHAT BUTTON === */
.chat-button {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    transition: all 0.3s ease;
    z-index: 1000;
    animation: pulse 2s infinite;
}

.chat-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.6);
}

.chat-button.active {
    display: none;
    animation: none;
}

.chat-button.no-pulse {
    animation: none;
}

/* Mobile positioning */
@media (max-width: 768px) {
    .chat-button {
        top: auto;
        bottom: 20px;
        right: 20px;
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.85;
        transform: scale(1.05);
    }
}

/* === CHAT PANEL === */
.chat-panel {
    position: fixed;
    top: 0;
    right: -100%;
    width: 800px; /* Doublé de 400px à 800px */
    height: 100vh;
    background: white;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
    z-index: 999;
    display: flex;
    flex-direction: column;
    transition: right 0.3s ease;
}

.chat-panel.open {
    right: 0;
}

/* Desktop: resizable panel */
@media (min-width: 769px) {
    /* Visual resize handle */
    .chat-panel::before {
        content: '';
        position: absolute;
        left: 0;
        top: 0;
        width: 8px;
        height: 100%;
        background: linear-gradient(to right, rgba(99, 102, 241, 0.1), transparent);
        cursor: ew-resize;
        z-index: 1000;
    }

    .chat-panel:hover::before {
        background: linear-gradient(to right, rgba(99, 102, 241, 0.3), transparent);
    }

    .chat-panel.resizing::before {
        background: linear-gradient(to right, rgba(99, 102, 241, 0.5), transparent);
        width: 12px;
    }

    .chat-panel.resizing {
        user-select: none;
    }
}

/* Mobile full-screen */
@media (max-width: 768px) {
    .chat-panel {
        width: 100vw;
        border-radius: 0;
    }
}

/* === CHAT HEADER === */
.chat-header {
    background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    color: white;
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 60px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.chat-header-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.125rem;
    font-weight: 600;
}

.chat-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
    display: inline-block;
    animation: statusPulse 2s infinite;
}

@keyframes statusPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.chat-header-actions {
    display: flex;
    gap: 0.5rem;
}

.chat-header-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
    font-size: 1rem;
}

.chat-header-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* === MESSAGES AREA === */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    background: #f9fafb;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #c4b5fd;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a78bfa;
}

/* === MESSAGE BUBBLES === */
.message {
    display: flex;
    margin-bottom: 0.75rem;
    animation: messageFadeIn 0.3s ease;
}

@keyframes messageFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.user {
    justify-content: flex-end;
}

.message.professor {
    justify-content: flex-start;
}

.message-bubble {
    max-width: 85%;
    padding: 0.75rem 1rem;
    border-radius: 18px;
    word-wrap: break-word;
    line-height: 1.5;
}

.message.user .message-bubble {
    background: linear-gradient(to right, #6366f1, #9333ea);
    color: white;
    border-radius: 18px 18px 4px 18px;
}

.message.professor .message-bubble {
    background: white;
    color: #1f2937;
    border-radius: 18px 18px 18px 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Markdown styling in professor messages */
.message.professor .message-bubble p {
    margin: 0.5rem 0;
}

.message.professor .message-bubble p:first-child {
    margin-top: 0;
}

.message.professor .message-bubble p:last-child {
    margin-bottom: 0;
}

.message.professor .message-bubble code {
    background: #f3f4f6;
    color: #ec4899;
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9em;
}

.message.professor .message-bubble pre {
    background: #1f2937;
    color: #f3f4f6;
    padding: 0.875rem;
    border-radius: 0.5rem;
    overflow-x: auto;
    margin: 0.75rem 0;
}

.message.professor .message-bubble pre code {
    background: none;
    color: inherit;
    padding: 0;
    font-size: 0.875rem;
}

.message.professor .message-bubble ul,
.message.professor .message-bubble ol {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

.message.professor .message-bubble li {
    margin: 0.25rem 0;
}

.message.professor .message-bubble a {
    color: #4f46e5;
    text-decoration: underline;
}

.message.professor .message-bubble a:hover {
    color: #3730a3;
}

.message.professor .message-bubble strong {
    font-weight: 600;
    color: #111827;
}

.message.professor .message-bubble em {
    font-style: italic;
}

/* Timestamp */
.message-timestamp {
    font-size: 0.7rem;
    opacity: 0.6;
    margin-top: 0.25rem;
}

.message.user .message-timestamp {
    text-align: right;
}

/* === TYPING INDICATOR === */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: white;
    border-radius: 18px 18px 18px 4px;
    max-width: fit-content;
    color: #6b7280;
    font-size: 0.875rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.typing-dots {
    display: flex;
    gap: 0.25rem;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #9ca3af;
    animation: loadingDots 1.4s infinite;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes loadingDots {
    0%, 60%, 100% {
        opacity: 0.3;
        transform: scale(0.8);
    }
    30% {
        opacity: 1;
        transform: scale(1);
    }
}

/* === INPUT AREA === */
.chat-input-area {
    padding: 1rem 1.25rem;
    background: white;
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
}

.chat-input {
    flex: 1;
    border: 2px solid #e5e7eb;
    border-radius: 24px;
    padding: 0.75rem 1rem;
    font-size: 0.9375rem;
    font-family: inherit;
    resize: none;
    max-height: 120px;
    min-height: 44px;
    transition: border-color 0.2s ease;
    overflow-y: auto;
}

.chat-input:focus {
    outline: none;
    border-color: #a855f7;
}

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

.chat-send-btn {
    background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    color: white;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.chat-send-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

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

.chat-send-btn.sending {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* === PROFILE MODAL === */
.profile-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.profile-modal {
    background: white;
    border-radius: 1rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    width: 90vw;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.profile-modal-header {
    background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    color: white;
    padding: 1.5rem;
    border-radius: 1rem 1rem 0 0;
}

.profile-modal-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0 0 0.5rem 0;
}

.profile-modal-header p {
    margin: 0;
    opacity: 0.9;
    font-size: 0.9375rem;
}

.profile-modal-body {
    padding: 2rem;
}

.profile-form-group {
    margin-bottom: 1.5rem;
}

.profile-form-group label {
    display: block;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.5rem;
    font-size: 0.9375rem;
}

.profile-form-group label .required {
    color: #ef4444;
    margin-left: 0.25rem;
}

.profile-form-group input,
.profile-form-group select,
.profile-form-group textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 0.5rem;
    font-size: 0.9375rem;
    font-family: inherit;
    transition: border-color 0.2s ease;
}

.profile-form-group input:focus,
.profile-form-group select:focus,
.profile-form-group textarea:focus {
    outline: none;
    border-color: #a855f7;
}

.profile-form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.profile-form-group small {
    display: block;
    color: #6b7280;
    font-size: 0.8125rem;
    margin-top: 0.375rem;
}

.profile-form-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 2rem;
}

.profile-btn {
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.profile-btn-primary {
    background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    color: white;
}

.profile-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.profile-btn-secondary {
    background: #f3f4f6;
    color: #374151;
}

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

/* === ERROR BANNER === */
.error-banner {
    background: #fee2e2;
    color: #991b1b;
    padding: 1rem 1.25rem;
    margin: 1rem 1.25rem 0;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    animation: slideDown 0.3s ease;
}

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

.error-banner-content {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.error-banner-close {
    background: none;
    border: none;
    color: #991b1b;
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
    padding: 0.25rem;
}

.error-banner-close:hover {
    opacity: 0.7;
}

/* === WELCOME MESSAGE === */
.welcome-message {
    background: linear-gradient(135deg, #eef2ff 0%, #f3e8ff 100%);
    border: 2px solid #c4b5fd;
    border-radius: 0.75rem;
    padding: 1.5rem;
    margin: 1rem 0;
    text-align: center;
}

.welcome-message h3 {
    color: #4f46e5;
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0 0 0.75rem 0;
}

.welcome-message p {
    color: #4b5563;
    margin: 0.5rem 0;
    font-size: 0.9375rem;
}

.welcome-message .emoji {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

/* === EMPTY STATE === */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 2rem;
    text-align: center;
    color: #6b7280;
}

.empty-state .emoji {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.empty-state h3 {
    color: #374151;
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0 0 0.5rem 0;
}

.empty-state p {
    margin: 0;
    font-size: 0.9375rem;
}

/* === RESPONSIVE ADJUSTMENTS === */
@media (max-width: 480px) {
    .chat-input-area {
        padding: 0.75rem 1rem;
    }

    .profile-modal-body {
        padding: 1.5rem;
    }

    .message-bubble {
        max-width: 90%;
    }
}

/* === ACCESSIBILITY === */
.chat-button:focus-visible,
.chat-header-btn:focus-visible,
.chat-send-btn:focus-visible,
.profile-btn:focus-visible {
    outline: 3px solid #a855f7;
    outline-offset: 2px;
}

.chat-input:focus-visible {
    outline: 3px solid #a855f7;
    outline-offset: -1px;
}

/* === UTILITY CLASSES === */
.hidden {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}
