/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header Styles */
header {
    text-align: center;
    margin-bottom: 30px;
    color: white;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Main Content Layout */
.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    align-items: start;
}

/* Form Section Styles */
.form-section {
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    max-height: 90vh;
    overflow-y: auto;
}

.form-section h2 {
    color: #4a5568;
    margin-bottom: 25px;
    font-size: 1.8rem;
    border-bottom: 3px solid #667eea;
    padding-bottom: 10px;
}

/* Form Group Styles */
.form-group {
    margin-bottom: 25px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
    border-left: 4px solid #667eea;
}

.form-group h3 {
    color: #2d3748;
    margin-bottom: 15px;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-group h3 i {
    color: #667eea;
}

/* Form Row and Input Styles */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 15px;
}

.form-row:last-child {
    margin-bottom: 0;
}

input, select, textarea {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s ease;
    background: white;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    transform: translateY(-1px);
}

input:required:invalid {
    border-color: #e53e3e;
}

input:required:valid {
    border-color: #38a169;
}

/* Items Section Styles */
.item-row {
    display: grid;
    grid-template-columns: 2fr 80px 120px 100px 40px;
    gap: 10px;
    align-items: center;
    margin-bottom: 10px;
    padding: 10px;
    background: white;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.item-total {
    font-weight: bold;
    color: #2d3748;
    text-align: right;
}

.remove-item {
    background: #e53e3e;
    color: white;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.remove-item:hover {
    background: #c53030;
    transform: scale(1.1);
}

/* Totals Section */
.totals-grid {
    background: white;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.total-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 15px;
    align-items: center;
    margin-bottom: 10px;
    padding: 8px 0;
}

.total-row:not(:last-child) {
    border-bottom: 1px solid #f1f5f9;
}

.total-row.grand-total {
    font-size: 1.2rem;
    font-weight: bold;
    color: #2d3748;
    border-top: 2px solid #667eea;
    padding-top: 15px;
    margin-top: 15px;
}

.total-row label {
    font-weight: 500;
    color: #4a5568;
}

.total-row input {
    width: 120px;
    margin: 0;
}

/* Button Styles */
.btn-primary, .btn-secondary, .btn-danger {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

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

.btn-secondary {
    background: #718096;
    color: white;
    margin-left: 10px;
}

.btn-secondary:hover {
    background: #4a5568;
    transform: translateY(-2px);
}

.btn-secondary:disabled {
    background: #cbd5e0;
    cursor: not-allowed;
    transform: none;
}

.btn-danger {
    background: #e53e3e;
    color: white;
    margin-left: 10px;
}

.btn-danger:hover {
    background: #c53030;
    transform: translateY(-2px);
}

/* Photo Upload Styles */
.upload-container {
    border: 2px dashed #dee2e6;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    transition: all 0.3s ease;
    background: #f8f9fa;
}

.upload-container:hover {
    border-color: #667eea;
    background: #f0f4ff;
}

.file-input {
    display: none;
}

.file-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    color: #6c757d;
    font-size: 16px;
    padding: 20px;
}

.file-label i {
    font-size: 48px;
    color: #667eea;
}

.file-label small {
    font-size: 12px;
    color: #adb5bd;
}

.upload-preview {
    margin-top: 20px;
    padding: 20px;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    background: white;
}

.upload-preview img {
    max-width: 100%;
    max-height: 300px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.upload-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.upload-actions .btn-primary,
.upload-actions .btn-secondary,
.upload-actions .btn-danger {
    min-width: 120px;
    padding: 8px 16px;
    font-size: 14px;
}

.ocr-results {
    margin-top: 20px;
    padding: 20px;
    background: linear-gradient(135deg, #e8f5e8 0%, #f0f8f0 100%);
    border: 1px solid #28a745;
    border-radius: 8px;
}

.ocr-results h4 {
    color: #155724;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ocr-results h4 i {
    color: #28a745;
}

#extractedData {
    background: white;
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 15px;
    border-left: 4px solid #28a745;
}

.extracted-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #e9ecef;
}

.extracted-item:last-child {
    border-bottom: none;
}

.extracted-label {
    font-weight: 600;
    color: #495057;
}

.extracted-value {
    color: #28a745;
    font-weight: 500;
}

#addItem {
    width: 100%;
    margin-top: 10px;
}

.action-buttons {
    text-align: center;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 2px solid #e2e8f0;
}

/* Preview Section Styles */
.preview-section {
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    position: sticky;
    top: 20px;
}

.preview-section h2 {
    color: #4a5568;
    margin-bottom: 25px;
    font-size: 1.8rem;
    border-bottom: 3px solid #667eea;
    padding-bottom: 10px;
}

/* Receipt Container */
.receipt-container {
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    min-height: 600px;
    position: relative;
    overflow: hidden;
}

.receipt-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 600px;
    color: #a0aec0;
    text-align: center;
}

