/* Responsive design styles */

/* Base mobile-first approach */
body {
    font-size: 16px;
}

/* Medium screens (tablets) */
@media (min-width: 768px) and (max-width: 1023px) {
    .chat-container {
        max-width: 90%;
    }
}

/* Large screens (desktops) */
@media (min-width: 1024px) {
    .chat-container {
        max-width: 1000px;
    }
    
    .chat-box {
        padding-bottom: 120px;
    }
}

/* Small screens (mobile) */
@media (max-width: 767px) {
    .chat-container {
        border-radius: 0;
        max-width: 100%;
        height: 100dvh;
    }

    .chat-header-content {
        align-items: flex-start;
    }
    
    .header-disclaimer {
        font-size: 0.7rem;
    }
    
    .suggested-questions {
        grid-template-columns: 1fr;
    }

    .user-message, .response-message {
        max-width: 90%;
    }

    .chat-box {
        padding-bottom: 140px; /* More padding for mobile bottom controls */
    }
    
    /* Mobile optimizations for the bottom controls */
    .chat-controls {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
    }
    
    #new-topic-button span {
        display: none; /* Hide text on mobile */
    }
    
    #new-topic-button {
        min-width: 38px;
        width: 38px;
        padding: 0.5rem;
        justify-content: center;
    }
    
    .model-select-label {
        font-size: 0.75rem;
    }
    
    #model-select {
        font-size: 0.75rem;
        padding-right: 1.25rem;
    }
    
    /* Force elements to maintain consistent sizes on mobile */
    #theme-toggle, #new-topic-button {
        flex: 0 0 auto;
    }
    
    .model-select-wrapper {
        min-width: 0;
        flex: 1 1 auto;
    }
}

/* Extra small screens */
@media (max-width: 480px) {
    .chat-header {
        padding: 0.625rem 0.75rem;
    }

    .header-left {
        gap: 0.5rem;
    }
    
    /* Even more compact on very small screens */
    .model-select-wrapper {
        padding: 0.4rem 0.5rem;
    }
    
    .model-select-label {
        margin-right: 0.25rem;
    }
    
    .user-message, .response-message {
        max-width: 95%;
        padding: 0.875rem 1rem;
    }
    
    .message-content {
        font-size: 0.9375rem;
    }
}

/* Landscape mode on mobile */
@media (max-width: 767px) and (orientation: landscape) {
    .chat-box {
        padding-bottom: 120px;
    }
    
    .chat-header {
        padding: 0.5rem 0.75rem;
    }
    
    .welcome-message {
        padding: 1rem;
    }
    
    .welcome-message h3 {
        font-size: 1.125rem;
    }
    
    .welcome-message p {
        margin-bottom: 0.75rem;
    }
}

/* High-DPI screens (Retina) */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* Optimize certain elements for high-DPI screens if needed */
    .chat-container {
        box-shadow: var(--shadow);
    }
}

/* Print styles */
@media print {
    .chat-container {
        box-shadow: none;
        height: auto;
    }
    
    .chat-header,
    #chat-form,
    .welcome-message,
    .suggested-questions,
    .copy-button,
    .error-message {
        display: none;
    }
    
    .chat-box {
        padding: 0;
        height: auto;
        overflow: visible;
    }
    
    .user-message, .response-message {
        page-break-inside: avoid;
        border: 1px solid #ddd;
        max-width: 100%;
        margin-bottom: 1rem;
    }
    
    body {
        background-color: white;
        color: black;
    }
}

/* Accessibility: Prefers reduced motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    .user-message, .response-message, .welcome-message {
        animation: none !important;
    }
    
    .suggested-questions a:hover {
        transform: none !important;
    }
}

/* iOS Safari viewport height fix */
@supports (-webkit-touch-callout: none) {
    .chat-container {
        height: -webkit-fill-available;
    }
    
    body, html {
        height: -webkit-fill-available;
    }
}

/* Fix for older Firefox versions */
@-moz-document url-prefix() {
    @media (max-width: 767px) {
        .chat-container {
            height: 100%;
            min-height: 100vh;
        }
    }
}
