/* Custom Scrollbar */
.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

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

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

/* Smooth scrolling for all scrollable elements */
.custom-scrollbar {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* Sidebar Transition */
.sidebar-transition {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reasoning Toggle Icon */
.rotate-90 {
    transform: rotate(90deg);
}

/* Reasoning Gradient Border */
.reasoning-gradient-border {
    background: linear-gradient(135deg, rgba(242, 0, 0, 0.35) 0%, rgba(255, 107, 53, 0.35) 100%);
    padding: 2px;
    border-radius: 0.5rem;
}

.reasoning-gradient-border button {
    border-radius: calc(0.5rem - 2px);
}

/* Base Styles */
body {
    background-color: #f9fafb;
    color: #111827;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    overscroll-behavior: contain;
}

/* Markdown Styling for AI responses */
.markdown-body {
    line-height: 1.6;
}

.markdown-body pre {
    background-color: #1f2937;
    padding: 1rem;
    border-radius: 0.5rem;
    margin: 1rem 0;
    overflow-x: auto;
}

.markdown-body code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.875rem;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

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

/* Input Focus */
.input-focus:focus {
    border-color: rgba(255, 255, 255, 0.3);
    outline: none;
}

/* No Gradients */
.bg-gradient-to-r, .bg-gradient-to-b, .bg-gradient-to-tr {
    background-image: none !important;
}

/* Thinking Animation */
.thinking-animation {
    display: inline-flex;
    gap: 4px;
    padding: 12px 16px;
}

.thinking-dot {
    width: 8px;
    height: 8px;
    background-color: #6b7280;
    border-radius: 50%;
    animation: thinkingBounce 1.4s infinite ease-in-out both;
}

.thinking-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.thinking-dot:nth-child(2) {
    animation-delay: -0.16s;
}

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

/* Chat Container - Prevent horizontal scroll */
#chatContainer {
    overflow-x: hidden;
}

#messagesContainer {
    overflow-x: hidden;
}

/* Message Spacing */
.message-wrapper {
    margin-bottom: 1.5rem;
    max-width: 100%;
    overflow-x: hidden;
}

