@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;700&display=swap');

body {
    font-family: 'Roboto', sans-serif;
    background-color: #f0f2f5;
    color: #333;
    margin: 0;
}

header {
    text-align: center;
    margin-bottom: 4px;
    padding: 4px 4px;
    background-color: #494949;
    box-shadow: 0 2px 4px rgba(255, 255, 255, 0.08);
    font-size: 0.8em;
}

header h1 {
    background-color: #484747; 
    color: rgb(255, 0, 0);    
    padding: 4px 4px;       
    border-radius: 3px;  
    margin: 0;
    font-size: 1.7em;
}

.container {
    max-width: 98%;
    margin: 0 auto;
}

@media (min-width: 1024px) {
    .main-layout {
        display: flex;
        align-items: flex-start;
        gap: 25px;
    }

    .left-sidebar {
        width: 500px;
        flex-shrink: 0;
        position: sticky;
        top: 10px;
        
        display: flex; 
        flex-direction: column; 
        height: calc(100vh - 40px);
    }

    .right-content {
        flex-grow: 1;
        width: 100%;
        overflow-anchor: none;
    }

    .search-bar {
        flex-direction: row;
        align-items: center;
        padding: 5px;
        flex-shrink: 0;
    }

    #text-input { margin-bottom: 0; width: auto; }
    #file-btn, #search-btn { margin-left: 5px; width: auto; justify-content: flex-start; }
    #results-section { margin-top: 0; }
    .results-grid { column-count: 4; }
    #preview-placeholder { width: 100%; }
}

.call-mobile img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 50%; /* Giúp ảnh bo tròn vừa vặn với nút */
}

.search-bar {
    display: flex;
    background-color: #fff;
    border-radius: 10px;
    padding: 5px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

#text-input {
    flex-grow: 1; border: none; outline: none; padding: 5px 10px;
    white-space: normal;word-wrap: break-word;overflow-wrap: break-word;
    font-size: 0.55em; background-color: transparent;
}

#file-btn, #search-btn {
    background-color: #e4e6eb; border: none; border-radius: 10px; padding: 6px 10px;
    cursor: pointer; font-weight: 500; color: #050505; display: flex;
    align-items: center; gap: 8px; transition: background-color 0.2s; margin-left: 5px;
}
#file-btn:hover, #search-btn:hover { background-color: #d8dbdf; }

#preview-area {
    margin-top: 20px;
    width: 100%;
    border: 2px dashed #ccc;
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #fff;
    position: relative;
    overflow: hidden;
    min-height: 500px;
    flex-grow: 1;
}

#preview-canvas { max-width: 100%; display: block; object-fit: contain; }

#preview-placeholder {
    width: 100%;
    padding: 20px;
    color: #aaa;
    
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

#preview-placeholder i { font-size: 48px; }
.hidden { display: none !important; }

#loading-spinner {
    border: 6px solid #f3f3f3; border-top: 6px solid #007bff; border-radius: 50%;
    width: 50px; height: 50px; animation: spin 1s linear infinite; margin: 40px auto;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

#results-section { margin-top: 1px; }
#results-section h2 { text-align: center; color: #0080ff; margin-bottom: 25px; }

.results-grid { column-count: 5; column-gap: 15px; }
.result-item {
    display: inline-block; width: 100%; margin-bottom: 15px;
    break-inside: avoid; border-radius: 8px; overflow: hidden;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1); background-color: #fff;
    transition: box-shadow 0.2s ease; position: relative;
}
.result-item:hover { box-shadow: 0 8px 15px rgba(0,0,0,0.15); }
.result-image-link { display: block; cursor: pointer; }
.result-item img { width: 100%; height: auto; display: block; }
.result-item .info { padding: 10px; user-select: text; }
.product-name {
    font-size: 0.7em; line-height: 1; font-weight: 500;
    margin: 0; white-space: normal; word-break: break-word;
}

.view-original-btn {
  display: none !important;
} 

.view-original-btn {
    position: absolute; top: 8px; right: 8px; background-color: rgba(0, 0, 0, 0.6);
    color: white; border: none; border-radius: 50%; width: 32px; height: 32px;
    font-size: 16px; cursor: pointer; display: flex; align-items: center;
    justify-content: center; opacity: 0; transition: opacity 0.2s ease-in-out; z-index: 10;
} 
.result-item:hover .view-original-btn { opacity: 1; }
#lightbox-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.85); display: flex; justify-content: center;
    align-items: center; z-index: 1000; cursor: pointer;
} 
#lightbox-img { max-width: 90vw; max-height: 90vh; object-fit: contain; }
#lightbox-close { position: absolute; top: 20px; right: 30px; font-size: 40px; color: #fff; cursor: pointer; }

#pagination-controls { display: flex; justify-content: center; align-items: center; margin-top: 30px; gap: 5px; }
.page-btn {
    border: 1px solid #ddd; background-color: #fff; color: #007bff; padding: 8px 12px;
    border-radius: 5px; cursor: pointer; transition: background-color 0.2s, color 0.2s; font-size: 0.9em;
}
.page-btn:disabled { color: #ccc; cursor: not-allowed; }
.page-btn:not(:disabled):hover { background-color: #f0f2f5; }
.page-btn.active { background-color: #007bff; color: white; border-color: #007bff; }
.page-ellipsis { padding: 8px 5px; color: #6c757d; }

@media (max-width: 1023px) {
    body { padding: 10px; }
    .results-grid { column-count: 3; }
}
@media (max-width: 768px) {
    .results-grid { column-count: 2; column-gap: 10px; }
    .result-item { margin-bottom: 10px; }
    .search-bar { border-radius: 10px; }
    #text-input { padding: 8px 10px; font-size: 0.9em; }
    #file-btn .file-btn-text { display: none; }
    #file-btn, #search-btn { padding: 8px 12px; gap: 0; }
    header h1 { font-size: 1.5em; }
    #preview-area { min-height: 150px; max-height: 350px; }
    #preview-placeholder { padding: 50px 0; }
    #preview-placeholder i { font-size: 36px; }
}
@media (max-width: 480px) {
    header h1 { font-size: 1.3em; }
    #preview-area { max-height: 300px; }
}