/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f7fa;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header Styles */
header {
    text-align: center;
    margin-bottom: 40px;
    padding: 20px 0;
}

header h1 {
    color: #2c3e50;
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.subtitle {
    color: #7f8c8d;
    font-size: 1.1rem;
    font-weight: 400;
}

/* Main Content */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Loading State */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e3e3e3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Enhanced loading animation */
.loading-container p {
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

.loading-container p {
    color: #7f8c8d;
    font-size: 1.1rem;
}

/* Error State */
.error-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    border-left: 4px solid #e74c3c;
}

.error-icon {
    font-size: 3rem;
    margin-bottom: 20px;
}

.error-content h3 {
    color: #e74c3c;
    margin-bottom: 10px;
    font-size: 1.5rem;
}

.error-content p {
    color: #7f8c8d;
    margin-bottom: 20px;
    max-width: 500px;
}

.error-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.retry-btn {
    background: #3498db;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.2s;
    min-width: 120px;
}

.retry-btn:hover:not(:disabled) {
    background: #2980b9;
    transform: translateY(-1px);
}

.retry-btn:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
    transform: none;
}

.retry-btn:active:not(:disabled) {
    transform: translateY(0);
}

/* Empty State */
.empty-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 20px;
    opacity: 0.5;
}

.empty-container h3 {
    color: #2c3e50;
    margin-bottom: 10px;
    font-size: 1.5rem;
}

.empty-container p {
    color: #7f8c8d;
    margin-bottom: 20px;
}

.empty-actions {
    display: flex;
    justify-content: center;
    margin-top: 20px;
}

/* Table Container */
.table-container {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
}

.table-header h2 {
    color: #2c3e50;
    font-size: 1.5rem;
    font-weight: 600;
}

.table-info {
    display: flex;
    align-items: center;
    gap: 16px;
    color: #7f8c8d;
    font-size: 0.9rem;
}

/* Refresh Button */
.refresh-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #3498db;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s;
    min-width: auto;
}

.refresh-btn:hover:not(:disabled) {
    background: #2980b9;
    transform: translateY(-1px);
}

.refresh-btn:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
    transform: none;
}

.refresh-btn:active:not(:disabled) {
    transform: translateY(0);
}

.refresh-icon {
    font-size: 0.9rem;
    transition: transform 0.3s ease;
}

.refresh-btn:hover .refresh-icon {
    transform: rotate(180deg);
}

.refresh-btn.refreshing .refresh-icon {
    animation: spin 1s linear infinite;
}

/* Table Styles */
.table-wrapper {
    overflow-x: auto;
}

.receipts-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.receipts-table th {
    background: #f8f9fa;
    color: #2c3e50;
    font-weight: 600;
    padding: 16px 12px;
    text-align: left;
    border-bottom: 2px solid #e9ecef;
    white-space: nowrap;
}

.receipts-table td {
    padding: 16px 12px;
    border-bottom: 1px solid #e9ecef;
    vertical-align: top;
}

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

/* Table Cell Specific Styles */
.receipts-table .date-cell {
    font-weight: 500;
    color: #2c3e50;
}

.receipts-table .merchant-cell {
    font-weight: 500;
    max-width: 200px;
    word-wrap: break-word;
}

.receipts-table .amount-cell {
    text-align: right;
    font-weight: 600;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
}

.receipts-table .currency-cell {
    text-align: center;
    font-weight: 500;
    color: #7f8c8d;
}

.receipts-table .type-cell {
    text-transform: capitalize;
}

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

/* Status Badges */
.status-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
    text-transform: uppercase;
}

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

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

/* Document Type Badges */
.type-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
    text-transform: uppercase;
}

.type-receipt {
    background: #e3f2fd;
    color: #1565c0;
}

.type-invoice {
    background: #f3e5f5;
    color: #7b1fa2;
}

.type-other {
    background: #f5f5f5;
    color: #616161;
}

/* Footer */
footer {
    text-align: center;
    padding: 20px 0;
    margin-top: 40px;
    color: #7f8c8d;
    font-size: 0.9rem;
}

/* Connection Status Indicator */
.connection-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 10px;
    font-size: 0.8rem;
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #27ae60;
    animation: pulse-status 2s ease-in-out infinite;
}

.status-indicator.offline {
    background: #e74c3c;
    animation: none;
}

