/* Custom styles for Oryx Chat - Enhanced UI/UX with Dark Green Theme */
:root {
    --primary-color: #133B54;      /* Bleu foncé pour couleur principale */
    --secondary-color: #0078b4;    /* Bleu moyen pour accent secondaire */
    --accent-color: #0096dd;       /* Bleu clair pour accent */
    --text-primary: #333333;
    --text-secondary: #555555;
    --bot-bubble-color: #e4eef5;   /* Bleu très clair pour bulles du bot */
    --user-bubble-color: #f7f7f7;  /* Blanc cassé pour bulles utilisateur */
    --bot-bubble-gradient: linear-gradient(135deg, #e4eef5, #ccdcea);
    --user-bubble-gradient: linear-gradient(135deg, #f8f9fa, #edf2f7);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.05), 0 4px 6px rgba(0, 0, 0, 0.05);
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
    --z-index-negative: -10;
    --z-index-base: 1;
    --z-index-dropdown: 10;
    --z-index-modal: 50;
    --z-index-top: 100;
}

/* Animation Keyframes */
@keyframes blob {
    0% {
        transform: translate(0px, 0px) scale(1);
    }
    33% {
        transform: translate(30px, -50px) scale(1.1);
    }
    66% {
        transform: translate(-20px, 20px) scale(0.9);
    }
    100% {
        transform: translate(0px, 0px) scale(1);
    }
}

/* Utility Classes for Animations */
.animate-blob {
    animation: blob 7s infinite;
}

.animation-delay-2000 {
    animation-delay: 2s;
}

.animation-delay-4000 {
    animation-delay: 4s;
}

/* Text Gradient Animation */
@keyframes gradient-text {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.gradient-text {
    background-size: 200% auto;
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
    animation: gradient-text 3s ease-in-out infinite;
    background-image: linear-gradient(45deg, var(--primary-color), var(--secondary-color), var(--accent-color), var(--primary-color));
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
    transition: background var(--transition-fast);
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

#chat-messages {
    scroll-behavior: smooth;
    overflow-y: auto;
    padding: 2rem 1rem;
    scroll-padding-bottom: 2rem;
}

#chat-messages .message {
    margin-bottom: 2rem;
    padding: 1.5rem;
    border-radius: 1.2rem;
    opacity: 0;
    transform: translateY(20px);
    animation: messageAppear 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    max-width: 85%;
    box-shadow: var(--shadow-md);
    word-wrap: break-word;
    overflow-wrap: break-word;
    box-sizing: border-box;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

#chat-messages .message:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

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

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(37, 99, 235, 0); }
    100% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0); }
}

#chat-messages .message.user {
    background: var(--user-bubble-gradient);
    margin-left: auto;
    border-top-right-radius: 0.3rem;
    border-bottom-right-radius: 1.2rem;
    border-bottom-left-radius: 1.2rem;
    border-top-left-radius: 1.2rem;
    position: relative;
}

#chat-messages .message.user::after {
    content: '';
    position: absolute;
    top: 0;
    right: -0.5rem;
    width: 1rem;
    height: 1rem;
    background: linear-gradient(135deg, #f8f9fa 0%, #f8f9fa 50%, transparent 50%, transparent 100%);
    transform: rotate(45deg);
    border-radius: 0.1rem;
}

#chat-messages .message.bot {
    background: var(--bot-bubble-gradient);
    margin-right: auto;
    border-top-left-radius: 0.3rem;
    border-bottom-right-radius: 1.2rem;
    border-bottom-left-radius: 1.2rem;
    border-top-right-radius: 1.2rem;
    position: relative;
}

#chat-messages .message.bot::after {
    content: '';
    position: absolute;
    top: 0;
    left: -0.5rem;
    width: 1rem;
    height: 1rem;
    background: linear-gradient(225deg, #e4eef5 0%, #e4eef5 50%, transparent 50%, transparent 100%);
    transform: rotate(45deg);
    border-radius: 0.1rem;
}

.message.bot img {
    width: 4rem;
    height: 4rem;
    object-fit: cover;
    border-radius: 50%;
    box-shadow: var(--shadow-md);
    border: 2px solid white;
    transition: transform var(--transition-fast);
    animation: pulseAvatar 4s infinite;
}

