/* Custom styles for Invoice Dashboard */

:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --secondary-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --success-gradient: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    --warning-gradient: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
    --card-shadow: 0 8px 30px rgba(0,0,0,0.12);
    --border-radius: 16px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Light mode colors */
    --bg-primary: #f8f9fa;
    --bg-secondary: #ffffff;
    --bg-gradient: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --border-color: #e9ecef;
    --navbar-bg: #ffffff;
    --card-bg: #ffffff;
    --shadow-light: 0 1px 3px rgba(0,0,0,0.08);
}

[data-theme="dark"] {
    /* Dark mode colors */
    --bg-primary: #1e1e1e;
    --bg-secondary: #2a2a2a;
    --bg-gradient: linear-gradient(135deg, #1e1e1e 0%, #2a2a2a 100%);
    --text-primary: #ffffff;
    --text-secondary: #cccccc;
    --border-color: #404040;
    --navbar-bg: #2a2a2a;
    --card-bg: #2a2a2a;
    --shadow-light: 0 1px 3px rgba(0,0,0,0.3);
    --card-shadow: 0 8px 30px rgba(0,0,0,0.5);
}

body {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--text-primary);
}

/* Only add transition after page has loaded to prevent flash */
body.loaded {
    transition: var(--transition);
}

/* Desktop professional background */
@media (min-width: 992px) {
    body {
        background: var(--bg-gradient);
    }
}

.navbar {
    background: rgba(255, 255, 255, 0.95) !important;
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 2px 20px rgba(0,0,0,0.1);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1030;
    transition: var(--transition);
}

/* Desktop professional navbar */
@media (min-width: 992px) {
    .navbar {
        background: var(--navbar-bg) !important;
        border-bottom: 1px solid var(--border-color);
        box-shadow: var(--shadow-light);
        padding: 1rem 3rem;
    }
}

/* Add padding to body to account for fixed navbar */
body {
    padding-top: 80px;
}

/* Dark mode navbar styling */
[data-theme="dark"] .navbar {
    background: var(--navbar-bg) !important;
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-light);
}

.navbar-brand, .nav-link {
    color: var(--text-primary) !important;
    font-weight: 600;
    transition: var(--transition);
}

/* Dark mode toggle button */
.theme-toggle {
    background: none;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    transition: var(--transition);
    cursor: pointer;
}

.theme-toggle:hover {
    background: var(--bg-primary);
    transform: scale(1.1);
}

/* Desktop: Full width professional layout */
@media (min-width: 992px) {
    .container {
        max-width: 100%;
        width: 100%;
        margin: 0;
        padding: 2rem 3rem;
        border-radius: 0;
        background: var(--bg-secondary);
        backdrop-filter: blur(10px);
        box-shadow: none;
        min-height: calc(100vh - 80px);
    }
    
    body.loaded .container {
        transition: var(--transition);
    }
}

/* Tablet and mobile: Keep existing container styling */
@media (max-width: 991px) {
    .container {
        background: rgba(255, 255, 255, 0.95);
        border-radius: var(--border-radius);
        margin-top: 2rem;
        margin-bottom: 2rem;
        padding: 2rem;
        backdrop-filter: blur(10px);
        box-shadow: var(--card-shadow);
    }
    
    body.loaded .container {
        transition: var(--transition);
    }
}

.card {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    color: var(--text-primary);
}

body.loaded .card {
    transition: var(--transition);
}

/* Desktop professional cards */
@media (min-width: 992px) {
    .card {
        background: var(--card-bg);
        border: 1px solid var(--border-color);
        box-shadow: var(--shadow-light);
        margin-bottom: 2rem;
    }
    
    .card-header {
        background-color: var(--bg-primary);
        border-bottom: 1px solid var(--border-color);
        font-weight: 600;
        color: var(--text-primary);
        padding: 1.25rem 1.5rem;
    }
    
    .card-body {
        padding: 1.5rem;
        background: var(--card-bg);
        color: var(--text-primary);
    }
}



