/* Custom CSS for the Markdown Editor with DaisyUI */

/* Custom scrollbar styling for chat and file areas */
.chat-container::-webkit-scrollbar,
.overflow-y-auto::-webkit-scrollbar {
    width: 6px;
}

.chat-container::-webkit-scrollbar-track,
.overflow-y-auto::-webkit-scrollbar-track {
    background: hsl(var(--b2));
}

.chat-container::-webkit-scrollbar-thumb,
.overflow-y-auto::-webkit-scrollbar-thumb {
    background: hsl(var(--bc) / 0.3);
    border-radius: 3px;
}

.chat-container::-webkit-scrollbar-thumb:hover,
.overflow-y-auto::-webkit-scrollbar-thumb:hover {
    background: hsl(var(--bc) / 0.5);
}

/* Enhanced prose styling for the preview */
.prose {
    color: hsl(var(--bc));
    max-width: none;
    line-height: 1.7;
}

.prose h1, .prose h2, .prose h3, .prose h4, .prose h5, .prose h6 {
    color: hsl(var(--bc));
    font-weight: 600;
}

.prose h1 {
    font-size: 2.25rem;
    line-height: 2.5rem;
    margin-bottom: 1rem;
    margin-top: 2rem;
}

.prose h2 {
    font-size: 1.875rem;
    line-height: 2.25rem;
    margin-bottom: 0.75rem;
    margin-top: 1.5rem;
}

.prose h3 {
    font-size: 1.5rem;
    line-height: 2rem;
    margin-bottom: 0.5rem;
    margin-top: 1.25rem;
}

.prose p {
    margin-bottom: 1rem;
    line-height: 1.6;
}

.prose strong {
    font-weight: 700;
    color: hsl(var(--bc));
}

.prose em {
    font-style: italic;
}

.prose ul, .prose ol {
    margin-bottom: 1rem;
    padding-left: 1.5rem;
}

.prose li {
    margin-bottom: 0.25rem;
}

.prose blockquote {
    border-left: 4px solid hsl(var(--p));
    padding-left: 1rem;
    margin: 1rem 0;
    font-style: italic;
    background: hsl(var(--b2));
    padding: 1rem;
    border-radius: 0.5rem;
    color: hsl(var(--bc) / 0.8);
}

.prose code {
    background: hsl(var(--b2));
    color: hsl(var(--bc));
    padding: 0.125rem 0.25rem;
    border-radius: 0.25rem;
    font-size: 0.875rem;
    font-family: 'SF Mono', 'Monaco', 'Cascadia Code', 'Roboto Mono', 'Consolas', monospace;
}

.prose pre {
    background: hsl(var(--n));
    color: hsl(var(--nc));
    padding: 1rem;
    border-radius: 0.5rem;
    overflow-x: auto;
    margin: 1rem 0;
}

.prose pre code {
    background: transparent;
    color: inherit;
    padding: 0;
}

.prose table {
    border-collapse: collapse;
    width: 100%;
    margin: 1rem 0;
}

.prose th, .prose td {
    border: 1px solid hsl(var(--bc) / 0.2);
    padding: 0.5rem;
    text-align: left;
}

.prose th {
    background: hsl(var(--b2));
    font-weight: 600;
}

.prose a {
    color: hsl(var(--p));
    text-decoration: underline;
}

.prose a:hover {
    color: hsl(var(--pf));
}

/* Task list styling */
.prose input[type="checkbox"] {
    margin-right: 0.5rem;
    accent-color: hsl(var(--p));
}

