/* Custom Styles for Receipt Processor */

:root {
    --primary-color: #0d6efd;
    --secondary-color: #6c757d;
    --success-color: #198754;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --light-bg: #f8f9fa;
    --border-radius: 0.5rem;
    --shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

body {
    background-color: var(--light-bg);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.form-control::placeholder, ::placeholder {
    color: #b0b0b0 !important;
    opacity: 1;
}



input::-webkit-input-placeholder { /* Chrome/Opera/Safari */
    color: #b0b0b0 !important;
    opacity: 1;
}
input::-moz-placeholder { /* Firefox 19+ */
    color: #b0b0b0 !important;
    opacity: 1;
}
input:-ms-input-placeholder { /* IE 10+ */
    color: #b0b0b0 !important;
    opacity: 1;
}
input::-ms-input-placeholder { /* Edge */
    color: #b0b0b0 !important;
    opacity: 1;
}
input::placeholder {
    color: #b0b0b0;
    opacity: 1;
}


/* Card Enhancements */
.card {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.card-header {
    background: linear-gradient(135deg, var(--primary-color), #0056b3);
    color: white;
    border-bottom: none;
    border-radius: var(--border-radius) var(--border-radius) 0 0 !important;
}

.card-header h4 {
    margin: 0;
    font-weight: 600;
}

/* Button Enhancements */
.btn {
    border-radius: var(--border-radius);
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.15);
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1.1rem;
}

/* File Upload Area */
.file-upload-area {
    border: 2px dashed var(--secondary-color);
    border-radius: var(--border-radius);
    padding: 2rem;
    text-align: center;
    background-color: white;
    transition: all 0.2s ease;
    cursor: pointer;
}

.file-upload-area:hover {
    border-color: var(--primary-color);
    background-color: rgba(13, 110, 253, 0.05);
}

.file-upload-area.dragover {
    border-color: var(--primary-color);
    background-color: rgba(13, 110, 253, 0.1);
}

/* File List */
.file-item {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: var(--border-radius);
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.file-item .file-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.file-item .file-actions {
    display: flex;
    gap: 0.25rem;
}

/* Job Status Badges */
.status-badge {
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.375rem 0.75rem;
    border-radius: 1rem;
}

.status-processing {
    background-color: var(--warning-color);
    color: #000;
}

.status-completed {
    background-color: var(--success-color);
    color: white;
}

.status-failed {
    background-color: var(--danger-color);
    color: white;
}

/* Progress Indicators */
.progress {
    height: 0.75rem;
    border-radius: 0.5rem;
    background-color: #e9ecef;
}

.progress-bar {
    border-radius: 0.5rem;
    transition: width 0.3s ease;
}

/* Receipt Grid */
.receipt-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.receipt-card {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: var(--border-radius);
    padding: 1rem;
    transition: all 0.2s ease;
}

.receipt-card:hover {
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.receipt-card.completed {
    border-left: 4px solid var(--success-color);
}

.receipt-card.failed {
    border-left: 4px solid var(--danger-color);
}

.receipt-card.processing {
    border-left: 4px solid var(--warning-color);
}

/* Camera Modal */
#cameraModal .modal-content {
    border-radius: var(--border-radius);
    overflow: hidden;
}

#camera {
    border-radius: var(--border-radius);
    max-height: 400px;
}

#photoCanvas {
    border-radius: var(--border-radius);
    max-height: 400px;
}

/* Mobile Optimizations */
@media (max-width: 768px) {
    .container {
        padding: 0 1rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .btn-lg {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    .receipt-grid {
        grid-template-columns: 1fr;
    }
    
    .file-upload-area {
        padding: 1rem;
    }
    
    .navbar-brand {
        font-size: 1.1rem;
    }
}

/* Drag and Drop Enhancements */
.drag-over {
    background-color: rgba(13, 110, 253, 0.1);
    border-color: var(--primary-color);
}

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

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid var(--primary-color);
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Notification Styles */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    max-width: 350px;
}

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

.notification-error {
    background-color: var(--danger-color);
    color: white;
}

.notification-warning {
    background-color: var(--warning-color);
    color: #000;
}

/* Table Enhancements */
.table {
    background: white;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.table thead th {
    background-color: var(--light-bg);
    border-bottom: 2px solid #dee2e6;
    font-weight: 600;
}

/* Form Enhancements */
.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

.form-label {
    font-weight: 500;
    color: #495057;
}

/* Animation Classes */
.fade-in {
    animation: fadeIn 0.3s ease-in;
}

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

.slide-in {
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from { transform: translateX(-100%); }
    to { transform: translateX(0); }
}

/* PWA Specific Styles */
.install-prompt {
    background: linear-gradient(135deg, var(--primary-color), #0056b3);
    color: white;
    padding: 1rem;
    border-radius: var(--border-radius);
    margin-bottom: 1rem;
    text-align: center;
}

.install-prompt button {
    background: white;
    color: var(--primary-color);
    border: none;
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    margin-left: 1rem;
    font-weight: 500;
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    :root {
        --light-bg: #212529;
        --secondary-color: #adb5bd;
    }
    
    body {
        background-color: var(--light-bg);
        color: #f8f9fa;
    }
    
    .card {
        background-color: #343a40;
        color: #f8f9fa;
    }
    
    .receipt-card {
        background-color: #343a40;
        color: #f8f9fa;
        border-color: #495057;
    }
    
    .table {
        background-color: #343a40;
        color: #f8f9fa;
    }
    
    .table thead th {
        background-color: #495057;
        color: #f8f9fa;
    }
}

/* RTL Language Support */
.rtl {
    direction: rtl;
    text-align: right;
}

.rtl .navbar-nav {
    flex-direction: row-reverse;
}

.rtl .dropdown-menu {
    right: auto;
    left: 0;
}

.rtl .btn-group > .btn:not(:last-child):not(.dropdown-toggle) {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    border-top-right-radius: var(--border-radius);
    border-bottom-right-radius: var(--border-radius);
}

.rtl .btn-group > .btn:not(:first-child) {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-top-left-radius: var(--border-radius);
    border-bottom-left-radius: var(--border-radius);
}

.rtl .file-item .file-actions {
    order: -1;
}

.rtl .receipt-card.completed,
.rtl .receipt-card.failed,
.rtl .receipt-card.processing {
    border-right: 4px solid;
    border-left: none;
}

.rtl .receipt-card.completed {
    border-right-color: var(--success-color);
}

.rtl .receipt-card.failed {
    border-right-color: var(--danger-color);
}

.rtl .receipt-card.processing {
    border-right-color: var(--warning-color);
}

.rtl .modal-header .btn-close {
    margin: calc(-0.5 * var(--bs-modal-header-padding-y)) auto calc(-0.5 * var(--bs-modal-header-padding-y)) calc(-0.5 * var(--bs-modal-header-padding-x));
}

.rtl .dropdown-item.active::after {
    content: '\f633';
    font-family: 'bootstrap-icons';
    margin-left: 0.5rem;
    margin-right: 0;
}

/* Language Switcher Styles */
.language-dropdown .dropdown-menu {
    min-width: 200px;
}

.language-dropdown .dropdown-item {
    padding: 0.5rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.language-dropdown .dropdown-item:hover {
    background-color: rgba(13, 110, 253, 0.1);
}

/* Responsive RTL adjustments */
@media (max-width: 768px) {
    .rtl .navbar-nav {
        flex-direction: column;
    }
    
    .rtl .btn-group {
        flex-direction: row-reverse;
    }
}

/* New Workflow Styles */
/* Processing Section Styles */
.processing-step {
    border-left: 4px solid #0d6efd;
    padding-left: 1rem;
    margin-bottom: 1.5rem;
}

.processing-step.active {
    border-left-color: #198754;
    background-color: rgba(25, 135, 84, 0.1);
}

.processing-step.completed {
    border-left-color: #20c997;
    background-color: rgba(32, 201, 151, 0.05);
}

/* Enhanced Progress Bars */
.progress-bar-striped.progress-bar-animated {
    animation: progress-bar-stripes 1s linear infinite;
}

/* Step Headers */
.card-header.bg-primary {
    background-color: #0d6efd !important;
}

.card-header.bg-info {
    background-color: #0dcaf0 !important;
}

.card-header.bg-success {
    background-color: #198754 !important;
}

/* Results Section */
.results-stats .col-4 > div {
    transition: transform 0.2s ease;
}

.results-stats .col-4 > div:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

/* Table Enhancements */
.table-hover tbody tr:hover {
    background-color: rgba(0,0,0,0.075);
}

.table th {
    border-top: none;
    font-weight: 600;
}

/* Animation for processing */
@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

.processing-row {
    animation: pulse 2s infinite;
}

/* Document Status Indicators */
#documentsTable .progress {
    height: 4px;
    border-radius: 2px;
}

#documentsTable .badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
}

/* Overall Progress Header */
#overallProgress {
    transition: width 0.5s ease;
}

#overallProgressText {
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* File Thumbnail Styles */
.file-thumbnail {
    position: relative;
    overflow: hidden;
    border-radius: 0.375rem;
}

.file-thumbnail img {
    transition: transform 0.2s ease;
    border-radius: 0.375rem;
}

.file-thumbnail:hover img {
    transform: scale(1.05);
}

.selected-files .file-preview {
    transition: all 0.2s ease;
}

.selected-files .file-preview:hover {
    background-color: rgba(0,0,0,0.02);
    transform: translateX(2px);
}

/* Processing table enhancements */
#documentsTableBody tr {
    transition: background-color 0.2s ease;
}

#documentsTableBody tr:hover {
    background-color: rgba(0,0,0,0.02);
}

.processing-row {
    background-color: rgba(255, 193, 7, 0.1) !important;
}

/* Receipt Items Details */
tr.collapse .card {
    border-left: 4px solid #0d6efd;
    margin: 0;
}

tr.collapse .card-header {
    background-color: rgba(13, 110, 253, 0.1);
    border-bottom: 1px solid rgba(0,0,0,0.125);
}

tr.collapse .table th {
    font-weight: 600;
    font-size: 0.875rem;
    border-top: none;
}

tr.collapse .table td {
    font-size: 0.875rem;
    vertical-align: middle;
}

tr.collapse .badge {
    font-size: 0.75rem;
}

/* Smooth transition for table row collapse */
tr.collapse {
    transition: all 0.3s ease;
}

tr.collapse:not(.show) {
    display: none;
}

tr.collapse.show {
    display: table-row;
}

/* Shop name badges with different colors */
.badge.bg-secondary {
    background-color: #6c757d !important;
}

/* Hover effects for expandable items */
button[data-bs-toggle="collapse"] {
    transition: all 0.2s ease;
}

button[data-bs-toggle="collapse"]:hover {
    transform: translateX(2px);
}

button[data-bs-toggle="collapse"] .bi-chevron-down {
    transition: transform 0.2s ease;
}

button[data-bs-toggle="collapse"][aria-expanded="true"] .bi-chevron-down {
    transform: rotate(180deg);
}

/* Lightbox styles */
.lightbox-trigger {
    transition: all 0.2s ease;
}

.lightbox-trigger:hover {
    transform: scale(1.05);
    cursor: pointer;
    opacity: 0.8;
}

/* Lightbox modal enhancements */
#imageLightbox .modal-dialog {
    max-width: 90vw;
}