@keyframes pulseAvatar {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.message.bot img:hover {
    transform: scale(1.1) rotate(5deg);
}

/* Message content styling */
.message .content {
    line-height: 1.8;
    margin: 0;
    color: var(--text-primary);
    font-size: 1rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
    hyphens: auto;
    transition: color var(--transition-fast);
}

.message.bot .content {
    color: #1a365d;
}

/* Headers in messages */
.message h1, .message h2, .message h3 {
    margin: 1.5rem 0 1rem;
    color: #1a365d;
    font-weight: 600;
    line-height: 1.4;
}

.message h1:first-child,
.message h2:first-child,
.message h3:first-child {
    margin-top: 0;
}

/* Tables in messages */
.message table {
    width: 100%;
    margin: 1.5rem 0;
    border-collapse: collapse;
    background: white;
    border-radius: 0.5rem;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.message table th {
    background: #f8fafc;
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid #e5e7eb;
}

.message table td {
    padding: 1rem;
    border-bottom: 1px solid #e5e7eb;
}

.message table tr:last-child td {
    border-bottom: none;
}

/* Code blocks in messages */
.message pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 1.25rem;
    border-radius: 0.5rem;
    overflow-x: auto;
    margin: 1.5rem 0;
    max-width: 100%;
    font-size: 0.9em;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.message code {
    font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', Menlo, monospace;
    font-size: 0.95em;
}

.message p code {
    background: #f1f5f9;
    color: #0f172a;
    padding: 0.2em 0.4em;
    border-radius: 0.25rem;
}

/* Lists in messages */
.message ul, .message ol {
    margin: 1.25rem 0;
    padding-left: 1.75rem;
}

.message ul li, .message ol li {
    margin: 0.75rem 0;
    padding-left: 0.5rem;
}

.message ul {
    list-style-type: disc;
}

.message ol {
    list-style-type: decimal;
}

/* Blockquotes in messages */
.message blockquote {
    border-left: 4px solid #3b82f6;
    margin: 1.5rem 0;
    padding: 1rem 1.5rem;
    background: #f8fafc;
    border-radius: 0 0.5rem 0.5rem 0;
    font-style: italic;
    color: #4a5568;
}

/* Form elements - Enhanced */
input[type="text"],
input[type="password"],
input[type="email"] {
    transition: all var(--transition-normal);
    width: 100%;
    padding: 0.9rem 1.2rem;
    border: 1px solid #e5e7eb;
    border-radius: 1.2rem;
    background-color: white;
    font-size: 1rem;
    box-shadow: var(--shadow-sm);
}

input[type="text"]:hover,
input[type="password"]:hover,
input[type="email"]:hover {
    border-color: #d1d5db;
    box-shadow: var(--shadow-md);
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
    outline: none;
    transform: translateY(-1px);
}

button {
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
}

button::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 5px;
    height: 5px;
    background: rgba(255, 255, 255, 0.5);
    opacity: 0;
    border-radius: 100%;
    transform: scale(1, 1) translate(-50%, -50%);
    transform-origin: 50% 50%;
}

@keyframes ripple {
    0% {
        transform: scale(0, 0);
        opacity: 0.5;
    }
    100% {
        transform: scale(100, 100);
        opacity: 0;
    }
}

button:focus::after {
    animation: ripple 1s ease-out;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

button:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

/* Chat form specific styling */
footer {
    background: rgba(255, 255, 255, 0.9) !important;
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(229, 231, 235, 0.8);
    box-shadow: 0 -5px 10px rgba(0, 0, 0, 0.02);
}

#chat-form {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: 1.2rem;
    background: white;
    box-shadow: var(--shadow-md);
    margin: 0.5rem 0;
    transition: all var(--transition-normal);
}

#chat-form:focus-within {
    box-shadow: var(--shadow-lg), 0 0 0 3px rgba(59, 130, 246, 0.15);
    transform: translateY(-2px);
}

#chat-form textarea {
    border: none;
    box-shadow: none;
    background: transparent;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    font-family: inherit;
    line-height: 1.5;
    overflow-y: auto;
    overflow-x: hidden;
}

#chat-form textarea:focus {
    box-shadow: none;
    transform: none;
    outline: none;
}

#chat-form button[type="submit"] {
    background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
    color: white;
    border-radius: 1rem;
    padding: 0.75rem 1.5rem;
    font-weight: 500;
    transition: all var(--transition-fast);
}

#chat-form button[type="submit"]:hover {
    background: linear-gradient(to right, var(--primary-color), var(--accent-color));
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

#voice-input-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 50%;
    background: #f3f4f6;
    color: #6b7280;
    transition: all var(--transition-normal);
}

#voice-input-btn:hover {
    background: #e5e7eb;
    color: var(--primary-color);
    transform: rotate(5deg);
}

/* Responsive adjustments */
@media (max-width: 640px) {
    body {
        font-size: 14px;
    }

    .container {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }

    #chat-messages {
        padding: 1rem 0.5rem;
    }

    #chat-messages .message {
        max-width: 95%;
        margin-left: 0.25rem;
        margin-right: 0.25rem;
        padding: 0.875rem;
        width: auto;
        box-sizing: border-box;
    }

    .message.bot img {
        width: 2rem;
        height: 2rem;
    }

    .message table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
        font-size: 0.9em;
    }

    .message pre {
        padding: 0.75rem;
        font-size: 0.85em;
        max-width: 100%;
        overflow-x: auto;
    }

    .message h1 {
        font-size: 1.5em;
    }

    .message h2 {
        font-size: 1.25em;
    }

    .message h3 {
        font-size: 1.1em;
    }

    /* Mobile-specific form adjustments */
    input[type="text"],
    input[type="password"],
    input[type="email"] {
        padding: 0.625rem 0.875rem;
        font-size: 1rem;
    }

    button {
        padding: 0.625rem 1rem;
        font-size: 0.875rem;
    }

    /* Fix chat input on mobile */
    #chat-form {
        padding: 0.5rem;
        gap: 0.5rem;
    }

    #chat-form input {
        font-size: 1rem;
        padding: 0.75rem;
    }

    #chat-form button {
        padding: 0.75rem 1rem;
        min-width: 4rem;
    }
}

