/* Reset và các biến màu sắc cơ bản - GIAO DIỆN Đỏ AGRIBANK */
:root {
    --primary: #C62828; /* Agribank Red theme */
    --primary-light: #ef5350;
    --primary-dark: #8e0000;
    --accent-gold: #ff8a65;
    --text-light: #ffffff;
    --text-dark: #333333;
    --bg-light: #ffebee; /* Light red background */
    --bg-white: #ffffff;
    --border-light: #ffcdd2; /* Light red border */
    --shadow-light: rgba(198, 40, 40, 0.1); /* Red tinted shadow */
    --border-radius-sm: 5px;
    --border-radius-md: 8px;
    --border-radius-lg: 20px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 2px 5px rgba(0,0,0,0.15);
    --transition-default: all 0.2s ease;
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 12px;
    --spacing-lg: 16px;
    --spacing-xl: 24px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body, html {
    height: 100%;
    background-color: var(--bg-light);
    font-family: 'Times New Roman', Times, serif;
    color: var(--text-dark);
    display: flex;
    flex-direction: column;
    text-align: center;
}

/* Header styling - GIAO DIỆN SÁNG */
#header-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-xs) var(--spacing-sm);
    background-color: #ffffff !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
    border-bottom: 1px solid #e9ecef !important;
}

#agribank-logo-container {
    flex-shrink: 0;
    width: 80px;
    margin: 0 auto; /* Canh giữa logo */
}

#agribank-logo {
    width: 100%;
    height: auto;
}

#header-text {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-right: 0px;
    text-align: center;
}

#header-text h1, #header-text h2 {
    margin: 0;
    color: #8B0000; /* Agribank Red color */
    line-height: 1.2;
    font-weight: bold; /* Making it bolder for better visibility */
}

#header-text h1 {
    font-size: 18px;
    margin-bottom: 1px;
}

#header-text h2 {
    font-size: 16px;
    margin-bottom: 1px;
}

/* Controls container */
#controls-container {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    width: 100%;
    gap: var(--spacing-xs);
    margin-top: 0;
    position: relative;
}

/* Main controls (always visible on desktop) */
#main-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 2px;
    width: 100%;
}

/* Menu toggle (nút chức năng) - moved to top-left */
.menu-toggle {
    display: none;
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 1000;
}

.toggle-menu-btn {
    background-color: var(--primary);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
    transition: var(--transition-default);
}

.toggle-menu-btn:hover {
    background-color: var(--primary-dark);
    transform: scale(1.1);
}

.toggle-menu-btn.active {
    background-color: var(--primary-light);
    transform: rotate(180deg);
}

/* Advanced menu (hidden by default) */
.advanced-menu {
    background: linear-gradient(to bottom, #ffffff 0%, #f8f9fa 100%);
    border-radius: 16px;
    margin-top: 0;
    padding: 0;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    border: 1px solid #e9ecef;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    flex-direction: column;
    width: 100%;
    gap: var(--spacing-sm);
    transition: max-height 0.3s ease, opacity 0.2s ease, padding 0.3s ease, margin 0.3s ease;
}

.advanced-menu.active {
    display: flex;
    max-height: 1000px;
    opacity: 1;
    padding: 20px;
    margin-top: var(--spacing-sm);
}

/* Menu section title */
.menu-section-title {
    font-size: 15px;
    font-weight: 700;
    color: #495057;
    margin: 16px 0 12px 0;
    padding-bottom: 8px;
    border-bottom: 2px solid #e9ecef;
    text-align: left;
}

.menu-section-title:first-child {
    margin-top: 0;
}

/* Thêm separator giữa các section */
#mobile-image-selection::after {
    content: '';
    display: block;
    height: 1px;
    background: linear-gradient(to right, transparent, #dee2e6, transparent);
    margin: 20px 0 8px 0;
}

/* Hide capture selection on desktop - use floating button instead */
#capture-selection {
    display: none;
}

/* File selection */
#file-selection {
    display: flex;
    align-items: center;
}