.border-dashed {
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius);
    transition: var(--transition);
    background: var(--bg-primary);
    backdrop-filter: blur(10px);
    color: var(--text-primary);
}



.border-dashed.drag-over {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.2);
    transform: scale(1.02);
}

.step-icon {
    margin-bottom: 1rem;
}

.invoice-content {
    background-color: var(--bg-primary);
    border-radius: 8px;
    padding: 1.5rem;
    max-height: 600px;
    overflow-y: auto;
    color: var(--text-primary);
    transition: var(--transition);
}

.rendered-markdown {
    background-color: var(--bg-primary);
    border-radius: 8px;
    padding: 1.5rem;
    max-height: 600px;
    overflow-y: auto;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    transition: var(--transition);
}

.rendered-markdown h1,
.rendered-markdown h2,
.rendered-markdown h3,
.rendered-markdown h4,
.rendered-markdown h5,
.rendered-markdown h6 {
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.rendered-markdown h1 {
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.rendered-markdown h2 {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.3rem;
}

.rendered-markdown table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
}

.rendered-markdown table th,
.rendered-markdown table td {
    border: 1px solid var(--border-color);
    padding: 0.75rem;
    text-align: left;
    color: var(--text-primary);
}

.rendered-markdown table th {
    background-color: var(--bg-primary);
    font-weight: 600;
    color: var(--text-primary);
}

.rendered-markdown blockquote {
    border-left: 4px solid #0d6efd;
    padding-left: 1rem;
    margin: 1rem 0;
    background-color: var(--bg-primary);
    padding: 1rem;
    border-radius: 4px;
    color: var(--text-primary);
}

.rendered-markdown code {
    background-color: var(--bg-primary);
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    color: var(--text-primary);
}

.rendered-markdown pre {
    background-color: var(--bg-primary);
    padding: 1rem;
    border-radius: 5px;
    overflow-x: auto;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.rendered-markdown ul,
.rendered-markdown ol {
    padding-left: 2rem;
    margin: 1rem 0;
}

.rendered-markdown li {
    margin-bottom: 0.5rem;
}

.navbar-brand {
    font-weight: 600;
}



.btn {
    border-radius: 12px;
    font-weight: 600;
    padding: 0.75rem 1.5rem;
    transition: var(--transition);
    border: none;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.875rem;
}

.btn-primary {
    background: var(--primary-gradient);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

.btn-success {
    background: var(--success-gradient);
    box-shadow: 0 4px 15px rgba(79, 172, 254, 0.3);
}

.btn-warning {
    background: var(--warning-gradient);
    box-shadow: 0 4px 15px rgba(250, 112, 154, 0.3);
}

.btn-danger {
    background: var(--secondary-gradient);
    box-shadow: 0 4px 15px rgba(240, 147, 251, 0.3);
}

.btn-outline-primary {
    border: 2px solid #667eea;
    color: #667eea;
    background: transparent;
}

.btn-outline-primary:hover {
    background: var(--primary-gradient);
    transform: translateY(-2px);
}

.btn-outline-danger {
    border: 2px solid #f5576c;
    color: #f5576c;
    background: transparent;
}

.btn-outline-danger:hover {
    background: var(--secondary-gradient);
    transform: translateY(-2px);
}

.alert {
    border: none;
    border-radius: var(--border-radius);
    backdrop-filter: blur(10px);
    box-shadow: var(--card-shadow);
    color: var(--text-primary);
}

/* Dark mode alert styling */
[data-theme="dark"] .alert {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
}

[data-theme="dark"] .alert-info {
    background-color: rgba(13, 110, 253, 0.2);
    border-color: #0d6efd;
    color: #ffffff;
}

/* Modern stat cards */
.stat-card {
    background: var(--card-bg);
    border: none;
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
    transition: var(--transition);
    overflow: hidden;
    position: relative;
    color: var(--text-primary);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--primary-gradient);
}

/* Desktop professional stat cards */
@media (min-width: 992px) {
    .stat-card {
        background: var(--card-bg);
        border: 1px solid var(--border-color);
        box-shadow: var(--shadow-light);
        margin-bottom: 1.5rem;
    }
    
    .stat-card::before {
        background: #0d6efd;
        height: 3px;
    }
    
    .stat-number {
        font-size: 2.25rem;
        font-weight: 600;
        color: var(--text-primary);
    }
    
    .stat-label {
        color: var(--text-secondary);
        font-size: 0.875rem;
        font-weight: 500;
    }
}


.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    background: var(--primary-gradient);
    color: white;
    font-size: 1.5rem;
}

.stat-number {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0;
}

/* Mobile responsive improvements */
@media (max-width: 768px) {
    .container {
        margin: 1rem;
        padding: 1rem;
        border-radius: var(--border-radius);
    }
    
    .invoice-content,
    .rendered-markdown {
        padding: 1rem;
        max-height: 400px;
    }
    
    .d-flex.justify-content-between {
        flex-direction: column;
        gap: 1rem;
    }
    
    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.8rem;
    }
    
    .stat-card {
        margin-bottom: 1rem;
    }
    
    .stat-number {
        font-size: 2rem;
    }
    
    .navbar-brand {
        font-size: 1.1rem;
    }
    
    .table-responsive {
        font-size: 0.875rem;
    }
}

