/* admin.css - Estilos do Dashboard & Suporte */
body {
    background-color: #050505;
    color: white;
    font-family: 'Outfit', sans-serif;
}

/* --- SIDEBAR & LAYOUT --- */
.sidebar {
    background: rgba(18, 18, 18, 0.95);
    border-right: 1px solid rgba(136, 67, 255, 0.1);
    height: 100vh;
    position: fixed;
    width: 260px;
    padding: 2rem;
    z-index: 50;
    transition: transform 0.3s ease;
}

.main-content {
    margin-left: 260px;
    padding: 2rem;
    min-height: 100vh;
}

/* --- MOBILE MENU TOGGLE --- */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 60;
    background: #8843ff;
    border: none;
    padding: 0.75rem;
    border-radius: 8px;
    color: white;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(136, 67, 255, 0.4);
}

.mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    z-index: 49;
}

.admin-card {
    background: #121212;
    border: 1px solid #333;
    border-radius: 12px;
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
    transition: border-color 0.3s;
}

.stat-value {
    font-size: 2rem;
    font-weight: bold;
    color: white;
}

.stat-label {
    color: #888;
    font-size: 0.9rem;
    text-transform: uppercase;
}

/* --- TABELAS --- */
.admin-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.admin-table th {
    text-align: left;
    padding: 1rem;
    color: #8843ff;
    border-bottom: 1px solid #333;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.admin-table td {
    padding: 1rem;
    border-bottom: 1px solid #222;
    color: #ccc;
    font-size: 0.95rem;
}

.admin-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

/* --- NAVEGAÇÃO --- */
.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    border-radius: 10px;
    color: #888;
    transition: all 0.3s;
    margin-bottom: 8px;
    cursor: pointer;
    font-weight: 500;
}

.nav-link:hover, .nav-link.active {
    background: rgba(136, 67, 255, 0.15);
    color: #8843ff;
    border: 1px solid rgba(136, 67, 255, 0.2);
}

.nav-link i {
    font-size: 1.1rem;
}

/* --- ABAS INTERNAS (Sub-tabs) --- */
.sub-tab-btn {
    padding-bottom: 0.75rem;
    color: #666;
    font-weight: 600;
    border-bottom: 2px solid transparent;
    transition: all 0.3s;
}

.sub-tab-btn:hover { color: #ccc; }

.sub-tab-btn.active {
    color: white;
    border-color: #8843ff;
}

/* --- MODAIS --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.85);
    backdrop-filter: blur(5px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: #1a1a1a;
    padding: 2rem;
    border-radius: 16px;
    width: 500px;
    border: 1px solid #333;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    animation: modalSlideUp 0.3s ease-out;
}

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

/* --- GERENCIADOR DE IMAGENS --- */
.image-manager-container {
    background: #0a0a0a;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.image-input-group {
    display: flex;
    gap: 10px;
    margin-bottom: 1rem;
}

.image-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 10px;
    margin-top: 1rem;
}

.image-item {
    position: relative;
    background: #1a1a1a;
    border: 1px solid #444;
    border-radius: 6px;
    aspect-ratio: 1;
    cursor: grab;
    overflow: hidden;
    transition: transform 0.2s;
}

.image-item:active {
    cursor: grabbing;
    transform: scale(1.05);
    border-color: #8843ff;
}

