:root {
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --surface-color: #ffffff;
    --bg-color: #f8fafc;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --message-user-bg: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    --message-fusikab-bg: #f8fafc;
    --glow-color: rgba(99, 102, 241, 0.5);
    --neon-shadow: 0 0 10px var(--glow-color), 0 0 20px var(--glow-color), 0 0 30px var(--glow-color);
}

body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    min-height: 100vh;
    background:
        radial-gradient(circle at top right, rgba(99, 102, 241, 0.1), transparent 40%),
        radial-gradient(circle at bottom left, rgba(79, 70, 229, 0.1), transparent 40%),
        linear-gradient(135deg, #EEF2FF 0%, #F5F3FF 100%);
    margin: 0;
    background-attachment: fixed;
}

.chat-container {
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--surface-color);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.navbar {
    background: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem;
}

.model-selector {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.model-selector label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-select {
    min-width: 200px;
    border-radius: 0.75rem;
    border-color: var(--border-color);
    padding: 0.8rem 1rem;
    font-size: 0.975rem;
    background-color: var(--bg-color);
}

.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.btn-outline-primary {
    border-color: var(--border-color);
    color: var(--text-primary);
    border-radius: 0.75rem;
    padding: 0.8rem 1.5rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-outline-primary:hover {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    border-color: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--neon-shadow);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    background:
        radial-gradient(circle at top right, rgba(99, 102, 241, 0.05), transparent 50%),
        radial-gradient(circle at bottom left, rgba(79, 70, 229, 0.05), transparent 50%);
}

.welcome-message {
    text-align: center;
    margin: auto;
    max-width: 600px;
    animation: fadeIn 0.5s ease-out;
}

.welcome-message h1 {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 1rem;
    background: var(--message-user-bg);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.welcome-message p {
    color: var(--text-secondary);
    font-size: 1.1rem;
    line-height: 1.6;
}

.message {
    max-width: 80%;
    padding: 1rem 1.25rem;
    animation: messageAppear 0.3s ease-out;
    position: relative;
    line-height: 1.6;
}

.message.user {
    background: var(--message-user-bg);
    color: white;
    align-self: flex-end;
    border-radius: 1.25rem 1.25rem 0.25rem 1.25rem;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
    animation: glow 2s ease-in-out infinite alternate;
}

.message.fusikab {
    background: var(--message-fusikab-bg);
    color: var(--text-primary);
    align-self: flex-start;
    border-radius: 1.25rem 1.25rem 1.25rem 0.25rem;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    backdrop-filter: blur(10px);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.message-content {
    font-size: 1rem;
    white-space: pre-wrap;
}

.message-time {
    font-size: 0.75rem;
    margin-top: 0.5rem;
    opacity: 0.8;
}

.message.user .message-time {
    color: rgba(255, 255, 255, 0.9);
}

.message.fusikab .message-time {
    color: var(--text-secondary);
}

.chat-input {
    background: var(--surface-color);
    border-top: 1px solid var(--border-color);
    padding: 1.5rem;
}

.input-container {
    position: relative;
}

.form-control {
    border-radius: 1rem !important;
    border-color: var(--border-color);
    padding: 1rem 3rem 1rem 1.25rem !important;
    font-size: 1rem;
    resize: none;
    max-height: 200px;
    background: var(--bg-color);
    transition: all 0.2s ease;
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
    outline: none;
}

.char-counter {
    position: absolute;
    right: 1rem;
    bottom: 1rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    opacity: 0.7;
    pointer-events: none;
}

.btn-primary {
    background: var(--message-user-bg);
    border: none;
    padding: 1rem 2rem;
    border-radius: 1rem;
    font-weight: 600;
    transition: all 0.2s ease;
    height: 100%;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.loading {
    display: flex;
    gap: 0.5rem;
    padding: 0.5rem;
    justify-content: center;
}

.loading span {
    width: 8px;
    height: 8px;
    background: var(--primary-color);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.loading span:nth-child(1) { animation-delay: -0.32s; }
.loading span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

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

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes glow {
    from {
        box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
    }
    to {
        box-shadow: var(--neon-shadow);
    }
}

.message.fusikab:hover {
    transform: translateX(5px);
}

.btn-primary, .btn-outline-primary {
    position: relative;
    overflow: hidden;
}

/* Accessibility improvements */
:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.btn:focus {
    box-shadow: var(--neon-shadow);
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

.modal-dialog {
    animation: slideIn 0.3s ease-out;
}

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

/* High contrast mode */
@media (prefers-contrast: more) {
    :root {
        --primary-color: #0000ff;
        --primary-dark: #0000cc;
        --text-primary: #000000;
        --text-secondary: #333333;
        --border-color: #000000;
    }

    .message.user {
        background: var(--primary-color);
        box-shadow: none;
        border: 2px solid #000;
    }

    .message.fusikab {
        background: #ffffff;
        border: 2px solid #000;
    }
}

/* Better visibility for tooltips */
.tooltip {
    --bs-tooltip-bg: var(--primary-dark);
    --bs-tooltip-color: white;
    font-size: 0.875rem;
}

/* Loading animation with better visibility */
.loading span {
    box-shadow: 0 0 5px var(--glow-color);
}

/* Focus visible utility */
.focus-visible:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Improved scrollbar */
.chat-messages::-webkit-scrollbar {
    width: 10px;
}

.chat-messages::-webkit-scrollbar-track {
    background: var(--bg-color);
    border-radius: 5px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 5px;
    opacity: 0.8;
    transition: opacity 0.3s ease;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    opacity: 1;
}

.btn-primary::after, .btn-outline-primary::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 300%;
    height: 300%;
    background: radial-gradient(circle, rgba(255,255,255,0.2) 0%, transparent 50%);
    transform: translate(-50%, -50%) scale(0);
    opacity: 0;
    transition: transform 0.8s ease-out, opacity 0.5s ease-out;
}

.btn-primary:hover::after, .btn-outline-primary:hover::after {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

.modal-content {
    backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, 0.95);
    border: none;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.form-control:focus, .form-select:focus {
    box-shadow: 0 0 0 3px var(--glow-color);
    animation: input-glow 1s ease-out;
}

@keyframes input-glow {
    0% {
        box-shadow: 0 0 0 0 var(--glow-color);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(99, 102, 241, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(99, 102, 241, 0);
    }
}

/* Media Queries */
@media (max-width: 768px) {
    .chat-messages {
        padding: 1rem;
    }

    .message {
        max-width: 90%;
        padding: 0.875rem 1rem;
    }

    .navbar {
        padding: 0.75rem;
    }

    .form-select {
        min-width: 160px;
    }

    .btn-outline-primary {
        padding: 0.6rem 1rem;
    }

    .welcome-message h1 {
        font-size: 2rem;
    }

    .chat-input {
        padding: 1rem;
    }
}