#file-selection input[type="file"] {
    width: 0.1px;
    height: 0.1px;
    opacity: 0;
    overflow: hidden;
    position: absolute;
    z-index: -1;
}

#file-selection label {
    cursor: pointer;
    background-color: var(--primary-dark);
    color: #ffffff;
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--border-radius-lg);
    font-weight: 600;
    font-size: 14px;
    margin-right: var(--spacing-sm);
    transition: var(--transition-default);
    white-space: nowrap;
    box-shadow: var(--shadow-sm);
}

#file-selection label:hover {
    background-color: var(--primary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

#fileName {
    padding: var(--spacing-xs) var(--spacing-md);
    background-color: #ffffff;
    border-radius: var(--border-radius-lg);
    border: 1px solid var(--border-light);
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 130px;
    color: var(--text-dark);
    box-shadow: 0 1px 2px var(--shadow-light);
}

/* Image selection (similar to file selection) */
#image-selection {
    display: flex;
    align-items: center;
}

#image-selection input[type="file"] {
    width: 0.1px;
    height: 0.1px;
    opacity: 0;
    overflow: hidden;
    position: absolute;
    z-index: -1;
}

#image-selection label {
    cursor: pointer;
    background-color: var(--primary-dark); /* Using primary dark color */
    color: var(--text-light);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--border-radius-lg);
    font-weight: 600;
    font-size: 14px;
    margin-right: var(--spacing-sm); /* Space between label and file name */
    transition: var(--transition-default);
    white-space: nowrap;
    box-shadow: var(--shadow-sm);
}

#image-selection label:hover {
    background-color: var(--primary); /* Using primary color on hover */
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

#image-selection #imageName {
    padding: var(--spacing-xs) var(--spacing-md);
    background-color: #ffffff;
    border-radius: var(--border-radius-lg);
    border: 1px solid var(--border-light);
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 130px; /* Keep max width consistent */
    color: var(--text-dark);
    box-shadow: 0 1px 2px var(--shadow-light);
}

/* Capture selection (similar to file/image selection) */
#capture-selection {
    display: flex;
    align-items: center;
}

#capture-selection input[type="file"] {
    width: 0.1px;
    height: 0.1px;
    opacity: 0;
    overflow: hidden;
    position: absolute;
    z-index: -1;
}

#capture-selection label {
    cursor: pointer;
    background-color: var(--primary-dark); /* Using primary dark color */
    color: var(--text-light);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--border-radius-lg);
    font-weight: 600;
    font-size: 14px;
    margin-right: var(--spacing-sm); /* Space between label and file name */
    transition: var(--transition-default);
    white-space: nowrap;
    box-shadow: var(--shadow-sm);
}

#capture-selection label:hover {
    background-color: var(--primary); /* Using primary color on hover */
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

#capture-selection #captureName {
    padding: var(--spacing-xs) var(--spacing-md);
    background-color: #ffffff;
    border-radius: var(--border-radius-lg);
    border: 1px solid var(--border-light);
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 130px; /* Keep max width consistent */
    color: var(--text-dark);
    box-shadow: 0 1px 2px var(--shadow-light);
}

/* Controls buttons */
#controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 2px;
}

button {
    padding: 6px 12px;
    font-size: 13px;
    cursor: pointer;
    background-color: var(--primary-dark);
    color: #ffffff;
    border: none;
    border-radius: var(--border-radius-lg);
    transition: var(--transition-default);
    white-space: nowrap;
    font-weight: 600;
    box-shadow: var(--shadow-sm);
}

button:hover {
    background-color: var(--primary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* Search input */
#searchInput {
    width: calc(100% - 30px);
    padding: 8px 12px;
    margin: 0 auto;
    font-size: 14px;
    border-radius: var(--border-radius-lg);
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
    transition: var(--transition-default);
}

#searchInput:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 1px 5px rgba(0, 59, 112, 0.2);
    word-break: break-word;
    white-space: pre-wrap;
}

