@charset "UTF-8";
/* Modern, clean and balanced layout */

body {
    font-family: 'Inter', Arial, Helvetica, sans-serif;
    background: #f3f6fb;
    margin: 0;
    padding: 0;
}

.header-bar {
    width: 100vw;
  background-image: url('../../assets/img/header-bg.gif');
  background-color: #CCFFFF; /* fallback nếu không có ảnh */
  background-size: cover;
  background-position: center;
    border-bottom: 1.5px solid #e0e5f1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px 0 16px;
    height: 60px;
    box-sizing: border-box;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
}

.header-logo {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    margin-right: 14px;
    box-shadow: 0 1px 4px rgba(44,80,160,0.07);
    background: #f7fbfe;
    object-fit: contain;
}

.header-title {
    font-size: 1.38em;
    font-weight: bold;
    color: #2462a5;
    letter-spacing: 0.1px;
    line-height: 1.2;
}

.header-backhome {
    color: #2978f2;
    background: #e8f1fd;
    border-radius: 7px;
    padding: 8px 18px;
    font-size: 1em;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.15s;
    margin-left: 10px;
    display: flex;
    align-items: center;
    box-shadow: 0 1px 4px rgba(44,100,200,0.06);
}
.header-backhome:hover {
    background: #d0e5fd;
    color: #2462a5;
    text-decoration: none;
}
.header-menu {
    display: flex;
    align-items: center;
    gap: 8px;
}
.header-trend {
    background: #fff7ec;
    color: #f47321;
    font-weight: 500;
    padding: 7px 15px 7px 10px;
    border-radius: 9px;
    text-decoration: none;
    box-shadow: 0 1px 7px #f7e0c1a3;
    margin-right: 12px;
    transition: background 0.15s;
}
.header-trend:hover {
    background: #ffe4b9;
    color: #ce6405;
}
.container {
    display: flex;
    flex-direction: row;
    width: 100vw;
    min-height: calc(100vh - 60px);
    box-sizing: border-box;
    background: #f3f6fb;
    justify-content: flex-start;
    gap: 0;
}

.left {
    background: #fff;
    padding: 28px 18px 22px 28px;
    width: 440px;
    min-width: 220px;
    max-width: 460px;
    box-sizing: border-box;
    border-right: 1px solid #e0e4ed;
    box-shadow: 1px 0 7px rgba(160,160,180,0.04);
}

.right {
      background-image: url('../../assets/img/center-bg.jpg');
  background-color: #CCFFFF; /* fallback nếu không có ảnh */
  background-size: cover;
  background-position: center;
    padding: 32px 32px 16px 32px;
    flex: 1 1 340px;
    min-width: 320px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    border-right: 1px solid #e0e4ed;
    box-shadow: 1px 0 7px rgba(160,160,180,0.03);
    position: relative;
}

.resize-panel {
    flex-basis: 360px;
    background: #f8fbfe;
    border-radius: 12px;
    padding: 24px 18px 18px 18px;
    box-shadow: 0 1px 8px rgba(80,150,200,0.08);
    min-width: 300px;
    margin-left: 0;
    margin-top: 32px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    height: fit-content;
}

h3, h4 {
    color: #1e375a;
    margin-top: 0;
    font-family: inherit;
    font-weight: 600;
    letter-spacing: 0.1px;
}
hr {
    margin: 24px 0;
    border: none;
    border-top: 1.5px solid #e6eaf3;
}
form {
    margin-bottom: 14px;
    font-size: 1em;
}
input[type="file"], input[type="number"], select {
    font-size: 1em;
}
input[type="file"] {
    padding: 7px 0;
    margin-bottom: 8px;
    width: 99%;
    background: #f8fafd;
    border-radius: 6px;
}
input[type="number"], select {
    padding: 5px 8px;
    border: 1.1px solid #b7cdfa;
    border-radius: 6px;
    outline: none;
    margin: 0 3px 0 0;
}
input[type="number"]:focus, select:focus {
    border-color: #3686f7;
    background: #f8fcff;
}
button {
    background: linear-gradient(90deg, #3686f7 60%, #51aaf3 100%);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 7px 20px;
    font-size: 1em;
    margin-top: 3px;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.18s, box-shadow 0.12s;
    box-shadow: 0 2px 6px rgba(90,130,255,0.05);
}
button:hover {
    background: linear-gradient(90deg, #295ec6 60%, #4c99da 100%);
}

#frameLibrary {
    margin-top: 10px;
    max-height: 530px;
    overflow-y: auto;
    background: #f8f9fd;
    padding: 10px 8px 16px 8px;
    border-radius: 12px;
    box-shadow: 0 1px 8px rgba(50,90,150,0.06);
}

.frame-category-title {
    font-weight: bold;
    color: #2763a6;
    font-size: 1.09em;
    margin: 16px 0 7px 6px;
}

.frame-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 13px;
    margin-bottom: 10px;
}