/* Tablet adjustments */
@media (min-width: 641px) and (max-width: 1024px) {
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    #chat-messages .message {
        max-width: 90%;
    }

    .message table {
        font-size: 0.95em;
    }
}

/* Enhanced Utility classes */
.text-gradient {
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
    background-image: linear-gradient(to right, #133B54, #0078b4);
}

/* Feedback buttons and modals enhancement */
.feedback-btn {
    transition: all var(--transition-normal);
    position: relative;
    border-radius: 1rem;
    padding: 0.5rem 1rem;
    font-weight: 500;
    letter-spacing: 0.25px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border: 1px solid #e5e7eb;
    background: white;
}

.feedback-btn:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: var(--shadow-md);
}

/* Positive feedback button */
.feedback-btn.positive:hover {
    background: #ecfdf5;
    color: #047857;
    border-color: #a7f3d0;
}

/* Negative feedback button */
.feedback-btn.negative:hover {
    background: #fef2f2;
    color: #b91c1c;
    border-color: #fecaca;
}

/* Enhanced tooltip style */
.feedback-btn .tooltip {
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%) scale(0.95);
    background: rgba(17, 24, 39, 0.9);
    color: white;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    box-shadow: var(--shadow-lg);
    transition: all var(--transition-normal);
    z-index: 10;
}

.feedback-btn .tooltip::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 50%;
    transform: translateX(-50%) rotate(45deg);
    width: 10px;
    height: 10px;
    background: rgba(17, 24, 39, 0.9);
}

.feedback-btn:hover .tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) scale(1);
}

/* Modal enhancements */
#feedbackModal, #successAlert {
    backdrop-filter: blur(8px);
}

#feedbackModal .bg-white {
    border-radius: 1.5rem;
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.2), 0 5px 15px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    transition: all var(--transition-normal);
    transform: scale(0.98);
    opacity: 0;
    animation: modalAppear 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes modalAppear {
    from {
        transform: scale(0.95);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

#successAlert {
    transform: translateY(-20px);
    opacity: 0;
    transition: all 0.5s cubic-bezier(0.68, -0.6, 0.32, 1.6);
}

#successAlert.show {
    transform: translateY(0);
    opacity: 1;
}

#successAlert > div {
    border-radius: 1rem;
    box-shadow: var(--shadow-lg);
    transition: all var(--transition-normal);
}

#successAlert > div:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
}

/* Voice status indicator */
#voice-status {
    border-radius: 1rem;
    background: rgba(17, 24, 39, 0.85);
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(8px);
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform: translateY(10px) translateX(-50%);
}

#voice-status.show {
    opacity: 1 !important;
    transform: translateY(0) translateX(-50%);
}

/* Recording indicator pulse animation */
.recording-indicator {
    animation: recordingPulse 1.5s infinite;
}

@keyframes recordingPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

/* Enhanced Header with Dark Green Theme */
header {
    background: linear-gradient(135deg, #133B54 0%, #2270a3 100%) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 100;
    transition: all var(--transition-normal);
}

header:hover {
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18) !important;
}

header .container {
    padding: 0.75rem 1.5rem;
}

header img {
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 2px solid rgba(255, 255, 255, 0.2);
    box-shadow: var(--shadow-md);
}

header img:hover {
    transform: scale(1.1) rotate(5deg);
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.3);
}

header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    letter-spacing: 0.5px;
    transition: all var(--transition-normal);
}

header a, header button {
    transition: all var(--transition-fast);
    padding: 0.6rem 1rem;
    border-radius: 0.8rem;
    font-weight: 500;
    position: relative;
    overflow: hidden;
    border: 1px solid transparent;
}

header a:hover, header button:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

header a:active, header button:active {
    transform: translateY(0);
    box-shadow: none;
}

header .user-info {
    color: rgba(255, 255, 255, 0.85);
    font-weight: 500;
}

/* Header adjustments for mobile */
@media (max-width: 640px) {
    header .container {
        padding: 0.5rem 1rem;
    }

    header h1 {
        font-size: 1.25rem;
    }

    header .user-info {
        font-size: 0.875rem;
    }

    header button, header a {
        padding: 0.5rem 0.75rem !important;
        font-size: 0.875rem;
    }
    
    /* Improve spacing in navigation on mobile */
    header .flex.items-center.space-x-4 {
        gap: 0.5rem !important;
    }
}

/* Safe area insets for modern mobile browsers */
@supports(padding: max(0px)) {
    .footer {
        padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
    }

    header {
        padding-top: max(0.5rem, env(safe-area-inset-top));
    }
    
    #chat-messages {
        padding-bottom: max(2rem, env(safe-area-inset-bottom) + 1rem);
    }
    
    .safe-area-inset-bottom {
        padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
    }
}