/* Result area - Tối ưu để hiển thị nhiều kết quả hơn */
#resultArea {
    margin: 4px auto;
    width: calc(100% - 16px);
    background-color: var(--bg-white);
    padding: 6px;
    max-height: calc(100vh - 110px);
    min-height: 200px;
    overflow-y: auto;
    flex-grow: 1;
    border-radius: 6px;
    text-align: left;
    font-size: 13px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
}

/* Floating Camera Button - moved to top-right */
.floating-camera-btn {
    position: fixed;
    top: 10px;
    right: 10px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, #C62828 0%, #8B0000 100%);
    color: white;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer !important;
    box-shadow: 0 4px 12px rgba(198, 40, 40, 0.4);
    z-index: 9999;
    transition: all 0.3s ease;
    border: none;
    outline: 3px solid white;
    pointer-events: all;
    /* Mobile touch optimization */
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(198, 40, 40, 0.3);
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    padding: 0;
}

.floating-camera-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(198, 40, 40, 0.6);
}

.floating-camera-btn:active {
    transform: scale(0.95);
    background: linear-gradient(135deg, var(--primary-dark) 0%, #8B0000 100%);
}

/* Search chip & tooltip (moved from index.html) */
.search-wrapper { display:flex; align-items:center; gap:8px; margin:0; }
#searchInput { flex:1; min-height:38px; padding:8px 10px; border-radius:25px; border:1px solid #ccc; font-size:14px; }
.search-chip { display:none; background:#f0f0f0; border-radius:25px; padding:6px 10px; font-size:14px; align-items:center; gap:8px; }
.chip-edit { margin-left:8px; background:transparent; border:none; cursor:pointer; color:#007bff; }
.info-tooltip { display:inline-block; width:20px; height:20px; border-radius:25px; background:#007bff; color:#fff; text-align:center; line-height:20px; font-weight:bold; cursor:default; position:relative; }
.info-tooltip::after {
    content: attr(data-tooltip);
    position:absolute;
    left:50%;
    transform:translateX(-50%);
    bottom:calc(100% + 8px);
    background:rgba(0,0,0,0.85);
    color:#fff;
    padding:8px 10px;
    border-radius:25px;
    white-space:pre-line; /* giữ xuống dòng */
    font-size:13px;
    line-height:1.2;
    opacity:0;
    visibility:hidden;
    pointer-events:none;
    z-index:9999;
    max-width:260px;
    text-align:center;
}
/* hiển thị khi hover / focus / active (tap) */
.info-tooltip:hover::after,
.info-tooltip:focus::after,
.info-tooltip:active::after {
    opacity:1;
    visibility:visible;
}

/* Responsive tweak */
@media (max-width:600px) {
	#searchInput { font-size:16px; border-radius: 25px; }
	button { border-radius: 25px; }
	label { border-radius: 25px; }
}

/* Footer styling */
#footer {
    text-align: center;
    background-color: var(--primary-dark);
    padding: var(--spacing-md) 0;
    margin-top: auto;
}

#footer p {
    margin: 3px 0;
    font-size: 15px;
    color: #ffffff;
    font-weight: 500;
}

#footer p:last-child {
    font-size: 13px;
    opacity: 0.9;
}

/* Responsive styles */
@media (max-width: 768px) {
    /* Adjust floating button position on mobile */
    .floating-camera-btn {
        top: 8px;
        right: 8px;
        width: 44px;
        height: 44px;
        font-size: 20px;
    }
    
    .menu-toggle {
        top: 8px;
        left: 8px;
    }
    
    .toggle-menu-btn {
        width: 44px;
        height: 44px;
        font-size: 20px;
    }
    
    #header-container {
        padding: var(--spacing-sm);
        flex-direction: column;
        align-items: center;
        min-height: auto;
    }
    
    #agribank-logo-container {
        width: 80px;
        margin-bottom: var(--spacing-xs);
    }
    
    #header-text {
        padding-right: 0;
        width: 100%;
    }
    
    #header-text h1 {
        font-size: 16px;
        line-height: 1.1;
        text-align: center;
        padding-right: 0;
        width: 100%;
    }
    
    #header-text h2 {
        font-size: 14px;
        margin-bottom: var(--spacing-xs);
    }
    
    #controls-container {
        flex-direction: column;
        gap: var(--spacing-xs);
        margin-top: var(--spacing-xs);
        width: 100%;
    }
    
    /* Hiển thị nút chức năng trên mobile */
    .menu-toggle {
        display: block;
        top: 5px;
        right: 5px;
        position: fixed;
        z-index: 1000;
    }
    
    .toggle-menu-btn {
        width: 40px;
        height: 40px;
        font-size: 18px;
        border-radius: 25px;
        box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    }
    
    /* Ẩn các nút không cần thiết trên mobile */
    #file-selection,
    #image-selection,
    #capture-selection {
        display: none;
    }
    
    /* Chỉ hiển thị các nút chính */
    #main-controls {
        justify-content: center;
        align-items: center;
        flex-wrap: wrap;
        gap: var(--spacing-sm);
        width: 100%;
    }
    
    /* Buttons chính tối ưu cho touch */
    #controls {
        gap: var(--spacing-sm);
        width: 100%;
        justify-content: center;
    }
    
    #controls button {
        padding: 12px 16px;
        font-size: 14px;
        min-width: 80px;
        min-height: 44px; /* Tối thiểu cho touch target */
        border-radius: 25px;
        touch-action: manipulation;
    }
    
    /* Advanced menu styles cho mobile */
    .advanced-menu {
        background-color: var(--bg-white);
        border: 1px solid var(--border-light);
        border-radius: 25px;
        box-shadow: 0 4px 12px rgba(0,0,0,0.15);
        margin-top: 0;
        padding: 0;
    }
    
    .advanced-menu.active {
        margin-top: var(--spacing-sm);
        padding: var(--spacing-md);
    }
    
    /* Ẩn input file mặc định */
    #mobile-file-selection input[type="file"],
    #mobile-image-selection input[type="file"],
    #mobile-capture-selection input[type="file"] {
        width: 0.1px;
        height: 0.1px;
        opacity: 0;
        overflow: hidden;
        position: absolute;
        z-index: -1;
    }
    
    /* Styles cho các nút trong advanced menu */
    #mobile-file-selection,
    #mobile-image-selection,
    #mobile-capture-selection {
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: stretch;
        margin-bottom: var(--spacing-md);
        gap: 10px;
    }
    
    #mobile-file-selection label,
    #mobile-image-selection label,
    #mobile-capture-selection label {
        padding: 18px 24px;
        font-size: 17px;
        font-weight: 700;
        letter-spacing: 0.3px;
        margin-right: 0;
        min-height: 64px;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 12px;
        border-radius: 16px;
        width: 100%;
        box-shadow: 0 4px 12px rgba(0,0,0,0.15), 0 2px 4px rgba(0,0,0,0.1);
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        cursor: pointer;
        text-shadow: 0 1px 2px rgba(0,0,0,0.1);
        /* Mobile touch optimization */
        touch-action: manipulation;
        -webkit-tap-highlight-color: rgba(198, 40, 40, 0.3);
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
    }
    
    .btn-icon {
        font-size: 28px;
        line-height: 1;
        filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
    }
    
    .btn-text {
        font-size: 16px;
        font-weight: 700;
        letter-spacing: 0.5px;
    }
    
    #mobile-file-selection label:active,
    #mobile-image-selection label:active,
    #mobile-capture-selection label:active {
        transform: scale(0.98);
        box-shadow: 0 1px 4px rgba(0,0,0,0.1);
    }
    
    /* Màu đỏ đô đồng nhất cho tất cả nút - giống nút Bắt đầu nói */
    #mobile-file-selection label,
    #mobile-image-selection label,
    #mobile-capture-selection label {
        background: linear-gradient(135deg, #C62828 0%, #8e0000 100%);
        color: white;
        position: relative;
    }
    
    #mobile-file-selection label::after,
    #mobile-image-selection label::after,
    #mobile-capture-selection label::after {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: linear-gradient(135deg, rgba(255,255,255,0.2) 0%, transparent 100%);
        border-radius: 16px;
        pointer-events: none;
    }
    
    #mobileFileName,
    #mobileImageName,
    #mobileCaptureName {
        font-size: 13px;
        padding: 10px 16px;
        max-width: 100%;
        min-height: 40px;
        text-align: center;
        background: #f8f9fa;
        border-radius: 8px;
        border: 2px dashed #dee2e6;
        display: flex;
        align-items: center;
        justify-content: center;
        color: #6c757d;
        font-weight: 500;
        transition: all 0.3s ease;
    }
    
    /* Hiệu ứng khi có file được chọn */
    #mobileFileName:not(:empty),
    #mobileImageName:not(:contains("Chưa")),
    #mobileCaptureName:not(:contains("Chưa")) {
        background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
        border-color: #4caf50;
        color: #2e7d32;
    }
    
    /* Thêm hiệu ứng glow cho nút */
    #mobile-file-selection label,
    #mobile-image-selection label,
    #mobile-capture-selection label {
        position: relative;
        overflow: hidden;
    }
    
    #mobile-file-selection label::before,
    #mobile-image-selection label::before,
    #mobile-capture-selection label::before {
        content: '';
        position: absolute;
        top: 50%;
        left: 50%;
        width: 0;
        height: 0;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.3);
        transform: translate(-50%, -50%);
        transition: width 0.6s, height 0.6s;
    }
    
    #mobile-file-selection label:active::before,
    #mobile-image-selection label:active::before,
    #mobile-capture-selection label:active::before {
        width: 300px;
        height: 300px;
    }
    
    #resultArea {
        max-height: calc(100vh - 120px);
        padding: var(--spacing-md);
        margin: 0 auto;
        border-radius: 25px;
        font-size: 14px;
    }
    
    /* Search input tối ưu cho mobile */
    #searchInput {
        margin: 0 auto;
        padding: 8px 12px;
        font-size: 16px; /* Ngăn zoom trên iOS */
        border-radius: 25px;
        min-height: 40px;
        touch-action: manipulation;
    }
    
    /* Search wrapper responsive */
    .search-wrapper {
        margin: 0 auto;
        width: calc(100% - 30px);
    }
    
    .search-wrapper #searchInput {
        border-radius: 25px;
    }
    
    /* Đảm bảo tất cả nút trên mobile đều có border-radius 25px */
    @media (max-width: 768px) {
        button, label, input, .search-chip, .info-tooltip, .selection-handle {
            border-radius: 25px !important;
        }
        
        /* Cập nhật thêm một số element khác */
        .advanced-menu, #resultArea, .modal-content {
            border-radius: 25px !important;
        }
    }
    
    /* Footer responsive */
    #footer {
        padding: var(--spacing-sm) var(--spacing-md);
        font-size: 13px;
    }
    
    #footer p {
        font-size: 13px;
        margin: 2px 0;
    }
}