.user-message {
    background: linear-gradient(135deg, #2f2f2f 0%, #3a3a3a 100%);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.assistant-message {
    background: transparent;
    max-width: 100%;
}

/* Improved message containers */
.message-content {
    word-wrap: break-word;
    overflow-wrap: break-word;
    overflow-x: auto;
    max-width: 100%;
}

.message-content p {
    margin-bottom: 0.75rem;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content pre,
.message-content .code-block-wrapper {
    overflow-x: auto;
    max-width: 100%;
}

/* Markdown Styling */
.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4,
.message-content h5,
.message-content h6 {
    font-weight: 600;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    color: #111827;
}

.message-content h1 { font-size: 1.5rem; }
.message-content h2 { font-size: 1.3rem; }
.message-content h3 { font-size: 1.1rem; }

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

.message-content li {
    margin: 0.25rem 0;
}

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

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

.message-content blockquote {
    border-left: 3px solid #d1d5db;
    padding-left: 1rem;
    margin: 1rem 0;
    color: #6b7280;
    font-style: italic;
}

.message-content code {
    background: #f3f4f6;
    padding: 0.15rem 0.4rem;
    border-radius: 0.25rem;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9em;
    color: #991b1b;
}

.message-content pre {
    background: transparent;
    border-radius: 0;
    padding: 0;
    margin: 0;
    overflow: hidden;
    border: none;
}

.message-content pre code {
    display: block;
    padding: 1rem;
    overflow-x: auto;
    overflow-y: hidden;
    background: transparent;
    color: inherit;
    font-size: 0.875rem;
    line-height: 1.5;
    max-width: 100%;
    white-space: pre;
}

.message-content a {
    color: #2563eb;
    text-decoration: underline;
}

.message-content a:hover {
    color: #1d4ed8;
}

.message-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    display: block;
    overflow-x: auto;
}

.message-content th,
.message-content td {
    border: 1px solid #e5e7eb;
    padding: 0.5rem;
    text-align: left;
    white-space: nowrap;
}

.message-content th {
    background: #f3f4f6;
    font-weight: 600;
}

.message-content hr {
    border: none;
    border-top: 1px solid #e5e7eb;
    margin: 1.5rem 0;
}

/* Code Block Header */
.code-block-wrapper {
    margin: 1.25rem 0;
    border-radius: 0.75rem;
    overflow: hidden;
    background: #0b0f19;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.2), 0 8px 10px -6px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.code-block-wrapper:hover {
    box-shadow: 0 12px 30px -5px rgba(0, 0, 0, 0.25), 0 10px 15px -6px rgba(0, 0, 0, 0.25);
}

.code-block-wrapper pre {
    margin: 0;
    background: transparent;
    overflow-x: auto;
}

.code-block-wrapper pre code {
    color: #e2e8f0;
    background: transparent;
    padding: 1.25rem;
    display: block;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.875rem;
    line-height: 1.7;
}

/* Custom Scrollbar for Code Blocks */
.code-block-wrapper pre::-webkit-scrollbar {
    height: 8px;
    width: 8px;
}

.code-block-wrapper pre::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

.code-block-wrapper pre::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.code-block-wrapper pre::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

.message-content .code-block-wrapper:first-child {
    margin-top: 0;
}

.message-content .code-block-wrapper:last-child {
    margin-bottom: 0;
}
.code-header {
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    padding: 0.625rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    color: #94a3b8;
    font-family: inherit;
    letter-spacing: 0.025em;
    user-select: none;
}

.code-header span {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-weight: 500;
}

.copy-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.35rem 0.85rem;
    border-radius: 0.5rem;
    color: #e2e8f0;
    cursor: pointer;
    font-size: 0.7rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.copy-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

.copy-btn:active {
    transform: translateY(0);
}

.copy-btn.copied {
    background: #059669;
    color: white;
    border-color: transparent;
}


/* Valentine Creative Styling */
.valentine-hearts {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 0;
}

.valentine-badge {
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.valentine-input-glow {
    position: relative;
}

.valentine-input-glow::before {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 1.75rem;
    padding: 2px;
    background: linear-gradient(45deg, transparent, rgba(236, 72, 153, 0.3), transparent);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    animation: valentine-glow 3s ease-in-out infinite;
    opacity: 0;
}

.valentine-input-glow.valentine-active::before {
    opacity: 1;
    animation: valentine-glow-active 2s ease-in-out infinite;
}

@keyframes valentine-glow {
    0%, 100% { opacity: 0; }
    50% { opacity: 0.5; }
}

@keyframes valentine-glow-active {
    0%, 100% { 
        opacity: 0.6;
        background: linear-gradient(45deg, rgba(236, 72, 153, 0.2), rgba(236, 72, 153, 0.5), rgba(236, 72, 153, 0.2));
    }
    50% { 
        opacity: 1;
        background: linear-gradient(45deg, rgba(236, 72, 153, 0.4), rgba(236, 72, 153, 0.8), rgba(236, 72, 153, 0.4));
    }
}

/* Sample Prompts Styling */
.sample-prompt-btn {
    cursor: pointer;
    white-space: normal;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    position: relative;
    display: inline-block;
}

.sample-prompt-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(255, 255, 255, 0.1);
}

.sample-prompt-btn::before {
    content: '→';
    position: absolute;
    left: 0.75rem;
    opacity: 0;
    transition: all 0.2s;
}

.sample-prompt-btn:hover::before {
    opacity: 1;
    left: 0.5rem;
}

#samplePrompts {
    animation: slideIn 0.3s ease-out;
}

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

@media (max-width: 768px) {
    .sample-prompt-btn {
        font-size: 0.7rem;
        padding: 0.5rem 0.75rem;
        line-height: 1.3;
    }
}

/* Valentine Modal Styling */
.valentine-modal-container {
    animation: valentineModalIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.valentine-float-btn {
    animation: btnPulse 2s ease-in-out infinite;
}

@keyframes btnPulse {
    0%, 100% {
        box-shadow: 0 4px 14px rgba(236, 72, 153, 0.4);
    }
    50% {
        box-shadow: 0 4px 20px rgba(236, 72, 153, 0.7);
    }
}

.valentine-fab {
    box-shadow: 0 4px 20px rgba(236, 72, 153, 0.6);
    animation: fabPulse 2s ease-in-out infinite;
}

@keyframes fabPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 4px 20px rgba(236, 72, 153, 0.6);
    }
    50% {
        transform: scale(1.1);
        box-shadow: 0 6px 30px rgba(236, 72, 153, 0.9);
    }
}

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

