/**
 * ═══════════════════════════════════════════════════════════════════════════════════════
 * EXCEL VIEW STYLES - Estilos da Visualização em Planilha
 * ═══════════════════════════════════════════════════════════════════════════════════════
 * 
 * Estilos customizados para a view estilo Excel usando Tabulator
 * 
 * @package DecisaoEmendas
 * @version 3.4.0
 */

/* ═══════════════════════════════════════════════════════════════════════════════════
   CONTAINER PRINCIPAL
   ═══════════════════════════════════════════════════════════════════════════════════ */

#vcpm-excel-container {
    display: none;
    margin-top: 16px;
}

.vcpm-excel-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: #f8f9fa;
    border: 1px solid #e9e9e9;
    border-bottom: none;
    border-radius: 6px 6px 0 0;
    gap: 12px;
    flex-wrap: wrap;
}

.vcpm-excel-toolbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.vcpm-excel-toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.vcpm-excel-search {
    min-width: 200px;
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 12px;
}

.vcpm-excel-search:focus {
    outline: none;
    border-color: #2185d0;
    box-shadow: 0 0 0 2px rgba(33, 133, 208, 0.15);
}

.vcpm-excel-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
}

.vcpm-excel-btn:hover {
    background: #f0f0f0;
    border-color: #ccc;
}

.vcpm-excel-btn.primary {
    background: #2185d0;
    border-color: #2185d0;
    color: white;
}

.vcpm-excel-btn.primary:hover {
    background: #1a6db3;
}

.vcpm-excel-btn i {
    font-size: 12px;
}

/* ═══════════════════════════════════════════════════════════════════════════════════
   TABULATOR CUSTOMIZATION
   ═══════════════════════════════════════════════════════════════════════════════════ */

#vcpm-excel-table {
    border: 1px solid #e9e9e9;
    border-radius: 0 0 6px 6px;
    font-size: 11px;
}

/* Header */
#vcpm-excel-table .tabulator-header {
    background: linear-gradient(180deg, #f8f9fa 0%, #e9ecef 100%);
    border-bottom: 2px solid #dee2e6;
}

#vcpm-excel-table .tabulator-col {
    background: transparent;
    border-right: 1px solid #dee2e6;
}

#vcpm-excel-table .tabulator-col-title {
    font-weight: 600;
    font-size: 11px;
    color: #495057;
    padding: 8px 6px;
}

#vcpm-excel-table .tabulator-col-sorter {
    color: #6c757d;
}

/* Filtros de cabeçalho */
#vcpm-excel-table .tabulator-header-filter input {
    padding: 4px 6px;
    font-size: 10px;
    border: 1px solid #ced4da;
    border-radius: 3px;
    width: 100%;
}

#vcpm-excel-table .tabulator-header-filter input:focus {
    outline: none;
    border-color: #2185d0;
}

/* Linhas */
#vcpm-excel-table .tabulator-row {
    border-bottom: 1px solid #f0f0f0;
    min-height: 32px;
}

#vcpm-excel-table .tabulator-row:nth-child(even) {
    background: #fafbfc;
}

#vcpm-excel-table .tabulator-row:hover {
    background: #e8f4fd !important;
}

#vcpm-excel-table .tabulator-row.tabulator-selected {
    background: #cce5ff !important;
}

/* Células */
#vcpm-excel-table .tabulator-cell {
    padding: 6px 8px;
    border-right: 1px solid #f0f0f0;
    font-size: 11px;
    line-height: 1.3;
}

#vcpm-excel-table .tabulator-cell:last-child {
    border-right: none;
}

/* Célula congelada (Município) */
#vcpm-excel-table .tabulator-frozen {
    background: #f8f9fa;
    border-right: 2px solid #dee2e6 !important;
}

/* ═══════════════════════════════════════════════════════════════════════════════════
   CÉLULAS ESPECÍFICAS
   ═══════════════════════════════════════════════════════════════════════════════════ */

.vcpm-cell-municipio {
    font-weight: 600;
    color: #A7016D;
}

.vcpm-cell-solicitante {
    font-weight: 500;
}

.vcpm-cell-valor {
    font-family: 'Roboto Mono', 'Consolas', monospace;
    font-size: 10px;
}

.vcpm-cell-readonly {
    color: #6c757d;
    background: #f8f9fa;
}

.vcpm-cell-editable {
    cursor: pointer;
}

.vcpm-cell-editable:hover {
    background: #fff3cd !important;
}

/* ═══════════════════════════════════════════════════════════════════════════════════
   ESTADOS DE CÉLULA (SALVAMENTO)
   ═══════════════════════════════════════════════════════════════════════════════════ */

.vcpm-cell-saving {
    position: relative;
    opacity: 0.7;
}

.vcpm-cell-saving::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 4px;
    width: 12px;
    height: 12px;
    margin-top: -6px;
    border: 2px solid #2185d0;
    border-top-color: transparent;
    border-radius: 50%;
    animation: vcpm-spin 0.8s linear infinite;
}

@keyframes vcpm-spin {
    to { transform: rotate(360deg); }
}