/* Tablet styles */
@media (min-width: 769px) and (max-width: 1024px) {
    #header-container {
        padding: var(--spacing-md) var(--spacing-lg);
    }
    
    #agribank-logo-container {
        width: 100px;
    }
    
    #header-text h1 {
        font-size: 20px;
    }
    
    #controls button {
        padding: 10px 14px;
        font-size: 14px;
        min-height: 40px;
    }
    
    #searchInput {
        font-size: 15px;
        padding: 10px 14px;
    }
    
    #resultArea {
        max-height: calc(100vh - 160px);
    }
}

/* Large desktop styles */
@media (min-width: 1200px) {
    #header-container {
        padding: var(--spacing-lg) var(--spacing-xl);
    }
    
    #agribank-logo-container {
        width: 140px;
    }
    
    #header-text h1 {
        font-size: 24px;
    }
    
    #controls button {
        padding: 12px 18px;
        font-size: 15px;
    }
    
    #searchInput {
        font-size: 16px;
        padding: 12px 18px;
    }
    
    #resultArea {
        max-height: calc(100vh - 200px);
    }
}

#searchButton:active {
    background-color: #001a33 !important;
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

/* Đảm bảo nút search có thể nhận focus */
#searchButton:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 59, 112, 0.3);
}

/* Column F info */
#columnFInfo {
    font-style: italic;
    background-color: #ffffff;
    border-left: 4px solid var(--primary-dark);
    border: 1px solid var(--border-light);
    padding: var(--spacing-sm) var(--spacing-md);
    margin: var(--spacing-md) auto;
    width: calc(100% - 30px);
    border-radius: var(--border-radius-sm);
    font-weight: 600;
    color: var(--primary-dark);
    display: flex;
    align-items: center;
    box-shadow: 0 2px 4px var(--shadow-light);
    text-align: left;
}

