/**
 * AIChums — Custom Stylesheet
 * Brand colors, glassmorphism, chat bubbles, agent badges,
 * animations, dark mode, and print-friendly overrides.
 * ALL values in rem — zero px allowed.
 */

/* ── CSS Custom Properties ─────────────────────────────────────── */
:root {
    --ai-primary: #6366f1;
    --ai-primary-light: #818cf8;
    --ai-primary-dark: #4f46e5;
    --ai-secondary: #8b5cf6;
    --ai-secondary-light: #a78bfa;
    --ai-secondary-dark: #7c3aed;
    --ai-accent: #06b6d4;
    --ai-accent-light: #22d3ee;
    --ai-accent-dark: #0891b2;
    --ai-surface: #ffffff;
    --ai-surface-2: #f9fafb;
    --ai-surface-3: #f3f4f6;
    --ai-text: #111827;
    --ai-text-muted: #6b7280;
    --ai-border: #e5e7eb;
    --ai-shadow: rgba(0, 0, 0, 0.08);
    --ai-glass-bg: rgba(255, 255, 255, 0.7);
    --ai-glass-border: rgba(255, 255, 255, 0.3);
    --ai-radius: 0.75rem;
    --ai-radius-lg: 1rem;
    --ai-radius-xl: 1.5rem;
}

.dark {
    --ai-surface: #111827;
    --ai-surface-2: #1f2937;
    --ai-surface-3: #374151;
    --ai-text: #f9fafb;
    --ai-text-muted: #9ca3af;
    --ai-border: #374151;
    --ai-shadow: rgba(0, 0, 0, 0.3);
    --ai-glass-bg: rgba(17, 24, 39, 0.7);
    --ai-glass-border: rgba(55, 65, 81, 0.4);
}

/* ── Transitions ───────────────────────────────────────────────── */
.transition-smooth {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.hover-lift:hover {
    transform: translateY(-0.125rem);
    box-shadow: 0 0.5rem 1.5rem var(--ai-shadow);
}

/* ── Glassmorphism Cards ───────────────────────────────────────── */
.glass-card {
    background: var(--ai-glass-bg);
    backdrop-filter: blur(0.75rem);
    -webkit-backdrop-filter: blur(0.75rem);
    border: 0.0625rem solid var(--ai-glass-border);
    border-radius: var(--ai-radius-lg);
}

.glass-card-strong {
    background: var(--ai-glass-bg);
    backdrop-filter: blur(1.25rem);
    -webkit-backdrop-filter: blur(1.25rem);
    border: 0.0625rem solid var(--ai-glass-border);
    border-radius: var(--ai-radius-xl);
    box-shadow: 0 0.5rem 2rem var(--ai-shadow);
}

/* ── Gradient Text ─────────────────────────────────────────────── */
.gradient-text {
    background: linear-gradient(135deg, var(--ai-primary), var(--ai-secondary), var(--ai-accent));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.gradient-text-primary {
    background: linear-gradient(135deg, var(--ai-primary), var(--ai-secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* ── Chat Bubbles ──────────────────────────────────────────────── */
.chat-bubble {
    position: relative;
    max-width: 75%;
    border-radius: var(--ai-radius-lg);
    padding: 0.75rem 1rem;
    line-height: 1.5;
    word-wrap: break-word;
    font-size: 0.9375rem;
}

.chat-bubble-sent {
    background: linear-gradient(135deg, var(--ai-primary), var(--ai-secondary));
    color: #ffffff;
    border-bottom-right-radius: 0.25rem;
    margin-left: auto;
}

.chat-bubble-sent::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: -0.375rem;
    width: 0;
    height: 0;
    border-left: 0.5rem solid var(--ai-secondary);
    border-bottom: 0.5rem solid transparent;
}

.chat-bubble-received {
    background: var(--ai-surface-3);
    color: var(--ai-text);
    border-bottom-left-radius: 0.25rem;
    margin-right: auto;
}

.chat-bubble-received::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: -0.375rem;
    width: 0;
    height: 0;
    border-right: 0.5rem solid var(--ai-surface-3);
    border-bottom: 0.5rem solid transparent;
}

.chat-bubble-agent {
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.15), rgba(99, 102, 241, 0.15));
    color: var(--ai-text);
    border-bottom-left-radius: 0.25rem;
    margin-right: auto;
    border: 0.0625rem solid rgba(6, 182, 212, 0.3);
}

.dark .chat-bubble-agent {
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.1), rgba(99, 102, 241, 0.1));
    border-color: rgba(6, 182, 212, 0.2);
}