@media (max-width: 576px) {
    .container {
        margin: 0.5rem;
        padding: 0.75rem;
    }
    
    .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    .d-grid .btn {
        width: auto;
    }
    
    .stat-number {
        font-size: 1.8rem;
    }
    
    .card-body {
        padding: 1rem;
    }
}

/* Loading animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

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

/* Improved upload area */
.upload-area {
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.upload-area::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: conic-gradient(transparent, rgba(102, 126, 234, 0.1), transparent);
    animation: rotate 4s linear infinite;
    opacity: 0;
    transition: opacity 0.3s;
}



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

/* Method selection cards */
.method-card {
    transition: var(--transition);
    cursor: pointer;
    border: 2px solid transparent;
}



.method-card.selected {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.05);
}

/* Camera canvas styling */
#jscanify {
    max-width: 100%;
    height: auto;
    background: #f8f9fa;
}

#result-canvas {
    max-width: 100%;
    height: auto;
    background: #f8f9fa;
}

/* Filter section styling */
#filterSection {
    background: var(--bg-primary);
    border-radius: var(--border-radius);
    transition: var(--transition);
}

#filterSection .card-body {
    background: var(--bg-primary);
    border-radius: var(--border-radius);
}

#filterSection .form-control,
#filterSection .form-select {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 8px;
    transition: var(--transition);
}

#filterSection .form-control:focus,
#filterSection .form-select:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
    background: var(--card-bg);
    color: var(--text-primary);
}

#filterSection .form-label {
    color: var(--text-primary);
    font-weight: 500;
    margin-bottom: 0.5rem;
}

#activeFilters .badge {
    font-size: 0.75rem;
    padding: 0.5rem 0.75rem;
    border-radius: 12px;
    font-weight: 500;
}

/* Desktop QR code section styling */
#desktop-qr-section {
    border-left: 4px solid #0d6efd;
    background: rgba(13, 110, 253, 0.1);
    border-radius: var(--border-radius);
}

#qr-code-container .card {
    border: 2px solid #dee2e6;
    transition: var(--transition);
}



#qr-code canvas {
    border-radius: 8px;
    max-width: 100%;
    height: auto;
}

/* Mobile camera adjustments */
@media (max-width: 768px) {
    #jscanify {
        width: 100%;
        height: 300px;
    }
    
    #result-canvas {
        width: 100%;
        height: 200px;
    }
    
    .method-card {
        margin-bottom: 1rem;
    }
    
    /* Hide desktop QR section on mobile */
    #desktop-qr-section {
        display: none !important;
    }
}