#columnFInfo:before {
    content: "⚠️";
    margin-right: var(--spacing-sm);
    font-size: 18px;
}

/* Result area styles - Tối ưu để hiển thị nhiều kết quả hơn */
#resultArea > div {
    margin-bottom: 6px;
    padding: 8px 10px 4px 10px;
    border-radius: 6px;
    background-color: #ffffff !important;
    border-left: 3px solid var(--primary-dark);
    border: 1px solid var(--border-light);
    transition: var(--transition-default);
    line-height: 1.35;
    box-shadow: 0 1px 2px var(--shadow-light);
}

#resultArea > div:hover {
    background-color: #f8f9fa !important;
    box-shadow: 0 1px 4px var(--shadow-light);
    transform: translateY(-0.5px);
}

#resultArea > div:last-child {
    margin-bottom: 0;
}

/* Reset tất cả style cho span để không bị ảnh hưởng */
#resultArea span {
    background-color: transparent;
    border: none;
    padding: 0;
    margin: 0;
}

/* Không áp dụng bất kỳ style nào cho các phần tử con */
#resultArea * {
    box-sizing: border-box;
}

/* Consistent style for Column F highlights - DISABLED */
/* .column-f-highlight {
    display: inline-block;
    color: #ffffff !important;
    font-weight: bold !important;
    font-size: 1.1em !important;
    background-color: var(--primary-dark) !important;
    padding: var(--spacing-xs) var(--spacing-md) !important;
    border-radius: var(--border-radius-sm) !important;
    box-shadow: var(--shadow-sm) !important;
    margin: 0 3px !important;
    position: relative !important;
    max-width: 100% !important;
    overflow-wrap: break-word !important;
    transition: var(--transition-default) !important;
}

.column-f-highlight:hover {
    transform: scale(1.02);
    box-shadow: var(--shadow-md) !important;
    background-color: var(--primary) !important;
}

.column-f-highlight * {
    background-color: inherit !important;
    color: #ffffff !important;
}

.column-f-highlight span {
    background-color: var(--primary-dark) !important;
    color: #ffffff !important;
}

#resultArea .column-f-highlight,
#resultArea div .column-f-highlight {
    background-color: var(--primary-dark) !important;
    color: #ffffff !important;
} */

