/**
 * =============================================================================
 * SmartVision - Feedback Widget CSS
 * =============================================================================
 *
 * Widget flutuante para envio de bugs e sugestões.
 * Posicionado no canto inferior direito da tela.
 */

/* =============================================================================
   WIDGET CONTAINER
   ============================================================================= */

.feedback-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
}

/* =============================================================================
   TAB (BOTÃO MINIMIZADO)
   ============================================================================= */

.feedback-tab {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--primary, #3b82f6) 0%, var(--primary-dark, #2563eb) 100%);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.4);
    transition: all 0.3s ease;
    position: relative;
}

.feedback-tab:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(59, 130, 246, 0.5);
}

.feedback-tab svg {
    width: 24px;
    height: 24px;
    color: white;
}

/* Badge de notificação */
.feedback-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    background: var(--danger, #ef4444);
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
}

/* Esconde tab quando painel está aberto */
.feedback-widget.expanded .feedback-tab {
    display: none;
}

/* =============================================================================
   PAINEL EXPANDIDO
   ============================================================================= */

.feedback-panel {
    display: none;
    width: 380px;
    max-height: 520px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    flex-direction: column;
}

.feedback-widget.expanded .feedback-panel {
    display: flex;
    animation: feedbackSlideUp 0.3s ease;
}

@keyframes feedbackSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* =============================================================================
   HEADER DO PAINEL
   ============================================================================= */

.feedback-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: linear-gradient(135deg, var(--primary, #3b82f6) 0%, var(--primary-dark, #2563eb) 100%);
    color: white;
}

.feedback-header-title {
    font-size: 0.95rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.feedback-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: background 0.2s;
}

.feedback-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* =============================================================================
   TABS DE NAVEGAÇÃO
   ============================================================================= */

.feedback-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color, #e2e8f0);
    background: #f8fafc;
}

