/* Alpine.js cloak */
[x-cloak] { display: none !important; }

/* Site-first navigation shell */
summary.list-none::-webkit-details-marker { display: none; }
summary.list-none { list-style: none; }
.pb-safe { padding-bottom: env(safe-area-inset-bottom, 0px); }
header [data-nav-brand="true"]:focus-visible,
header a:focus-visible,
header button:focus-visible,
header summary:focus-visible {
    outline: 2px solid #0d9488;
    outline-offset: 2px;
}

/* HTMX loading states */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline-flex; }
.htmx-indicator-skeleton { display: none; }
.htmx-request .htmx-indicator-skeleton { display: block; }
.htmx-request.htmx-swap-content > .htmx-content-area { display: none; }

/* Skeleton loaders */
@keyframes skeleton-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.45; }
}
.skeleton-pulse { animation: skeleton-pulse 1.5s ease-in-out infinite; }
.skeleton-bar { background-color: #e2e8f0; border-radius: 0.5rem; }
.skeleton-block { background-color: #e2e8f0; border-radius: 0.75rem; }

/* Animations */
.fade-in { animation: fadeIn 0.3s ease-in-out; }
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}
.slide-in { animation: slideIn 0.2s ease-out; }
@keyframes slideIn {
    from { opacity: 0; transform: translateX(-10px); }
    to { opacity: 1; transform: translateX(0); }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .fade-in, .slide-in, .skeleton-pulse { animation: none; }
}

/* LTR fields for English/numeric input */
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="url"],
input[type="date"],
input[type="datetime-local"],
.field-ltr {
    direction: ltr;
    text-align: left;
}

