/* Modern Residuals Dashboard Styles */
.residuals-dashboard {
    max-width: 100%;
}

/* Dashboard Header */
.dashboard-header .report-title {
    font-size: 1.75rem;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 0;
}

.dashboard-header .report-subtitle {
    font-size: 1rem;
    color: #718096;
    margin-bottom: 0.5rem;
}

.dashboard-header .filter-status {
    font-size: 0.875rem;
}

/* Filters Panel */
.filters-panel {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
}

.filter-section-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: #495057;
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.search-input {
    border-radius: 0.375rem 0 0 0.375rem;
}

.btn-clear {
    border-radius: 0 0.375rem 0.375rem 0;
}

.filter-chips .filter-chip {
    border-radius: 1rem;
    font-size: 0.8rem;
    padding: 0.375rem 0.75rem;
}

.hierarchy-controls .btn {
    font-size: 0.8rem;
}

/* Reseller Cards */
.reseller-card {
    border-radius: 0.5rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: box-shadow 0.2s ease;
}

.reseller-card:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.level-parent {
    border-left: 4px solid #3182ce;
}

.level-child {
    border-left: 4px solid #38a169;
    margin-left: 1rem;
    background: #f7fafc;
}

.level-grandchild {
    border-left: 4px solid #d69e2e;
    margin-left: 2rem;
    background: #fffaf0;
    border: 1px solid #fbd38d;
    border-radius: 0.375rem;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
}

/* Reseller Headers */
.reseller-header {
    background: #5a67d8;
    color: white;
    border-radius: 0.5rem 0.5rem 0 0 !important;
}

.child-header {
    background: #4299e1;
    color: white;
}

/* Child header text styling */
.child-header .reseller-name {
    color: #f7fafc !important;
}

.child-header .metric-link {
    color: #f7fafc;
}

.child-header .metric-value,
.child-header .metric-label {
    color: #f7fafc;
}

.grandchild-header {
    background: #a855f7;
    color: white;
    border-radius: 0.375rem;
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.75rem;
}

.expand-toggle {
    color: inherit;
    border: none;
    background: none;
}

.expand-toggle:hover {
    color: inherit;
    opacity: 0.8;
}

.reseller-name {
    font-weight: 600;
    color: whitesmoke;
    text-transform: uppercase;
}

.reseller-status {
    font-size: 0.7rem;
    text-transform: uppercase;
}

.sub-reseller-indicator {
    font-size: 0.7rem;
    background-color: rgba(255,255,255,0.9) !important;
    color: #495057 !important;
    border: 1px solid rgba(255,255,255,0.8);
}

.sub-reseller-indicator i {
    font-size: 0.6rem;
    margin-right: 0.25rem;
}

/* Metrics Display */
.reseller-metrics, .grandchild-metrics {
    display: flex;
    flex-wrap: wrap;
}

.metric {
    text-align: center;
    min-width: 80px;
}

.metric.small {
    min-width: 60px;
}

.metric-link {
    color: inherit;
    text-decoration: none;
    display: block;
    padding: 0.25rem;
    border-radius: 0.25rem;
    transition: background-color 0.2s ease;
}

.metric-link:hover {
    background-color: rgba(255,255,255,0.1);
    color: inherit;
    text-decoration: none;
}

.metric-value {
    display: block;
    font-size: 1.1rem;
    font-weight: 600;
    line-height: 1.2;
}

.metric.small .metric-value {
    font-size: 0.95rem;
}

.metric-label {
    display: block;
    font-size: 0.7rem;
    opacity: 0.8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 0.125rem;
}

/* Section Titles */
.section-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: #495057;
    margin-bottom: 0.75rem;
    padding-bottom: 0.375rem;
    border-bottom: 1px solid #e9ecef;
}

.section-divider {
    text-align: center;
    margin: 1rem 0;
    position: relative;
}

.section-divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: #e9ecef;
}

