/* Fee Configuration Matrix Styles */

.fee-matrix-container {
    padding: 20px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

/* Header Section */
.fee-matrix-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px solid #f0f0f0;
    flex-wrap: wrap;
    gap: 12px;
}

.header-left {
    flex: 1;
    min-width: 0;
}

.header-left h2 {
    margin: 0 0 8px 0;
    font-size: 24px;
    color: #333;
    font-weight: 600;
}

.header-left .subtitle {
    margin: 0;
    font-size: 14px;
    color: #666;
}

.header-right {
    display: flex;
    gap: 12px;
    flex-shrink: 0;
    align-items: center;
}

/* Controls Section */
.fee-matrix-controls {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
    width: 100%;
}

.control-label {
    font-size: 13px;
    font-weight: 500;
    color: #555;
}

.mdc-select-field {
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    background: #fff;
    transition: border-color 0.2s;
    width: 100%;
    box-sizing: border-box;
}

.mdc-select-field:hover {
    border-color: #1976d2;
}

.mdc-select-field:focus {
    outline: none !important;
    border-color: #1976d2;
    box-shadow: none !important;
}

/* Legend */
.fee-matrix-legend {
    display: flex;
    gap: 20px;
    margin-bottom: 16px;
    padding: 16px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #555;
    font-weight: 500;
}

.legend-color {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 2px solid #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
    display: inline-block;
}