/* .column-f-label {
    position: absolute !important;
    top: -10px !important;
    left: 0 !important;
    background-color: #ffffff !important;
    color: var(--primary-dark) !important;
    font-size: 9px !important;
    padding: 1px 4px !important;
    border-radius: 3px !important;
    font-weight: bold !important;
} */

/* Modal styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    overflow: hidden;
}

.modal-content {
    position: relative;
    background-color: #fefefe;
    margin: 0;
    padding: 20px;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

.close {
    position: absolute;
    right: 20px;
    top: 10px;
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    z-index: 1001;
    cursor: pointer;
}

.close:hover {
    color: #000;
}

.image-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #000;
    margin: 20px 0;
}

#cropImage {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.crop-controls {
    display: flex;
    justify-content: center;
    gap: 20px;
    padding: 10px;
    background-color: #f8f8f8;
    border-top: 1px solid #ddd;
}

#cropButton, #cancelCropButton {
    padding: 12px 30px;
    font-size: 16px;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    transition: background-color 0.3s;
}

#cropButton {
    background-color: var(--primary);
    color: white;
}

#cropButton:hover {
    background-color: var(--primary-dark);
}

#cancelCropButton {
    background-color: #6c757d;
    color: white;
}

#cancelCropButton:hover {
    background-color: #5a6268;
}

/* Selection overlay styles */
.selection-overlay {
    position: absolute;
    border: 2px solid var(--primary);
    background-color: rgba(0, 59, 112, 0.1);
    cursor: move;
}

