/* CSS Variables */
:root {
    --primary-color: #2196F3;
    --primary-dark: #1976D2;
    --primary-light: #BBDEFB;
    --secondary-color: #FF5722;
    --success-color: #4CAF50;
    --warning-color: #FFC107;
    --error-color: #F44336;
    --text-primary: #212121;
    --text-secondary: #757575;
    --divider-color: #BDBDBD;
    --background-color: #FAFAFA;
    --card-background: #FFFFFF;
    --header-height: 60px;
    --nav-height: 56px;
    --border-radius: 8px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
    --shadow-md: 0 3px 6px rgba(0,0,0,0.15), 0 2px 4px rgba(0,0,0,0.12);
    --shadow-lg: 0 10px 20px rgba(0,0,0,0.15), 0 3px 6px rgba(0,0,0,0.10);
    --transition: all 0.3s ease;
}

/* Reset & Base Styles */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: var(--background-color);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
}

/* App Container */
#app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 100;
    box-shadow: var(--shadow-md);
}

.app-header h1 {
    font-size: 1.25rem;
    font-weight: 500;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.status-indicator {
    font-size: 0.75rem;
    padding: 4px 8px;
    border-radius: 12px;
    background: var(--success-color);
}

.status-indicator.offline {
    background: var(--warning-color);
    color: var(--text-primary);
}

/* Navigation */
.app-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    background: var(--card-background);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 100;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
}

.nav-btn {
    flex: 1;
    height: 100%;
    border: none;
    background: none;
    font-size: 0.75rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.nav-btn.active {
    color: var(--primary-color);
}

.nav-btn:hover {
    background: var(--primary-light);
}

/* Main Content */
.app-main {
    margin-top: var(--header-height);
    margin-bottom: var(--nav-height);
    padding: 16px;
    flex: 1;
}

/* Views */
.view {
    display: none;
    animation: fadeIn 0.3s ease;
}

.view.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

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

.view-header h2 {
    font-size: 1.5rem;
    font-weight: 500;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

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

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

.btn-secondary {
    background: var(--divider-color);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: #9E9E9E;
}

.btn-icon {
    padding: 8px;
    background: transparent;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    border-radius: 50%;
}

.btn-icon:hover {
    background: rgba(255,255,255,0.1);
}

.btn-large {
    padding: 16px 32px;
    font-size: 1.1rem;
}

.btn-google {
    background: #DB4437;
    color: white;
    width: 100%;
    max-width: 300px;
}

.btn-google:hover {
    background: #C53929;
}

.btn-microsoft {
    background: #00A4EF;
    color: white;
    width: 100%;
    max-width: 300px;
}

.btn-microsoft:hover {
    background: #0093D8;
}

.btn-microsoft:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-microsoft:disabled:hover {
    background: #00A4EF;
}

/* Login View */
.login-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    text-align: center;
    padding: 20px;
}

.login-container h2 {
    margin-bottom: 10px;
}

.login-container p {
    color: var(--text-secondary);
    margin-bottom: 30px;
}

.login-buttons {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
    align-items: center;
}

/* Reports Grid */
.reports-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.report-card {
    background: var(--card-background);
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: var(--transition);
}

.report-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.report-card h3 {
    font-size: 1.1rem;
    margin-bottom: 8px;
}

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

.report-card .report-meta {
    display: flex;
    justify-content: space-between;
    margin-top: 12px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Capture View */
.capture-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.capture-preview {
    width: 100%;
    max-width: 400px;
    aspect-ratio: 3/4;
    background: var(--divider-color);
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.capture-preview img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.capture-placeholder {
    text-align: center;
    color: var(--text-secondary);
}

.capture-placeholder span {
    font-size: 4rem;
}

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

.select-report {
    padding: 10px 16px;
    border: 1px solid var(--divider-color);
    border-radius: var(--border-radius);
    font-size: 0.9rem;
    background: var(--card-background);
    min-width: 200px;
}

/* OCR Review View */
.ocr-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

@media (min-width: 768px) {
    .ocr-container {
        grid-template-columns: 1fr 1fr;
    }
}

.ocr-image {
    background: var(--divider-color);
    border-radius: var(--border-radius);
    overflow: hidden;
    max-height: 50vh;
}

.ocr-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.ocr-form {
    background: var(--card-background);
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.ocr-status {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    color: var(--text-secondary);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--primary-light);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

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

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 0.9rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--divider-color);
    border-radius: var(--border-radius);
    font-size: 1rem;
    transition: var(--transition);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.checkbox-group input {
    width: auto;
}

.checkbox-group label {
    margin-bottom: 0;
}

.form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 20px;
}

/* Categories List */
.categories-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.category-item {
    background: var(--card-background);
    padding: 16px;
    border-radius: var(--border-radius);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
}

.category-item button {
    padding: 6px 12px;
    font-size: 0.8rem;
}

/* Report Detail View */
.table-container {
    overflow-x: auto;
    background: var(--card-background);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
}

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

.receipts-table th,
.receipts-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--divider-color);
}

.receipts-table th {
    background: var(--primary-light);
    font-weight: 600;
    white-space: nowrap;
}

.receipts-table tr:hover {
    background: var(--background-color);
}

.report-summary {
    margin-top: 20px;
    padding: 16px;
    background: var(--card-background);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    display: flex;
    justify-content: space-around;
    font-weight: 500;
}

/* Settings View */
.settings-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.setting-group {
    background: var(--card-background);
    padding: 20px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
}

.setting-group h3 {
    margin-bottom: 12px;
    font-size: 1.1rem;
}

.setting-group p {
    color: var(--text-secondary);
    margin-bottom: 16px;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--card-background);
    border-radius: var(--border-radius);
    padding: 24px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.modal-content h3 {
    margin-bottom: 20px;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: calc(var(--nav-height) + 20px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    background: var(--text-primary);
    color: white;
    padding: 12px 24px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    animation: toastIn 0.3s ease;
    pointer-events: auto;
}

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

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

.toast.warning {
    background: var(--warning-color);
    color: var(--text-primary);
}

@keyframes toastIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Loading State */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.empty-state span {
    font-size: 4rem;
    display: block;
    margin-bottom: 16px;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.mt-2 {
    margin-top: 8px;
}

.mt-4 {
    margin-top: 16px;
}

/* Responsive */
@media (max-width: 480px) {
    .app-header h1 {
        font-size: 1rem;
    }
    
    .view-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .view-header h2 {
        font-size: 1.25rem;
    }
    
    .btn-large {
        width: 100%;
    }
}