#imageLightbox .modal-body {
    padding: 1rem;
}

#lightboxImage {
    border-radius: 0.375rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    max-width: 100%;
    height: auto;
}

/* Mobile Enhancements for New Workflow */
@media (max-width: 768px) {
    .processing-step {
        padding-left: 0.5rem;
        border-left-width: 2px;
    }
    
    .table-responsive {
        font-size: 0.875rem;
    }
    
    .results-stats .col-4 {
        margin-bottom: 1rem;
    }
    
    #documentsTable th:nth-child(4),
    #documentsTable td:nth-child(4) {
        display: none; /* Hide progress column on mobile */
    }
    
    /* Mobile thumbnail adjustments */
    .file-thumbnail {
        width: 36px !important;
        height: 36px !important;
    }
    
    .file-thumbnail img {
        width: 36px !important;
        height: 36px !important;
    }
    
    .selected-files .file-preview .fw-medium {
        max-width: 150px !important;
    }
    
    /* Mobile adjustments for item details */
    tr.collapse .table th:nth-child(4),
    tr.collapse .table td:nth-child(4),
    tr.collapse .table th:nth-child(6),
    tr.collapse .table td:nth-child(6) {
        display: none; /* Hide unit price and category on mobile */
    }
    
    tr.collapse .table th,
    tr.collapse .table td {
        font-size: 0.75rem;
        padding: 0.25rem;
    }
    
    tr.collapse .badge {
        font-size: 0.65rem;
    }
}