.receipt-placeholder i {
    margin-bottom: 20px;
    opacity: 0.5;
}

.receipt-placeholder p {
    font-size: 1.1rem;
    max-width: 250px;
}

/* Generated Receipt Styles */
.receipt {
    padding: 40px;
    font-family: 'Courier New', monospace;
    line-height: 1.4;
    color: #2d3748;
}

.receipt-header {
    text-align: center;
    margin-bottom: 30px;
    border-bottom: 2px solid #2d3748;
    padding-bottom: 20px;
}

.receipt-header h1 {
    font-size: 1.8rem;
    margin-bottom: 5px;
    color: #2d3748;
}

.receipt-header .business-info {
    font-size: 0.9rem;
    color: #4a5568;
}

.receipt-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
}

.receipt-info div {
    font-size: 0.9rem;
}

.receipt-info strong {
    color: #2d3748;
}

.receipt-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

.receipt-table th,
.receipt-table td {
    padding: 8px;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
    font-size: 0.9rem;
}

.receipt-table th {
    background: #f8f9fa;
    font-weight: bold;
    color: #2d3748;
}

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

.receipt-totals {
    margin-left: auto;
    width: 250px;
    margin-bottom: 30px;
}

.receipt-totals .total-line {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    font-size: 0.9rem;
}

.receipt-totals .grand-total {
    border-top: 2px solid #2d3748;
    font-weight: bold;
    font-size: 1.1rem;
    padding-top: 10px;
    margin-top: 10px;
}

.receipt-footer {
    text-align: center;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #e2e8f0;
    font-size: 0.8rem;
    color: #718096;
}

.payment-info {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin: 20px 0;
    border-left: 4px solid #667eea;
}

.payment-info strong {
    color: #2d3748;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .main-content {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .preview-section {
        position: static;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .form-section,
    .preview-section {
        padding: 20px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .item-row {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .item-row .remove-item {
        justify-self: end;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .action-buttons {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }
    
    .btn-primary,
    .btn-secondary,
    .btn-danger {
        margin: 0;
        justify-content: center;
        width: 100%;
    }
    
    .upload-actions {
        flex-direction: column;
    }
    
    .upload-actions .btn-primary,
    .upload-actions .btn-secondary,
    .upload-actions .btn-danger {
        width: 100%;
    }
}

/* Print Styles */
@media print {
    body {
        background: white;
    }
    
    .form-section,
    .preview-section h2 {
        display: none;
    }
    
    .preview-section {
        box-shadow: none;
        padding: 0;
    }
    
    .receipt-container {
        border: none;
    }
}

/* Scrollbar Styling */
.form-section::-webkit-scrollbar {
    width: 8px;
}

.form-section::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.form-section::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 4px;
}

.form-section::-webkit-scrollbar-thumb:hover {
    background: #5a67d8;
}

/* Animation for form validation */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.shake {
    animation: shake 0.5s ease-in-out;
}

/* Loading animation */
.loading {
    position: relative;
    overflow: hidden;
}

.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(102, 126, 234, 0.2), transparent);
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* Drag and Drop States */
.upload-container.drag-over {
    border-color: #667eea !important;
    background: #f0f4ff !important;
    transform: scale(1.02);
}

/* Spinner Animation for Buttons */
.fa-spinner {
    animation: spin 1s linear infinite;
}

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

/* Notification Styles */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 20px;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    z-index: 1000;
    animation: slideIn 0.3s ease;
    max-width: 300px;
}

.notification.success {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
}

.notification.error {
    background: linear-gradient(135deg, #dc3545 0%, #fd7e14 100%);
}

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