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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    margin-top: 20px;
    margin-bottom: 20px;
    backdrop-filter: blur(10px);
    will-change: transform;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .container {
        margin: 10px;
        padding: 15px;
        border-radius: 15px;
        margin-top: 10px;
        margin-bottom: 10px;
    }
    
    header h1 {
        font-size: 1.8rem;
    }
    
    header p {
        font-size: 1rem;
    }
}

/* Header */
header {
    text-align: center;
    margin-bottom: 40px;
    padding: 20px 0;
    border-bottom: 2px solid #f0f0f0;
}

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

header p {
    font-size: 1.1rem;
    color: #718096;
}

/* Upload Section */
.upload-section {
    margin-bottom: 40px;
}

.upload-area {
    border: 3px dashed #cbd5e0;
    border-radius: 15px;
    padding: 60px 20px;
    text-align: center;
    background: #f7fafc;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
}

.upload-area:hover {
    border-color: #667eea;
    background: #edf2f7;
    transform: translateY(-2px);
}

.upload-area.dragover {
    border-color: #667eea;
    background: #e6fffa;
    transform: scale(1.02);
}

.upload-content {
    pointer-events: none;
}

.upload-icon {
    font-size: 4rem;
    margin-bottom: 20px;
    opacity: 0.7;
}

.upload-area h3 {
    font-size: 1.5rem;
    color: #4a5568;
    margin-bottom: 10px;
}

.upload-area p {
    color: #718096;
    font-size: 1rem;
}

/* Processing Section */
.processing-section {
    background: #f7fafc;
    border-radius: 15px;
    padding: 30px;
    margin-bottom: 30px;
}

.processing-header h3 {
    color: #4a5568;
    margin-bottom: 20px;
    text-align: center;
}

.progress-bar {
    width: 100%;
    height: 20px;
    background: #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 10px;
}

#progressText {
    text-align: center;
    font-weight: bold;
    color: #4a5568;
}

/* Results Section */
.results-section {
    margin-bottom: 40px;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 15px;
}

/* Mobile responsive for results */
@media (max-width: 768px) {
    .results-header {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }
    
    .actions {
        justify-content: center;
    }
    
    .actions .btn {
        flex: 1;
        min-width: 120px;
    }
}

.results-header h3 {
    color: #4a5568;
    font-size: 1.5rem;
}

.actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    display: inline-block;
    position: relative;
    overflow: hidden;
    will-change: transform;
}

/* Mobile responsive for buttons */
@media (max-width: 768px) {
    .btn {
        padding: 10px 20px;
        font-size: 0.9rem;
        min-height: 44px; /* Touch-friendly */
    }
    
    .btn-large {
        padding: 15px 25px;
        font-size: 1rem;
        min-height: 50px;
    }
}

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

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

.btn-primary:active {
    transform: translateY(0) scale(0.98);
    transition: all 0.1s ease;
}

.btn-secondary {
    background: #e2e8f0;
    color: #4a5568;
}

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

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.result-card {
    background: white;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    border: 1px solid #e2e8f0;
    transition: all 0.3s ease;
}

.result-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.result-image {
    width: 100%;
    height: 200px;
    object-fit: contain;
    border-radius: 10px;
    margin-bottom: 15px;
    background: #f8f9fa;
}

.result-info {
    margin-bottom: 15px;
}

.result-filename {
    font-weight: bold;
    color: #4a5568;
    margin-bottom: 5px;
}

.result-confidence {
    font-size: 0.9rem;
    color: #718096;
}

.result-text {
    background: #f7fafc;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid #667eea;
    max-height: 150px;
    overflow-y: auto;
    font-size: 0.9rem;
    line-height: 1.5;
}