.feedback-tabs button {
    flex: 1;
    padding: 12px 8px;
    background: none;
    border: none;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary, #64748b);
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.feedback-tabs button:hover {
    color: var(--text-primary, #1e293b);
    background: #f1f5f9;
}

.feedback-tabs button.active {
    color: var(--primary, #3b82f6);
    font-weight: 600;
}

.feedback-tabs button.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary, #3b82f6);
}

/* Badge nas tabs */
.feedback-tabs button .tab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    background: var(--danger, #ef4444);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    border-radius: 9px;
    margin-left: 4px;
    padding: 0 4px;
}

/* =============================================================================
   CONTEÚDO DO PAINEL
   ============================================================================= */

.feedback-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.feedback-tab-content {
    display: none;
}

.feedback-tab-content.active {
    display: block;
}

/* =============================================================================
   FORMULÁRIO
   ============================================================================= */

.feedback-form .form-group {
    margin-bottom: 14px;
}

.feedback-form label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary, #64748b);
    margin-bottom: 6px;
}

.feedback-form input,
.feedback-form select,
.feedback-form textarea {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid var(--border-color, #e2e8f0);
    border-radius: 8px;
    font-size: 0.9rem;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.feedback-form input:focus,
.feedback-form select:focus,
.feedback-form textarea:focus {
    outline: none;
    border-color: var(--primary, #3b82f6);
}

.feedback-form textarea {
    min-height: 80px;
    resize: vertical;
}

/* Upload de imagens */
.feedback-attachments {
    margin-top: 12px;
}

.feedback-attachments-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-secondary, #64748b);
    margin-bottom: 8px;
}

.feedback-attachments-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.feedback-attachment-slot {
    aspect-ratio: 1;
    border: 2px dashed var(--border-color, #e2e8f0);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
    background: #f8fafc;
}

.feedback-attachment-slot:hover {
    border-color: var(--primary, #3b82f6);
    background: #f1f5f9;
}

.feedback-attachment-slot.filled {
    border-style: solid;
    border-color: var(--success, #10b981);
}

.feedback-attachment-slot img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.feedback-attachment-slot .remove-btn {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    background: var(--danger, #ef4444);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.7rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.feedback-attachment-slot .add-icon {
    color: var(--text-muted, #94a3b8);
    font-size: 1.5rem;
}

/* Botão de debug info */
.feedback-debug-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 10px 12px;
    background: #f1f5f9;
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 8px;
    font-size: 0.8rem;
    color: var(--text-secondary, #64748b);
    cursor: pointer;
    transition: all 0.2s;
}

.feedback-debug-btn:hover {
    background: #e2e8f0;
}

.feedback-debug-btn.copied {
    background: #d1fae5;
    border-color: var(--success, #10b981);
    color: #065f46;
}

/* Botões de ação */
.feedback-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

.feedback-actions .btn {
    flex: 1;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.feedback-actions .btn-primary {
    background: var(--primary, #3b82f6);
    color: white;
}

.feedback-actions .btn-primary:hover {
    background: var(--primary-dark, #2563eb);
}

.feedback-actions .btn-primary:disabled {
    background: #94a3b8;
    cursor: not-allowed;
}

/* =============================================================================
   LISTA DE MENSAGENS (Minhas Mensagens)
   ============================================================================= */

.feedback-messages-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.feedback-message-item {
    background: #f8fafc;
    border-radius: 10px;
    padding: 12px;
    border-left: 3px solid var(--primary, #3b82f6);
}

.feedback-message-item.has-reply {
    border-left-color: var(--success, #10b981);
}

.feedback-message-item.unread {
    background: #fef3c7;
    border-left-color: var(--warning, #f59e0b);
}

.feedback-message-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.feedback-message-type {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    text-transform: uppercase;
}

.feedback-message-type.bug {
    background: #fee2e2;
    color: #991b1b;
}

.feedback-message-type.sugestao {
    background: #dbeafe;
    color: #1e40af;
}

.feedback-message-date {
    font-size: 0.7rem;
    color: var(--text-muted, #94a3b8);
}

.feedback-message-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary, #1e293b);
    margin-bottom: 4px;
}

.feedback-message-status {
    font-size: 0.75rem;
    color: var(--text-secondary, #64748b);
}

/* Resposta do admin */
.feedback-reply-box {
    margin-top: 10px;
    padding: 10px;
    background: white;
    border-radius: 8px;
    border: 1px solid var(--border-color, #e2e8f0);
}

.feedback-reply-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: var(--text-secondary, #64748b);
    margin-bottom: 6px;
}

.feedback-reply-text {
    font-size: 0.85rem;
    color: var(--text-primary, #1e293b);
    line-height: 1.4;
}

.feedback-reply-actions {
    margin-top: 8px;
    display: flex;
    justify-content: flex-end;
}

.feedback-ok-btn {
    padding: 6px 16px;
    background: var(--success, #10b981);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.feedback-ok-btn:hover {
    background: #059669;
}

/* Estado vazio */
.feedback-empty {
    text-align: center;
    padding: 30px 20px;
    color: var(--text-secondary, #64748b);
}

.feedback-empty svg {
    width: 48px;
    height: 48px;
    margin-bottom: 12px;
    opacity: 0.4;
}

.feedback-empty p {
    font-size: 0.875rem;
    margin: 0;
}

/* =============================================================================
   LOADING E SUCESSO
   ============================================================================= */

.feedback-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.feedback-loading::after {
    content: '';
    width: 32px;
    height: 32px;
    border: 3px solid #e2e8f0;
    border-top-color: var(--primary, #3b82f6);
    border-radius: 50%;
    animation: feedbackSpin 0.8s linear infinite;
}

@keyframes feedbackSpin {
    to {
        transform: rotate(360deg);
    }
}

.feedback-success {
    text-align: center;
    padding: 30px 20px;
}

.feedback-success svg {
    width: 48px;
    height: 48px;
    color: var(--success, #10b981);
    margin-bottom: 12px;
}

.feedback-success h4 {
    margin: 0 0 8px 0;
    font-size: 1rem;
    color: var(--text-primary, #1e293b);
}

.feedback-success p {
    margin: 0;
    font-size: 0.875rem;
    color: var(--text-secondary, #64748b);
}

/* =============================================================================
   RESPONSIVO (MOBILE)
   ============================================================================= */

@media (max-width: 480px) {
    .feedback-widget {
        bottom: 10px;
        right: 10px;
        left: 10px;
    }

    .feedback-panel {
        width: 100%;
        max-height: 70vh;
    }

    .feedback-tab {
        width: 50px;
        height: 50px;
    }

    .feedback-tabs button {
        padding: 10px 4px;
        font-size: 0.75rem;
    }

    .feedback-content {
        padding: 12px;
    }

    .feedback-attachments-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 6px;
    }
}
