:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --secondary: #8b5cf6;
    --success: #10b981;
    --error: #ef4444;
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --border: #475569;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, var(--bg-primary) 0%, #1a1f3a 100%);
    color: var(--text-primary);
    min-height: 100vh;
    padding: 2rem 1rem;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 3rem;
}

.header h1 {
    font-size: 3rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
}

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

/* Upload Section */
.upload-section {
    margin-bottom: 2rem;
}

.upload-card {
    background: var(--bg-secondary);
    border-radius: 1.5rem;
    padding: 2.5rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
}

.upload-card h2 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    text-align: center;
}

/* Upload Zone */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: 1rem;
    padding: 3rem 2rem;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
}

.upload-zone:hover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

.upload-zone.drag-over {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
    transform: scale(1.02);
}

.upload-icon {
    width: 64px;
    height: 64px;
    color: var(--primary);
    margin-bottom: 1rem;
}

.upload-text {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.upload-subtext {
    color: var(--text-secondary);
    margin: 1rem 0;
}

.upload-btn {
    display: inline-block;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    padding: 0.875rem 2rem;
    border-radius: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
}

.upload-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(99, 102, 241, 0.4);
}

.upload-info {
    margin-top: 1rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Divider */
.divider {
    position: relative;
    text-align: center;
    margin: 2rem 0;
}

.divider::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    width: 100%;
    height: 1px;
    background: var(--border);
}

.divider span {
    position: relative;
    background: var(--bg-secondary);
    padding: 0 1rem;
    color: var(--text-secondary);
    font-weight: 600;
}

/* Camera Button */
.camera-btn {
    width: 100%;
    background: linear-gradient(135deg, #059669, #10b981);
    color: white;
    padding: 1rem 2rem;
    border-radius: 0.75rem;
    font-size: 1.125rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.camera-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(16, 185, 129, 0.4);
}

.btn-icon {
    width: 24px;
    height: 24px;
}

/* Camera Preview */
.camera-preview {
    margin-top: 1.5rem;
    border-radius: 1rem;
    overflow: hidden;
    background: black;
}

.camera-preview video {
    width: 100%;
    display: block;
}

.camera-controls {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-card);
}

.capture-btn,
.close-btn {
    flex: 1;
    padding: 0.875rem;
    border-radius: 0.5rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
}

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

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

.close-btn {
    background: var(--error);
    color: white;
}

.close-btn:hover {
    background: #dc2626;
}

/* Loading */
.loading {
    text-align: center;
    padding: 3rem;
    background: var(--bg-secondary);
    border-radius: 1.5rem;
    margin: 2rem 0;
}

.spinner {
    width: 64px;
    height: 64px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

/* Results Section */
.results-section {
    margin: 2rem 0;
}

.result-card {
    background: var(--bg-secondary);
    border-radius: 1.5rem;
    padding: 2.5rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
}

.result-card h2 {
    font-size: 1.75rem;
    margin-bottom: 1.5rem;
}

.result-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.result-item {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: 0.75rem;
    border: 1px solid var(--border);
}

.result-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

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

.result-value.highlight {
    color: var(--primary);
    font-size: 1.5rem;
}

/* Items Table */
.items-section {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}

.items-section h3 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
}

.items-table-wrapper {
    overflow-x: auto;
}

.items-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border-radius: 0.75rem;
    overflow: hidden;
}

.items-table th,
.items-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.items-table th {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.875rem;
    letter-spacing: 0.05em;
}

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

.items-table td {
    color: var(--text-secondary);
}

/* New Scan Button */
.new-scan-btn {
    width: 100%;
    margin-top: 2rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    padding: 1rem 2rem;
    border-radius: 0.75rem;
    font-size: 1.125rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.new-scan-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(99, 102, 241, 0.4);
}

/* Error Message */
.error-message {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--error);
    color: var(--error);
    padding: 1.5rem;
    border-radius: 0.75rem;
    margin: 2rem 0;
    text-align: center;
}

/* Recent Invoices */
.recent-section {
    margin-top: 3rem;
}

.recent-section h2 {
    font-size: 1.75rem;
    margin-bottom: 1.5rem;
}

.recent-list {
    display: grid;
    gap: 1rem;
}

.recent-item {
    background: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: 1rem;
    border: 1px solid var(--border);
    transition: all 0.3s ease;
    cursor: pointer;
}

.recent-item:hover {
    border-color: var(--primary);
    transform: translateX(4px);
}

.recent-item-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 1rem;
}

.recent-item-title {
    font-weight: 600;
    font-size: 1.125rem;
}

.recent-item-date {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.recent-item-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.empty-state {
    text-align: center;
    color: var(--text-secondary);
    padding: 3rem;
    background: var(--bg-secondary);
    border-radius: 1rem;
    border: 1px dashed var(--border);
}

/* Responsive */
@media (max-width: 768px) {
    .header h1 {
        font-size: 2rem;
    }

    .upload-card {
        padding: 1.5rem;
    }

    .result-grid {
        grid-template-columns: 1fr;
    }

    .items-table {
        font-size: 0.875rem;
    }

    .items-table th,
    .items-table td {
        padding: 0.75rem;
    }
}