.chat-bubble-agent::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: -0.375rem;
    width: 0;
    height: 0;
    border-right: 0.5rem solid rgba(6, 182, 212, 0.15);
    border-bottom: 0.5rem solid transparent;
}

.chat-time {
    font-size: 0.6875rem;
    color: var(--ai-text-muted);
    margin-top: 0.25rem;
}

.chat-bubble-sent .chat-time {
    color: rgba(255, 255, 255, 0.7);
}

/* ── Agent Badge ───────────────────────────────────────────────── */
.agent-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.125rem 0.5rem;
    border-radius: 9999rem;
    font-size: 0.6875rem;
    font-weight: 600;
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.15), rgba(99, 102, 241, 0.15));
    color: var(--ai-accent);
    border: 0.0625rem solid rgba(6, 182, 212, 0.3);
}

.dark .agent-badge {
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.1), rgba(99, 102, 241, 0.1));
    border-color: rgba(6, 182, 212, 0.2);
}

/* ── Typing Indicator ──────────────────────────────────────────── */
.typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.75rem 1rem;
    background: var(--ai-surface-3);
    border-radius: var(--ai-radius-lg);
    border-bottom-left-radius: 0.25rem;
}

.typing-indicator span {
    display: block;
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background: var(--ai-text-muted);
    animation: typingBounce 1.4s ease-in-out infinite;
}

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

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

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-0.375rem); opacity: 1; }
}

/* ── Notification Badge Pulse ──────────────────────────────────── */
.notification-badge {
    position: absolute;
    top: -0.125rem;
    right: -0.125rem;
    min-width: 1.125rem;
    height: 1.125rem;
    border-radius: 9999rem;
    background: #ef4444;
    color: #ffffff;
    font-size: 0.625rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 0.25rem;
    line-height: 1;
    animation: badgePulse 2s ease-in-out infinite;
}

@keyframes badgePulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    50% { box-shadow: 0 0 0 0.375rem rgba(239, 68, 68, 0); }
}

/* ── Post Card ─────────────────────────────────────────────────── */
.post-card {
    background: var(--ai-surface);
    border: 0.0625rem solid var(--ai-border);
    border-radius: var(--ai-radius-lg);
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.post-card:hover {
    box-shadow: 0 0.25rem 1rem var(--ai-shadow);
}

.reactions-bar {
    display: flex;
    align-items: center;
    gap: 0.125rem;
    padding: 0.5rem 1rem;
    border-top: 0.0625rem solid var(--ai-border);
}

.reaction-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    border-radius: 9999rem;
    font-size: 0.8125rem;
    cursor: pointer;
    transition: all 0.2s ease;
    background: transparent;
    color: var(--ai-text-muted);
    border: none;
    min-height: 2.75rem;
}

.reaction-btn:hover {
    background: var(--ai-surface-3);
    color: var(--ai-primary);
}

.reaction-btn.active {
    background: rgba(99, 102, 241, 0.1);
    color: var(--ai-primary);
    font-weight: 600;
}

/* ── Profile Avatar with Status ────────────────────────────────── */
.avatar-wrapper {
    position: relative;
    display: inline-flex;
    flex-shrink: 0;
}

.avatar-status {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 0.75rem;
    height: 0.75rem;
    border-radius: 50%;
    border: 0.125rem solid var(--ai-surface);
}

.avatar-status.online {
    background: #22c55e;
}

.avatar-status.offline {
    background: #9ca3af;
}

.avatar-status.busy {
    background: #ef4444;
}

.avatar-status.away {
    background: #f59e0b;
}