.vcpm-cell-saved {
    animation: vcpm-flash-success 0.5s ease;
}

@keyframes vcpm-flash-success {
    0% { background: #d4edda; }
    100% { background: inherit; }
}

.vcpm-cell-error {
    background: #f8d7da !important;
    animation: vcpm-shake 0.3s ease;
}

@keyframes vcpm-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-3px); }
    75% { transform: translateX(3px); }
}

/* ═══════════════════════════════════════════════════════════════════════════════════
   EDIÇÃO DE CÉLULAS
   ═══════════════════════════════════════════════════════════════════════════════════ */

#vcpm-excel-table .tabulator-cell.tabulator-editing {
    background: #fff;
    border: 2px solid #2185d0 !important;
    padding: 4px 6px;
}

#vcpm-excel-table .tabulator-cell.tabulator-editing input,
#vcpm-excel-table .tabulator-cell.tabulator-editing select,
#vcpm-excel-table .tabulator-cell.tabulator-editing textarea {
    width: 100%;
    border: none;
    background: transparent;
    font-size: 11px;
    padding: 0;
    outline: none;
}

#vcpm-excel-table .tabulator-cell.tabulator-editing textarea {
    resize: vertical;
    min-height: 60px;
}

/* Dropdown de edição */
#vcpm-excel-table .tabulator-edit-list {
    max-height: 200px;
    overflow-y: auto;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

#vcpm-excel-table .tabulator-edit-list-item {
    padding: 6px 10px;
    font-size: 11px;
    cursor: pointer;
}

#vcpm-excel-table .tabulator-edit-list-item:hover {
    background: #e8f4fd;
}

#vcpm-excel-table .tabulator-edit-list-item.active {
    background: #2185d0;
    color: white;
}

/* ═══════════════════════════════════════════════════════════════════════════════════
   PAGINAÇÃO
   ═══════════════════════════════════════════════════════════════════════════════════ */

#vcpm-excel-table .tabulator-footer {
    background: #f8f9fa;
    border-top: 1px solid #dee2e6;
    padding: 8px 12px;
}

#vcpm-excel-table .tabulator-paginator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
}

#vcpm-excel-table .tabulator-page {
    padding: 4px 10px;
    border: 1px solid #dee2e6;
    border-radius: 3px;
    background: white;
    cursor: pointer;
    font-size: 11px;
}

#vcpm-excel-table .tabulator-page:hover {
    background: #e9ecef;
}

#vcpm-excel-table .tabulator-page.active {
    background: #2185d0;
    border-color: #2185d0;
    color: white;
}

#vcpm-excel-table .tabulator-page[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
}

#vcpm-excel-table .tabulator-page-size {
    padding: 4px 8px;
    border: 1px solid #dee2e6;
    border-radius: 3px;
    font-size: 11px;
}

/* ═══════════════════════════════════════════════════════════════════════════════════
   AÇÕES
   ═══════════════════════════════════════════════════════════════════════════════════ */

.vcpm-excel-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 3px;
    color: #6c757d;
    text-decoration: none;
    transition: all 0.2s;
}

.vcpm-excel-action-btn:hover {
    background: #e9ecef;
    color: #2185d0;
}

.vcpm-cell-actions {
    padding: 4px !important;
}

/* ═══════════════════════════════════════════════════════════════════════════════════
   RESPONSIVIDADE
   ═══════════════════════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    .vcpm-excel-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .vcpm-excel-toolbar-left,
    .vcpm-excel-toolbar-right {
        justify-content: center;
    }
    
    .vcpm-excel-search {
        width: 100%;
    }
    
    #vcpm-excel-table {
        font-size: 10px;
    }
    
    #vcpm-excel-table .tabulator-col-title {
        font-size: 10px;
        padding: 6px 4px;
    }
    
    #vcpm-excel-table .tabulator-cell {
        padding: 4px 6px;
        font-size: 10px;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════════
   LOADING STATE
   ═══════════════════════════════════════════════════════════════════════════════════ */

#vcpm-excel-table .tabulator-loader {
    background: rgba(255, 255, 255, 0.9);
}

#vcpm-excel-table .tabulator-loader-msg {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 24px;
    background: white;
    border-radius: 6px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.15);
    font-size: 13px;
    color: #495057;
}

#vcpm-excel-table .tabulator-loader-msg::before {
    content: '';
    width: 20px;
    height: 20px;
    border: 3px solid #e9ecef;
    border-top-color: #2185d0;
    border-radius: 50%;
    animation: vcpm-spin 0.8s linear infinite;
}

/* ═══════════════════════════════════════════════════════════════════════════════════
   PLACEHOLDER
   ═══════════════════════════════════════════════════════════════════════════════════ */

#vcpm-excel-table .tabulator-placeholder {
    padding: 40px 20px;
    text-align: center;
    color: #6c757d;
    font-size: 13px;
}

#vcpm-excel-table .tabulator-placeholder::before {
    content: '\f0ce';
    font-family: 'Font Awesome 5 Free', 'Icons';
    font-weight: 900;
    display: block;
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.3;
}
