/* ==================== CHATBOT RESPONSIVE STYLES ==================== */
/* This file contains all responsive and mobile-specific styles for the chatbot page */
/* Can be included separately or merged with main chatbot.css */

/* ==================== RESPONSIVE BREAKPOINTS ==================== */

/* Tablet Landscape and Below (1024px) */
@media (max-width: 1024px) {
    .chat-page-container {
        grid-template-columns: 280px 1fr;
    }
    
    .chat-header-content {
        flex-direction: column;
        gap: 12px;
    }
    
    .chat-header-right {
        width: 100%;
    }
    
    .project-select-btn {
        width: 100%;
    }
    
    .chat-messages {
        padding: 20px;
    }
}

/* Tablet Portrait and Below (768px) */
@media (max-width: 768px) {
    /* Main Layout Adjustments */
    body .main-content.responsive-main-content {
        margin-left: 0;
        margin-top: 64px;
    }
    
    .chat-page-container {
        grid-template-columns: 1fr;
    }
    
    /* ==================== SIDEBAR MOBILE BEHAVIOR ==================== */
    .chat-sidebar {
        position: fixed;
        left: -100%;
        top: 64px;
        width: 280px;
        height: calc(100vh - 64px);
        z-index: 1000;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 2px 0 12px rgba(0, 0, 0, 0.15);
    }
    
    .chat-sidebar.active {
        left: 0;
    }
    
    /* Sidebar Overlay */
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        display: none;
        backdrop-filter: blur(2px);
    }
    
    .sidebar-overlay.active {
        display: block;
        animation: fadeIn 0.3s ease;
    }
    
    /* ==================== MOBILE TOGGLES ==================== */
    .mobile-toggles {
        position: fixed;
        top: 64px;
        left: 0;
        right: 0;
        padding: 12px;
        background: white;
        border-bottom: 1px solid #e5e7eb;
        z-index: 998;
    }
    
    .sidebar-toggle {
        position: fixed;
        bottom: 24px;
        left: 24px;
        width: 56px;
        height: 56px;
        border-radius: 50%;
        background: white;
        border: 1px solid #e5e7eb;
        border-radius: 8px;
        padding: 10px 16px;
        font-size: 18px;
        cursor: pointer;
        transition: all 0.2s ease;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
        z-index: 1001;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .sidebar-toggle:hover {
        background: #f8fafc;
        border-color: #3b82f6;
    }
    
    .sidebar-toggle:active {
        transform: scale(0.95);
    }
    
    /* ==================== CHAT MAIN MOBILE ==================== */
    .chat-main {
        margin-top: 48px;
    }
    
    /* Chat Header Mobile */
    .chat-header {
        padding: 16px;
    }
    
    .chat-quick-meta {
        padding: 0 16px 10px;
        gap: 8px;
    }
    
    .meta-pill {
        padding: 8px 12px;
    }
    
    .project-context-icon {
        width: 36px;
        height: 36px;
    }
    
    .chat-header-title {
        font-size: 20px;
    }
    
    .chat-header-subtitle {
        font-size: 13px;
    }
    
    /* Messages Mobile */
    .chat-messages {
        padding: 16px;
    }
    
    .message {
        gap: 10px;
    }
    
    .message-content {
        max-width: 85%;
        padding: 12px 16px;
    }
    
    .message-text {
        font-size: 14px;
    }
    
    .message-avatar {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }
    
    /* ==================== INPUT AREA MOBILE ==================== */
    .chat-input-container {
        padding: 12px 14px 14px;
    }
    
    .chat-input-wrapper {
        gap: 8px;
        padding: 8px 10px;
        border-radius: 16px;
    }
    
    .attachment-btn,
    .send-btn {
        width: 34px;
        height: 34px;
        font-size: 15px;
        border-radius: 10px;
    }
    
    .chat-input {
        font-size: 13px;
        padding: 10px;
        min-height: 44px;
    }
    
    /* ==================== PROJECT MODAL MOBILE ==================== */
    .project-filter-content {
        width: 95%;
        max-width: 95vw;
        max-height: 90vh;
        border-radius: 12px;
    }
    
    .project-filter-header {
        padding: 20px 16px 12px;
    }
    
    .project-filter-header h3 {
        font-size: 18px;
    }
    
    .project-filter-body {
        padding: 16px;
    }
    
    .project-filter-footer {
        padding: 12px 16px 20px;
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
        padding: 12px 20px;
    }
    
    .project-option {
        padding: 14px;
    }
    
    /* ==================== CHAT HISTORY MOBILE ==================== */
    .chat-history-section {
        max-height: calc(100vh - 320px);
    }
    
    .history-item {
        padding: 12px;
        margin-bottom: 8px;
    }
    
    .history-item-title {
        font-size: 13px;
    }
    
    .history-item-meta {
        font-size: 11px;
    }
    
    /* ==================== WELCOME SCREEN MOBILE ==================== */
    .welcome-screen {
        padding: 24px 16px;
    }
    
    .welcome-icon {
        font-size: 48px;
        margin-bottom: 20px;
    }
    
    .welcome-title {
        font-size: 22px;
    }
    
    .welcome-subtitle {
        font-size: 14px;
    }
}