@keyframes pulse-status {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* Upload Section Styles */
.upload-section {
    margin-bottom: 40px;
}

.upload-container {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.upload-header {
    padding: 20px 24px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    text-align: center;
}

.upload-header h2 {
    color: #2c3e50;
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.upload-header p {
    color: #7f8c8d;
    font-size: 1rem;
}

/* Drag and Drop Zone */
.drop-zone {
    padding: 40px 24px;
    text-align: center;
    border: 2px dashed #bdc3c7;
    margin: 24px;
    border-radius: 8px;
    background: #fafbfc;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
}

.drop-zone:hover:not(.uploading) {
    border-color: #3498db;
    background: #f0f8ff;
    transform: translateY(-2px);
}

.drop-zone.drag-over {
    border-color: #3498db;
    background: #e3f2fd;
    transform: scale(1.02);
}

.drop-zone.uploading {
    border-color: #95a5a6;
    background: #ecf0f1;
    cursor: not-allowed;
    opacity: 0.7;
}

.drop-zone-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.upload-icon {
    font-size: 3rem;
    opacity: 0.6;
    margin-bottom: 8px;
}

.drop-text {
    font-size: 1.2rem;
    font-weight: 500;
    color: #2c3e50;
    margin: 0;
}

.drop-subtext {
    font-size: 1rem;
    color: #7f8c8d;
    margin: 0;
}

.file-picker-btn {
    background: #3498db;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.2s;
    min-width: 140px;
}

.file-picker-btn:hover:not(:disabled) {
    background: #2980b9;
    transform: translateY(-1px);
}

.file-picker-btn:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
    transform: none;
}

.file-requirements {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #e9ecef;
}

.file-requirements small {
    color: #7f8c8d;
    font-size: 0.85rem;
}

/* Upload Progress */
.upload-progress {
    padding: 20px 24px;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.progress-header span {
    font-size: 0.9rem;
    color: #2c3e50;
    font-weight: 500;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #3498db, #2980b9);
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0%;
}

/* Upload Status Messages */
.upload-status {
    border-top: 1px solid #e9ecef;
}

.status-message {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 20px 24px;
}

.status-message.success {
    background: #d4edda;
    border-left: 4px solid #28a745;
}

.status-message.error {
    background: #f8d7da;
    border-left: 4px solid #dc3545;
}

.status-icon {
    font-size: 1.2rem;
    margin-top: 2px;
}

.status-content {
    flex: 1;
}

.status-content strong {
    display: block;
    margin-bottom: 4px;
    font-size: 1rem;
}

.status-content p {
    margin: 0;
    color: #6c757d;
    font-size: 0.9rem;
    line-height: 1.4;
}

.status-message .retry-btn {
    margin-top: 12px;
    padding: 8px 16px;
    font-size: 0.9rem;
    min-width: 100px;
}

/* Upload Animation Effects */
@keyframes uploadPulse {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; }
}

.drop-zone.uploading .upload-icon {
    animation: uploadPulse 2s ease-in-out infinite;
}

/* Success Animation */
@keyframes successSlide {
    0% {
        transform: translateY(-10px);
        opacity: 0;
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

.status-message.success {
    animation: successSlide 0.3s ease-out;
}

/* Error Animation */
@keyframes errorShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.status-message.error {
    animation: errorShake 0.5s ease-out;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    /* Upload responsive styles */
    .upload-header {
        padding: 16px 20px;
    }
    
    .upload-header h2 {
        font-size: 1.3rem;
    }
    
    .drop-zone {
        padding: 30px 20px;
        margin: 20px;
    }
    
    .upload-icon {
        font-size: 2.5rem;
    }
    
    .drop-text {
        font-size: 1.1rem;
    }
    
    .file-picker-btn {
        padding: 10px 20px;
        font-size: 0.95rem;
        min-width: 120px;
    }
    
    .upload-progress,
    .status-message {
        padding: 16px 20px;
    }
    
    .table-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .table-info {
        width: 100%;
        justify-content: space-between;
    }
    
    .refresh-btn {
        padding: 6px 10px;
        font-size: 0.8rem;
    }
    
    .receipts-table {
        font-size: 0.85rem;
    }
    
    .receipts-table th,
    .receipts-table td {
        padding: 12px 8px;
    }
    
    .receipts-table .merchant-cell {
        max-width: 150px;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.75rem;
    }
    
    .subtitle {
        font-size: 1rem;
    }
    
    /* Upload mobile styles */
    .upload-header {
        padding: 12px 16px;
    }
    
    .upload-header h2 {
        font-size: 1.2rem;
    }
    
    .upload-header p {
        font-size: 0.9rem;
    }
    
    .drop-zone {
        padding: 24px 16px;
        margin: 16px;
    }
    
    .upload-icon {
        font-size: 2rem;
    }
    
    .drop-text {
        font-size: 1rem;
    }
    
    .drop-subtext {
        font-size: 0.9rem;
    }
    
    .file-picker-btn {
        padding: 8px 16px;
        font-size: 0.9rem;
        min-width: 100px;
    }
    
    .upload-progress,
    .status-message {
        padding: 12px 16px;
    }
    
    .progress-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    
    .status-content strong {
        font-size: 0.95rem;
    }
    
    .status-content p {
        font-size: 0.85rem;
    }
    
    .receipts-table {
        font-size: 0.8rem;
    }
    
    .receipts-table th,
    .receipts-table td {
        padding: 10px 6px;
    }
    
    /* Stack table on very small screens */
    .table-wrapper {
        overflow-x: scroll;
    }
    
    .receipts-table {
        min-width: 600px;
    }
}