.section-label {
    background: white;
    padding: 0 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

/* Metrics Grids */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.metrics-grid-small {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.metrics-grid-mini {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.5rem;
}

.metric-card, .metric-card-small, .metric-card-mini {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 0.375rem;
    padding: 0.75rem;
    text-align: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.metric-card:hover, .metric-card-small:hover, .metric-card-mini:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.metric-card-small {
    padding: 0.5rem;
}

.metric-card-mini {
    padding: 0.375rem;
}

.metric-header, .metric-header-small {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    padding-bottom: 0.375rem;
    border-bottom: 1px solid #e9ecef;
}

.metric-title, .metric-title-small, .metric-title-mini {
    font-size: 0.8rem;
    font-weight: 600;
    color: #495057;
}

.metric-title-mini {
    font-size: 0.7rem;
}

.metric-link-icon {
    color: #6c757d;
    font-size: 0.7rem;
}

.metric-link-icon:hover {
    color: #495057;
}

.metric-body, .metric-body-small {
    font-size: 1.25rem;
    font-weight: 600;
    color: #2d3748;
}

.metric-body-small {
    font-size: 1.1rem;
}

.metric-mini-content {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.metric-value-mini {
    font-size: 0.9rem;
    font-weight: 600;
    margin-top: 0.25rem;
}

.metric-currency, .metric-percent {
    font-size: 0.9em;
    opacity: 0.8;
}

/* Table Controls */
.table-controls {
    padding: 0.5rem 0;
}

.table-info {
    font-style: italic;
}

/* Responsive Design */
@media (max-width: 768px) {
    .dashboard-header .row {
        flex-direction: column;
    }
    
    .header-actions {
        margin-top: 1rem;
        justify-content: flex-start !important;
    }
    
    .reseller-metrics {
        justify-content: flex-start !important;
        margin-top: 0.75rem;
    }
    
    .metrics-grid {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    }
    
    .metrics-grid-small {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    }
    
    .metrics-grid-mini {
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    }
    
    .level-child {
        margin-left: 0.5rem;
    }
    
    .level-grandchild {
        margin-left: 1rem;
    }
}

@media (max-width: 576px) {
    .dashboard-header .report-title {
        font-size: 1.5rem;
    }
    
    .filter-section {
        margin-bottom: 1.5rem;
    }
    
    .hierarchy-controls .btn {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }
    
    .metric {
        min-width: 60px;
    }
    
    .metric-value {
        font-size: 1rem;
    }
    
    .level-child, .level-grandchild {
        margin-left: 0;
    }
}

/* Loading and Animation States */
.reseller-card {
    opacity: 1;
    transition: opacity 0.3s ease;
}

.expand-toggle i {
    transition: transform 0.2s ease;
}

.expand-toggle .rotated {
    transform: rotate(90deg);
}

/* Print Styles */
@media print {
    .filters-panel,
    .header-actions,
    .expand-toggle,
    .btn {
        display: none !important;
    }
    
    .reseller-card {
        break-inside: avoid;
        box-shadow: none !important;
        border: 1px solid #000 !important;
    }
    
    .card-header {
        background: #f8f9fa !important;
        color: #000 !important;
    }
}

/* Import Management Specific Styles */
.import-data-table {
    font-size: 0.9rem;
}

.table-header th {
    background: #5a67d8;
    color: white;
    border: none;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.5px;
    padding: 1rem 0.75rem;
    vertical-align: middle;
}

.table-header th i {
    color: rgba(255, 255, 255, 0.8);
}

.import-row {
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.import-row:hover {
    background-color: rgba(102, 126, 234, 0.05);
    border-left-color: #667eea;
    transform: translateX(2px);
}

.file-name-cell {
    font-weight: 600;
}

.file-info {
    display: flex;
    align-items: center;
}

.file-info i {
    font-size: 1.1rem;
}

.filename {
    color: #495057;
    font-weight: 600;
    font-size: 1rem;
}

.status-cell {
    text-align: center;
}

.status-text {
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: #495057;
    text-transform: uppercase;
    padding: 0.25rem 0.5rem;
    background-color: #f8f9fa;
    border-radius: 4px;
    border: 1px solid #e9ecef;
}

.processor-cell {
    font-weight: 600;
    color: #6c757d;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
}

.count-cell {
    text-align: center;
}

.count-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
}

.count-number {
    font-weight: 700;
    font-size: 1.1rem;
}

.count-display.accepted .count-number {
    color: #28a745;
}

.count-display.rejected .count-number {
    color: #dc3545;
}

.date-cell {
    font-size: 0.9rem;
    color: #6c757d;
}

.date-display {
    font-weight: 500;
}

/* Create isolated positioning context for actions cell */
.actions-cell {
    text-align: center;
    position: relative;
    z-index: 10;
    /* Create new stacking context to isolate from row transform */
    will-change: transform;
    contain: layout;
}

.actions-cell .dropdown {
    position: relative;
    z-index: 1000;
}

.actions-cell .dropdown-menu {
    position: absolute !important;
    z-index: 10000 !important;
    transform: none !important;
    border: none;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    padding: 0.5rem 0;
    min-width: 200px;
    margin-top: 0.25rem;
    /* Create completely isolated stacking context */
    isolation: isolate;
    /* Remove any inherited transforms */
    transform: translate3d(0, 0, 0) !important;
    /* Prevent pointer events from affecting parent row */
    pointer-events: auto;
}

/* Ensure dropdown menu positioning is calculated correctly */
.actions-cell .dropdown.show .dropdown-menu {
    display: block;
    z-index: 10000 !important;
    position: absolute !important;
}

/* Handle dropdowns that would be cut off at bottom of screen */
.actions-cell .dropdown.dropup .dropdown-menu {
    top: auto !important;
    bottom: 100% !important;
    margin-top: 0 !important;
    margin-bottom: 0.25rem !important;
}

/* Ensure action buttons don't interfere with open dropdowns */
.actions-cell .dropdown-toggle {
    border: none;
    background: transparent;
    color: #667eea;
    font-size: 1.2rem;
    padding: 0.5rem;
    border-radius: 4px;
    transition: all 0.2s ease;
    position: relative;
    z-index: 1001;
}

/* When dropdown is open, ensure button has lower z-index than menu */
.actions-cell .dropdown.show .dropdown-toggle {
    z-index: 9999;
}

/* Ensure other action buttons don't appear over open dropdown */
.import-row:not(.dropdown-open) .actions-cell {
    z-index: 1;
}

.import-row.dropdown-open .actions-cell {
    z-index: 10001;
}

/* Prevent table row from responding to hover when dropdown is open */
.import-row.dropdown-open {
    transform: none !important;
    background-color: transparent !important;
    border-left-color: transparent !important;
    pointer-events: none;
}

.import-row.dropdown-open .actions-cell {
    pointer-events: auto;
}

.import-row.dropdown-open:hover {
    transform: none !important;
    background-color: transparent !important;
    border-left-color: transparent !important;
}

.actions-cell .dropdown-toggle:hover {
    background-color: rgba(102, 126, 234, 0.1);
    color: #5a67d8;
}

/* Prevent any table row hover effects from affecting dropdown */

/* Fix for DataTables overflow issues */
.table-responsive {
    overflow: visible !important;
}

.import-data-table {
    overflow: visible !important;
    /* Ensure table doesn't create stacking context that interferes */
    position: static !important;
}

/* Ensure dropdown menu stays within viewport */
.dropdown-menu.dropdown-menu-right {
    right: 0;
    left: auto;
    transform: translateX(0) !important;
}

.dropdown-header {
    color: #667eea;
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.5rem 1rem 0.25rem;
}

.dropdown-item {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    color: #495057;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.dropdown-item:hover {
    background-color: rgba(102, 126, 234, 0.1);
    color: #667eea;
    transform: translateX(2px);
}

.dropdown-item i {
    width: 16px;
    text-align: center;
}

.dropdown-divider {
    margin: 0.5rem 0;
    border-color: rgba(102, 126, 234, 0.2);
}

/* Add Import Action Button */
.add-import-action .btn {
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.75rem 1.5rem;
    border-radius: 25px;
    box-shadow: 0 4px 15px rgba(40, 167, 69, 0.3);
    transition: all 0.3s ease;
}

.add-import-action .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(40, 167, 69, 0.4);
}

/* Date Filter Styling */
.date-filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.date-filter-group .form-label {
    font-weight: 600;
    color: #495057;
    font-size: 0.9rem;
    margin-bottom: 0;
}

.month-picker {
    border-radius: 8px;
    border: 2px solid #e9ecef;
    transition: all 0.2s ease;
}

.month-picker:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
}

/* Actions Group Styling */
.actions-group .dropdown-toggle {
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: 8px;
    padding: 0.75rem 1.25rem;
    box-shadow: 0 2px 10px rgba(102, 126, 234, 0.2);
    transition: all 0.3s ease;
}

.actions-group .dropdown-toggle:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

/* Table responsiveness enhancements */
@media (max-width: 768px) {
    .table-header th {
        padding: 0.75rem 0.5rem;
        font-size: 0.7rem;
    }
    
    .import-row td {
        padding: 0.75rem 0.5rem;
        font-size: 0.8rem;
    }
    
    .count-display {
        flex-direction: column;
        gap: 0.1rem;
    }
    
    .status-text {
        font-size: 0.65rem;
        padding: 0.25rem 0.5rem;
    }
}

/* Import Metrics Styling */
.import-metrics {
    gap: 1rem;
}

.import-metrics .metric-card-mini {
    background: white;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    padding: 1rem;
    text-align: center;
    min-width: 120px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
}

.import-metrics .metric-card-mini:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

.import-metrics .metric-value {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.import-metrics .metric-label {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6c757d;
} 