/* Smooth transitions */
* {
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

/* Focus styles for better accessibility */
.input:focus,
.select:focus,
.textarea:focus,
.btn:focus {
    outline: 2px solid hsl(var(--p));
    outline-offset: 2px;
}

/* Editor specific styles */
textarea {
    font-family: 'SF Mono', 'Monaco', 'Cascadia Code', 'Roboto Mono', 'Consolas', monospace;
    line-height: 1.6;
}

/* Chat interface styling */
.chat-container {
    scroll-behavior: smooth;
}

/* Animate chat message appearance */
.chat-message {
    animation: fadeInUp 0.3s ease-out;
}

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

/* Custom animation for loading */
@keyframes pulse-subtle {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

.loading-subtle {
    animation: pulse-subtle 2s infinite;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .w-80 {
        width: 100%;
    }
    
    .prose {
        font-size: 0.875rem;
        padding: 0.75rem;
    }
    
    .prose h1 {
        font-size: 1.5rem;
        margin-top: 1rem;
        margin-bottom: 0.75rem;
    }
    
    .prose h2 {
        font-size: 1.25rem;
        margin-top: 0.75rem;
        margin-bottom: 0.5rem;
    }
    
    .prose h3 {
        font-size: 1.125rem;
        margin-top: 0.5rem;
        margin-bottom: 0.5rem;
    }
    
    .navbar-end {
        flex-wrap: wrap;
        gap: 0.25rem;
    }
    
    .navbar-end .btn {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
        min-height: 2rem;
    }
    
    /* Mobile textarea improvements */
    textarea {
        font-size: 16px !important; /* Prevents zoom on iOS */
        line-height: 1.5;
    }
    
    /* Mobile form controls */
    .input, .select, .textarea {
        font-size: 16px !important; /* Prevents zoom */
    }
    
    /* AI Settings Panel Mobile Optimization */
    .ai-settings-panel {
        padding: 0.5rem;
    }
    
    .ai-settings-panel .form-control {
        margin-bottom: 0.75rem;
    }
    
    .ai-settings-panel .input,
    .ai-settings-panel .select {
        padding: 0.5rem;
        height: 2.5rem;
    }
    
    /* Settings button mobile styling */
    .btn-settings {
        padding: 0.375rem;
        min-height: 2rem;
        font-size: 0.875rem;
    }
    
    /* Connection status mobile styling */
    .connection-status {
        gap: 0.375rem;
    }
    
    .connection-status .badge {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }
    
    /* Quick actions mobile styling */
    .ai-quick-actions {
        flex-direction: column;
        gap: 0.5rem;
        align-items: stretch;
    }
    
    .ai-quick-actions .btn {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }
    
    /* Mobile chat optimizations */
    .chat-bubble {
        max-width: 85% !important;
        font-size: 0.875rem;
        word-wrap: break-word;
        word-break: break-word;
    }
    
    /* Mobile chat alignment fixes */
    .chat {
        margin-bottom: 1rem !important;
    }
    
    .chat-start {
        justify-self: start;
    }
    
    .chat-end {
        justify-self: end;
    }
    
    .chat-image {
        align-self: flex-end;
    }
    
    .chat-header {
        font-size: 0.75rem !important;
        margin-bottom: 0.25rem;
    }
    
    .chat-bubble {
        line-height: 1.4 !important;
        padding: 0.75rem !important;
    }
    
    /* Mobile action buttons */
    .chat-bubble .btn-xs {
        font-size: 0.6rem !important;
        padding: 0.125rem 0.25rem !important;
        margin: 0.125rem !important;
    }
    
    .chat-container {
        padding: 0.5rem;
        /* Ensure proper scrolling on mobile */
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }
    
    /* Mobile AI panel specific fixes */
    .resizable-panel {
        /* Ensure flex container works on mobile */
        height: 100vh;
        overflow: hidden;
    }
    
    /* Mobile chat input area */
    .join .input {
        font-size: 16px !important; /* Prevents zoom */
    }
    
    /* Mobile bottom navigation */
    .btm-nav .btm-nav-label {
        font-size: 0.75rem;
    }
    
    /* Fix AI chat panel height on mobile */
    .resizable-panel.bg-base-200.border-l.border-base-300.flex.flex-col {
        height: calc(100vh - 60px); /* Account for bottom nav */
        max-height: calc(100vh - 60px);
        /* Ensure content doesn't overflow and interfere with bottom nav */
        overflow: hidden;
        padding-bottom: 1rem !important;
    }
    
    /* Ensure chat container can scroll properly */
    .chat-container {
        flex: 1;
        min-height: 0;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
        /* Momentum scrolling for iOS */
        scroll-behavior: smooth;
        /* Add bottom padding to account for input area and bottom nav */
        padding-bottom: 2rem !important;
    }
    
    /* Chat input area mobile positioning */
    .border-t.border-base-300 {
        background: hsl(var(--b1));
        border-top: 1px solid hsl(var(--bc) / 0.2);
        /* Remove sticky positioning to prevent overlap */
        position: relative;
        /* Add bottom margin to keep space above bottom nav */
        margin-bottom: 1rem !important;
    }
    
    /* Fix flex layout issues on mobile */
    .flex-1.flex.flex-col.min-h-0 {
        flex: 1;
        min-height: 0;
        height: 100%;
    }
    
    /* Chat input area fixes */
    .join {
        flex-wrap: nowrap;
    }
    
    .join .btn {
        white-space: nowrap;
        min-width: auto;
    }
    
    /* Mobile chat specific styling */
    .mobile-chat {
        padding: 0.75rem !important;
        max-height: calc(100vh - 320px) !important; /* Increased space for input area */
        overflow-y: scroll !important;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        display: flex !important;
        flex-direction: column !important;
        gap: 0.75rem !important;
    }
    
    /* Mobile chat message improvements */
    .mobile-chat .chat {
        margin-bottom: 0 !important;
        width: 100%;
        display: flex;
        flex-direction: column;
    }
    
    .mobile-chat .chat-start {
        align-items: flex-start;
    }
    
    .mobile-chat .chat-end {
        align-items: flex-end;
    }
    
    .mobile-chat .chat-bubble {
        max-width: 80% !important;
        font-size: 0.875rem !important;
        line-height: 1.4 !important;
        word-wrap: break-word !important;
    }
    
    /* Mobile preview specific styling */
    .mobile-preview {
        flex: 1 !important;
        min-height: 0 !important;
        height: 100% !important;
        max-height: calc(100vh - 120px) !important;
        overflow-y: scroll !important;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        scroll-behavior: smooth;
    }
    
    /* Editor panel mobile fixes */
    .resizable-panel textarea {
        height: calc(100vh - 120px) !important;
        max-height: calc(100vh - 120px) !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
    
    /* Mobile editor specific styling */
    .mobile-editor {
        height: calc(100vh - 120px) !important;
        max-height: calc(100vh - 120px) !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        font-size: 16px !important; /* Prevents zoom on iOS */
    }
    
    /* Enhanced mobile chat styling for better alignment */
    /* Chat container improvements */
    .chat-container {
        padding: 0.5rem !important;
        gap: 0.75rem !important;
    }
    
    /* Chat message spacing and alignment */
    .chat {
        margin-bottom: 0.75rem !important;
        min-height: auto !important;
    }
    
    .chat-image {
        width: 2rem !important;
        height: 2rem !important;
        flex-shrink: 0;
    }
    
    .chat-image .rounded-full {
        width: 2rem !important;
        height: 2rem !important;
    }
    
    /* Chat bubble mobile enhancements */
    .chat-bubble {
        font-size: 0.875rem !important;
        line-height: 1.4 !important;
        padding: 0.5rem 0.75rem !important;
        max-width: 75% !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
    }
    
    /* Action buttons in chat */
    .chat-bubble .btn {
        font-size: 0.7rem !important;
        padding: 0.25rem 0.5rem !important;
        margin: 0.125rem !important;
        min-height: 1.5rem !important;
    }
    
    /* Chat input area mobile optimization */
    .join .input {
        font-size: 16px !important;
        padding: 0.5rem !important;
    }
    
    .join .btn {
        padding: 0.5rem 0.75rem !important;
        font-size: 0.875rem !important;
    }
    
    /* Quick action buttons mobile styling */
    .flex-wrap .btn-xs {
        font-size: 0.7rem !important;
        padding: 0.25rem 0.5rem !important;
        min-height: 1.75rem !important;
    }
    
    /* Quick suggestion buttons mobile optimization */
    .mt-2.flex.flex-wrap.gap-1 {
        margin-bottom: 1rem !important;
        padding-bottom: 0.5rem !important;
    }
    
    .mt-2.flex.flex-wrap.gap-1 .btn {
        font-size: 0.75rem !important;
        padding: 0.25rem 0.5rem !important;
        min-height: 2rem !important;
        white-space: nowrap;
    }
    
    /* Ensure chat input area has proper spacing on mobile */
    .p-2.lg\:p-4.border-t.border-base-300 {
        padding: 1rem !important;
        background: hsl(var(--b1));
        border-top: 1px solid hsl(var(--bc) / 0.2);
        /* Remove sticky positioning and use regular flow */
        position: relative;
        margin-bottom: 0.75rem !important;
        /* Lower z-index to not overlap bottom nav */
        z-index: 1;
    }
    
}

@media (max-width: 640px) {
    .dropdown-content {
        right: 0;
        left: auto;
        max-width: 90vw;
        width: 100vw;
        left: 0 !important;
        transform: none !important;
    }
    
    .prose {
        font-size: 0.8rem;
    }
    
    .btn-sm {
        padding: 0.125rem 0.25rem;
        font-size: 0.7rem;
        min-height: 1.75rem;
    }
    
    /* Extra mobile optimizations */
    .navbar {
        padding: 0.5rem;
    }
    
    .navbar-start h1 {
        font-size: 1rem;
    }
}

/* AI Settings Panel Transitions */
.ai-settings-panel {
    transition: all 0.3s ease-in-out;
}

.ai-settings-enter {
    opacity: 0;
    max-height: 0;
    overflow: hidden;
}

.ai-settings-enter-active {
    opacity: 1;
    max-height: 400px;
}

.ai-settings-leave {
    opacity: 1;
    max-height: 400px;
}

.ai-settings-leave-active {
    opacity: 0;
    max-height: 0;
    overflow: hidden;
}

/* Enhanced settings button styling */
.btn-settings {
    transition: all 0.2s ease;
}

.btn-settings:hover {
    background-color: hsl(var(--p) / 0.1);
    color: hsl(var(--p));
}

.btn-settings.btn-active {
    background-color: hsl(var(--p) / 0.1);
    color: hsl(var(--p));
}

/* Connection status badge improvements */
.connection-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.connection-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.connection-indicator.online {
    background-color: hsl(var(--su));
}

.connection-indicator.offline {
    background-color: hsl(var(--er));
}

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

/* Inline AI Popup Styling */
.inline-ai-popup {
    backdrop-filter: blur(8px);
    border: 1px solid hsl(var(--bc) / 0.1);
    box-shadow: 0 10px 25px hsl(var(--bc) / 0.15);
}

.inline-ai-popup .btn {
    transition: all 0.2s ease;
}

.inline-ai-popup .btn:hover {
    background-color: hsl(var(--p) / 0.1);
    color: hsl(var(--p));
    transform: translateX(2px);
}

.inline-ai-popup .btn:active {
    transform: translateX(1px);
}

/* Ensure popup appears above other elements */
.inline-ai-popup {
    z-index: 9999;
}

/* Animation for AI action feedback */
@keyframes ai-pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.02);
    }
}