/* Form field base styling */
.field-input {
    display: block;
    width: 100%;
    padding: 0.625rem 1rem;
    border: 1px solid #cbd5e1;
    border-radius: 0.75rem;
    font-size: 0.875rem;
    color: #0f172a;
    background-color: #fff;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field-input::placeholder { color: #94a3b8; }
.field-input:focus {
    outline: none;
    border-color: #0d9488;
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}

/* Card hover polish */
.card-interactive {
    transition: box-shadow 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}
.card-interactive:hover {
    box-shadow: 0 4px 20px -2px rgba(15, 23, 42, 0.06), 0 2px 10px -1px rgba(15, 23, 42, 0.04);
    transform: translateY(-1px);
}

/* Chat bubble text overflow fix */
#chat-messages { overflow-wrap: break-word; word-wrap: break-word; }
#chat-messages p { word-break: break-word; overflow-wrap: anywhere; hyphens: auto; }
#chat-messages .min-w-0 { overflow: hidden; }

/* Chat bubble variants */
.chat-bubble-me {
    background-color: #ccfbf1;
    border: 1px solid #99f6e4;
    border-radius: 1rem;
    border-top-right-radius: 0.25rem;
}
.chat-bubble-other {
    background-color: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 1rem;
    border-top-left-radius: 0.25rem;
}
.chat-bubble-admin {
    background-color: #f0fdfa;
    border: 1px solid #99f6e4;
    border-radius: 1rem;
}
.chat-bubble-client {
    background-color: #ecfdf5;
    border: 1px solid #a7f3d0;
    border-radius: 1rem;
}

/* Custom Scrollbar - Firefox */
.scrollbar-visible { scrollbar-width: thin; scrollbar-color: #94a3b8 #e2e8f0; }
/* Custom Scrollbar - Chrome, Safari, Edge */
.scrollbar-visible::-webkit-scrollbar { -webkit-appearance: none; width: 12px; height: 12px; display: block !important; }
.scrollbar-visible::-webkit-scrollbar-track { background: #e2e8f0; border-radius: 6px; }
.scrollbar-visible::-webkit-scrollbar-thumb { background: #64748b; border-radius: 6px; border: 3px solid #e2e8f0; min-height: 40px; }
.scrollbar-visible::-webkit-scrollbar-thumb:hover { background: #475569; }
.scrollbar-visible::-webkit-scrollbar-corner { background: #e2e8f0; }

/* Markdown Styles */
.markdown-body { font-size: 0.875rem; line-height: 1.6; }
.markdown-body p { margin-bottom: 0.5em; }
.markdown-body p:last-child { margin-bottom: 0; }
.markdown-body a { color: #0d9488; text-decoration: underline; }
.markdown-body ul { list-style-type: disc; padding-right: 1.5em; padding-left: 0; margin-bottom: 0.5em; }
.markdown-body ol { list-style-type: decimal; padding-right: 1.5em; padding-left: 0; margin-bottom: 0.5em; }
.markdown-body code { background-color: rgba(0,0,0,0.05); padding: 0.2em 0.4em; border-radius: 3px; font-family: monospace; direction: ltr; display: inline-block; }
.markdown-body pre { background-color: #f1f5f9; padding: 0.8em; border-radius: 0.5em; overflow-x: auto; margin-bottom: 0.5em; direction: ltr; text-align: left; }
.markdown-body pre code { background-color: transparent; padding: 0; direction: ltr; }
.markdown-body blockquote { border-right: 4px solid #cbd5e1; border-left: none; padding-right: 1em; padding-left: 0; color: #64748b; font-style: italic; }
[dir="rtl"] .markdown-body { text-align: right; direction: rtl; }
[dir="rtl"] .markdown-body p { text-align: right; }
[dir="rtl"] .markdown-body h1, [dir="rtl"] .markdown-body h2, [dir="rtl"] .markdown-body h3 { text-align: right; }

/* Emoji Picker Styles */
emoji-picker {
    width: 100%;
    max-width: 350px;
    height: 300px;
    --border-radius: 0.75rem;
    --background: #ffffff;
}

/* Toast notifications — fixed overlay, no layout shift */
.toast-host {
    position: fixed;
    top: max(1rem, env(safe-area-inset-top));
    inset-inline: 0;
    z-index: 9999;
    display: flex;
    justify-content: center;
    padding-inline: 1rem;
    pointer-events: none;
}
.toast-host--hub {
    top: calc(60px + 0.75rem);
}
.toast {
    width: min(100%, 24rem);
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    border-radius: 0.875rem;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(15, 23, 42, 0.08);
    box-shadow:
        0 16px 40px -12px rgba(15, 23, 42, 0.22),
        0 4px 12px rgba(15, 23, 42, 0.06);
    pointer-events: auto;
}
.toast--success { border-inline-start: 3px solid #16a34a; }
.toast--error   { border-inline-start: 3px solid #e11d48; }
.toast--warning { border-inline-start: 3px solid #d97706; }
.toast--info    { border-inline-start: 3px solid #0284c7; }
.toast__icon {
    flex-shrink: 0;
    width: 2rem;
    height: 2rem;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.toast--success .toast__icon { background: #dcfce7; color: #15803d; }
.toast--error   .toast__icon { background: #ffe4e6; color: #be123c; }
.toast--warning .toast__icon { background: #fef3c7; color: #b45309; }
.toast--info    .toast__icon { background: #e0f2fe; color: #0369a1; }
.toast__message {
    flex: 1;
    min-width: 0;
    margin: 0;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.45;
    color: #0f172a;
}
.toast__close {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 0.5rem;
    color: #94a3b8;
    transition: color 0.15s ease, background-color 0.15s ease;
}
.toast__close:hover {
    color: #475569;
    background-color: rgba(15, 23, 42, 0.06);
}
.toast-progress-track {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background-color: rgba(15, 23, 42, 0.06);
}
.toast-progress-bar {
    height: 100%;
    transition: width 0.1s linear;
}
.toast--success .toast__progress-fill { background-color: #16a34a; opacity: 0.55; }
.toast--error   .toast__progress-fill { background-color: #e11d48; opacity: 0.55; }
.toast--warning .toast__progress-fill { background-color: #d97706; opacity: 0.55; }
.toast--info    .toast__progress-fill { background-color: #0284c7; opacity: 0.55; }

@media (prefers-reduced-motion: reduce) {
    .toast-host[x-transition] { transition: none !important; }
}
