/* Category View Specific Styles */
.category-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Date Range Controls */
.date-controls {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-bottom: 24px;
}

.preset-filters {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.preset-filters button {
    padding: 8px 16px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

.preset-filters button.active {
    background: #4f46e5;
    color: white;
    border-color: #4f46e5;
}

.custom-date-range {
    display: none;
    background: #f8fafc;
    padding: 16px;
    border-radius: 6px;
    margin-top: 12px;
}

.date-inputs {
    display: flex;
    gap: 16px;
    align-items: center;
}

/* Category Analysis Layout */
.category-analysis {
    display: grid;
    grid-template-columns: minmax(300px, 1fr) 2fr;
    gap: 24px;
    margin-top: 24px;
}

.chart-section {
    background: white;
    border-radius: 8px;
    padding: 24px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    height: fit-content;
}

canvas#categoryChart {
    max-width: 100%;
    height: auto;
}

/* Table Styles */
.category-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;  /* Reduced font size */
}

.category-table th {
    background: #f8fafc;
    padding: 12px 16px;
    text-align: left;
    color: #1e293b;
    font-weight: 600;
    border-bottom: 2px solid #e2e8f0;
    white-space: nowrap;
    font-size: 0.875rem;  /* Consistent header size */
}

.category-table td {
    padding: 12px 16px;
    border-bottom: 1px solid #e2e8f0;
    vertical-align: middle;
}

.amount {
    font-family: 'Roboto Mono', monospace;
    font-size: 0.875rem;  /* Consistent size for amounts */
    text-align: right;
}

.percentage {
    font-size: 0.875rem;  /* Consistent size for percentages */
    text-align: right;
}

.text-center {
    text-align: center;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .category-analysis {
        grid-template-columns: 1fr;
    }

    .chart-section {
        order: -1; /* Show chart above table on mobile */
    }
}

.category-table th {
    background: #f8fafc;
    padding: 12px 16px;
    text-align: left;
    color: #1e293b;
    font-weight: 600;
    border-bottom: 2px solid #e2e8f0;
    white-space: nowrap;
}

.category-table td {
    padding: 12px 16px;
    border-bottom: 1px solid #e2e8f0;
}

.category-table tr:hover td {
    background: #f8fafc;
}

.category-table .category-name {
    font-weight: 600;
    color: #1e293b;
}

.amount {
    font-family: monospace;
    white-space: nowrap;
}

.amount.positive {
    color: #059669;
}

.amount.negative {
    color: #dc2626;
}

.percentage {
    text-align: right;
}

/* Loading and Error States */
.loader {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.loader-content {
    background: white;
    padding: 24px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.loader-spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 16px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #4f46e5;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.error-message {
    display: none;
    background: #fee2e2;
    color: #dc2626;
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 16px;
}

.no-data {
    text-align: center;
    padding: 2rem;
    color: #64748b;
    background: #f8fafc;
    border-radius: 8px;
    margin: 1rem 0;
}

/* Responsive Design */
@media (max-width: 768px) {
    .date-inputs {
        flex-direction: column;
    }

    .category-table {
        font-size: 0.85rem;
    }

    .category-table th,
    .category-table td {
        padding: 8px;
    }
}

@media (max-width: 480px) {
    .preset-filters {
        flex-direction: column;
    }

    .preset-filters button {
        width: 100%;
    }
}

/* Enhanced Table Section Styles */
.table-section {
    background: white;
    border-radius: 8px;
    padding: 24px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    height: fit-content;
}

.table-section h2 {
    font-size: 1.5rem;
    margin-top: 0;
    margin-bottom: 20px;
    color: #1e293b;
    text-align: left;
    padding-bottom: 0;
}

.table-section h2::after {
    display: none;
}

/* Enhanced Table Styles */
.category-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    background-color: white;
}

.category-table th {
    background: #f8fafc;
    padding: 14px 16px;
    text-align: left;
    color: #4f46e5;
    font-weight: 600;
    border-bottom: 2px solid #4f46e5;
    white-space: nowrap;
}

.category-table td {
    padding: 14px 16px;
    border-bottom: 1px solid #e2e8f0;
    color: #1e293b;
    font-size: 0.9rem;
}

.category-table tr:hover td {
    background: #f8fafc;
}

.category-table .category-name {
    font-weight: 600;
    color: #1e293b;
}

/* Improved Chart Section */
.chart-section {
    padding: 30px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(99, 102, 241, 0.1);
    min-height: 400px;
}

