/**
 * Estilos específicos para Reclamações (Complaints)
 */

/* =============================================================================
   Detail Grid (layout 2 colunas)
   ============================================================================= */

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 24px;
}

.detail-main {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.detail-sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.detail-section {
    padding-bottom: 16px;
    border-bottom: 1px solid var(--gray-200);
}

.detail-section:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.detail-section h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 12px;
}

.detail-section h4 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.detail-section p {
    color: var(--gray-700);
    line-height: 1.6;
}

.detail-badges {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* Detail List (dl/dt/dd) */
.detail-list {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 8px 16px;
}

.detail-list dt {
    font-size: 0.813rem;
    color: var(--gray-500);
}

.detail-list dd {
    font-size: 0.875rem;
    color: var(--gray-800);
    font-weight: 500;
}

/* =============================================================================
   Timeline (Interações)
   ============================================================================= */

.timeline {
    position: relative;
    padding-left: 32px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 11px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--gray-200);
}

.timeline-item {
    position: relative;
    padding-bottom: 20px;
}

.timeline-item:last-child {
    padding-bottom: 0;
}

.timeline-icon {
    position: absolute;
    left: -32px;
    top: 0;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--white);
    border: 2px solid var(--gray-300);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-500);
}

.timeline-icon svg {
    width: 12px;
    height: 12px;
}

/* Variantes de ícone por tipo */
.timeline-item[data-type="RESPOSTA_EMPRESA"] .timeline-icon {
    border-color: var(--success);
    color: var(--success);
    background: #f0fdf4;
}

.timeline-item[data-type="MENSAGEM_CLIENTE"] .timeline-icon {
    border-color: var(--primary);
    color: var(--primary);
    background: #eff6ff;
}

.timeline-item[data-type="MUDANCA_STATUS"] .timeline-icon {
    border-color: var(--warning);
    color: var(--warning);
    background: #fffbeb;
}

.timeline-content {
    background: var(--gray-50);
    border-radius: 8px;
    padding: 12px 16px;
}

.timeline-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.timeline-header strong {
    font-size: 0.875rem;
    color: var(--gray-800);
}

.timeline-date {
    font-size: 0.75rem;
    color: var(--gray-500);
}

.timeline-content p {
    margin: 0;
    font-size: 0.875rem;
    color: var(--gray-700);
}

.timeline-content small {
    display: block;
    margin-top: 8px;
}

/* =============================================================================
   Unread Indicator
   ============================================================================= */

.unread-badge {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
    margin-right: 8px;
    flex-shrink: 0;
}

.unread-row {
    background: #f0f7ff !important;
}

.unread-row:hover {
    background: #e0efff !important;
}

/* =============================================================================
   Overdue Indicator
   ============================================================================= */

.text-danger {
    color: var(--danger) !important;
}

.icon-xs {
    width: 14px;
    height: 14px;
    vertical-align: middle;
    margin-left: 4px;
}

/* =============================================================================
   Form Section Title
   ============================================================================= */

.form-section-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--gray-700);
    margin: 24px 0 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--gray-200);
}

.form-section-title:first-of-type {
    margin-top: 16px;
}

/* =============================================================================
   Text utilities
   ============================================================================= */

.text-lg {
    font-size: 1.125rem;
    font-weight: 600;
}

.text-muted {
    color: var(--gray-500);
}

.mt-2 {
    margin-top: 8px;
}

.mb-4 {
    margin-bottom: 16px;
}

/* =============================================================================
   Detail Row (label + value inline)
   ============================================================================= */

.detail-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    font-size: 0.875rem;
}

.detail-label {
    color: var(--gray-500);
    font-weight: 500;
    min-width: 120px;
    flex-shrink: 0;
}

.detail-description {
    background: var(--gray-50);
    border-radius: 6px;
    padding: 12px;
    margin-top: 8px;
    font-size: 0.875rem;
    color: var(--gray-700);
    line-height: 1.6;
}

.detail-response {
    background: #f0fdf4;
    border-left: 3px solid var(--success);
    border-radius: 0 6px 6px 0;
    padding: 12px;
    font-size: 0.875rem;
    color: var(--gray-700);
    line-height: 1.6;
}

/* =============================================================================
   Detail Grid (4 colunas)
   ============================================================================= */

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* =============================================================================
   Evolution Chain
   ============================================================================= */

.evolution-chain {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    padding: 16px;
}

