
/**************************
DATATABLE STYLES
***********************************/

/* Estilos para tabelas reutilizáveis */
.custom-table-container {
    margin-top: 20px;
    overflow: hidden;
    border-radius: 8px;
    border: 1px solid var(--border-light);
}

.table-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background-color: var(--border-base);
    border-bottom: 1px solid var(--border-light);
}

.table-search {
    display: flex;
    align-items: center;
}

.table-search input {
    padding: 8px 12px;
    border: 1px solid var(--border-light);
    border-radius: 4px;
    font-size: 14px;
    width: 250px;
}

.table-search i {
    margin-right: 8px;
    color: #6c757d;
}

.table-pagination {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.table-pagination button {
    background-color: #fff;
    border: 1px solid var(--border-light);
    border-radius: 4px;
    padding: 6px 12px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
    min-width: 36px;
}

.table-pagination button:hover {
    background-color: var(--border-light);
}

.table-pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.table-pagination button.active {
    background-color: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

.table-pagination .page-info {
    font-size: 14px;
    color: #6c757d;
    margin-left: 8px;
    white-space: nowrap;
}

.custom-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.custom-table thead {
    background-color: var(--border-base);
}

.custom-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: #495057;
    border-bottom: 2px solid var(--border-light);
    position: relative;
    cursor: pointer;
}

.custom-table th:hover {
    background-color: var(--border-light);
}

.custom-table th::after {
    content: '↕';
    position: absolute;
    right: 8px;
    opacity: 0.3;
}

.custom-table th.sort-asc::after {
    content: '↑';
    opacity: 1;
}

.custom-table th.sort-desc::after {
    content: '↓';
    opacity: 1;
}

.custom-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
}

.custom-table:last-child td {
    border-bottom: none;
}

.custom-table tbody tr:hover {
    background-color: var(--border-light) !important;
}

.custom-table tbody tr:nth-child(even) {
    background-color: var(--border-base);
}



.custom-table .positive {
    color: var(--color-success);
    font-weight: 500;
}

.custom-table .negative {
    color: var(--color-danger);
    font-weight: 500;
}

.custom-table .empty-message {
    text-align: center;
    padding: 40px;
    color: #6c757d;
}