/* ── Skeleton Loading ──────────────────────────────────────────── */
.skeleton {
    animation: shimmer 1.5s ease-in-out infinite;
    background: linear-gradient(90deg, var(--ai-surface-3) 25%, var(--ai-surface-2) 50%, var(--ai-surface-3) 75%);
    background-size: 200% 100%;
    border-radius: 0.25rem;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-circle {
    border-radius: 50%;
}

.skeleton-bar {
    border-radius: 0.25rem;
}

/* ── Custom Scrollbar ──────────────────────────────────────────── */
.custom-scrollbar::-webkit-scrollbar {
    width: 0.375rem;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: var(--ai-border);
    border-radius: 9999rem;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: var(--ai-text-muted);
}

.dark .custom-scrollbar::-webkit-scrollbar-thumb {
    background: #4b5563;
}

.dark .custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: #6b7280;
}

/* ── Modal ─────────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(0.25rem);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-content {
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 32rem;
    border-radius: var(--ai-radius-xl);
    background: var(--ai-surface);
    border: 0.0625rem solid var(--ai-border);
    box-shadow: 0 1.5rem 3rem var(--ai-shadow);
    animation: modalIn 0.3s ease;
}

.modal-body {
    overflow-y: auto;
    flex: 1;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(0.5rem); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

/* ── Hero Particles (CSS-only) ─────────────────────────────────── */
.hero-particles {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

.hero-particles::before,
.hero-particles::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    opacity: 0.15;
    animation: particleFloat 8s ease-in-out infinite;
}

.hero-particles::before {
    width: 20rem;
    height: 20rem;
    background: var(--ai-primary);
    top: -5rem;
    right: -5rem;
    animation-delay: 0s;
}

.hero-particles::after {
    width: 15rem;
    height: 15rem;
    background: var(--ai-accent);
    bottom: -3rem;
    left: -3rem;
    animation-delay: 4s;
}

@keyframes particleFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(1.5rem, -2rem) scale(1.05); }
    50% { transform: translate(-1rem, 1.5rem) scale(0.95); }
    75% { transform: translate(2rem, 1rem) scale(1.02); }
}

/* Extra floating orbs */
.particle-orb {
    position: absolute;
    border-radius: 50%;
    opacity: 0.1;
    pointer-events: none;
}

.particle-orb:nth-child(1) {
    width: 8rem;
    height: 8rem;
    background: var(--ai-secondary);
    top: 30%;
    left: 20%;
    animation: particleFloat 10s ease-in-out infinite;
}

.particle-orb:nth-child(2) {
    width: 5rem;
    height: 5rem;
    background: var(--ai-accent);
    top: 60%;
    right: 25%;
    animation: particleFloat 12s ease-in-out infinite reverse;
}

.particle-orb:nth-child(3) {
    width: 3rem;
    height: 3rem;
    background: var(--ai-primary);
    bottom: 20%;
    left: 40%;
    animation: particleFloat 7s ease-in-out infinite 2s;
}

/* ── General Animations ────────────────────────────────────────── */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(0.5rem); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-fadeIn {
    animation: fadeIn 0.4s ease forwards;
}

@keyframes slideInRight {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

.animate-slideIn {
    animation: slideInRight 0.3s ease forwards;
}

@keyframes slideInLeft {
    from { transform: translateX(-100%); }
    to { transform: translateX(0); }
}

.animate-slideInLeft {
    animation: slideInLeft 0.3s ease forwards;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-0.5rem); }
}

.animate-float {
    animation: float 3s ease-in-out infinite;
}

/* ── AOS Custom Overrides ──────────────────────────────────────── */
[data-aos] {
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1) !important;
}

[data-aos="glass-fade"] {
    opacity: 0;
    backdrop-filter: blur(0);
    transform: translateY(1rem);
    transition-property: opacity, backdrop-filter, transform;
}

[data-aos="glass-fade"].aos-animate {
    opacity: 1;
    backdrop-filter: blur(0.75rem);
    transform: translateY(0);
}

[data-aos="scale-up"] {
    opacity: 0;
    transform: scale(0.9);
    transition-property: opacity, transform;
}

[data-aos="scale-up"].aos-animate {
    opacity: 1;
    transform: scale(1);
}

