/* AI Assistant Styles */

/* Login/Logout bar */
.ai-auth-bar {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    position: relative;
    z-index: 99;
}

.ai-auth-content {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.ai-auth-icon {
    font-size: 1.5rem;
}

.ai-auth-text h3 {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 600;
}

.ai-auth-text p {
    margin: 0;
    font-size: 0.75rem;
    opacity: 0.9;
}

.ai-login-btn {
    background: white;
    color: #28a745;
    border: none;
    padding: 0.5rem 1.5rem;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.ai-login-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* Desktop chat toggle button */
@media (min-width: 769px) {
  /* Esconder botão flutuante no desktop */
  #ai-chat-toggle {
    display: none !important;
  }
  
  /* Mostrar botão na bottom bar */
  .btn-chat-desktop {
    display: flex !important;
  }
}

.ai-logout-btn {
    background: rgba(255,255,255,0.2);
    color: white;
    border: 1px solid rgba(255,255,255,0.3);
    padding: 0.4rem 1rem;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.ai-logout-btn:hover {
    background: rgba(255,255,255,0.3);
}

/* AI Controls Container */
.ai-controls {
    margin-top: 0.5rem;
    padding: 0.75rem;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border-radius: 8px;
    border-left: 4px solid #28a745;
}

.ai-controls-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #28a745;
    margin-bottom: 0.5rem;
    display: block;
}

/* Audio Recording */
.ai-audio-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

.ai-audio-process-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

.ai-btn {
    padding: 0.4rem 0.8rem;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.ai-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ai-btn-record {
    background: #ef4444;
    color: white;
}

.ai-btn-record:hover:not(:disabled) {
    background: #dc2626;
}

.ai-btn-stop {
    background: #f59e0b;
    color: white;
}

.ai-btn-play {
    background: #10b981;
    color: white;
}

.ai-btn-clear {
    background: #6b7280;
    color: white;
}

/* Processing Options */
.ai-process-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.ai-btn-process {
    padding: 0.4rem 0.7rem;
    font-size: 0.8rem;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.ai-btn-es {
    background: #3b82f6;
    color: white;
}

.ai-btn-en {
    background: #8b5cf6;
    color: white;
}

.ai-btn-fix {
    background: #10b981;
    color: white;
}

.ai-btn-improve {
    background: #f59e0b;
    color: white;
}

.ai-btn-transcribe {
    background: #6b7280;
    color: white;
}

.ai-btn-process:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

/* Loading Indicator */
.ai-loading {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: #fef3c7;
    border-radius: 6px;
    font-size: 0.85rem;
    color: #92400e;
    margin-top: 0.5rem;
}

.ai-loading-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #f59e0b;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Recording Animation */
.recording-pulse {
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(1.05);
    }
}

/* Responsive */
@media (max-width: 768px) {
    .ai-auth-bar {
        flex-direction: column;
        gap: 0.75rem;
        align-items: stretch;
    }
    
    .ai-process-options {
        flex-direction: column;
        gap: 0.4rem !important;
    }
    
    /* Linha de áudio com 3 botões - todos com largura igual */
    .ai-audio-controls {
        gap: 0.3rem !important;
        flex-wrap: nowrap !important;
        display: flex !important;
    }
    
    .ai-audio-controls .ai-btn {
        flex: 1 1 32% !important;
        min-width: 32% !important;
    }
    
    /* Linha de processamento de áudio */
    .ai-audio-process-row {
        display: flex !important;
        gap: 0.3rem !important;
        flex-wrap: wrap !important;
    }
    
    /* Organizar botões em linhas específicas no mobile */
    .ai-btn-row {
        display: flex !important;
        flex-direction: row !important;
        gap: 0.4rem !important;
        width: 100% !important;
        flex-wrap: wrap !important;
    }
    
    /* Reduzir LARGURA dos botões de IA no mobile para caberem 3 por linha */
    .ai-btn {
        padding: 0.35rem 0.2rem !important;
        border-radius: 4px !important;
        font-size: 0.65rem !important;
        gap: 0.15rem !important;
        min-height: 44px !important;
        flex: 1 1 30% !important;
        min-width: 30% !important;
        white-space: nowrap !important;
    }
    
    .ai-btn-process {
        padding: 0.35rem 0.2rem !important;
        font-size: 0.6rem !important;
        border-radius: 4px !important;
        min-height: 44px !important;
        flex: 1 1 30% !important;
        min-width: 30% !important;
        white-space: nowrap !important;
    }
    
    .ai-controls-label {
        font-size: 0.7rem !important;
    }
}

.hidden {
    display: none !important;
}

/* AI Chat Sidebar - Toggle button removed, now in bottom bar */
.ai-chat-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: 400px;
    height: 100vh;
    background: white;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s ease;
}

.ai-chat-sidebar:not(.hidden) {
    transform: translateX(0);
}

.ai-chat-header {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ai-chat-header h3 {
    margin: 0;
    font-size: 1.2rem;
}

.ai-chat-close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.ai-chat-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    background: #f8f9fa;
}

.ai-chat-welcome {
    text-align: center;
    padding: 2rem 1rem;
    color: #666;
}

.ai-chat-welcome h4 {
    margin: 0 0 0.5rem 0;
    color: #333;
}

.chat-message {
    margin-bottom: 1rem;
    display: flex;
    gap: 0.75rem;
}

.chat-message.user {
    flex-direction: row-reverse;
}

.chat-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.chat-message.user .chat-message-avatar {
    background: #28a745;
    color: white;
}

.chat-message.ai .chat-message-avatar {
    background: #e9ecef;
}

.chat-message-content {
    max-width: 75%;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    position: relative;
}

.chat-message.user .chat-message-content {
    background: #28a745;
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-message.ai .chat-message-content {
    background: white;
    color: #333;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.chat-message-text {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.4;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.chat-message-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.chat-copy-btn {
    background: rgba(0, 0, 0, 0.1);
    border: none;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: background 0.2s;
}

.chat-copy-btn:hover {
    background: rgba(0, 0, 0, 0.2);
}

.ai-chat-input-container {
    padding: 1rem;
    border-top: 1px solid #dee2e6;
    background: white;
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
}

.ai-chat-input {
    flex: 1;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 0.75rem;
    font-size: 0.9rem;
    resize: none;
    font-family: inherit;
}

.ai-chat-input:focus {
    outline: none;
    border-color: #28a745;
}

.ai-chat-send-btn {
    background: #28a745;
    color: white;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

.ai-chat-send-btn:hover {
    background: #218838;
}

.ai-chat-send-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

@media (max-width: 768px) {
    .ai-chat-sidebar {
        width: 100%;
        display: flex;
        flex-direction: column;
        height: 100vh;
    }
    
    /* Aumentar botão e ícone de enviar no mobile */
    .ai-chat-send-btn {
        width: 56px !important;
        height: 56px !important;
    }
    
    .ai-chat-send-btn svg {
        width: 32px !important;
        height: 32px !important;
    }
    
    .ai-chat-header {
        flex-shrink: 0;
        position: sticky;
        top: 0;
        z-index: 10;
        background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    }
    
    .ai-chat-messages {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 1rem;
    }
    
    .ai-chat-input-container {
        flex-shrink: 0;
        position: sticky;
        bottom: 0;
        background: white;
        border-top: 2px solid #dee2e6;
        box-shadow: 0 -4px 12px rgba(0,0,0,0.1);
        padding: 0.75rem;
        z-index: 10;
    }
    
    .ai-chat-input {
        max-height: 80px;
        font-size: 16px !important; /* Previne zoom no iOS */
    }
    
    .ai-chat-toggle-btn {
        bottom: 5rem;
        right: 1rem;
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
    }
}

/* Modal para configuração */
.ai-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.ai-modal-content {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.ai-modal-content h2 {
    margin: 0 0 1rem 0;
    color: #28a745;
}

.ai-modal-content p {
    margin: 0.5rem 0;
    color: #333;
}

.ai-modal-content a {
    color: #28a745;
    font-weight: 600;
}

.ai-modal-content ol {
    padding-left: 1.5rem;
}

.ai-modal-content ol li {
    margin: 0.5rem 0;
}