/* Light Theme - Green, Gray, Orange, White */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

:root {
    --primary: #10b981;
    --primary-dark: #059669;
    --primary-light: #34d399;
    --secondary: #6b7280;
    --accent: #f97316;
    --accent-light: #fb923c;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --bg-sidebar: #1e293b;
    --bg-hover: #f1f5f9;
    --bg-table-header: #e2e8f0;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --text-light: #f8fafc;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.2s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-main);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    font-size: 14px;
}

/* App Container */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar - Keep Dark */
.sidebar {
    width: 220px;
    background: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.sidebar-header {
    padding: 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    text-align: center;
}

.sidebar-logo {
    height: 36px;
    margin-bottom: 0.5rem;
}

.sidebar-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-light);
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0.75rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
}

.nav-item:hover {
    background: rgba(255,255,255,0.1);
    color: var(--text-light);
}

.nav-item.active {
    background: var(--primary);
    color: white;
}

.nav-item i {
    width: 18px;
    text-align: center;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid rgba(255,255,255,0.1);
    text-align: center;
}

.sidebar-footer p {
    font-size: 0.7rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.sidebar-footer .version {
    margin-top: 0.25rem;
    opacity: 0.6;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 220px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
}

.header-title h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.header-title p {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.btn-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.btn-icon:hover {
    background: var(--bg-hover);
    color: var(--primary);
}

/* Content Sections */
.content-section {
    flex: 1;
    padding: 1.5rem;
}

/* Upload Section */
.upload-container {
    max-width: 500px;
    margin: 0 auto;
}

.upload-box {
    background: var(--bg-card);
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 2.5rem 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
}

.upload-box:hover, .upload-box.dragover {
    border-color: var(--primary);
    background: rgba(16, 185, 129, 0.05);
}

.upload-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 1rem;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.upload-icon i {
    font-size: 1.5rem;
    color: white;
}

.upload-box h3 {
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.upload-box p {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.upload-hint {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 1rem;
}

/* Buttons */
.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    border: none;
    padding: 0.6rem 1.25rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-family: inherit;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 0.6rem 1.25rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-family: inherit;
}

.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--primary);
}

.btn-analyze {
    width: 100%;
    margin-top: 1.25rem;
    padding: 0.875rem;
    font-size: 0.9rem;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: inherit;
    font-weight: 500;
}

.btn-analyze:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.btn-analyze:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* File Preview */
.file-preview {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    margin-top: 1rem;
    border: 1px solid var(--border);
}

.file-icon {
    width: 40px;
    height: 40px;
    background: rgba(239, 68, 68, 0.1);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

.file-icon i {
    font-size: 1.25rem;
    color: #ef4444;
}

.file-details {
    flex: 1;
}

.file-name {
    display: block;
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--text-primary);
}

.file-size {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.btn-remove {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    cursor: pointer;
    transition: var(--transition);
}

.btn-remove:hover {
    background: #ef4444;
    color: white;
}

/* Loading Section */
.loading-container {
    max-width: 350px;
    margin: 0 auto;
    text-align: center;
    padding: 2rem;
}

.loading-animation {
    position: relative;
    width: 100px;
    height: 100px;
    margin: 0 auto 1.5rem;
}

.loading-circle {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50px;
    height: 50px;
    background: var(--bg-card);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow);
}

.loading-icon i {
    font-size: 1.25rem;
    color: var(--primary);
    animation: pulse 1.5s ease-in-out infinite;
}

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

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(0.9); }
}

.loading-container h3 {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.loading-container p {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 1.25rem;
}

.loading-progress-bar {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.loading-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    border-radius: 2px;
    transition: width 0.3s ease;
    width: 0%;
}

.loading-steps {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
}

.loading-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    color: var(--text-muted);
}

.loading-step.active {
    color: var(--primary);
}

.loading-step.completed {
    color: var(--success);
}

.loading-step i {
    font-size: 1rem;
}

.loading-step span {
    font-size: 0.7rem;
}

/* Result Section */
.result-container {
    max-width: 100%;
    margin: 0 auto;
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    background: var(--bg-card);
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.result-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.result-title i {
    font-size: 1.25rem;
    color: var(--success);
}

.result-title h3 {
    font-size: 1rem;
    font-weight: 600;
}

.result-actions {
    display: flex;
    gap: 0.5rem;
}

/* Result Summary Cards */
.result-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.summary-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    box-shadow: var(--shadow);
    border-top: 3px solid var(--primary);
}