/* ==================== MOBILE PORTRAIT (480px) ==================== */
@media (max-width: 480px) {
    /* Full Width Sidebar */
    .chat-sidebar {
        width: 100%;
        left: -100%;
    }
    
    .chat-sidebar.active {
        left: 0;
    }
    
    /* Smaller Text */
    .chat-header-title {
        font-size: 18px;
    }
    
    .chat-header-subtitle {
        font-size: 12px;
    }
    
    /* Messages */
    .message-content {
        max-width: 90%;
        padding: 10px 14px;
        font-size: 14px;
    }
    
    .message-avatar {
        width: 32px;
        height: 32px;
        font-size: 13px;
    }
    
    /* Input Controls */
    .attachment-btn,
    .send-btn {
        width: 38px;
        height: 38px;
        font-size: 16px;
    }
    
    .chat-input {
        font-size: 14px;
        padding: 10px 14px;
    }
    
    /* Modal */
    .project-filter-content {
        max-height: 95vh;
        border-radius: 8px;
    }
    
    .project-option {
        padding: 12px;
    }
    
    .project-name {
        font-size: 14px;
    }
    
    .project-details {
        font-size: 13px;
    }
    
    /* Welcome Screen */
    .welcome-icon {
        font-size: 40px;
    }
    
    .welcome-title {
        font-size: 20px;
    }
    
    .welcome-subtitle {
        font-size: 13px;
        padding: 0 10px;
    }
    
    /* Sidebar Elements */
    .new-chat-btn {
        padding: 10px 14px;
        font-size: 13px;
    }
    
    .sidebar-tab {
        padding: 8px;
        font-size: 12px;
    }
}

/* ==================== LANDSCAPE MODE FIXES ==================== */
@media (max-width: 768px) and (orientation: landscape) {
    .chat-main {
        margin-top: 0;
    }
    
    .mobile-toggles {
        display: none;
    }
    
    .chat-sidebar {
        top: 64px;
        height: calc(100vh - 64px);
    }
    
    .chat-messages {
        padding: 12px;
    }
    
    .chat-header {
        padding: 12px 16px;
    }
    
    .chat-input-container {
        padding: 12px 16px;
    }
    
    .system-prompts-section {
        max-height: 280px;
    }
    
    .chat-history-section {
        max-height: 50vh;
    }
    
    .welcome-screen {
        padding: 20px;
    }
}

/* ==================== TOUCH DEVICE OPTIMIZATIONS ==================== */
@media (hover: none) and (pointer: coarse) {
    /* Increase Touch Targets */
    .history-item,
    .project-option,
    .system-prompt-card {
        min-height: 44px;
        -webkit-tap-highlight-color: rgba(59, 130, 246, 0.1);
    }
    
    .sidebar-tab,
    .btn,
    .attachment-btn,
    .send-btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Prevent Text Selection */
    .sidebar-tab,
    .system-prompt-card,
    .history-item,
    .project-option,
    .new-chat-btn {
        -webkit-user-select: none;
        user-select: none;
        -webkit-touch-callout: none;
    }
    
    /* Remove Hover Effects on Touch */
    .history-item:hover,
    .project-option:hover,
    .system-prompt-card:hover {
        transform: none;
    }
    
    /* Better Touch Feedback */
    .history-item:active,
    .project-option:active,
    .system-prompt-card:active,
    .sidebar-tab:active,
    .btn:active {
        transform: scale(0.97);
        opacity: 0.9;
    }
    
    .attachment-btn:active,
    .send-btn:active {
        transform: scale(0.92);
    }
}

/* ==================== iOS SPECIFIC ==================== */
/* iOS Notch Support */
@supports (padding: max(0px)) {
    .chat-input-container {
        padding-bottom: max(20px, env(safe-area-inset-bottom));
    }
    
    .chat-sidebar {
        padding-bottom: max(0px, env(safe-area-inset-bottom));
    }
    
    @media (max-width: 768px) {
        .mobile-toggles {
            padding-top: max(12px, env(safe-area-inset-top));
        }
    }
}

/* iOS Bounce Fix */
@supports (-webkit-overflow-scrolling: touch) {
    .chat-messages,
    .chat-history-list {
        -webkit-overflow-scrolling: touch;
    }
}

/* ==================== ACCESSIBILITY ==================== */
/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    .chat-sidebar {
        transition: none !important;
    }
    
    .sidebar-overlay {
        animation: none !important;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .message-content,
    .project-option,
    .history-item,
    .chat-sidebar {
        border-width: 2px;
    }
    
    .btn {
        border: 2px solid currentColor;
    }
}

/* ==================== PRINT STYLES ==================== */
@media print {
    .chat-sidebar,
    .chat-header,
    .chat-input-container,
    .mobile-toggles,
    .sidebar-overlay,
    .attachment-btn,
    .send-btn {
        display: none !important;
    }
    
    .chat-page-container {
        grid-template-columns: 1fr;
        height: auto;
    }
    
    .chat-messages {
        padding: 0;
        background: white;
        overflow: visible;
    }
    
    .message {
        page-break-inside: avoid;
        margin-bottom: 10px;
    }
    
    .message-content {
        max-width: 100%;
        box-shadow: none;
        border: 1px solid #e5e7eb;
    }
}

/* ==================== ANIMATIONS FOR MOBILE ==================== */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideInFromLeft {
    from {
        transform: translateX(-100%);
    }
    to {
        transform: translateX(0);
    }
}

/* ==================== UTILITY CLASSES ==================== */
.mobile-only {
    display: none;
}

@media (max-width: 768px) {
    .mobile-only {
        display: block;
    }
    
    .desktop-only {
        display: none !important;
    }
}

/* ==================== END OF RESPONSIVE STYLES ==================== */