.result-actions {
    margin-top: 15px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn-small {
    padding: 8px 16px;
    font-size: 0.9rem;
}

/* Share buttons */
.btn-zalo {
    background: linear-gradient(135deg, #0068ff 0%, #0047cc 100%);
    color: white;
    border: none;
    transition: all 0.3s ease;
}

.btn-zalo:hover {
    background: linear-gradient(135deg, #0052cc 0%, #003399 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 104, 255, 0.3);
}

.btn-facebook {
    background: linear-gradient(135deg, #1877f2 0%, #0d5bb8 100%);
    color: white;
    border: none;
    transition: all 0.3s ease;
}

.btn-facebook:hover {
    background: linear-gradient(135deg, #0d5bb8 0%, #0a4a8a 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(24, 119, 242, 0.3);
}

/* Student Scanner Section */
.student-scanner-section {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border-radius: 15px;
    padding: 30px;
    margin-bottom: 30px;
    border: 2px solid #f59e0b;
}

.student-scanner-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    align-items: end;
    margin-bottom: 20px;
}

.student-item {
    display: flex;
    flex-direction: column;
}

.student-item label {
    font-weight: 600;
    color: #92400e;
    margin-bottom: 8px;
}

.student-item input[type="text"] {
    padding: 12px;
    border: 2px solid #f59e0b;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.student-item input[type="text"]:focus {
    outline: none;
    border-color: #d97706;
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.1);
}

.student-item small {
    color: #a16207;
    font-size: 0.85rem;
    margin-top: 4px;
}

.format-info {
    background: white;
    border-radius: 10px;
    padding: 20px;
    border-left: 4px solid #f59e0b;
}

.format-info h4 {
    color: #92400e;
    margin-bottom: 15px;
    font-size: 1.1rem;
}

.format-info ul {
    list-style: none;
    padding: 0;
}

.format-info li {
    margin-bottom: 8px;
    padding: 8px 12px;
    background: #fef3c7;
    border-radius: 6px;
    font-family: 'Courier New', monospace;
}

.format-info code {
    background: #f59e0b;
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: bold;
}

/* Capture Modal */
.capture-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.capture-content {
    background: white;
    border-radius: 15px;
    padding: 30px;
    max-width: 600px;
    width: 90%;
    text-align: center;
}

/* Mobile responsive for camera modal */
@media (max-width: 768px) {
    .capture-content {
        padding: 20px;
        width: 95%;
        max-width: none;
        border-radius: 10px;
    }
    
    .capture-actions {
        flex-direction: column;
        gap: 10px;
    }
    
    .capture-actions .btn {
        width: 100%;
        margin: 0;
    }
}

.capture-content h3 {
    color: #92400e;
    margin-bottom: 15px;
}

.capture-preview {
    margin: 20px 0;
    border: 3px dashed #f59e0b;
    border-radius: 10px;
    padding: 20px;
    background: #fef3c7;
}

.capture-preview video {
    width: 100%;
    max-width: 500px;
    height: auto;
    border-radius: 8px;
}

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

.capture-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    pointer-events: none;
}

.capture-frame {
    width: 80%;
    height: 60%;
    border: 3px solid #f59e0b;
    border-radius: 10px;
    background: transparent;
    position: relative;
}

.capture-frame::before {
    content: '';
    position: absolute;
    top: -3px;
    left: -3px;
    right: -3px;
    bottom: -3px;
    border: 2px dashed #f59e0b;
    border-radius: 10px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.capture-hint {
    color: #f59e0b;
    font-weight: bold;
    font-size: 1.1rem;
    margin-top: 20px;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
    background: rgba(255,255,255,0.9);
    padding: 8px 16px;
    border-radius: 20px;
}

.capture-tips {
    margin-top: 20px;
    text-align: left;
    background: #f8fafc;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid #f59e0b;
}

.capture-tips h4 {
    color: #92400e;
    margin-bottom: 10px;
    font-size: 1rem;
}

.capture-tips ul {
    margin: 0;
    padding-left: 20px;
}

.capture-tips li {
    margin-bottom: 5px;
    color: #6b7280;
    font-size: 0.9rem;
}

.btn-icon {
    margin-right: 8px;
    font-size: 1.1rem;
}

/* Document Scanner Section */
.document-scanner-section {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border-radius: 15px;
    padding: 30px;
    margin-bottom: 30px;
    border: 2px solid #0ea5e9;
}

.document-scanner-grid {
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Mobile responsive for document scanner */
@media (max-width: 768px) {
    .document-scanner-section {
        padding: 20px;
        margin-bottom: 20px;
    }
    
    .document-item {
        padding: 15px;
    }
}

.document-item {
    text-align: center;
    padding: 20px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
}

.document-item:hover {
    transform: translateY(-2px);
}

.document-item .btn-large {
    padding: 15px 25px;
    font-size: 1.1rem;
    width: 100%;
    margin-bottom: 10px;
}

.document-item small {
    color: #64748b;
    font-size: 0.9rem;
    display: block;
}

/* Mobile optimizations */
@media (max-width: 768px) {
    .capture-content {
        padding: 20px;
        margin: 10px;
    }
    
    .capture-preview {
        padding: 15px;
    }
    
    .capture-actions {
        flex-direction: column;
        gap: 10px;
    }
    
    .capture-actions .btn {
        width: 100%;
        padding: 12px;
        font-size: 1rem;
    }
    
    .capture-tips {
        font-size: 0.9rem;
    }
    
    .document-scanner-grid {
        grid-template-columns: 1fr;
    }
    
    .document-item {
        padding: 15px;
    }
}


/* Settings Section */
.settings-section {
    background: #f7fafc;
    border-radius: 15px;
    padding: 30px;
    margin-bottom: 30px;
}

.settings-section h3 {
    color: #4a5568;
    margin-bottom: 20px;
    font-size: 1.5rem;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

/* Mobile responsive for settings */
@media (max-width: 768px) {
    .settings-section {
        padding: 20px;
        margin-bottom: 20px;
    }
    
    .settings-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .setting-item input,
    .setting-item select {
        padding: 10px;
        font-size: 0.9rem;
    }
}

.setting-item {
    display: flex;
    flex-direction: column;
}

.setting-item label {
    font-weight: 600;
    color: #4a5568;
    margin-bottom: 8px;
}

.setting-item input,
.setting-item select {
    padding: 12px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

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

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

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

.loading-overlay p {
    color: white;
    font-size: 1.2rem;
    font-weight: 600;
}

/* Footer */
footer {
    text-align: center;
    padding: 20px 0;
    color: #718096;
    border-top: 1px solid #e2e8f0;
    margin-top: 40px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        margin: 10px;
        padding: 15px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .upload-area {
        padding: 40px 15px;
    }
    
    .results-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .actions {
        justify-content: center;
    }
    
    .results-grid {
        grid-template-columns: 1fr;
    }
    
    .settings-grid {
        grid-template-columns: 1fr;
    }
}

/* Animation */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-card {
    animation: fadeIn 0.5s ease;
}

/* Land Codes Styling */
.land-codes-section {
    margin: 15px 0;
    padding: 15px;
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border-radius: 10px;
    border-left: 4px solid #0ea5e9;
}

.land-codes-section h4 {
    color: #0c4a6e;
    margin-bottom: 15px;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.land-codes-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.land-code-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    border: 1px solid #e0f2fe;
}

.land-code-badge {
    background: linear-gradient(135deg, #0ea5e9, #0284c7);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 0.9rem;
    min-width: 50px;
    text-align: center;
    flex-shrink: 0;
}

.land-code-info {
    flex: 1;
}

.land-code-info strong {
    color: #0c4a6e;
    display: block;
    margin-bottom: 4px;
    font-size: 0.95rem;
}

.land-code-note {
    color: #64748b;
    font-size: 0.85rem;
    margin: 4px 0;
    line-height: 1.4;
}

.land-code-category {
    background: #f1f5f9;
    color: #475569;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
}

.btn-success {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(16, 185, 129, 0.3);
}

.btn-info {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: white;
}

.btn-info:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(59, 130, 246, 0.3);
}

.btn-warning {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
}

.btn-warning:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(245, 158, 11, 0.3);
}

.land-code-number {
    color: #0ea5e9;
    font-weight: 600;
    font-size: 0.9rem;
    margin: 4px 0;
}

/* Scrollbar Styling */
.result-text::-webkit-scrollbar {
    width: 6px;
}

.result-text::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.result-text::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

.result-text::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* Captured Images Display */
.captured-images {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.captured-image-item {
    position: relative;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    background: white;
}

.captured-image {
    width: 100%;
    height: 80px;
    object-fit: contain;
    background: #f8f9fa;
}

.page-number {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 0.75rem;
    text-align: center;
    padding: 4px;
    font-weight: 500;
}
