/* Mobile Responsive Improvements for Continuum */

/* Base Mobile Styles */
@media screen and (max-width: 768px) {
    /* Header Responsive */
    .header-content {
        flex-direction: column;
        gap: 1rem;
        padding: 0.5rem;
    }
    
    .logo {
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }
    
    .logo h1 {
        font-size: 1.2rem;
    }
    
    .header-controls {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
        width: 100%;
        justify-content: center;
    }
    
    .header-controls button {
        padding: 0.4rem 0.8rem;
        font-size: 0.9rem;
    }
    
    /* Main Layout */
    .main-container {
        padding: 0;
        margin: 0;
    }
    
    /* Chat Container */
    .chat-container {
        height: calc(100vh - 120px);
        margin: 0;
        border-radius: 0;
    }
    
    .messages-container {
        padding: 0.5rem;
    }
    
    .message {
        padding: 0.75rem;
        margin: 0.5rem 0;
    }
    
    .message-content {
        font-size: 0.95rem;
    }
    
    /* Input Area */
    .input-container {
        padding: 0.75rem;
        gap: 0.5rem;
    }
    
    #message-input {
        font-size: 16px; /* Prevents zoom on iOS */
        min-height: 40px;
        padding: 0.5rem;
    }
    
    .send-button {
        padding: 0.5rem 1rem;
        min-width: 60px;
    }
    
    /* Modals */
    .modal-content {
        margin: 1rem;
        width: calc(100% - 2rem);
        max-width: none;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    .modal-header h2 {
        font-size: 1.2rem;
    }
    
    /* Settings Modal */
    .config-section {
        padding: 1rem;
    }
    
    .config-section h3 {
        font-size: 1rem;
    }
    
    .form-group {
        margin-bottom: 1rem;
    }
    
    .form-group label {
        font-size: 0.9rem;
    }
    
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    /* Personality Sliders */
    .slider-container {
        gap: 0.5rem;
    }
    
    .slider-value {
        min-width: 30px;
        font-size: 0.85rem;
    }
    
    /* Model Selector */
    .model-selector-group {
        grid-template-columns: 1fr;
    }
    
    /* Tabs */
    .tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .tab-button {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
        white-space: nowrap;
    }
    
    /* Memory Items */
    .memory-item {
        padding: 0.5rem;
    }
    
    .memory-content {
        font-size: 0.85rem;
    }
    
    /* Status Bar */
    .status-bar {
        padding: 0.5rem;
        font-size: 0.8rem;
    }
    
    /* Hide less important elements on mobile */
    .desktop-only {
        display: none !important;
    }
}

/* Small Mobile (< 480px) */
@media screen and (max-width: 480px) {
    .header-content {
        padding: 0.25rem;
    }
    
    .logo-icon {
        width: 24px;
        height: 24px;
    }
    
    .logo h1 {
        font-size: 1rem;
    }
    
    .header-controls button {
        padding: 0.3rem 0.6rem;
        font-size: 0.8rem;
    }
    
    .chat-container {
        height: calc(100vh - 100px);
    }
    
    .message {
        padding: 0.5rem;
    }
    
    .message-content {
        font-size: 0.9rem;
    }
    
    .input-container {
        padding: 0.5rem;
    }
    
    #message-input {
        min-height: 36px;
        padding: 0.4rem;
    }
}

/* Landscape Mode Adjustments */
@media screen and (max-height: 600px) and (orientation: landscape) {
    .header {
        position: relative;
    }
    
    .chat-container {
        height: calc(100vh - 60px);
    }
    
    .header-content {
        padding: 0.25rem;
        flex-direction: row;
    }
    
    .logo h1 {
        font-size: 1rem;
    }
    
    .header-controls {
        flex-direction: row;
    }
    
    .header-controls button {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
    }
}

/* Fix button overlap on mobile */
@media screen and (max-width: 768px) {
    .header-controls {
        display: flex !important;
        align-items: center !important;
        gap: 1rem !important;
        flex-wrap: nowrap !important;
    }
    
    .header-controls button {
        position: relative !important;
        z-index: 10;
        flex-shrink: 0;
    }
    
    .button-spacer {
        flex-shrink: 0;
        min-width: 20px !important;
    }
    
    #theme-toggle {
        margin-right: 0 !important;
    }
    
    #config-button {
        margin-left: 0 !important;
        display: inline-flex !important;
        align-items: center;
        gap: 0.5rem;
    }
    
    .config-text {
        display: inline !important;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    /* Increase touch targets */
    button, .clickable {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Better spacing for touch */
    .form-group input,
    .form-group select {
        padding: 0.75rem;
    }
    
    /* Larger close buttons */
    .modal-close {
        width: 36px;
        height: 36px;
        font-size: 24px;
    }
    
    /* Better slider handles */
    input[type="range"]::-webkit-slider-thumb {
        width: 24px;
        height: 24px;
    }
    
    input[type="range"]::-moz-range-thumb {
        width: 24px;
        height: 24px;
    }
}

/* Tablet Adjustments (768px - 1024px) */
@media screen and (min-width: 769px) and (max-width: 1024px) {
    .main-container {
        padding: 1rem;
    }
    
    .chat-container {
        max-width: 100%;
    }
    
    .modal-content {
        width: 90%;
        max-width: 700px;
    }
    
    .model-selector-group {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Unsaved Changes Indicator */
.unsaved-indicator {
    display: none;
    background: var(--warning-color);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    margin-left: 0.5rem;
    animation: pulse 2s infinite;
}

.unsaved-indicator.active {
    display: inline-block;
}

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

/* Save Prompt Banner */
.save-prompt {
    position: fixed;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--warning-color);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    display: none;
    z-index: 1000;
    align-items: center;
    gap: 1rem;
}

.save-prompt.active {
    display: flex;
}

.save-prompt-buttons {
    display: flex;
    gap: 0.5rem;
}

.save-prompt button {
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    font-size: 0.875rem;
}

.save-prompt .save-btn {
    background: white;
    color: var(--warning-color);
}

.save-prompt .discard-btn {
    background: transparent;
    color: white;
    border: 1px solid white;
}

/* Mobile Save Prompt */
@media screen and (max-width: 768px) {
    .save-prompt {
        width: calc(100% - 2rem);
        left: 1rem;
        transform: none;
        top: auto;
        bottom: 1rem;
    }
}