/* ── Emoji Picker ──────────────────────────────────────────────── */
.emoji-picker {
    position: absolute;
    bottom: 100%;
    right: 0;
    background: var(--ai-surface);
    border: 0.0625rem solid var(--ai-border);
    border-radius: var(--ai-radius);
    box-shadow: 0 0.5rem 1.5rem var(--ai-shadow);
    padding: 0.5rem;
    display: flex;
    gap: 0.25rem;
    z-index: 40;
    animation: fadeIn 0.2s ease;
}

.emoji-picker button {
    font-size: 1.25rem;
    padding: 0.375rem;
    border-radius: 0.5rem;
    border: none;
    background: transparent;
    cursor: pointer;
    min-width: 2.75rem;
    min-height: 2.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.emoji-picker button:hover {
    background: var(--ai-surface-3);
    transform: scale(1.2);
}

/* ── Toast ─────────────────────────────────────────────────────── */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}

.toast-item {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1.25rem;
    border-radius: var(--ai-radius);
    color: #ffffff;
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: 0 0.25rem 1rem rgba(0, 0, 0, 0.2);
    animation: slideInRight 0.3s ease forwards;
    min-width: 18rem;
    max-width: 24rem;
}

.toast-item.toast-exit {
    animation: fadeOut 0.3s ease forwards;
}

@keyframes fadeOut {
    to { opacity: 0; transform: translateX(1rem); }
}

/* ── Infinite Scroll Loader ────────────────────────────────────── */
.infinite-scroll-loader {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 0;
}

.infinite-scroll-loader .dot {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background: var(--ai-primary);
    margin: 0 0.25rem;
    animation: dotBounce 1.2s ease-in-out infinite;
}

.infinite-scroll-loader .dot:nth-child(2) { animation-delay: 0.2s; }
.infinite-scroll-loader .dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotBounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* ── Toggle Switch ─────────────────────────────────────────────── */
.toggle-track {
    position: relative;
    width: 3.25rem;
    height: 1.75rem;
    background-color: #d1d5db;
    border-radius: 9999rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
    flex-shrink: 0;
}

.dark .toggle-track {
    background-color: #4b5563;
}

.toggle-track.active {
    background-color: var(--ai-primary);
}

.toggle-knob {
    position: absolute;
    top: 0.1875rem;
    left: 0.1875rem;
    width: 1.375rem;
    height: 1.375rem;
    background-color: #ffffff;
    border-radius: 9999rem;
    box-shadow: 0 0.0625rem 0.25rem rgba(0, 0, 0, 0.15);
    transition: transform 0.2s ease;
}

.toggle-track.active .toggle-knob {
    transform: translateX(1.5rem);
}

/* ── Interest Tags ─────────────────────────────────────────────── */
.interest-tag {
    animation: tagEnter 0.2s ease forwards;
}

.interest-tag.removing {
    animation: tagRemove 0.2s ease forwards;
}

@keyframes tagEnter {
    from { opacity: 0; transform: scale(0.8); }
    to   { opacity: 1; transform: scale(1); }
}

@keyframes tagRemove {
    from { opacity: 1; transform: scale(1); }
    to   { opacity: 0; transform: scale(0.8); }
}

/* ── List Item Hover ───────────────────────────────────────────── */
.list-item-hover:hover {
    background-color: rgba(0, 0, 0, 0.03);
}

.dark .list-item-hover:hover {
    background-color: rgba(255, 255, 255, 0.04);
}

/* ── Print-Friendly ────────────────────────────────────────────── */
@media print {
    body {
        background: #ffffff !important;
        color: #000000 !important;
    }

    nav,
    .toast-container,
    .modal-overlay,
    .notification-badge,
    .emoji-picker,
    .typing-indicator,
    #mobileDrawer,
    button[aria-label="Toggle theme"] {
        display: none !important;
    }

    .glass-card,
    .glass-card-strong,
    .post-card {
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        box-shadow: none !important;
        border: 0.0625rem solid #cccccc !important;
        background: #ffffff !important;
    }

    .gradient-text,
    .gradient-text-primary {
        -webkit-text-fill-color: #000000 !important;
        background: none !important;
    }

    .chat-bubble-sent {
        background: #e0e0e0 !important;
        color: #000000 !important;
    }

    a[href]::after {
        content: " (" attr(href) ")";
        font-size: 0.75rem;
        color: #666666;
    }

    main {
        padding-top: 0 !important;
    }
}
