/* Additional fixes for UI issues */

/* Style for missing image note */
.missing-image-note {
    color: #ff6b6b;
    font-style: italic;
    margin-top: 5px;
}

/* Carousel control fixes */
.carousel-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-top: 0.5rem;
}

.carousel-controls button {
    background-color: var(--btn-bg);
    color: var(--text-color);
    border: none;
    border-radius: 50%;
    width: 2rem;
    height: 2rem;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.carousel-controls button:hover {
    background-color: var(--btn-hover-bg);
}

.carousel-controls button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Ensure carousel images have consistent size */
.image-carousel img {
    max-width: 100%;
    object-fit: contain;
    border-radius: 8px;
}

/* Fix fullscreen view for images */
.fullscreen-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.fullscreen-overlay img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    border-radius: 8px;
}

/* Fix for the input area to ensure it's always visible */
.input-area {
    background-color: var(--primary-bg);
    position: sticky;
    z-index: 15;
    border-top: 1px solid var(--border-color);
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    padding: 15px 20px;
}

.input-container {
    display: flex;
    align-items: flex-end;
    background-color: var(--secondary-bg);
    border-radius: 10px;
    padding: 10px 15px;
    gap: 10px;
}

#user-input {
    flex-grow: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text-color);
    resize: none;
    padding: 5px 0;
    max-height: 150px;
    font-size: 1rem;
    font-family: inherit;
}

/* Ensure chat area has enough space for input area */
.chat-area {
    padding-bottom: 100px; /* Base padding to ensure content isn't hidden */
    margin-bottom: 15px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* Improve scrolling on iOS */
}

/* Fix for lists in message content to prevent overflow */
.message-content ol,
.message-content ul {
    padding-left: 20px; /* Reduce default padding */
    margin-left: 0;
    box-sizing: border-box;
    max-width: 100%;
    width: 100%; /* Ensure lists take full width of container */
}

.message-content li {
    margin-bottom: 5px;
    overflow-wrap: break-word;
    word-break: break-word;
    margin-right: 8px; /* Ensure text doesn't touch the right edge */
}

/* Fix for list item markers to ensure they're visible and properly aligned */
.message-content ol {
    list-style-position: inside; /* Keep markers inside the container */
}

/* Additional mobile fixes */
@media (max-width: 768px) {
    .input-area {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        padding: 10px;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.2);
        height: auto;
        z-index: 100;
    }
    
    .chat-area {
        padding-bottom: 200px !important; /* Increased padding for mobile to ensure content isn't hidden */
        margin-bottom: 0;
        -webkit-overflow-scrolling: touch; /* Improve scrolling on iOS */
    }
    
    /* Fix upload preview spacing */
    .upload-preview {
        margin-bottom: 0;
        padding: 10px;
        background-color: rgba(45, 45, 45, 0.8);
    }
    
    /* Ensure the content area is adjusted for keyboard */
    .main-content {
        display: flex;
        flex-direction: column;
        height: 100vh;
        position: relative;
        overflow: hidden;
    }
    
    /* Make the menu toggle more visible */
    .menu-toggle {
        background-color: var(--secondary-bg);
        padding: 8px;
        border-radius: 5px;
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    }
    
    /* Improve touch target size */
    .code-copy-btn, 
    .code-run-btn, 
    .download-btn,
    .menu-option {
        min-height: 44px; /* Recommended minimum touch target size */
        display: flex;
        align-items: center;
    }
    
    /* Improve the visibility of the tap and hold functionality */
    .message.bot .message-content {
        position: relative;
    }
    
    .message.bot .message-content::after {
        content: '';
        position: absolute;
        top: 5px;
        right: 5px;
        width: 5px;
        height: 5px;
        border-radius: 50%;
        background-color: var(--primary-accent);
        opacity: 0.5;
    }
    
    /* Adjust list styling on mobile for better readability */
    .message-content ol,
    .message-content ul {
        padding-left: 15px;
    }
}

/* Animation for tap feedback */
@keyframes tapFeedback {
    0% { transform: scale(1); }
    50% { transform: scale(0.95); }
    100% { transform: scale(1); }
}

.tapped {
    animation: tapFeedback 0.3s ease;
}

/* Ensure messages are always visible */
.message {
    opacity: 1 !important;
    visibility: visible !important;
}

/* Force proper layout even when virtual keyboard is active */
@media screen and (max-height: 450px) {
    .chat-area {
        height: calc(100vh - 120px);
        padding-bottom: 120px !important;
    }
    
    .input-area {
        position: fixed;
    }
}

/* Fix iOS Safari issues */
@supports (-webkit-touch-callout: none) {
    .chat-area {
        padding-bottom: 220px !important;
    }
}