.frame-thumb {
    width: 112px;
    height: 112px;
    object-fit: contain;
    border: 2.5px solid #dde6f6;
    border-radius: 13px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(70,90,160,0.10);
    cursor: pointer;
    transition: border 0.15s, transform 0.17s;
    display: block;
    margin: 0 auto;
}
.frame-thumb:hover, .frame-thumb.active {
    border: 2.5px solid #3686f7;
    transform: scale(1.06);
}

#photoPreview img, #resultPreview img {
    border-radius: 16px;
    margin-top: 8px;
    box-shadow: 0 2px 18px rgba(30,80,160,0.11);
    background: #fff;
    max-width: 240px;
}

#resultPreview {
    text-align: center;
    min-height: 240px;
    margin-bottom: 0;
}

#downloadBtn {
    display: block;
    margin: 20px auto 0 auto;
    background: #13c77b;
    color: #fff;
    border-radius: 8px;
    padding: 8px 26px;
    text-align: center;
    text-decoration: none;
    font-weight: bold;
    font-size: 1.1em;
    box-shadow: 0 1px 8px rgba(60,180,120,0.12);
    transition: background 0.18s;
    width: fit-content;
}
#downloadBtn:hover {
    background: #11915a;
}

/* Modal crop ảnh */
#cropModal {
    position: fixed;
    left: 0; top: 0; right: 0; bottom: 0;
    background: rgba(35,45,60,0.19);
    z-index: 99999;
    display: none;
    align-items: center;
    justify-content: center;
    animation: fadeIn .25s;
    overflow: auto;
}
#cropModal > div {
    background: #fff;
    padding: 18px 10px 18px 10px;
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(30,40,80,0.18);
    max-width: 98vw;
    width: 98vw;
    max-height: 97vh;
    min-width: unset;
    min-height: unset;
    overflow: auto;
    position: relative;
}


#cropModal h4 {
    margin-bottom: 12px;
    font-size: 1.13em;
    text-align: center;
}

#cropModal button {
    margin: 14px 10px 0 0;
    font-size: 1em;
}
#selectedFrame {
    max-width: 100%;
    position: absolute;
    top: 0; left: 0;
    z-index: 2;
    pointer-events: none;
}
#avatarToCrop {
    max-width: 100%;
    position: absolute;
    top: 0; left: 0;
    z-index: 1;
}

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

/* Resize panel */
#resizePreview img {
    border-radius: 12px;
    box-shadow: 0 1px 8px rgba(100,120,180,0.09);
    max-width: 140px;
    max-height: 140px;
}
#resizeUploadForm {
    margin-bottom: 8px;
    font-size: 1em;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 7px 6px;
}
#resizeUploadForm > * {
    margin-bottom: 3px !important;
}
#resizeUploadForm button {
    margin: 0 0 0 6px;
}
.resize-panel h3 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1.07em;
}
.resize-panel small {
    font-size: 0.97em;
    margin-top: 2px;
    display: block;
}

/* Cartoon */
.cartoon-panel {
    flex-basis: 360px;
    background: #fff8ee;
    border-radius: 12px;
    padding: 22px 18px 18px 18px;
    box-shadow: 0 1px 8px rgba(255,180,100,0.11);
    min-width: 300px;
    margin-left: 0;
    margin-top: 22px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    height: fit-content;
}
.cartoon-panel h3 {
    margin-top: 0;
    margin-bottom: 9px;
    font-size: 1.05em;
    color: #e98d13;
}

.user-frame-item {
    position: relative;
    display: inline-block;
}
.frame-remove {
    position: absolute;
    top: 6px;
    right: 10px;
    background: rgba(255,255,255,0.91);
    color: #ed3842;
    font-size: 1.35em;
    font-weight: bold;
    cursor: pointer;
    border-radius: 50%;
    padding: 1px 6px 1px 6px;
    z-index: 10;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    transition: background 0.13s;
}
.frame-remove:hover {
    background: #ffe6e8;
    color: #c81a22;
}

/* Phóng to Frame khi di chuyển chuột vào */
#framePreviewPopup {
    transition: opacity .17s;
    background:rgba(250,252,255,0.97);
    padding:12px;
    border-radius:18px;
    border:1.5px solid #e0e6f2;
}
#framePreviewPopup img {
    display:block;
}

/* ======================= PANEL CROP INLINE (MOBILE/RESPONSIVE) ======================= */
#inlineCropPanel {
    background: #fff;
    border-radius: 15px;
    box-shadow: 0 2px 12px rgba(80,120,180,0.11);
    padding: 12px 8px 18px 8px;
    max-width: 430px;
    margin-left: auto;
    margin-right: auto;
    z-index: 120;
    position: relative;
    /* NEW: Set a higher z-index for inline crop panel */
}