/* Inline editing styles */
.edit-controls {
    white-space: nowrap;
}

.edit-mode input,
.edit-mode select {
    min-width: 80px;
    font-size: 0.875rem;
}

.edit-mode .item-name {
    min-width: 150px;
}

.edit-mode .shop-name {
    min-width: 120px;
}

.edit-mode .quantity {
    min-width: 70px;
}

.edit-mode .unit-price {
    min-width: 90px;
}

.edit-mode .category {
    min-width: 140px;
    font-size: 0.8rem;
}

/* Edit mode transitions */
.edit-mode,
.edit-mode-only {
    transition: all 0.2s ease;
}

/* Highlight edited rows */
.items-table tbody tr:hover {
    background-color: rgba(0, 123, 255, 0.05);
}

/* Edit button styling */
.edit-items-btn {
    transition: all 0.2s ease;
}

.edit-items-btn:hover {
    background-color: #0d6efd;
    color: white;
}

/* Items button in editing state */
.btn-warning.editing-state {
    animation: pulse-edit 2s infinite;
}

@keyframes pulse-edit {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 193, 7, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(255, 193, 7, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(255, 193, 7, 0);
    }
}

/* Form validation styling */
.edit-mode input:invalid {
    border-color: #dc3545;
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25);
}

.edit-mode input:valid {
    border-color: #198754;
    box-shadow: 0 0 0 0.2rem rgba(25, 135, 84, 0.25);
}

/* Loading states */
.save-items-btn:disabled {
    opacity: 0.6;
}

/* Mobile responsive editing */
@media (max-width: 768px) {
    .edit-mode input,
    .edit-mode select {
        font-size: 0.8rem;
        padding: 0.25rem;
    }
    
    .edit-mode .item-name {
        min-width: 120px;
    }
    
    .edit-mode .shop-name {
        min-width: 100px;
    }
    
    .edit-controls .btn {
        font-size: 0.8rem;
        padding: 0.25rem 0.5rem;
    }
}