.ai-action-feedback {
    animation: ai-pulse 0.6s ease-in-out;
}

/* Custom input styling for inline AI */
.inline-ai-custom-input {
    font-size: 0.75rem !important;
    padding: 0.25rem 0.5rem !important;
    height: 1.75rem !important;
    min-height: 1.75rem !important;
}

.inline-ai-custom-input:focus {
    outline: 2px solid hsl(var(--p)) !important;
    outline-offset: 1px !important;
}

/* Divider styling in popup */
.inline-ai-popup .divider {
    margin: 0.25rem 0;
    height: 1px;
    opacity: 0.3;
}

/* Mobile optimizations for inline AI popup */
@media (max-width: 768px) {
    .inline-ai-popup {
        min-width: 200px;
        max-width: calc(100vw - 20px);
        font-size: 0.875rem;
    }
    
    .inline-ai-popup .btn {
        padding: 0.375rem 0.75rem;
        height: 2rem;
        font-size: 0.75rem;
    }
    
    .inline-ai-popup .btn:hover {
        transform: none; /* Disable transform on mobile for better touch experience */
    }
    
    .inline-ai-custom-input {
        font-size: 0.7rem !important;
        padding: 0.25rem 0.5rem !important;
    }
}

/* New Mobile Panel Classes */
@media (max-width: 768px) {
    /* GitHub panel mobile fixes */
    .mobile-github-panel {
        height: calc(100vh - 60px) !important;
        height: calc(100dvh - 60px) !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        width: 100% !important;
        border: none !important;
    }
    
    /* Editor panel mobile fixes */
    .mobile-editor-panel {
        height: calc(100vh - 60px) !important;
        height: calc(100dvh - 60px) !important;
        width: 100% !important;
        border: none !important;
    }
    
    /* Preview panel mobile fixes */
    .mobile-preview-panel {
        height: calc(100vh - 60px) !important;
        height: calc(100dvh - 60px) !important;
        width: 100% !important;
        border: none !important;
    }
    
    /* Settings panel mobile fixes */
    .mobile-settings-panel {
        height: calc(100vh - 60px) !important;
        height: calc(100dvh - 60px) !important;
        width: 100% !important;
        border: none !important;
    }
}
