/* Main container */
.cpfg-container {
    background-color: #fff;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    padding: 20px;
    margin: 20px 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

/* Preview mode styling */
.cpfg-preview-mode {
    width: 100%;
    cursor: pointer;
    transition: all 0.2s ease;
}

.cpfg-preview-mode:hover {
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.1);
}

.cpfg-preview-mode .cpfg-graph-wrapper {
    height: 120px;
    position: relative;
}

.cpfg-preview-mode .cpfg-header {
    margin-bottom: 10px;
}

.cpfg-preview-mode .cpfg-header h3 {
    font-size: 14px;
    margin: 0;
}

.cpfg-preview-mode .cpfg-year-selector {
    display: flex;
    align-items: center;
}

.cpfg-preview-mode .cpfg-year-selector label {
    display: none;
}

.cpfg-preview-mode #cpfg-year-select {
    padding: 3px 5px;
    font-size: 12px;
}

.cpfg-preview-mode .cpfg-all-time-btn {
    padding: 3px 8px;
    font-size: 11px;
}

.cpfg-preview-mode .cpfg-legend {
    margin-top: 5px;
    font-size: 11px;
}

.cpfg-preview-mode .cpfg-legend-item {
    font-size: 11px;
}

/* Preview overlay */
.cpfg-preview-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.2);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.cpfg-preview-overlay span {
    background-color: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
}

.cpfg-preview-mode:hover .cpfg-preview-overlay {
    opacity: 1;
}

/* Graph header */
.cpfg-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.cpfg-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

/* Year selector */
.cpfg-year-selector {
    display: flex;
    align-items: center;
}

.cpfg-year-selector label {
    margin-right: 10px;
    font-size: 14px;
    color: #666;
}

#cpfg-year-select,
#cpfg-modal-year-select {
    padding: 5px 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
    background-color: #f9f9f9;
    margin-right: 10px;
}

.cpfg-all-time-btn,
.cpfg-modal-all-time-btn {
    background-color: #fef5f4;
    border: 1px solid #fde8e6;
    color: #e74c3c;
    padding: 5px 12px;
    border-radius: 5px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.cpfg-all-time-btn:hover,
.cpfg-modal-all-time-btn:hover {
    background-color: #fde8e6;
}

/* Expand button */
.cpfg-expand-btn {
    background-color: transparent;
    border: none;
    color: #e74c3c;
    cursor: pointer;
    padding: 5px;
    margin-left: 5px;
    transition: color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cpfg-expand-btn:hover {
    color: #c0392b;
}

.cpfg-preview-mode .cpfg-expand-btn {
    font-size: 12px;
}

/* Graph wrapper */
.cpfg-graph-wrapper {
    position: relative;
    height: 350px;
    margin-bottom: 20px;
}

/* Loading indicator */
.cpfg-loading,
.cpfg-modal-loading {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
    font-size: 16px;
    color: #666;
    display: none;
}

/* Legend */
.cpfg-legend,
.cpfg-modal-legend {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 10px;
}

.cpfg-legend-item {
    display: flex;
    align-items: center;
    font-size: 13px;
    color: #666;
}

.cpfg-legend-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 5px;
    display: inline-block;
}

/* Modal styles */
.cpfg-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.cpfg-modal.active {
    opacity: 1;
    visibility: visible;
}

.cpfg-modal-content {
    background-color: #fff;
    border-radius: 10px;
    width: 90%;
    max-width: 1000px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 5px 30px rgba(0, 0, 0, 0.15);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.cpfg-modal.active .cpfg-modal-content {
    transform: scale(1);
}

.cpfg-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
}

.cpfg-modal-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: #333;
}

.cpfg-close-modal {
    background: none;
    border: none;
    font-size: 28px;
    line-height: 1;
    color: #999;
    cursor: pointer;
    transition: color 0.2s;
}

.cpfg-close-modal:hover {
    color: #333;
}

.cpfg-modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.cpfg-modal-controls {
    margin-bottom: 20px;
}

.cpfg-modal-graph-wrapper {
    position: relative;
    height: 350px;
    margin-bottom: 20px;
}

/* Detail table styles */
.cpfg-modal-details {
    margin-top: 30px;
    border-top: 1px solid #eee;
    padding-top: 20px;
}

.cpfg-modal-details h4 {
    margin: 0 0 15px 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.cpfg-modal-table-wrapper {
    overflow-x: auto;
    margin-bottom: 20px;
}

.cpfg-modal-table {
    width: 100%;
    border-collapse: collapse;
}

.cpfg-modal-table th {
    background-color: #f8f9fa;
    color: #333;
    padding: 12px 15px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid #eee;
}

.cpfg-modal-table td {
    padding: 10px 15px;
    border-bottom: 1px solid #eee;
    color: #555;
}

.cpfg-modal-table tr:hover td {
    background-color: #fafafa;
}

.cpfg-modal-table .amount-column {
    font-weight: 600;
    color: #e74c3c;
    text-align: right;
}

.cpfg-modal-table .empty-data {
    text-align: center;
    padding: 30px;
    color: #999;
    font-style: italic;
}

/* Body styles when modal is open */
body.cpfg-modal-open {
    overflow: hidden;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .cpfg-header,
    .cpfg-modal-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .cpfg-year-selector {
        margin-top: 10px;
    }
    
    .cpfg-modal-graph-wrapper {
        height: 300px;
    }
    
    .cpfg-preview-mode {
        width: 100%;
    }
    
    .cpfg-modal-table th,
    .cpfg-modal-table td {
        padding: 8px 10px;
    }
}

@media (max-width: 480px) {
    .cpfg-modal-graph-wrapper {
        height: 250px;
    }
    
    .cpfg-preview-mode .cpfg-graph-wrapper {
        height: 40px;
    }
    
    .cpfg-modal-controls {
        flex-direction: column;
    }
    
    .cpfg-year-selector {
        margin-bottom: 10px;
    }
}