/* Column Visibility Controls */
.column-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.column-toggle-btn {
    background-color: #fff;
    border: 1px solid var(--border-light);
    border-radius: 4px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.column-toggle-btn:hover {
    background-color: var(--border-light);
}

.column-select-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.column-select-label {
    font-size: 14px;
    color: #495057;
    white-space: nowrap;
}

.column-select {
    background-color: #fff;
    border: 1px solid var(--border-light);
    border-radius: 4px;
    padding: 8px 12px;
    font-size: 14px;
    cursor: pointer;
    min-width: 120px;
    transition: all 0.2s ease;
}

.column-select[multiple] {
    max-height: 200px;
    overflow-y: auto;
    transition: height 0.2s ease, padding 0.2s ease;
}

.column-select[multiple][size="1"] {
    height: 38px; /* Standard input height */
    overflow: hidden;
    padding: 8px 32px 8px 12px;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%23666' d='M8 13.1l-6-6L3.4 5.7 8 10.3l4.6-4.6L14 7.1z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 12px;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
}

.column-select[multiple]:not([size="1"]) {
    height: auto;
    padding: 4px;
    background-image: none;
    appearance: listbox;
    -webkit-appearance: listbox;
    -moz-appearance: listbox;
}

.column-select:hover,
.column-select:focus {
    border-color: var(--color-primary);
    outline: none;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

.column-select option {
    padding: 6px 8px;
    margin: 1px 0;
    border-radius: 2px;
}

.column-select[multiple] option:checked {
    background-color: var(--color-primary);
    color: white;
}

.column-select:not([multiple]) option {
    padding: 8px;
}

/* Remove old dropdown styles */
.column-dropdown {
    display: none;
}

.column-menu {
    display: none;
}

.column-menu-item {
    display: none;
}

/* Expandable Row Styles */
.expandable-row {
    cursor: pointer;
    transition: background-color 0.2s;
}

.expandable-row:hover {
    background-color: var(--border-light) !important;
}

.expandable-row.expanded {
    background-color: var(--color-primary-light) !important;
}

.row-details {
    background-color: var(--border-base);
    border-left: 3px solid var(--color-primary);
}

.row-details td {
    padding: 16px !important;
}

.row-details-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.detail-label {
    font-weight: 600;
    color: #495057;
    font-size: 12px;
    text-transform: uppercase;
}

.detail-value {
    color: #212529;
    font-size: 14px;
}

/* Mensagem especial quando todas as colunas estão visíveis */
.detail-item.no-hidden-columns-message {
    grid-column: 1 / -1;
    padding: 20px;
    background-color: #f8f9fa;
    border-radius: 6px;
    border: 1px dashed #dee2e6;
    text-align: center;
}

.detail-item.no-hidden-columns-message .detail-value {
    font-size: 13px;
    color: #6c757d;
    font-style: italic;
}

.expand-icon {
    margin-left: 8px;
    transition: transform 0.2s;
    font-size: 12px;
    opacity: 0.6;
}

.expanded .expand-icon {
    transform: rotate(180deg);
}

/* Column hiding for mobile */
.custom-table th[data-priority="low"],
.custom-table td[data-priority="low"] {
    display: none;
}

.custom-table th[data-priority="medium"],
.custom-table td[data-priority="medium"] {
    display: none;
}

/* Mobile-first responsive approach */
@media (min-width: 480px) {
    .custom-table th[data-priority="medium"],
    .custom-table td[data-priority="medium"] {
        display: table-cell;
    }
}

@media (min-width: 768px) {
    .custom-table th[data-priority="low"],
    .custom-table td[data-priority="low"] {
        display: table-cell;
    }
    
    /* Keep column selector visible on all screen sizes */
    .column-controls {
        display: flex;
    }
}

/* Responsividade */
@media (max-width: 768px) {
    .table-controls {
        flex-direction: column;
        gap: 12px;
    }
    
    .table-search {
        width: 100%;
    }
    
    .table-search input {
        width: 100%;
    }
    
    .column-controls {
        justify-content: space-between;
        width: 100%;
    }
    
    .custom-table {
        font-size: 13px;
    }
    
    .custom-table th, 
    .custom-table td {
        padding: 8px 6px;
    }
    
    .table-responsive {
        overflow-x: auto;
    }
    
    /* Show expand icon on mobile */
    .custom-table tbody tr:first-child .expand-icon {
        display: inline;
    }
    
    /* Keep column selector on mobile but simpler */
    .column-controls {
        display: flex;
    }
    
    /* Adjust pagination for mobile */
    .table-pagination {
        justify-content: center;
        gap: 2px;
    }
    
    .table-pagination button {
        padding: 4px 8px;
        font-size: 12px;
        min-width: 32px;
    }
    
    .table-pagination .page-info {
        display: none; /* Hide detailed info on mobile */
    }
}

@media (max-width: 480px) {
    .custom-table th, 
    .custom-table td {
        padding: 6px 4px;
        font-size: 12px;
    }
    
    .row-details-content {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    /* Simplify column selector on very small screens */
    .column-select-label {
        display: none;
    }
    
    .column-select {
        min-width: 100px;
        font-size: 12px;
        padding: 6px 8px;
    }
    
    /* Force show main columns only */
    .custom-table th[data-priority="low"],
    .custom-table td[data-priority="low"],
    .custom-table th[data-priority="medium"],
    .custom-table td[data-priority="medium"] {
        display: none !important;
    }
    
    /* Ensure expandable rows are more obvious */
    .expandable-row::after {
        content: '⋮';
        position: absolute;
        right: 8px;
        font-weight: bold;
        color: var(--color-primary);
    }
    
    .expandable-row {
        position: relative;
    }
}


/* Estilos adicionais para melhor UX */
.custom-table tbody tr {
    transition: all 0.2s ease;
}

.custom-table tbody tr.expandable-row:hover {
    background-color: var(--border-light) !important;
    cursor: pointer;
}

/* Elementos interativos dentro da tabela */
.custom-table a,
.custom-table button,
.custom-table .btn,
.custom-table .clickable,
.custom-table [role="button"] {
    cursor: pointer !important;
    transition: all 0.2s ease;
    position: relative;
    z-index: 10;
}

/* Evitar conflito com expansão de linha */
.custom-table td:has(a),
.custom-table td:has(button),
.custom-table td:has(.btn),
.custom-table td:has(.clickable) {
    position: relative;
}

/* Linhas que não são expansíveis */
.custom-table tbody tr.no-expand {
    cursor: default !important;
}


.status-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.status-badge.success {
    background-color: #d4edda;
    color: #155724;
}

.status-badge.warning {
    background-color: #fff3cd;
    color: #856404;
}

.status-badge.danger {
    background-color: #f8d7da;
    color: #721c24;
}

.tag-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    color: white;
    font-size: 12px;
    font-weight: 500;
}

.category-type {
    font-weight: 500;
    text-transform: capitalize;
}

.category-type.expense {
    color: var(--color-danger);
}

.category-type.income {
    color: var(--color-success);
}

.category-type.investment {
    color: var(--color-primary, #007bff);
}

/* Mobile hint text */
@media (max-width: 768px) {
    .custom-table-container::before {
        content: "💡 Toque nas linhas para ver mais detalhes";
        display: block;
        padding: 8px 12px;
        background-color: #e9ecef;
        border-radius: 4px;
        font-size: 12px;
        color: #6c757d;
        margin-bottom: 8px;
        text-align: center;
    }
}

/**********************************************/