/* Khung cropper thực tế - KHÔNG để height/width cứng */
#inlineCropPanel > div[style*="relative"] {
    width: 100vw !important;
    max-width: 98vw !important;
    height: 65vw !important;
    min-height: 170px;
    max-height: 410px;
    margin: auto;
    background: #f7f9fd;
    border-radius: 13px;
    overflow: hidden;
    position: relative;
    /* NEW: Ensure images are contained, no overflow */
    display: flex;
    justify-content: center;
    align-items: center;
}

#avatarToCropInline, #selectedFrameInline {
    width: 100% !important;
    max-width: 100vw !important;
    height: auto;
    max-height: 410px;
    left: 0; top: 0;
    position: absolute;
    border-radius: 13px;
    /* NEW: Prevent image overflow */
    box-sizing: border-box;
}

/* Overlay nền khi crop (tùy chọn: chỉ show khi crop inline mobile) */
#inlineCropOverlay {
    display: none;
    position: fixed;
    left: 0; top: 0;
    width: 100vw; height: 100vh;
    z-index: 110;
    background: rgba(0,0,0,0.16);
    /* Click ra ngoài để đóng panel (cần JS hỗ trợ) */
}

/* Căn chỉnh nút dưới panel crop inline */
#inlineCropPanel .button-group,
#inlineCropPanel div[style*="margin:12px"] {
    text-align: center !important;
    margin-top: 14px !important;
    margin-bottom: 0 !important;
    gap: 6px 10px;
}

/* Mobile riêng biệt */
@media (max-width: 750px) {
    #inlineCropPanel {
        width: 99vw !important;
        min-width: unset;
        max-width: 99vw;
        box-shadow: 0 1px 8px rgba(80,120,180,0.07);
        padding: 7px 2vw 11px 2vw;
    }
    #inlineCropPanel > div[style*="relative"] {
        width: 98vw !important;
        max-width: 98vw !important;
        height: 63vw !important;
        min-height: 160px;
        max-height: 340px;
    }
    #avatarToCropInline, #selectedFrameInline {
        max-width: 98vw !important;
        max-height: 340px !important;
        border-radius: 10px;
    }
}

/* Mobile */

@media (max-width: 750px) {
    html, body {
        width: 100vw;
        min-width: unset;
        box-sizing: border-box;
        overscroll-behavior: contain;
    }
    body {
        font-size: 1em;
    }
    .header-bar {
        flex-direction: column;
        height: auto;
        padding: 8px 3vw;
        align-items: flex-start;
        gap: 7px;
    }
    .header-left {
        flex-direction: row;
        align-items: center;
        margin-bottom: 0;
    }
    .header-logo {
        width: 30px;
        height: 30px;
        margin-right: 7px;
    }
    .header-title {
        font-size: 1.06em;
        margin-bottom: 0;
        margin-right: 5px;
    }
    .header-menu {
        width: 100%;
        justify-content: flex-end;
        gap: 7px;
        margin-top: 4px;
    }
    .header-backhome, .header-trend {
        font-size: 0.98em;
        padding: 8px 11px;
        margin: 0 0 0 6px;
    }

    .container {
        flex-direction: column;
        align-items: stretch;
        width: 100vw;
        min-width: unset;
        gap: 0;
    }
    .left, .right, .resize-panel, .cartoon-panel {
        width: 100vw !important;
        min-width: unset !important;
        max-width: 100vw !important;
        border: none;
        box-shadow: none;
        padding: 12px 3vw 16px 3vw;
        margin: 0;
    }
    .resize-panel, .cartoon-panel {
        margin-top: 14px;
    }
    .frame-category-title {
        font-size: 1em;
        margin-left: 2px;
    }
    .frame-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 9px;
    }
    .frame-thumb {
        width: 92px;
        height: 92px;
    }
    #photoPreview img, #resultPreview img {
        max-width: 93vw;
        border-radius: 11px;
    }
    #framePreviewPopup {
        padding: 6px;
        border-radius: 12px;
        max-width: 96vw;
    }
    #framePreviewPopup img {
        max-width: 85vw !important;
        max-height: 38vh !important;
    }
    .right {
        min-height: 130px;
        align-items: center;
        justify-content: flex-start;
        padding: 10px 2vw 14px 2vw;
    }
    #cropModal > div {
        min-width: unset;
        max-width: 98vw;
        min-height: unset;
        width: 95vw;
        padding: 13px 2vw 15px 2vw;
    }
}

@media (max-width: 1200px) {
    .container {
        flex-direction: column;
        align-items: stretch;
        width: 100vw;
        min-width: unset;
    }
    .left, .right, .resize-panel, .cartoon-panel {
        width: 100vw;
        min-width: unset;
        border: none;
        box-shadow: none;
        padding: 16px 5vw;
        margin: 0;
    }
    .resize-panel, .cartoon-panel {
        margin-top: 22px;
    }
    .right {
        align-items: center;
        justify-content: flex-start;
    }
}

input, button, select, textarea {
    font-size: 1em;
    max-width: 100vw;
}
html, body {
    width: 100vw;
    box-sizing: border-box;
}
