/* ===================================
   MOBILE-FIRST CSS - CHAT LLM
   Interface otimizada para dispositivos móveis
   =================================== */

/* Esconder elementos desktop no mobile */
@media (max-width: 768px) {
    /* PÁGINA INICIAL - MOBILE */
    .sidebar,
    .models-dropdown-container,
    .cost-info {
        display: none !important;
    }
    
    .app-layout {
        flex-direction: column;
        padding: 0;
    }
    
    .main-content {
        padding: 1rem;
        padding-bottom: 100px; /* Espaço para bottom nav */
        height: 100vh;
        overflow-y: auto;
        display: flex;
        flex-direction: column;
    }
    
    .welcome-screen {
        padding: 0;
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }
    
    .welcome-header {
        text-align: center;
        margin-bottom: 2rem;
        position: relative;
    }
    
    .theme-toggle-home {
        display: flex !important;
        position: absolute;
        top: 0;
        right: 0;
        background: var(--bg-sidebar);
        border: 1px solid var(--border);
        border-radius: 50%;
        width: 44px;
        height: 44px;
        align-items: center;
        justify-content: center;
        font-size: 1.25rem;
        cursor: pointer;
    }
    
    .welcome-icon {
        font-size: 4rem;
        margin-bottom: 1rem;
    }
    
    .welcome-header h2 {
        font-size: 1.75rem;
        margin-bottom: 0.5rem;
        font-weight: 700;
    }
    
    .welcome-subtitle {
        font-size: 1rem;
        color: var(--text-secondary);
        margin-bottom: 1rem;
    }
    
    /* BOTÃO FLUTUANTE DE MODELO (REMOVIDO - USANDO TESS-STYLE) */
    .models-grid-mobile,
    .floating-model-btn,
    .current-model-indicator {
        display: none !important;
    }
    
    /* TESS-STYLE INPUT AREA - Mobile Override */
    .tess-input-area {
        display: block !important; /* Garantir visibilidade */
        max-width: 100%;
        margin: 0 0 1rem 0;
        background: var(--bg-sidebar);
        border: 1px solid var(--border);
        border-radius: 1rem;
        padding: 1rem;
        box-shadow: none;
    }
    
    .tess-textarea {
        width: 100%;
        border: none;
        background: transparent;
        font-size: 1rem;
        line-height: 1.5;
        resize: none;
        outline: none;
        color: var(--text-primary);
        font-family: inherit;
        margin-bottom: 0.75rem;
        min-height: 60px;
    }
    
    .tess-textarea::placeholder {
        color: var(--text-muted);
    }
    
    .tess-toolbar {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 0.5rem;
    }
    
    .tess-toolbar-left,
    .tess-toolbar-right {
        display: flex;
        gap: 0.5rem;
        align-items: center;
    }
    
    .tess-tool-btn {
        width: 40px;
        height: 40px;
        border-radius: 0.5rem;
        border: 1px solid var(--border);
        background: var(--bg-main);
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.25rem;
        cursor: pointer;
        transition: all 0.2s;
    }
    
    .tess-tool-btn:active {
        transform: scale(0.95);
        background: var(--border);
    }
    
    .tess-model-selector {
        padding: 0.5rem 1rem;
        border-radius: 1.5rem;
        border: 1px solid var(--border);
        background: var(--bg-main);
        display: flex;
        align-items: center;
        gap: 0.5rem;
        font-size: 0.9rem;
        font-weight: 500;
        cursor: pointer;
        transition: all 0.2s;
        color: var(--text-primary);
        white-space: nowrap;
    }
    
    .tess-model-selector:active {
        transform: scale(0.95);
    }
    
    .tess-send-btn {
        width: 44px;
        height: 44px;
        border-radius: 50%;
        border: none;
        background: linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%);
        color: white;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.5rem;
        cursor: pointer;
        transition: all 0.2s;
        box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
    }
    
    .tess-send-btn:active {
        transform: scale(0.95);
    }
    
    /* RECURSOS ABAIXO DO INPUT */
    .tess-resources {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
        margin-bottom: 1.5rem;
    }
    
    .tess-resource-btn {
        padding: 0.75rem 1rem;
        border-radius: 0.75rem;
        border: 1px solid var(--border);
        background: var(--bg-sidebar);
        font-size: 0.85rem;
        text-align: left;
        cursor: pointer;
        transition: all 0.2s;
        color: var(--text-primary);
    }
    
    .tess-resource-btn:active {
        transform: scale(0.98);
        background: var(--bg-main);
    }
    
    .model-card-mobile {
        background: transparent;
        border: none;
        border-bottom: 1px solid var(--border);
        border-radius: 0;
        padding: 1rem;
        display: flex;
        align-items: center;
        gap: 0.75rem;
        cursor: pointer;
        transition: all 0.2s;
        text-decoration: none;
        color: var(--text-primary);
        margin: 0;
    }
    
    .model-card-mobile:active {
        background: var(--bg-main);
    }
    
    .model-card-mobile.selected {
        background: var(--bg-main);
    }
    
    .model-card-mobile:last-child {
        border-bottom: none;
    }
    
    .model-card-icon {
        font-size: 2.5rem;
        flex-shrink: 0;
    }
    
    .model-card-info {
        flex: 1;
    }
    
    .model-card-name {
        font-weight: 600;
        font-size: 1rem;
        margin-bottom: 0.25rem;
        color: var(--text-primary);
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }
    
    .model-logo {
        width: 20px;
        height: 20px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
    }
    
    .model-logo img {
        width: 100%;
        height: 100%;
        object-fit: contain;
    }
    
    .model-icon-inline {
        font-size: 1.2rem;
    }
    
    .model-card-provider {
        font-size: 0.85rem;
        color: var(--text-secondary);
    }
    
    .model-card-badge {
        padding: 0.25rem 0.5rem;
        border-radius: 0.375rem;
        font-size: 0.65rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.3px;
    }
    
    .model-card-badge.badge-novo {
        background: #10B981;
        color: white;
    }
    
    .model-card-badge.badge-beta {
        background: #8B5CF6;
        color: white;
    }
    
    .model-card-badge.badge-max {
        background: #000000;
        color: white;
    }
    
    /* BOTTOM SHEET PARA MAIS MODELOS */
    .bottom-sheet-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 199;
        display: none;
        backdrop-filter: blur(2px);
    }
    
    .bottom-sheet-overlay.active {
        display: block;
    }
    
    .models-bottom-sheet {
        position: fixed;
        bottom: -100%;
        left: 0;
        right: 0;
        background: var(--bg-sidebar);
        border-radius: 1.5rem 1.5rem 0 0;
        max-height: 80vh;
        transition: bottom 0.3s ease;
        z-index: 200;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.2);
    }
    
    .models-bottom-sheet.active {
        bottom: 0;
    }
    
    .bottom-sheet-handle {
        width: 40px;
        height: 4px;
        background: var(--border);
        border-radius: 2px;
        margin: 0.75rem auto;
    }
    
    .bottom-sheet-header {
        padding: 0.5rem 1rem 1rem;
        border-bottom: 1px solid var(--border);
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    
    .bottom-sheet-header h3 {
        font-size: 1.1rem;
        margin: 0;
        font-weight: 700;
        color: var(--text-primary);
    }
    
    .bottom-sheet-close {
        background: none;
        border: none;
        font-size: 1.5rem;
        color: var(--text-secondary);
        cursor: pointer;
        padding: 0.25rem 0.5rem;
        line-height: 1;
    }
    
    .bottom-sheet-close:active {
        transform: scale(0.9);
    }
    
    .bottom-sheet-search {
        width: 100%;
        padding: 0.75rem 1rem;
        border: 1px solid var(--border);
        border-radius: 0.75rem;
        font-size: 0.95rem;
        background: var(--bg-main);
        outline: none;
    }
    
    .bottom-sheet-search:focus {
        border-color: var(--primary);
    }
    
    .model-section-label {
        padding: 0.75rem 1rem 0.5rem;
        font-size: 0.75rem;
        font-weight: 600;
        color: var(--text-secondary);
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }
    
    .bottom-sheet-content {
        padding: 1rem;
        overflow-y: auto;
        max-height: calc(80vh - 120px);
    }
    
    /* PÁGINA DE CHAT - MOBILE */
    .chat-main {
        width: 100%;
        height: calc(100vh - 80px);
        display: flex;
        flex-direction: column;
    }
    
    .chat-header {
        padding: 0.75rem 1rem;
        border-bottom: 1px solid var(--border);
        background: var(--bg-sidebar);
        flex-shrink: 0;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    
    .chat-info h2 {
        font-size: 1rem;
        margin: 0;
    }
    
    .provider-badge {
        font-size: 0.75rem;
        padding: 0.125rem 0.5rem;
        margin-top: 0.25rem;
    }
    
    .chat-actions {
        display: none;
    }
    
    .mobile-menu-btn {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        border: none;
        background: var(--bg-main);
        border-radius: 0.5rem;
        font-size: 1.25rem;
        cursor: pointer;
    }
    
    .mobile-menu-btn:active {
        transform: scale(0.95);
    }
    
    .model-selector {
        display: none;
    }
    
    /* ÁREA DE MENSAGENS */
    .messages-container {
        flex: 1;
        overflow-y: auto;
        padding: 1rem;
        padding-bottom: 150px; /* Espaço para input + bottom nav */
        -webkit-overflow-scrolling: touch;
    }
    
    .message {
        margin-bottom: 1rem;
    }
    
    .message-avatar {
        width: 32px;
        height: 32px;
        font-size: 1.25rem;
    }
    
    .message-content {
        max-width: 80%;
    }
    
    .message-text {
        padding: 0.75rem 1rem;
        font-size: 0.95rem;
        line-height: 1.5;
    }
    
    .message-time {
        font-size: 0.7rem;
        margin-top: 0.25rem;
    }
    
    /* INPUT DE MENSAGEM - MOBILE */
    .input-container {
        position: fixed;
        bottom: 60px; /* Acima do bottom nav */
        left: 0;
        right: 0;
        padding: 0.75rem 1rem;
        background: var(--bg-sidebar);
        border-top: 1px solid var(--border);
        flex-shrink: 0;
        z-index: 90;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
    }
    
    .input-wrapper {
        display: flex;
        gap: 0.5rem;
        align-items: flex-end;
        background: var(--bg-main);
        border-radius: 1.5rem;
        padding: 0.5rem;
    }
    
    #message-input {
        flex: 1;
        border: none;
        background: transparent;
        padding: 0.5rem 0.75rem;
        font-size: 16px; /* Evita zoom no iOS */
        max-height: 120px;
        resize: none;
    }
    
    .send-btn {
        width: 40px;
        height: 40px;
        border-radius: 50%;
        background: var(--primary);
        border: none;
        color: white;
        font-size: 1.25rem;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        flex-shrink: 0;
        transition: transform 0.2s;
    }
    
    .send-btn:active {
        transform: scale(0.9);
    }
    
    .send-btn:disabled {
        opacity: 0.5;
        background: var(--text-muted);
    }
    
    .input-footer {
        display: none;
    }
    
    /* BOTTOM NAVIGATION */
    .bottom-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--bg-sidebar);
        border-top: 1px solid var(--border);
        padding: 0.5rem 0;
        z-index: 100;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
    }
    
    .bottom-nav-items {
        display: flex;
        justify-content: space-around;
        align-items: center;
    }
    
    .bottom-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0.25rem;
        padding: 0.5rem 1rem;
        background: none;
        border: none;
        color: var(--text-muted);
        font-size: 0.7rem;
        cursor: pointer;
        transition: color 0.2s;
        text-decoration: none;
        min-width: 60px;
    }
    
    .bottom-nav-item.active {
        color: var(--primary);
    }
    
    .bottom-nav-item:active {
        transform: scale(0.95);
    }
    
    .bottom-nav-icon {
        font-size: 1.5rem;
    }
    
    /* EMPTY STATES */
    .empty-chat {
        text-align: center;
        padding: 3rem 1.5rem;
    }
    
    .empty-icon {
        font-size: 4rem;
        margin-bottom: 1rem;
    }
    
    .empty-chat h3 {
        font-size: 1.25rem;
        margin-bottom: 0.5rem;
    }
    
    .empty-chat p {
        font-size: 0.9rem;
        color: var(--text-secondary);
    }
    
    /* FEATURES GRID */
    .features-grid {
        display: grid;
        grid-template-columns: 1fr;
        gap: 1rem;
        margin-top: 2rem;
    }
    
    .feature-card {
        background: var(--bg-sidebar);
        border: 1px solid var(--border);
        border-radius: 1rem;
        padding: 1.5rem;
        text-align: center;
    }
    
    .feature-icon {
        font-size: 2.5rem;
        margin-bottom: 0.75rem;
    }
    
    .feature-card h3 {
        font-size: 1.1rem;
        margin-bottom: 0.5rem;
    }
    
    .feature-card p {
        font-size: 0.85rem;
        color: var(--text-secondary);
        line-height: 1.4;
    }
    
    /* BOTÃO PRIMÁRIO */
    .primary-btn {
        width: 100%;
        padding: 1rem;
        background: var(--primary);
        color: white;
        border: none;
        border-radius: 1rem;
        font-size: 1.1rem;
        font-weight: 600;
        cursor: pointer;
        transition: all 0.2s;
        margin-bottom: 1.5rem;
    }
    
    .primary-btn:active {
        transform: scale(0.98);
    }
    
    .primary-btn:disabled {
        opacity: 0.5;
        cursor: not-allowed;
    }
    
    /* TYPING INDICATOR */
    .typing-indicator {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        padding: 0.75rem;
        margin-bottom: 1rem;
    }
    
    .typing-avatar {
        width: 32px;
        height: 32px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        background: var(--msg-assistant-bg);
        font-size: 1.25rem;
    }
    
    .typing-content {
        flex: 1;
    }
    
    .typing-status {
        font-size: 0.85rem;
        color: var(--text-secondary);
        margin-bottom: 0.25rem;
    }
    
    .typing-dots {
        display: flex;
        gap: 0.25rem;
    }
    
    .typing-dots span {
        width: 6px;
        height: 6px;
        border-radius: 50%;
        background: var(--primary);
        animation: typing 1.4s infinite;
    }
    
    .typing-dots span:nth-child(2) {
        animation-delay: 0.2s;
    }
    
    .typing-dots span:nth-child(3) {
        animation-delay: 0.4s;
    }
    
    @keyframes typing {
        0%, 60%, 100% {
            opacity: 0.3;
            transform: scale(0.8);
        }
        30% {
            opacity: 1;
            transform: scale(1);
        }
    }
    
    /* SIDEBAR MOBILE (estilo Tess) */
    .mobile-menu-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 198;
        display: none;
        backdrop-filter: blur(2px);
    }
    
    .mobile-menu-overlay.active {
        display: block;
    }
    
    .mobile-menu-modal {
        position: fixed;
        top: 0;
        left: -100%;
        bottom: 0;
        width: 85%;
        max-width: 320px;
        background: var(--bg-sidebar);
        z-index: 199;
        transition: left 0.3s ease;
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
        display: flex;
        flex-direction: column;
    }
    
    .mobile-menu-modal.active {
        left: 0;
    }
    
    .mobile-sidebar-header {
        padding: 1.5rem 1rem;
        border-bottom: 1px solid var(--border);
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    
    .mobile-sidebar-logo h2 {
        font-size: 1.25rem;
        font-weight: 700;
        color: var(--text-primary);
        margin: 0;
    }
    
    .mobile-sidebar-close {
        background: none;
        border: none;
        font-size: 1.5rem;
        color: var(--text-muted);
        cursor: pointer;
        padding: 0.25rem;
        width: 32px;
        height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .mobile-sidebar-actions {
        padding: 1rem;
        border-bottom: 1px solid var(--border);
    }
    
    .mobile-new-chat-btn {
        width: 100%;
        padding: 0.75rem;
        background: var(--primary);
        color: white;
        border: none;
        border-radius: 0.5rem;
        font-size: 0.95rem;
        font-weight: 600;
        cursor: pointer;
        transition: opacity 0.2s;
    }
    
    .mobile-new-chat-btn:active {
        opacity: 0.8;
    }
    
    .mobile-sidebar-content {
        flex: 1;
        overflow-y: auto;
        padding: 0;
    }
    
    .mobile-search-box {
        padding: 1rem 1rem 0.5rem;
    }
    
    .mobile-search-input {
        width: 100%;
        padding: 0.75rem;
        border: 1px solid var(--border);
        border-radius: 0.5rem;
        background: var(--bg-main);
        font-size: 0.9rem;
        outline: none;
    }
    
    .mobile-search-input:focus {
        border-color: var(--primary);
    }
    
    .mobile-filters {
        padding: 0.5rem 1rem;
    }
    
    .mobile-filter-select {
        width: 100%;
        padding: 0.5rem;
        border: 1px solid var(--border);
        border-radius: 0.5rem;
        background: var(--bg-main);
        font-size: 0.85rem;
        color: var(--text-primary);
    }
    
    .mobile-sessions-section {
        padding: 0.5rem 0;
    }
    
    .mobile-section-label {
        padding: 0.75rem 1rem 0.5rem;
        font-size: 0.7rem;
        font-weight: 700;
        color: var(--text-secondary);
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }
    
    .mobile-session-item {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        padding: 0.75rem 1rem;
        text-decoration: none;
        color: var(--text-primary);
        border-left: 3px solid transparent;
        transition: all 0.2s;
    }
    
    .mobile-session-item:active {
        background: var(--bg-main);
    }
    
    .mobile-session-item.active {
        background: var(--bg-main);
        border-left-color: var(--primary);
    }
    
    .mobile-session-icon {
        font-size: 1.25rem;
        flex-shrink: 0;
    }
    
    .mobile-session-info {
        flex: 1;
        min-width: 0;
    }
    
    .mobile-session-title {
        font-size: 0.9rem;
        font-weight: 500;
        color: var(--text-primary);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        margin-bottom: 0.125rem;
    }
    
    .mobile-session-meta {
        font-size: 0.75rem;
        color: var(--text-secondary);
    }
    
    .mobile-session-menu {
        background: none;
        border: none;
        font-size: 1.25rem;
        color: var(--text-muted);
        cursor: pointer;
        padding: 0.25rem;
        flex-shrink: 0;
        width: 28px;
        height: 28px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 0.25rem;
    }
    
    .mobile-session-menu:active {
        background: var(--border);
    }
    
    .mobile-empty-sessions {
        padding: 2rem 1rem;
        text-align: center;
        color: var(--text-secondary);
        font-size: 0.9rem;
    }
}