.summary-card.total {
    border-top-color: var(--accent);
}

.summary-card h4 {
    font-size: 0.65rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.summary-card .value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.summary-card.total .value {
    color: var(--accent);
}

/* Result Table - Clean Style */
.result-table-container {
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.result-table {
    width: 100%;
    border-collapse: collapse;
}

.result-table th {
    background: var(--bg-table-header);
    padding: 0.875rem 1rem;
    text-align: left;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    font-weight: 600;
    border-bottom: 1px solid var(--border);
}

.result-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
    color: var(--text-primary);
}

.result-table tbody tr:hover {
    background: var(--bg-hover);
}

.result-table tbody tr:last-child td {
    border-bottom: none;
}

.result-table .text-right {
    text-align: right;
}

.result-table .category-row td {
    background: rgba(16, 185, 129, 0.05);
    font-weight: 500;
}

.result-table .category-name {
    color: var(--primary);
    font-weight: 600;
}

.result-table .category-code {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-left: 0.5rem;
}

.result-table .item-row td {
    padding-left: 2rem;
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.result-table .amount {
    font-weight: 600;
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    color: var(--text-primary);
}

.result-table tfoot td {
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    color: white;
    font-weight: 700;
    font-size: 0.95rem;
    padding: 1rem;
}

.result-table tfoot .total-label {
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* History Section */
.history-container {
    max-width: 100%;
}

.history-header {
    margin-bottom: 1.25rem;
}

.history-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    box-shadow: var(--shadow);
}

.stat-card i {
    width: 40px;
    height: 40px;
    background: rgba(16, 185, 129, 0.1);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: var(--primary);
}

.stat-card:nth-child(2) i {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.stat-card:nth-child(3) i {
    background: rgba(249, 115, 22, 0.1);
    color: var(--accent);
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

/* History List */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.history-item {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 0.875rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: var(--transition);
    border-left: 3px solid var(--border);
    box-shadow: var(--shadow);
}

.history-item:hover {
    box-shadow: var(--shadow-lg);
}

.history-item.status-completed {
    border-left-color: var(--success);
}

.history-item.status-processing {
    border-left-color: var(--primary);
}

.history-item.status-error {
    border-left-color: var(--error);
}

.history-item.status-pending,
.history-item.status-uploading {
    border-left-color: var(--warning);
}

.history-file-icon {
    width: 36px;
    height: 36px;
    background: rgba(239, 68, 68, 0.1);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

.history-file-icon i {
    color: #ef4444;
    font-size: 0.9rem;
}

.history-info {
    flex: 1;
}

.history-filename {
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--text-primary);
}

.history-meta {
    font-size: 0.7rem;
    color: var(--text-secondary);
    display: flex;
    gap: 0.75rem;
}

.history-status {
    margin-left: auto;
}

.status-badge {
    padding: 0.3rem 0.6rem;
    border-radius: 20px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.status-badge.completed {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
}

.status-badge.processing {
    background: rgba(16, 185, 129, 0.15);
    color: var(--primary);
}

.status-badge.error {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error);
}

.status-badge.pending,
.status-badge.uploading {
    background: rgba(249, 115, 22, 0.15);
    color: var(--accent);
}

.history-actions {
    display: flex;
    gap: 0.375rem;
}

.btn-view, .btn-delete {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
}

.btn-view {
    background: var(--primary);
    color: white;
}

.btn-view:hover {
    background: var(--primary-dark);
}

.btn-delete {
    background: var(--bg-hover);
    color: var(--error);
    border: 1px solid var(--border);
}

.btn-delete:hover {
    background: var(--error);
    color: white;
    border-color: var(--error);
}

.history-empty {
    text-align: center;
    padding: 2.5rem;
    color: var(--text-muted);
    background: var(--bg-card);
    border-radius: var(--radius);
}

.history-empty i {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    opacity: 0.3;
}

.history-progress {
    width: 100%;
    height: 3px;
    background: var(--border);
    border-radius: 2px;
    margin-top: 0.5rem;
    overflow: hidden;
}

.history-progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 2px;
    transition: width 0.3s ease;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 0.875rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
    border-left: 3px solid var(--primary);
    font-size: 0.85rem;
}

.toast.success {
    border-left-color: var(--success);
}

.toast.error {
    border-left-color: var(--error);
}

.toast.warning {
    border-left-color: var(--warning);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(100px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100px);
    }
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        display: none;
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .history-stats,
    .result-summary {
        grid-template-columns: 1fr;
    }
}
