* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: "Inter", sans-serif;
}

body {
    background-color: #f5f7fa;
    color: #333;
}

/* =========================================================
   CẤU TRÚC KHUNG TRANG & SIDEBAR QUẢNG CÁO (3 CỘT)
   ========================================================= */
.main-container {
    display: flex;
    gap: 20px;
    max-width: 1450px;
    margin: 30px auto;
    align-items: flex-start;
}

/* Sidebar quảng cáo bên trái */
.promo-sidebar {
    width: 280px;
    background: #ffffff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    flex-shrink: 0;
    border: 1px solid #e5e7eb;
}

.promo-sidebar h3 {
    color: #5B42F3;
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 18px;
    text-align: center;
    border-bottom: none;
    padding-bottom: 0;
}

.promo-sidebar p {
    font-size: 14px;
    color: #444;
    line-height: 1.5;
    margin-bottom: 10px;
}

.promo-sidebar ul {
    font-size: 14px;
    color: #444;
    padding-left: 20px;
    margin-bottom: 20px;
    line-height: 1.6;
}

.promo-sidebar li {
    margin-bottom: 8px;
}

.promo-image-box {
    margin-bottom: 15px;
    text-align: center;
}

/* Hiệu ứng di chuột xem ảnh lớn */
.img-wrapper {
    position: relative;
    cursor: pointer;
    display: block;
    width: 100%;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e5e7eb;
}

.img-wrapper img {
    display: block;
    width: 100%;
    height: auto;
    transition: transform 0.3s ease;
}

.promo-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    font-size: 13px;
    font-weight: 600;
}

.img-wrapper:hover .promo-overlay {
    opacity: 1;
}

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

.promo-image-box .caption {
    font-size: 12px;
    color: #777;
    margin-top: 6px;
    font-style: italic;
}

/* Popup (Modal) hiển thị ảnh Full */
.image-modal {
    display: none; 
    position: fixed;
    z-index: 99999;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.85);
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
}

.image-modal.show {
    display: flex;
    animation: fadeIn 0.25s ease;
}

.image-modal img {
    max-width: 90%;
    max-height: 90vh;
    border-radius: 8px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.5);
    object-fit: contain;
}

.image-modal-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: white;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    user-select: none;
    transition: color 0.2s;
}

.image-modal-close:hover {
    color: #ff4757;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* =========================================================
   CỘT NỘI DUNG (GIỮA & PHẢI)
   ========================================================= */
h2 {
    font-size: 18px;
    margin-bottom: 20px;
    color: #1a1a1a;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.left-panel {
    flex: 1;
    padding: 30px;
    background: #ffffff;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.right-panel {
    width: 380px;
    padding: 30px;
    background: #ffffff;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    flex-shrink: 0;
}

/* SỬA LỖI VÙNG UPLOAD ẢNH ĐẦU VÀO BỊ NÉN/CẮT */
.upload-area {
    width: 100%;
    min-height: 120px;
    height: auto;
    border: 2px dashed #e0e0e0;
    border-radius: 10px;
    background: #fafafa;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    padding: 20px;
    box-sizing: border-box;
}

.upload-area:hover {
    border-color: #5B42F3;
    background: #f0f0ff;
}

.upload-area p {
    margin-top: 15px;
    font-weight: 00;
    color: #444;
}

.sub-text {
    font-size: 12px;
    color: #888;
    margin-top: 5px;
}

/* Hiển thị chuẩn kích thước ảnh xem trước */
.upload-area img#previewImage {
    max-width: 100%;
    max-height: 300px;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 6px;
    margin: auto;
    display: block;
}

.success-box {
    background: #e8f5e9;
    border: 1px solid #c8e6c9;
    padding: 20px;
    border-radius: 8px;
    text-align: center;
}

.success-box p {
    color: #2e7d32;
    font-weight: 600;
    margin-bottom: 15px;
    font-size: 16px;
}

/* Control settings */
.control-group {
    margin-bottom: 25px;
}

.control-group > label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 10px;
    color: #444;
}

/* Scale options */
.scale-options {
    display: flex;
    gap: 10px;
}

.scale-options input {
    display: none;
}

.scale-options label {
    flex: 1;
    text-align: center;
    padding: 10px;
    background: #f0f0f0;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: 0.2s;
    color: #666;
}

.scale-options label:hover {
    background: #e4e4e4;
}

.scale-options label.active {
    background: #5B42F3;
    color: white;
    box-shadow: 0 4px 10px rgba(91, 66, 243, 0.3);
}

/* Select */
.form-select {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    outline: none;
    transition: 0.2s;
    cursor: pointer;
    background: #fff;
}

.form-select:focus {
    border-color: #5B42F3;
}

.model-description {
    margin-top: 8px;
    font-size: 12px;
    color: #888;
}

/* Toggle */
.header-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.header-flex label {
    margin: 0;
}