.image-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.remove-img-btn {
    position: absolute;
    top: 2px;
    right: 2px;
    background: rgba(0,0,0,0.8);
    color: #ff4444;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* --- SCROLLBAR --- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #0a0a0a; }
::-webkit-scrollbar-thumb { background: #333; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #8843ff; }

/* =========================================
   NOVO: CENTRAL DE SUPORTE (Help Desk)
   ========================================= */

.support-container {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 20px;
    /* Aumentei o desconto de 140px para 220px para compensar os botões novos */
    height: calc(100vh - 220px); 
}
/* Lista de Tickets (Esquerda) */
.ticket-sidebar {
    background: #121212;
    border: 1px solid #333;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.ticket-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.ticket-item {
    padding: 15px;
    border-radius: 8px;
    background: #1a1a1a;
    border: 1px solid transparent;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.ticket-item:hover {
    background: #222;
    border-color: #444;
}

.ticket-item.active {
    background: rgba(136, 67, 255, 0.1);
    border-color: #8843ff;
}

.ticket-item.unread::after {
    content: '';
    position: absolute;
    top: 15px;
    right: 15px;
    width: 8px;
    height: 8px;
    background: #00ff88;
    border-radius: 50%;
    box-shadow: 0 0 5px #00ff88;
}

.ticket-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
}

.ticket-protocol {
    font-size: 0.75rem;
    color: #888;
    font-family: monospace;
}

.ticket-time {
    font-size: 0.7rem;
    color: #666;
}

.ticket-last-msg {
    font-size: 0.85rem;
    color: #ccc;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Área de Chat (Direita) */
.chat-area-container {
    background: #121212;
    border: 1px solid #333;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* Tela de "Selecione um Ticket" */
.no-chat-selected {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #444;
}

.no-chat-selected i {
    font-size: 4rem;
    margin-bottom: 1rem;
    color: #333;
}

/* Área de Conversa Ativa */
.active-chat-interface {
    display: none; /* Oculto por padrão */
    flex-direction: column;
    height: 100%;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    background: #0a0a0a;
}

.admin-msg-bubble {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 0.95rem;
    line-height: 1.4;
    position: relative;
}

.msg-user {
    align-self: flex-start;
    background: #1f1f1f;
    color: #e0e0e0;
    border-bottom-left-radius: 2px;
    border: 1px solid #333;
}

.msg-staff {
    align-self: flex-end;
    background: #8843ff;
    color: white;
    border-bottom-right-radius: 2px;
}

.msg-bot {
    align-self: flex-start;
    background: #111;
    border: 1px solid #333;
    color: #888;
    font-size: 0.85rem;
    border-radius: 8px;
    max-width: 90%;
}

.msg-system {
    align-self: center;
    background: rgba(255, 255, 255, 0.05);
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 0.75rem;
    color: #888;
    margin: 10px 0;
}

/* Painel de Controle (Input) */
.chat-controls {
    padding: 15px;
    background: #121212;
    border-top: 1px solid #333;
    display: flex;
    gap: 10px;
}

.chat-input-admin {
    flex: 1;
    background: #0a0a0a;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 12px;
    color: white;
    outline: none;
}

.chat-input-admin:focus { border-color: #8843ff; }

/* Botão de Assumir */
.take-ticket-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 20px;
    background: rgba(18, 18, 18, 0.9);
    backdrop-filter: blur(5px);
    border-top: 1px solid #333;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 10px;
}

/* AI Summary Box */
.ai-summary-box {
    background: linear-gradient(135deg, rgba(136, 67, 255, 0.1), rgba(10, 10, 10, 0.8));
    border: 1px solid rgba(136, 67, 255, 0.3);
    border-radius: 12px;
    padding: 15px;
    margin: 15px;
    display: flex;
    gap: 15px;
    align-items: start;
}

.ai-icon-pulse {
    background: #8843ff;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 15px rgba(136, 67, 255, 0.5);
    flex-shrink: 0;
}

.summary-content h4 {
    color: #8843ff;
    font-weight: bold;
    font-size: 0.9rem;
    margin-bottom: 5px;
    text-transform: uppercase;
}

.summary-text {
    color: #ddd;
    font-size: 0.9rem;
    line-height: 1.4;
}

/* =========================================
   ESTILOS DO NOVO SUPORTE (FILTROS E FILA)
   ========================================= */

/* --- 1. Botões de Filtro (Abas) --- */
.sub-tab-btn {
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 10px 16px;
    font-size: 0.9rem;
    font-weight: 600;
    color: #666; /* Cor padrão inativo */
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    outline: none;
}

.sub-tab-btn:hover {
    color: #ccc;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 4px 4px 0 0;
}

/* Estado Ativo (Geral) */
.sub-tab-btn.active {
    color: #fff;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px 4px 0 0;
}

/* Cores específicas quando ativo (Borda inferior) */
.sub-tab-btn.active.border-red-500 {
    border-bottom-color: #ef4444 !important; /* Vermelho para Fila */
}

.sub-tab-btn.active.border-brand-purple {
    border-bottom-color: #8843ff !important; /* Roxo para Atendendo/IA */
}

.sub-tab-btn.active.border-gray-500 {
    border-bottom-color: #6b7280 !important; /* Cinza para Finalizados */
}

/* Badge (Contador) da Fila */
#badge-queue {
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 10px;
    background: #ef4444;
    color: white;
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.5);
}

/* --- 2. Lista de Tickets --- */
.ticket-list {
    padding-right: 5px; /* Espaço para scrollbar não colar */
}

.ticket-item {
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ticket-item:hover {
    background: #222;
    transform: translateX(2px); /* Leve movimento para direita ao passar mouse */
    border-color: #555;
}

.ticket-item.active {
    background: rgba(136, 67, 255, 0.05);
    border-color: #8843ff;
    box-shadow: 0 0 15px rgba(136, 67, 255, 0.1);
}

/* Estilo Específico: NA FILA (Waiting Human) */
.ticket-item.border-l-red-500 {
    border-left: 4px solid #ef4444;
    background: linear-gradient(90deg, rgba(239, 68, 68, 0.05) 0%, rgba(26, 26, 26, 1) 100%);
}
.ticket-item.border-l-red-500:hover {
    border-color: #ef4444; /* Borda fica vermelha ao passar mouse */
}

/* Estilo Específico: EM ATENDIMENTO (In Progress) */
.ticket-item.border-l-brand-purple {
    border-left: 4px solid #8843ff;
    background: linear-gradient(90deg, rgba(136, 67, 255, 0.05) 0%, rgba(26, 26, 26, 1) 100%);
}

/* Tipografia dentro do Ticket */
.ticket-protocol {
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
    color: #888;
    background: rgba(0,0,0,0.3);
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0.5px;
}

.ticket-time {
    font-size: 0.7rem;
    color: #666;
}

.ticket-last-msg {
    font-size: 0.8rem;
    color: #aaa;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2; /* Limita a 2 linhas */
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* --- 3. Scrollbar Personalizada para a Lista --- */
.ticket-list::-webkit-scrollbar {
    width: 6px;
}

.ticket-list::-webkit-scrollbar-track {
    background: #121212;
}

.ticket-list::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 10px;
}

.ticket-list::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* --- 4. Animação de Pulso Vermelho (Para alertas urgentes) --- */
@keyframes pulse-red-glow {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    70% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.animate-pulse {
    animation: pulse-red-glow 2s infinite;
}

/* =========================================
   RESPONSIVIDADE MOBILE
   ========================================= */

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    /* Aumenta área de toque dos botões */
    button, .nav-link, .ticket-item {
        min-height: 44px; /* Tamanho mínimo recomendado pela Apple */
        -webkit-tap-highlight-color: rgba(136, 67, 255, 0.2);
    }

    /* Remove hover em dispositivos touch */
    .nav-link:hover, .ticket-item:hover {
        transform: none;
    }
}

/* Scroll suave em mobile */
@media (max-width: 768px) {
    * {
        -webkit-overflow-scrolling: touch;
    }
}

@media (max-width: 768px) {
    /* --- MENU HAMBÚRGUER --- */
    .mobile-menu-toggle {
        display: block !important;
    }

    /* Sidebar escondida por padrão no mobile */
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
        padding: 1.5rem;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .mobile-overlay.active {
        display: block;
    }

    /* Conteúdo ocupa tela toda */
    .main-content {
        margin-left: 0;
        padding: 1rem;
        padding-top: 4rem; /* Espaço pro botão hambúrguer */
    }

    /* --- DASHBOARD CARDS --- */
    .grid {
        grid-template-columns: 1fr !important;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    /* --- TABELAS RESPONSIVAS --- */
    .admin-table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }

    .admin-table thead {
        display: none; /* Esconde cabeçalho em mobile */
    }

    .admin-table tbody,
    .admin-table tr,
    .admin-table td {
        display: block;
        width: 100%;
    }

    .admin-table tr {
        background: #1a1a1a;
        border: 1px solid #333;
        border-radius: 8px;
        margin-bottom: 1rem;
        padding: 1rem;
    }

    .admin-table td {
        border: none;
        padding: 0.5rem 0;
        text-align: left !important;
        position: relative;
        padding-left: 50%;
    }

    .admin-table td::before {
        content: attr(data-label);
        position: absolute;
        left: 0;
        width: 45%;
        padding-right: 10px;
        white-space: nowrap;
        font-weight: bold;
        color: #8843ff;
        font-size: 0.85rem;
    }

    /* Botões de ação em cards mobile */
    .admin-table td .flex {
        flex-direction: column;
        gap: 0.5rem;
    }

    .admin-table td button {
        width: 100%;
        justify-content: center;
    }

    /* --- MODAIS --- */
    .modal-content {
        width: 95%;
        max-width: 95%;
        max-height: 90vh;
        overflow-y: auto;
        padding: 1.5rem;
    }

    /* --- FORMS --- */
    .grid.grid-cols-2 {
        grid-template-columns: 1fr !important;
    }

    /* --- SUPORTE (CHAT) --- */
    .support-container {
        grid-template-columns: 1fr !important;
        height: calc(100vh - 180px);
        position: relative;
    }

    .ticket-sidebar {
        display: none; /* Esconde lista em mobile por padrão */
    }

    .ticket-sidebar.mobile-show {
        display: flex;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        z-index: 55;
        border-radius: 0;
        margin: 0;
    }

    .chat-area-container {
        height: calc(100vh - 180px);
        width: 100%;
    }

    .chat-messages {
        padding: 15px 10px;
    }

    .admin-msg-bubble {
        max-width: 85%;
        font-size: 0.9rem;
        padding: 10px 12px;
    }

    .chat-controls {
        padding: 10px;
        flex-wrap: nowrap;
    }

    .chat-controls button {
        flex-shrink: 0;
    }

    /* Ajusta o overlay de assumir ticket */
    .take-ticket-overlay {
        padding: 20px 15px;
    }

    .take-ticket-overlay h3 {
        font-size: 1.25rem;
    }

    .take-ticket-overlay p {
        font-size: 0.85rem;
    }

    /* --- BOTÕES E FILTROS --- */
    .flex.gap-6,
    .flex.gap-4 {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .sub-tab-btn {
        font-size: 0.8rem;
        padding: 8px 12px;
    }

    /* --- CATEGORIAS GRID --- */
    #categories-grid {
        grid-template-columns: 1fr !important;
    }

    /* --- IMAGE MANAGER --- */
    .image-list {
        grid-template-columns: repeat(3, 1fr) !important;
    }

    /* --- OVERLAY DO TICKET --- */
    .take-ticket-overlay {
        padding: 15px;
    }

    .take-ticket-overlay button {
        width: 100%;
        padding: 15px;
    }

    /* --- TÍTULOS --- */
    h1 {
        font-size: 1.5rem !important;
    }

    h2 {
        font-size: 1.25rem !important;
    }

    /* --- ACTIONS BAR --- */
    .flex.justify-between {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch !important;
    }

    .flex.justify-between button,
    .flex.justify-end button {
        width: 100%;
        justify-content: center;
    }

    /* Botões full width em mobile */
    .flex.items-center.gap-2 button,
    .flex.items-center.gap-3 button {
        width: 100%;
    }

    /* --- CHARTS --- */
    .admin-card.h-96 {
        height: 300px !important;
    }

    /* --- TABELAS: SCROLL HORIZONTAL SUAVE --- */
    .admin-card.overflow-hidden {
        overflow-x: auto;
    }

    /* Indicador visual de scroll */
    .admin-card.overflow-hidden::after {
        content: '← Arraste →';
        position: sticky;
        right: 0;
        bottom: 10px;
        background: rgba(136, 67, 255, 0.8);
        padding: 5px 10px;
        border-radius: 20px;
        font-size: 0.7rem;
        color: white;
        pointer-events: none;
        opacity: 0.7;
        float: right;
        margin-top: -30px;
    }

    /* --- REVIEW MODAL (Análise de Produto) --- */
    #review-modal .modal-content {
        max-width: 98%;
    }

    #review-modal .grid {
        grid-template-columns: 1fr !important;
    }

    #review-modal img {
        height: 200px !important;
    }

    /* --- MELHORIAS DE USABILIDADE --- */
    /* Remove outline azul do iOS */
    * {
        -webkit-tap-highlight-color: transparent;
        outline: none;
    }

    /* Melhora o scroll em iOS */
    body {
        -webkit-overflow-scrolling: touch;
        overflow-x: hidden;
    }
}