.selection-handle {
    position: absolute;
    width: 20px;
    height: 20px;
    background-color: var(--primary);
    border: 2px solid white;
    border-radius: 25px;
}

.selection-handle.nw {
    top: -10px;
    left: -10px;
    cursor: nw-resize;
}

.selection-handle.ne {
    top: -10px;
    right: -10px;
    cursor: ne-resize;
}

.selection-handle.sw {
    bottom: -10px;
    left: -10px;
    cursor: sw-resize;
}

.selection-handle.se {
    bottom: -10px;
    right: -10px;
    cursor: se-resize;
}

/* Mobile styles */
@media screen and (max-width: 768px) {
    .modal-content {
        padding: 10px;
    }

    .close {
        right: 15px;
        top: 5px;
        font-size: 24px;
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 25px;
    }

    .image-container {
        margin: 10px 0;
    }

    #cropButton, #cancelCropButton {
        padding: 15px 40px;
        font-size: 18px;
        min-height: 48px;
        border-radius: 25px;
    }

    .selection-handle {
        width: 30px;
        height: 30px;
        border-radius: 25px;
    }
}

/* Touch optimizations */
@media (hover: none) and (pointer: coarse) {
    button:hover {
        transform: none;
        box-shadow: var(--shadow-sm);
    }
    
    #file-selection label:hover,
    #image-selection label:hover,
    #capture-selection label:hover {
        transform: none;
        box-shadow: var(--shadow-sm);
    }
    
    button:active {
        transform: scale(0.98);
        background-color: var(--primary-dark);
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    #agribank-logo {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Đảm bảo giao diện sáng cho tất cả elements */
body {
    background-color: var(--bg-light) !important;
    color: var(--text-dark) !important;
}

#resultArea {
    background-color: var(--bg-white) !important;
    border-color: var(--border-light) !important;
    box-shadow: 0 2px 8px var(--shadow-light) !important;
}

#searchInput {
    background-color: var(--bg-white) !important;
    border-color: var(--border-light) !important;
    color: var(--text-dark) !important;
    box-shadow: 0 1px 3px var(--shadow-light) !important;
}

#searchInput:focus {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px rgba(0, 59, 112, 0.1) !important;
}

/* Advanced menu light theme */
.advanced-menu {
    background-color: var(--bg-white) !important;
    border-color: var(--border-light) !important;
    box-shadow: 0 4px 12px var(--shadow-light) !important;
}

/* Modal light theme */
.modal-content {
    background-color: var(--bg-white) !important;
    color: var(--text-dark) !important;
}

/* Dark mode support - chỉ khi user chọn dark mode */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-light: #1a1a1a;
        --bg-white: #2d2d2d;
        --text-dark: #ffffff;
        --border-light: #404040;
        --shadow-light: rgba(255, 255, 255, 0.1);
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .toggle-menu-btn {
        transition: none;
    }
    
    button {
        transition: none;
    }
}

/* Print styles */
@media print {
    .menu-toggle,
    .advanced-menu,
    #controls,
    .modal {
        display: none !important;
    }
    
    #header-container {
        box-shadow: none;
        border-bottom: 2px solid var(--primary);
    }
    
    #resultArea {
        box-shadow: none;
        border: 1px solid #000;
        max-height: none;
    }
    
    body {
        background: white;
        color: black;
    }
}