.toggle-switch {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.toggle-switch input {
    display: none;
}

.slider {
    position: relative;
    width: 40px;
    height: 22px;
    background-color: #ccc;
    transition: .4s;
    border-radius: 34px;
    margin-right: 10px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #5B42F3;
}

input:checked + .slider:before {
    transform: translateX(18px);
}

.label-text {
    font-size: 13px;
    color: #666;
    font-weight: 500;
}

/* Settings Sliders */
.settings-panel {
    padding-top: 2px;
}

.slider-group {
    margin-bottom: 12px;
}

.slider-header {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #555;
    margin-bottom: 6px;
}

input[type=range] {
    -webkit-appearance: none;
    width: 100%;
    background: transparent;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 16px;
    width: 16px;
    border-radius: 50%;
    background: #5B42F3;
    cursor: pointer;
    margin-top: -6px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 4px;
    cursor: pointer;
    background: #ddd;
    border-radius: 2px;
}

.setting-item {
    transition: opacity 0.2s;
}

.disabled-settings {
    opacity: 0.4;
    pointer-events: none;
}

.disabled-settings input[type=range]::-webkit-slider-thumb {
    background: #999;
}

.info-box {
    background: #fff3cd;
    color: #856404;
    padding: 6px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 20px;
    line-height: 1.5;
    border: 1px solid #ffeeba;
}

/* Buttons */
.btn {
    display: inline-block;
    width: 100%;
    text-align: center;
    padding: 14px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.3s;
    text-decoration: none;
    border: none;
}

.primary-btn {
    background: #5B42F3;
    color: white;
}

.primary-btn:hover {
    background: #4a35c4;
}

.primary-btn:disabled {
    background: #a698ed;
    cursor: not-allowed;
}

/* Loading overlay */
#loadingOverlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255,255,255,0.95);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10;
    text-align: center;
    padding: 30px;
}

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

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

#loadingOverlay h3 {
    color: #5B42F3;
    margin-bottom: 10px;
}

#loadingOverlay p {
    font-size: 13px;
    color: #666;
    line-height: 1.5;
}

/* Responsive */
@media (max-width: 1024px) {
    .main-container {
        flex-direction: column;
        align-items: center;
        padding: 0 15px;
    }

    .promo-sidebar, .left-panel, .right-panel {
        width: 100%;
        max-width: 100%;
    }
}

/* =========================================================
   THÔNG TIN KÍCH THƯỚC ẢNH
   ========================================================= */
.image-info { margin-top: 18px; border: 1px solid #e5e7eb; border-radius: 10px; background: #fff; overflow: hidden; }
.image-info-title { padding: 8px 12px; font-size: 13px; font-weight: 700; color: #4b5563; background: #f8fafc; border-bottom: 1px solid #e5e7eb; }
.image-info-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 0.5fr)); }
.image-info-item { min-height: 30px; padding: 4px 12px; display: flex; flex-direction: column; justify-content: center; gap: 3px; border-bottom: 1px solid #eef0f3; }
.image-info-item:nth-child(odd) { border-right: 1px solid #eef0f3; }
.image-info-item:nth-last-child(-n+2) { border-bottom: none; }
.image-info-item span { font-size: 7px; color: #8a94a6; text-transform: uppercase; letter-spacing: .02em; }
.image-info-item strong { font-size: 9px; color: #263245; font-weight: 500; white-space: nowrap; }

/* =========================================================
   XEM TRƯỚC ẢNH ĐÃ XỬ LÝ
   ========================================================= */
.compare-wrap {
    margin: 16px 0;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
    background: #f3f4f6;
}

.compare-viewport {
    width: 100%;
    min-height: 260px;
    max-height: 520px;
    position: relative;
    overflow: hidden;
    background: #eef1f4;
    user-select: none;
    cursor: default;
}

.compare-viewport > img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
    object-position: center;
    position: absolute;
    inset: 0;
    transform-origin: center center;
    will-change: transform;
    transition: transform 0.08s ease-out;
}

.compare-label {
    position: absolute;
    right: 12px;
    bottom: 12px;
    z-index: 4;
    padding: 6px 10px;
    border-radius: 6px;
    background: rgba(20,25,35,.62);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    pointer-events: none;
}

.compare-control {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background: #fff;
    border-top: 1px solid #e5e7eb;
    font-size: 11px;
    font-weight: 600;
    color: #687385;
}

/* Zoom Controls */
.zoom-control {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 0;
    padding-top: 0;
    border-top: none;
    flex-wrap: wrap;
}

.zoom-label {
    font-size: 12px;
    font-weight: 700;
    color: #4b5563;
    margin-right: 4px;
}

.zoom-preset {
    min-width: 48px;
    padding: 6px 8px;
    border: 1px solid #d9dee7;
    border-radius: 5px;
    background: #ffffff;
    color: #667085;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.zoom-preset:hover {
    border-color: #6d5dfc;
    color: #5b4df1;
}

.zoom-preset.active {
    background: #5b4df1;
    border-color: #5b4df1;
    color: #ffffff;
}

#zoomRange {
    width: 140px;
    flex: 1;
    min-width: 100px;
}

#zoomInput {
    width: 58px;
    padding: 5px 6px;
    border: 1px solid #d9dee7;
    border-radius: 5px;
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    outline: none;
}

#zoomInput:focus {
    border-color: #5b4df1;
}

