/**
 * UNICEF Chatbot - Custom Styles
 */

/* Hide elements with x-cloak until Alpine.js loads */
[x-cloak] {
    display: none !important;
}

/* Smooth transitions for all interactive elements */
* {
    -webkit-tap-highlight-color: transparent;
}

button, a, input, textarea {
    transition: all 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Custom scrollbar */
.messages-container::-webkit-scrollbar {
    width: 6px;
}

.messages-container::-webkit-scrollbar-track {
    background: transparent;
}

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

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

/* Firefox scrollbar */
.messages-container {
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

/* Message bubble tails */
.message-user {
    position: relative;
}

.message-user::after {
    content: '';
    position: absolute;
    right: -6px;
    top: 0;
    width: 0;
    height: 0;
    border-left: 8px solid #1CABE2;
    border-top: 8px solid transparent;
    border-bottom: 0;
}

.message-assistant {
    position: relative;
}

.message-assistant::after {
    content: '';
    position: absolute;
    left: -6px;
    top: 0;
    width: 0;
    height: 0;
    border-right: 8px solid white;
    border-top: 8px solid transparent;
    border-bottom: 0;
}

/* Typing indicator animation */
@keyframes bounce {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-4px);
    }
}

.animate-bounce {
    animation: bounce 1.2s infinite;
}

/* Code block styling */
.code-block {
    background-color: #1f2937;
    color: #e5e7eb;
    padding: 12px 16px;
    border-radius: 8px;
    margin: 8px 0;
    overflow-x: auto;
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    line-height: 1.5;
}

.code-block code {
    background: none;
    padding: 0;
    font-size: inherit;
}

.inline-code {
    background-color: #e5e7eb;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.875em;
}

.message-user .inline-code {
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
}

/* Message content styles */
.message-content strong {
    font-weight: 600;
}

.message-content em {
    font-style: italic;
}

/* Focus styles */
textarea:focus {
    outline: none;
}

button:focus {
    outline: none;
}

button:focus-visible {
    outline: 2px solid #1CABE2;
    outline-offset: 2px;
}

/* Safe area for mobile devices with notches */
.safe-area-bottom {
    padding-bottom: max(12px, env(safe-area-inset-bottom));
}

/* Mobile optimizations */
@media (max-width: 640px) {
    .max-w-2xl {
        max-width: 100%;
        border-radius: 0;
    }

    button, input, textarea {
        min-height: 44px;
        font-size: 16px; /* Prevent iOS zoom */
    }

    .message-content {
        font-size: 15px;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .message-assistant {
        border: 2px solid #374151;
    }

    .message-user {
        border: 2px solid #1CABE2;
    }
}

/* Print styles */
@media print {
    header, form {
        display: none !important;
    }

    .messages-container {
        overflow: visible !important;
        height: auto !important;
    }
}

/* Chat background pattern (subtle) */
.messages-container {
    background-image:
        radial-gradient(circle at 25% 25%, rgba(28, 171, 226, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 75% 75%, rgba(55, 78, 162, 0.03) 0%, transparent 50%);
}

/* Pulse animation for connection indicator */
@keyframes pulse-ring {
    0% {
        transform: scale(0.8);
        opacity: 1;
    }
    100% {
        transform: scale(2);
        opacity: 0;
    }
}

/* Shadow utilities */
.shadow-message {
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Textarea auto-resize smooth */
textarea {
    overflow-y: hidden;
    resize: none;
}

/* Tool call details styling */
.tool-call-details {
    transition: all 150ms ease;
}

.tool-call-details summary {
    list-style: none;
}

.tool-call-details summary::-webkit-details-marker {
    display: none;
}

.tool-call-details summary::marker {
    display: none;
}

/* Chevron rotation when open */
.tool-call-details[open] .chevron-icon {
    transform: rotate(90deg);
}

/* Tool call code blocks */
.tool-call-details pre {
    font-size: 11px;
    line-height: 1.4;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Subtle animation for tool call appearance */
@keyframes toolCallFadeIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tool-call-details {
    animation: toolCallFadeIn 200ms ease-out;
}