@media (max-width: 480px) {
    /* Ajustes extras para telas muito pequenas */
    .main-content {
        padding: 0.75rem;
        padding-top: 4rem;
    }

    .admin-card {
        padding: 1rem;
    }

    .stat-value {
        font-size: 1.25rem;
    }

    .modal-content {
        padding: 1rem;
        width: 98%;
    }

    .image-list {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Botões menores em mobile */
    button {
        font-size: 0.85rem;
    }

    /* Input e textarea com melhor tamanho */
    input, textarea, select {
        font-size: 16px !important; /* Evita zoom no iOS */
    }

    /* Chat controls mais compactos */
    .chat-input-admin {
        font-size: 14px;
        padding: 10px;
    }

    /* Sidebar mais estreita em telas muito pequenas */
    .sidebar {
        width: 85%;
        max-width: 280px;
    }
}

/* ============================================ */
/* === ESTILOS PARA GERENCIAMENTO DE USUÁRIOS === */
/* ============================================ */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 9999px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-success {
    background: rgba(0, 255, 136, 0.15);
    color: #00ff88;
    border: 1px solid rgba(0, 255, 136, 0.3);
}

.badge-danger {
    background: rgba(255, 0, 68, 0.15);
    color: #ff0044;
    border: 1px solid rgba(255, 0, 68, 0.3);
}

.badge-warning {
    background: rgba(255, 170, 0, 0.15);
    color: #ffaa00;
    border: 1px solid rgba(255, 170, 0, 0.3);
}

.badge-purple {
    background: rgba(136, 67, 255, 0.15);
    color: #8843ff;
    border: 1px solid rgba(136, 67, 255, 0.3);
}

.badge-blue {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.badge-pink {
    background: rgba(236, 72, 153, 0.15);
    color: #ec4899;
    border: 1px solid rgba(236, 72, 153, 0.3);
}

.badge-yellow {
    background: rgba(234, 179, 8, 0.15);
    color: #eab308;
    border: 1px solid rgba(234, 179, 8, 0.3);
}

/* Melhorias na tabela de usuários */
.admin-table tbody tr {
    transition: all 0.2s ease;
}

.admin-table tbody tr:hover {
    background: rgba(136, 67, 255, 0.05);
    transform: translateX(2px);
}

/* Badge Exclusiva de Owner */
.badge-owner {
    background: rgba(255, 215, 0, 0.15); /* Dourado */
    color: #FFD700;
    border: 1px solid rgba(255, 215, 0, 0.3);
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.2);
    font-weight: 800;
    letter-spacing: 1px;
}