.compare-viewport {
    cursor: default;
}

.compare-viewport.dragging {
    cursor: grabbing;
}

@media (min-width: 768px) {
    .compare-viewport:hover {
        cursor: grab;
    }
}

@media (max-width: 600px) {
    .image-info-grid { grid-template-columns: 1fr; }
    .image-info-item:nth-child(odd) { border-right: none; }
    .image-info-item:nth-last-child(-n+2) { border-bottom: 1px solid #eef0f3; }
    .image-info-item:last-child { border-bottom: none; }
    .compare-viewport { min-height: 220px; }
}

/* =========================================================
   HEADER & MENU NAVIGATION
   ========================================================= */
.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 25px;
    background: #ffffff;
    border-bottom: 1px solid #e5e7eb;
}

.logo {
    font-size: 22px;
    font-weight: 700;
    color: #f26b21;
    display: flex;
    align-items: center;
    gap: 15px;
}

.logo-img {
    height: 60px;
    width: auto;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.history-btn {
    text-decoration: none;
    color: #4b5563;
    font-size: 14px;
    font-weight: 500;
}

/* Khu vực Số dư xu */
.coin-balance {
    display: flex;
    align-items: center;
    background: #fff3e0;
    border: 1px solid #ffcc80;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 14px;
    color: #e65100;
    font-weight: 700;
}

.btn-deposit {
    background: #f26b21;
    color: white;
    text-decoration: none;
    padding: 2px 10px;
    border-radius: 12px;
    margin-left: 10px;
    font-size: 12px;
    transition: 0.2s;
}

.btn-deposit:hover {
    background: #d85918;
}

/* User Profile */
.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f8fafc;
    padding: 5px 15px 5px 5px;
    border-radius: 30px;
    border: 1px solid #e5e7eb;
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.username {
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

.logout-btn {
    font-size: 12px;
    color: #ef4444;
    text-decoration: none;
    margin-left: 5px;
}

.login-btn {
    width: auto;
    padding: 10px 20px;
}

/* Thanh Menu */
.main-nav {
    display: flex;
    gap: 30px;
    padding: 0 40px;
    background: #022700;
    border-bottom: 2px solid #eeff00;
}

.nav-item {
    padding: 15px 0;
    text-decoration: none;
    color: #ffffff;
    font-weight: 600;
    font-size: 14px;
    border-bottom: 3px solid transparent;
    transition: 0.2s;
}

.nav-item:hover {
    color: #f22121;
}

.nav-item.active {
    color: #ff0000;
    border-bottom-color: #f26b21;
}

/* Widget Zalo */
.zalo-widget {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 55px;
    height: 55px;
    background: white;
    border-radius: 50%;
    box-shadow: 0 6px 16px rgba(0,0,0,0.15);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: transform 0.3s;
}

.zalo-widget:hover {
    transform: scale(1.1);
}

.zalo-widget img {
    width: 35px;
    height: 35px;
}

/* TOAST NOTIFICATION */
.toast-notification {
    position: fixed;
    top: 30px;
    right: -400px;
    width: 320px;
    background: white;
    border-left: 5px solid #10b981;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    border-radius: 8px;
    display: flex;
    align-items: center;
    padding: 15px 20px;
    z-index: 10000;
    transition: right 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.toast-notification.show {
    right: 30px;
}

.toast-icon {
    font-size: 26px;
    margin-right: 15px;
}

.toast-content h4 {
    margin: 0 0 5px 0;
    color: #111827;
    font-size: 15px;
    font-weight: 700;
}

.toast-content p {
    margin: 0;
    color: #4b5563;
    font-size: 13px;
    font-weight: 500;
}

/* Khung nền tối bao phủ toàn màn hình */
.img-modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    overflow: hidden;
    justify-content: center;
    align-items: center;
}

/* Khung chứa ảnh để ẩn phần vượt quá */
.img-container {
    overflow: hidden;
    max-width: 90%;
    max-height: 90%;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Thẻ ảnh bên trong Modal */
#modalImg {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    transition: transform 0.1s ease-out; /* Giúp thao tác zoom mượt hơn */
    cursor: grab;
}

/* Nút đóng */
.close-btn {
    position: absolute;
    top: 20px;
    right: 35px;
    color: #fff;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
}