.legend-color.configured {
    background: linear-gradient(135deg, #4caf50 0%, #66bb6a 100%);
}

.legend-color.default-fee {
    background: linear-gradient(135deg, #ff9800 0%, #ffa726 100%);
}

.legend-color.not-set {
    background: linear-gradient(135deg, #e0e0e0 0%, #bdbdbd 100%);
}

.legend-color.expired {
    background: linear-gradient(135deg, #f44336 0%, #e57373 100%);
}

.legend-label {
    font-size: 18px;
    color: #111;
    font-weight: 700;
}

/* Legend & Stats Split Section */
.fee-matrix-legend-stats-container {
    height: 120px;
    max-height: 120px;
    margin-bottom: 10px;
    display: flex;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    overflow: hidden;
}

.fee-matrix-legend-section {
    flex: 0 0 25%;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 10px 16px;
    padding: 12px 16px;
    background: #f8f9fa;
    border-right: 1px solid #e0e0e0;
}

.fee-matrix-legend-section .legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 calc(50% - 8px);
    min-width: 90px;
}

.fee-matrix-legend-section .legend-item .legend-label {
    font-size: 14px;
    color: #333;
    font-weight: 600;
}

.fee-matrix-legend-section .legend-color {
    width: 24px;
    height: 24px;
    border-radius: 5px;
}

.fee-matrix-summary-section {
    flex: 0 0 75%;
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-evenly;
    gap: 16px;
    padding: 16px 24px;
    background: #fff;
}

/* Matrix Wrapper */
.fee-matrix-wrapper {
    overflow-x: auto;
    overflow-y: auto;
    max-height: 600px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    margin-bottom: 20px;
}

/* Matrix Table */
.fee-matrix-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    min-width: 800px;
}

.fee-matrix-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
    background: linear-gradient(135deg, #f70880 0%, #fead8b 100%);
}

.fee-matrix-table th {
    padding: 14px 10px;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: white;
    background: transparent;
    border-bottom: 2px solid rgba(255,255,255,0.3);
    white-space: nowrap;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.fee-matrix-table th.instrument-header {
    text-align: left;
    min-width: 180px;
    position: sticky;
    left: 0;
    z-index: 11;
    box-shadow: 2px 0 4px rgba(0,0,0,0.1);
    background: linear-gradient(135deg, #f70880 0%, #fead8b 100%);
}

.fee-matrix-table th.grade-header {
    min-width: 80px;
    max-width: 80px;
    font-size: 12px;
}

.fee-matrix-table th.actions-header {
    min-width: 120px;
}

.fee-matrix-table tbody tr {
    transition: background-color 0.2s;
}

.fee-matrix-table tbody tr:hover {
    background-color: #f8f9fa;
}

.fee-matrix-table td {
    padding: 0;
    border-bottom: 1px solid #e0e0e0;
    border-right: 1px solid #e0e0e0;
}

/* Instrument Cell (Sticky Column) */
.instrument-cell {
    padding: 12px;
    font-size: 14px;
    font-weight: 500;
    background: #fff;
    position: sticky;
    left: 0;
    z-index: 5;
    box-shadow: 2px 0 4px rgba(0,0,0,0.05);
    display: flex;
    align-items: center;
    gap: 8px;
}

.fee-matrix-table tbody tr:hover .instrument-cell {
    background-color: #f8f9fa;
}

.instrument-icon {
    font-size: 20px;
    line-height: 1;
}

.instrument-name {
    color: #333;
}

/* Fee Cells */
.fee-cell {
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    height: 52px;
    vertical-align: middle;
    position: relative;
    border: 1px solid transparent;
}

.fee-cell:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 12px rgba(247,8,128,0.25);
    z-index: 2;
    border-color: #f70880;
}

.fee-cell.configured {
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
    color: #2e7d32;
    font-weight: 600;
}

.fee-cell.configured:hover {
    background: linear-gradient(135deg, #c8e6c9 0%, #a5d6a7 100%);
}

.fee-cell.default-fee {
    background: linear-gradient(135deg, #fff3e0 0%, #ffe0b2 100%);
    color: #ef6c00;
    font-weight: 500;
}

.fee-cell.default-fee:hover {
    background: linear-gradient(135deg, #ffe0b2 0%, #ffcc80 100%);
}

.fee-cell.not-set {
    background-color: #fafafa;
    color: #999;
    font-style: italic;
}

.fee-cell.not-set:hover {
    background: linear-gradient(135deg, #f0f0f0 0%, #e8e8e8 100%);
    color: #f70880;
    font-weight: 600;
}

.fee-cell.expired {
    background-color: #ffebee;
    color: #c62828;
    text-decoration: line-through;
    opacity: 0.6;
}

.fee-cell.expired:hover {
    background-color: #ffcdd2;
}

.fee-amount {
    font-size: 14px;
    font-weight: 500;
}

/* Inline editing input */
.inline-fee-input {
    width: 100%;
    padding: 8px;
    font-size: 14px;
    border: 2px solid #f70880;
    border-radius: 4px;
    text-align: center;
    box-shadow: 0 0 0 3px rgba(247,8,128,0.1);
    font-weight: 600;
}

.inline-fee-input:focus {
    outline: none;
    border-color: #e91e63;
    box-shadow: 0 0 0 3px rgba(233,30,99,0.2);
}

/* Actions Cell */
.actions-cell {
    padding: 8px;
    text-align: center;
    background: #fff;
}

.icon-btn {
    padding: 6px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 50%;
    transition: background-color 0.2s;
    color: #666;
}

.icon-btn:hover {
    background-color: #f0f0f0;
    color: #1976d2;
}

.icon-btn .material-icons {
    font-size: 18px;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.empty-state .material-icons {
    font-size: 64px;
    color: #ddd;
    margin-bottom: 16px;
}

.empty-state h3 {
    margin: 0 0 8px 0;
    font-size: 20px;
    color: #666;
}

.empty-state p {
    margin: 0;
    font-size: 14px;
}

/* Summary Section */
.fee-matrix-summary {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid #f0f0f0;
}

.summary-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
}

/* Summary stat item for legend/stats section */
.summary-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    background: #f8f9fa;
    border-radius: 10px;
    min-width: 100px;
    height: 80px;
}

.summary-stat .summary-value {
    font-size: 36px;
    font-weight: 800;
    color: #333;
    line-height: 1;
}

.summary-stat .summary-value.configured {
    color: #4caf50;
}

.summary-stat .summary-value.default {
    color: #ff9800;
}

.summary-stat .summary-value.not-set {
    color: #9e9e9e;
}

.summary-stat .summary-label {
    font-size: 13px;
    color: #666;
    font-weight: 600;
    margin-top: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-card {
    padding: 16px;
    background: #f8f9fa;
    border-radius: 8px;
    text-align: center;
    border: 2px solid transparent;
    transition: all 0.2s;
}

.stat-card:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.stat-card.highlight {
    background: linear-gradient(135deg, #f70880 0%, #fead8b 100%);
    color: #fff;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 4px;
}

.stat-card.highlight .stat-value {
    color: #fff;
}

.stat-label {
    font-size: 13px;
    color: #666;
    font-weight: 500;
}

.stat-card.highlight .stat-label {
    color: rgba(255,255,255,0.9);
}

/* Fee Edit Form */
.fee-edit-form {
    padding: 16px 0;
}

.form-row {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 500;
    color: #555;
}

.mdc-text-field {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.mdc-text-field:focus {
    outline: none !important;
    border-color: #1976d2;
    box-shadow: none !important;
}

.form-hint {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: #888;
}

.fee-preview {
    margin-top: 20px;
    padding: 16px;
    background: #f8f9fa;
    border-radius: 6px;
    border-left: 4px solid #1976d2;
}

.fee-preview h4 {
    margin: 0 0 12px 0;
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

.breakdown-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 14px;
    border-bottom: 1px solid #e0e0e0;
}

.breakdown-item:last-child {
    border-bottom: none;
}

.breakdown-item span:first-child {
    color: #666;
}

.breakdown-item span:last-child {
    font-weight: 600;
    color: #333;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
    color: #555;
}

.mdc-checkbox {
    cursor: pointer;
}

/* Bulk Operations */
.bulk-operations-menu {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 8px 0;
}

.bulk-op-button {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.bulk-op-button:hover {
    border-color: #1976d2;
    background: #f8f9fa;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.bulk-op-button.danger:hover {
    border-color: #f44336;
    background: #ffebee;
}

.bulk-op-button .material-icons {
    font-size: 32px;
    color: #1976d2;
}

.bulk-op-button.danger .material-icons {
    color: #f44336;
}

.bulk-op-button strong {
    display: block;
    margin-bottom: 4px;
    font-size: 15px;
    color: #333;
}

.bulk-op-button p {
    margin: 0;
    font-size: 13px;
    color: #666;
}

/* Copy Fees Form */
.copy-fees-form,
.increase-form,
.default-fee-form {
    padding: 16px 0;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .fee-matrix-controls {
        grid-template-columns: 1fr;
    }

    .control-group {
        min-width: 100%;
    }

    .fee-matrix-wrapper {
        max-height: 400px;
    }

    .summary-stats {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .fee-matrix-container {
        padding: 16px;
    }

    .fee-matrix-header {
        flex-direction: column;
        gap: 16px;
    }

    .header-right {
        width: 100%;
    }

    .header-right .mdc-button {
        width: 100%;
    }

    .fee-matrix-legend {
        flex-wrap: wrap;
        gap: 12px;
    }

    .summary-stats {
        grid-template-columns: 1fr;
    }

    .fee-matrix-table th.grade-header {
        min-width: 60px;
        max-width: 60px;
        font-size: 11px;
    }

    .fee-cell {
        height: 40px;
    }

    .fee-amount {
        font-size: 12px;
    }
}

/* Sticky Column Shadow */
.fee-matrix-wrapper::-webkit-scrollbar {
    height: 8px;
}

.fee-matrix-wrapper::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.fee-matrix-wrapper::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.fee-matrix-wrapper::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Loading State */
.fee-matrix-loading {
    text-align: center;
    padding: 40px;
    color: #999;
}

.fee-matrix-loading .material-icons {
    font-size: 48px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Success/Error States */
.fee-cell.saving {
    opacity: 0.6;
    pointer-events: none;
}

.fee-cell.success {
    animation: successPulse 0.5s;
}

@keyframes successPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); background-color: #4caf50; }
}

/* Print Styles */
@media print {
    .fee-matrix-header,
    .fee-matrix-controls,
    .fee-matrix-legend,
    .actions-cell,
    .header-right {
        display: none;
    }

    .fee-matrix-wrapper {
        overflow: visible;
        max-height: none;
        border: none;
    }

    .fee-matrix-table {
        page-break-inside: avoid;
    }

    .fee-cell:hover {
        transform: none;
        box-shadow: none;
    }
}