.chain-flow {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.chain-item {
    padding: 10px 14px;
    border-radius: 6px;
    background: var(--white);
    border: 1px solid var(--gray-200);
    transition: all 0.15s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 120px;
    text-align: center;
}

.chain-item .badge {
    font-size: 0.7rem;
    white-space: nowrap;
}

.chain-item .chain-badges {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: nowrap;
}

.chain-badges {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: nowrap;
}

.chain-item:hover:not(.chain-current) {
    border-color: var(--primary);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.chain-current {
    border-color: var(--primary);
    background: #eff6ff;
    font-weight: 500;
}

.chain-arrow {
    color: var(--gray-400);
    font-size: 1.25rem;
    font-weight: 700;
    display: flex;
    align-items: center;
}

.chain-icon {
    font-size: 0.75rem;
}

/* =============================================================================
   Unread Dot
   ============================================================================= */

.unread-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
}

.row-unread {
    background: #f0f7ff !important;
}

.row-unread:hover {
    background: #e0efff !important;
}

/* =============================================================================
   Timeline Marker (emoji based)
   ============================================================================= */

.timeline-marker {
    position: absolute;
    left: -32px;
    top: 2px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    background: var(--white);
    border-radius: 50%;
    z-index: 1;
}

.timeline-body {
    font-size: 0.875rem;
    color: var(--gray-700);
    line-height: 1.5;
    margin: 4px 0;
}

.timeline-author {
    font-size: 0.75rem;
    color: var(--gray-400);
    margin-top: 6px;
}

/* =============================================================================
   Form Fieldset
   ============================================================================= */

.form-fieldset {
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    padding: 16px;
    margin: 12px 0;
}

.form-fieldset legend {
    font-size: 0.813rem;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0 8px;
}

/* =============================================================================
   Alert
   ============================================================================= */

.alert {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.875rem;
}

.alert-success {
    background: #f0fdf4;
    border: 1px solid #86efac;
    color: #166534;
}

.alert-warning {
    background: #fffbeb;
    border: 1px solid #fde68a;
    color: #92400e;
}

.alert-info {
    background: #eff6ff;
    border: 1px solid #93c5fd;
    color: #1e40af;
}

/* =============================================================================
   Responsive
   ============================================================================= */

@media (max-width: 768px) {
    .detail-grid {
        grid-template-columns: 1fr;
    }
    
    .detail-sidebar {
        order: -1;
    }
    
    .timeline {
        padding-left: 24px;
    }
    
    .timeline-icon {
        left: -24px;
        width: 20px;
        height: 20px;
    }
    
    .timeline-icon svg {
        width: 10px;
        height: 10px;
    }
}

/* =============================================================================
   Link Client Modal
   ============================================================================= */

.link-client-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 300px;
    overflow-y: auto;
}

.link-client-item {
    padding: 10px 12px;
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
}

.link-client-item:hover {
    background: var(--primary-subtle);
    border-color: var(--primary);
}

/* =============================================================================
   Menu Badge
   ============================================================================= */

.menu-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    font-size: 0.65rem;
    font-weight: 700;
    color: white;
    background: var(--primary);
    border-radius: 9px;
    margin-left: auto;
}

/* =============================================================================
   Attachments List
   ============================================================================= */

.attachments-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.attachment-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    transition: background 0.15s;
}

.attachment-item:hover {
    background: var(--gray-100);
}

.attachment-icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: white;
    border-radius: 6px;
    border: 1px solid var(--gray-200);
}

.attachment-info {
    flex: 1;
    min-width: 0;
}

.attachment-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--gray-800);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.attachment-meta {
    font-size: 0.75rem;
    margin-top: 2px;
}

.attachment-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

/* Link client / assign responsible list items */
.link-client-item.active {
    background: var(--primary-50, #eff6ff);
    border-color: var(--primary);
}

/* =============================================================================
   Timeline Types - WhatsApp e Telefone
   ============================================================================= */

.timeline-item.timeline-whatsapp .timeline-marker {
    background: #25d366;
    color: white;
}

.timeline-item.timeline-whatsapp .timeline-marker svg {
    stroke: white;
}

.timeline-item.timeline-phone .timeline-marker {
    background: #0ea5e9;
    color: white;
}

.timeline-item.timeline-phone .timeline-marker svg {
    stroke: white;
}

/* =============================================================================
   Badge Small
   ============================================================================= */

.badge-sm {
    font-size: 0.625rem;
    padding: 2px 4px;
    margin-left: 4px;
    vertical-align: middle;
}

/* =============================================================================
   Subject Cell (Coluna Assunto)
   ============================================================================= */

.subject-cell {
    display: block;
    max-width: 400px;
    font-weight: 500;
    color: var(--gray-900);
    line-height: 1.4;
    /* Permite quebra de linha */
    white-space: normal;
    word-break: break-word;
}

/* =============================================================================
   Indicators Cell (Coluna de indicadores: não lido, cadeia, incompleto)
   ============================================================================= */

.indicators-cell {
    display: flex;
    align-items: center;
    gap: 4px;
    min-height: 20px;
}

.indicators-cell .unread-dot {
    position: relative;
    top: 0;
    left: 0;
}

/* =============================================================================
   Incomplete Icon (Indicador de dados incompletos)
   ============================================================================= */

.incomplete-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.incomplete-icon svg {
    width: 14px;
    height: 14px;
}

/* =============================================================================
   Documento Gerado (Anexos)
   ============================================================================= */

.attachment-generated {
    background: linear-gradient(135deg, #faf5ff 0%, #f5f3ff 100%);
    border: 1px solid #c4b5fd;
}

.attachment-generated .attachment-icon {
    background: #ede9fe;
}

.badge-purple {
    background: #ede9fe;
    color: #7c3aed;
    font-weight: 500;
}

/* =============================================================================
   Form Section Title (para modais)
   ============================================================================= */

.form-section-title {
    font-size: 0.813rem;
    font-weight: 600;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* =============================================================================
   Modal Footer Actions (layout melhorado)
   ============================================================================= */

.modal-footer-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    gap: 12px;
}

.modal-footer-left {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

/* Botão outline */
.btn-outline {
    background: transparent;
    border: 1px solid var(--gray-300);
    color: var(--gray-700);
}

.btn-outline:hover {
    background: var(--gray-50);
    border-color: var(--gray-400);
}

/* Botão ghost (sem borda) */
.btn-ghost {
    background: transparent;
    border: 1px solid transparent;
    color: var(--gray-500);
}

.btn-ghost:hover {
    background: var(--gray-100);
    color: var(--gray-700);
}

/* Responsivo para footer */
@media (max-width: 768px) {
    .modal-footer-actions {
        flex-direction: column;
        align-items: stretch;
    }
    
    .modal-footer-left {
        justify-content: center;
    }
    
    .modal-footer-actions > .btn-ghost {
        align-self: center;
    }
}