/* Responsive Improvements */
@media (max-width: 1024px) {
    .category-analysis {
        grid-template-columns: 1fr;
        gap: 30px;
    }

    .chart-section {
        order: -1;
        min-height: 350px;
    }

    .table-section {
        overflow-x: auto;
    }
}

/* Font Consistency */
.category-table th,
.category-table td,
.date-controls h2,
.table-section h2 {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Amount Display Improvements */
.category-table .amount {
    font-family: 'Roboto Mono', monospace;
    text-align: right;
    font-weight: 500;
}

/* Percentage Column */
.category-table .percentage {
    text-align: right;
    font-weight: 500;
    color: #6b7280;
}

/* Date Control Improvements */
.date-controls {
    background: white;
    padding: 24px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
    border: 1px solid rgba(99, 102, 241, 0.1);
}

.date-controls h2 {
    font-size: 1.5rem;
    margin-top: 0;
    color: #1e293b;
    text-align: left;
    padding-bottom: 0;
    margin-bottom: 20px;
}

.date-controls h2::after {
    display: none;
}

.preset-filters button {
    padding: 10px 18px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: white;
    color: #4b5563;
    font-weight: 500;
    transition: all 0.3s ease;
}

.preset-filters button.active {
    background: #4f46e5;
    color: white;
    border-color: #4f46e5;
    box-shadow: 0 2px 4px rgba(79, 70, 229, 0.2);
}

/* Additional styling for no-data states */

/* Placeholder message styling */
.placeholder-message {
    background-color: #f8fafc;
    padding: 15px;
    border-radius: 8px;
    text-align: center;
    color: #6b7280;
    margin: 20px 0;
    font-style: italic;
    border: 1px dashed #e2e8f0;
}

/* Styling for placeholder data rows */
.category-table tr.placeholder-row td {
    color: #94a3b8;
}

.category-table tr.placeholder-row:hover td {
    background-color: #f8fafc;
    color: #6b7280;
}

/* Pulse animation for placeholder data */
@keyframes placeholderPulse {
    0% { opacity: 0.7; }
    50% { opacity: 1; }
    100% { opacity: 0.7; }
}

.placeholder-indicator {
    display: inline-block;
    padding: 3px 8px;
    background-color: #f3f4f6;
    border-radius: 4px;
    font-size: 0.7rem;
    color: #6b7280;
    margin-left: 10px;
    animation: placeholderPulse 2s infinite ease-in-out;
}

/* Empty state container */
.empty-state-container {
    padding: 40px 20px;
    text-align: center;
    background: #f8fafc;
    border-radius: 8px;
    margin: 20px 0;
}

.empty-state-container p {
    color: #6b7280;
    margin-bottom: 20px;
}

.empty-state-icon {
    font-size: 3rem;
    color: #cbd5e1;
    margin-bottom: 15px;
}

/* Enhanced chart wrapper for empty state */
.chart-section.empty-data {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Subtle placeholder highlight */
.table-section h2.has-placeholder-data::after {
    content: 'Demo Data';
    display: inline-block;
    font-size: 0.7rem;
    background-color: #f3f4f6;
    padding: 3px 8px;
    border-radius: 4px;
    color: #6b7280;
    margin-left: 10px;
    font-weight: normal;
    vertical-align: middle;
    animation: placeholderPulse 2s infinite ease-in-out;
}

/* Loading overlay enhancements */
.loader {
    background: rgba(255, 255, 255, 0.85);
}

.loader-content {
    border-radius: 12px;
    padding: 30px;
}

.loader-spinner {
    border-top-color: #4f46e5;
}

/* Make the table container scrollable */
.table-container {
    width: 100%;
    max-height: 500px;
    overflow-y: auto;
    position: relative;
}

/* Make the table header sticky */
.category-table th {
    background: #f8fafc;
    padding: 14px 16px;
    text-align: left;
    color: #4f46e5;
    font-weight: 600;
    border-bottom: 2px solid #4f46e5;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 10;
}

/* Ensure the table section doesn't overflow */
.table-section {
    background: white;
    border-radius: 8px;
    padding: 24px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    height: fit-content;
    overflow: hidden;
}

/* Add shadow effect to the header when scrolling */
.table-container:not(:hover) thead::after,
.table-container:hover thead::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 45px;
    height: 6px;
    background: linear-gradient(to bottom, rgba(0,0,0,0.08) 0%, rgba(0,0,0,0) 100%);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.table-container:hover thead::after {
    opacity: 1;
}

/* Custom scrollbar styling */
.table-container::-webkit-scrollbar {
    width: 8px;
}

.table-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.table-container::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.table-container::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}