.valentine-bg-heart {
    position: absolute;
    font-size: 2rem;
    opacity: 0.2;
    animation: floatHeart 4s ease-in-out infinite;
}

@keyframes floatHeart {
    0%, 100% {
        transform: translateY(0) rotate(0deg);
    }
    50% {
        transform: translateY(-20px) rotate(10deg);
    }
}

.valentine-option-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(236, 72, 153, 0.3);
    border-radius: 1rem;
    padding: 1.5rem 1rem;
    text-align: center;
    color: white;
    transition: all 0.3s;
    cursor: pointer;
    backdrop-filter: blur(10px);
}

.valentine-option-btn:hover {
    background: rgba(236, 72, 153, 0.2);
    border-color: rgba(236, 72, 153, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(236, 72, 153, 0.3);
}

/* Settings Tab Styles */
.settings-tab {
    transition: all 0.2s ease;
}

.settings-tab.active {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
}

.settings-tab:not(.active) {
    color: rgba(255, 255, 255, 0.7);
}

.settings-tab:not(.active):hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: white;
}

.settings-content {
    animation: fadeIn 0.2s ease-in;
}

/* Preset Card Styles */
.preset-card {
    transition: all 0.2s ease;
    cursor: pointer;
}

.preset-card:hover {
    transform: translateY(-2px);
}

.preset-card:active {
    transform: translateY(0);
}

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

    #sidebar {
        width: 80%;
        max-width: 280px;
    }

    .message-wrapper {
        margin-bottom: 1rem;
    }

    .max-w-\[85\%\] {
        max-width: 95%;
    }

    .user-message, .assistant-message {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }

    .code-header {
        font-size: 0.65rem;
        padding: 0.4rem 0.75rem;
    }

    .message-content pre code {
        font-size: 0.75rem;
        padding: 0.75rem;
    }

    #messageInput {
        font-size: 14px;
    }

    .valentine-option-btn {
        padding: 1rem 0.75rem;
        font-size: 0.85rem;
    }

    .valentine-modal-container {
        max-height: 85vh;
        margin: 0 0.5rem;
    }

    h1 {
        font-size: 1.5rem !important;
    }

    h2 {
        font-size: 1.25rem !important;
    }

    /* Better modal sizing for mobile */
    #settingsModal .bg-\\[\\#2a2a2a\\],
    #otpModal .bg-\\[\\#2a2a2a\\] {
        max-width: calc(100vw - 2rem);
    }

    /* Settings modal mobile */
    #settingsModal .flex {
        flex-direction: column;
    }

    #settingsModal .w-64 {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }
}

@media (min-width: 641px) and (max-width: 1024px) {
    /* Tablet Optimizations */
    #sidebar {
        width: 260px;
    }

    .message-content {
        font-size: 0.95rem;
    }

    .max-w-3xl {
        max-width: 95%;
    }

    .max-w-4xl {
        max-width: 95%;
    }

    .valentine-modal-container {
        max-width: 90%;
    }

    /* Better button spacing on tablet */
    .sample-prompt-btn {
        font-size: 0.8rem;
    }
}

@media (min-width: 1025px) {
    /* Desktop Optimizations */
    .message-content {
        font-size: 15px;
        line-height: 1.7;
    }

    #chatContainer {
        scroll-behavior: smooth;
    }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
    button, .sample-prompt-btn, .valentine-option-btn {
        min-height: 44px;
        min-width: 44px;
    }

    .copy-btn {
        padding: 0.5rem 1rem;
        font-size: 0.8rem;
    }
}

/* Landscape Mobile */
@media (max-width: 896px) and (orientation: landscape) {
    #welcomeScreen h1 {
        font-size: 1.25rem !important;
    }

    #welcomeScreen {
        padding: 1rem;
    }

    .valentine-modal-container {
        max-height: 90vh;
        overflow-y: auto;
    }
}

/* Animation for notification modal */
@keyframes scaleIn {
    from {
        transform: scale(0.9);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.animate-scale-in {
    animation: scaleIn 0.2s ease-out;
}

/* High DPI Screens */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .message-content {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}