﻿/* ── Google Font ── */
@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;600;700;800&family=DM+Sans:wght@300;400;500&display=swap');

:root {
    --bg: #0d0d0d;
    --surface: #161616;
    --surface2: #1e1e1e;
    --border: #2a2a2a;
    --accent: #e8ff3e;
    --accent-dim: #b8cc2e;
    --text: #f0f0f0;
    --text-muted: #888;
    --danger: #ff4d4d;
    --radius: 12px;
    --shadow: 0 8px 32px rgba(0,0,0,.6);
}

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

html {
    scroll-behavior: smooth;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ── HEADER ── */
.site-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: rgba(13,13,13,.92);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    padding: 0 1.5rem;
}

.header-inner {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
    gap: 1rem;
}

.logo {
    font-family: 'Syne', sans-serif;
    font-weight: 800;
    font-size: 1.35rem;
    letter-spacing: -0.5px;
    color: var(--text);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: .5rem;
}

    .logo span {
        color: var(--accent);
    }

/* Upload button */
.btn-upload {
    background: var(--accent);
    color: #000;
    font-family: 'Syne', sans-serif;
    font-weight: 700;
    font-size: .85rem;
    letter-spacing: .5px;
    border: none;
    border-radius: 8px;
    padding: .5rem 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: .45rem;
    transition: background .2s, transform .15s;
    flex-shrink: 0;
}

    .btn-upload:hover {
        background: var(--accent-dim);
        transform: translateY(-1px);
    }

    .btn-upload:active {
        transform: translateY(0);
    }

    .btn-upload i {
        font-size: .95rem;
    }

/* ── MAIN ── */
.site-main {
    max-width: 1600px;
    margin: 0 auto;
    padding: 2rem 1.5rem 4rem;
}

/* ── GALLERY SECTION HEADER ── */
.section-head {
    display: flex;
    align-items: baseline;
    gap: .75rem;
    margin-bottom: 1.5rem;
}

    .section-head h2 {
        font-family: 'Syne', sans-serif;
        font-weight: 700;
        font-size: 1.1rem;
        color: var(--text);
    }

.badge-count {
    background: var(--surface2);
    color: var(--text-muted);
    font-size: .75rem;
    padding: 2px 10px;
    border-radius: 20px;
    border: 1px solid var(--border);
}

.hint-drag {
    margin-left: auto;
    color: var(--text-muted);
    font-size: .8rem;
    display: flex;
    align-items: center;
    gap: .35rem;
}

/* ── GRID ── */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
}

@media (max-width: 900px) {
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 540px) {
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    /* Card nhỏ hơn: giảm padding footer */
    .card-footer-custom {
        padding: .4rem .5rem;
    }

    .card-filename {
        font-size: .65rem;
    }

    .card-order {
        font-size: .65rem;
    }

    /* Lightbox nav */
    .lightbox-prev,
    .lightbox-next {
        width: 36px;
        height: 36px;
        font-size: .85rem;
    }

    .lightbox-content {
        max-width: calc(100vw - 100px);
    }
}

/* ── CARD ── */
.img-card {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: grab;
    transition: transform .25s, box-shadow .25s, border-color .25s;
    user-select: none;
}

    .img-card:hover {
        transform: translateY(-4px);
        box-shadow: var(--shadow);
        border-color: #3a3a3a;
    }

    .img-card.sortable-ghost {
        opacity: .35;
        border: 2px dashed var(--accent);
    }

    .img-card.sortable-drag {
        cursor: grabbing;
        transform: scale(1.04) rotate(.8deg);
        box-shadow: 0 20px 60px rgba(0,0,0,.8);
        z-index: 9999;
    }

/* Thumbnail wrapper — fixed aspect ratio 4:3 */
/* Thumbnail wrapper — thay padding-bottom: 75% bằng height tự động */
.thumb-wrap {
    position: relative;
    width: 100%;
    padding-bottom: 0; /* bỏ aspect ratio cố định */
    overflow: hidden;
    background: #111;
}

    .thumb-wrap img {
        position: static; /* bỏ absolute */
        width: 100%;
        height: auto; /* chiều cao theo tỷ lệ gốc */
        display: block;
        object-fit: unset;
        transition: transform .35s;
    }

.img-card:hover .thumb-wrap img {
    transform: scale(1.06);
}

/* Drag handle overlay */
.drag-handle {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(0,0,0,.65);
    backdrop-filter: blur(4px);
    color: #fff;
    border-radius: 6px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .75rem;
    opacity: 0;
    transition: opacity .2s;
    pointer-events: none;
}

.img-card:hover .drag-handle {
    opacity: 1;
}

/* Delete button */
.btn-delete {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(255,77,77,.9);
    color: #fff;
    border: none;
    border-radius: 6px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .7rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity .2s, background .2s;
}

.img-card:hover .btn-delete {
    opacity: 1;
}

.btn-delete:hover {
    background: var(--danger);
}

/* Card footer */
.card-footer-custom {
    padding: .55rem .75rem;
    background: var(--surface);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
}

.card-filename {
    font-size: .72rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-order {
    font-family: 'Syne', sans-serif;
    font-size: .7rem;
    font-weight: 700;
    color: var(--accent);
    flex-shrink: 0;
}

/* ── EMPTY STATE ── */
.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 5rem 1rem;
    color: var(--text-muted);
}

    .empty-state i {
        font-size: 3rem;
        margin-bottom: 1rem;
        color: #2a2a2a;
    }

    .empty-state h3 {
        font-family: 'Syne', sans-serif;
        font-size: 1.1rem;
        margin-bottom: .5rem;
    }

    .empty-state p {
        font-size: .85rem;
    }

/* ── UPLOAD MODAL / DROP ZONE ── */
.modal-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    color: var(--text);
}

.modal-header {
    border-bottom: 1px solid var(--border);
    padding: 1rem 1.5rem;
}

    .modal-header .modal-title {
        font-family: 'Syne', sans-serif;
        font-weight: 700;
    }

    .modal-header .close {
        color: var(--text-muted);
        opacity: 1;
        text-shadow: none;
    }

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    border-top: 1px solid var(--border);
    padding: 1rem 1.5rem;
}

.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 2.5rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: border-color .2s, background .2s;
}

    .drop-zone:hover,
    .drop-zone.drag-over {
        border-color: var(--accent);
        background: rgba(232,255,62,.04);
    }

    .drop-zone i {
        font-size: 2.5rem;
        color: #333;
        margin-bottom: .75rem;
    }

    .drop-zone p {
        color: var(--text-muted);
        font-size: .9rem;
        margin: 0;
    }

        .drop-zone p strong {
            color: var(--accent);
        }

    .drop-zone input {
        display: none;
    }

/* Preview list */
.preview-list {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.preview-item {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .5rem .75rem;
}

    .preview-item img {
        width: 44px;
        height: 44px;
        object-fit: cover;
        border-radius: 6px;
        flex-shrink: 0;
    }

    .preview-item .p-name {
        font-size: .82rem;
        flex: 1;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .preview-item .p-size {
        font-size: .75rem;
        color: var(--text-muted);
        flex-shrink: 0;
    }

    .preview-item .p-remove {
        background: none;
        border: none;
        color: var(--text-muted);
        cursor: pointer;
        font-size: .85rem;
        padding: 2px 4px;
        transition: color .2s;
    }

        .preview-item .p-remove:hover {
            color: var(--danger);
        }

/* Progress */
.upload-progress {
    margin-top: 1rem;
    display: none;
}

.progress {
    height: 4px;
    background: var(--surface2);
    border-radius: 2px;
}

.progress-bar {
    background: var(--accent);
}

/* Toast */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: .5rem;
}

.toast-item {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    color: var(--text);
    padding: .75rem 1rem;
    border-radius: 8px;
    font-size: .85rem;
    box-shadow: var(--shadow);
    animation: slideIn .3s ease;
    display: flex;
    align-items: center;
    gap: .5rem;
    min-width: 240px;
    max-width: 340px;
}

    .toast-item.toast-error {
        border-left-color: var(--danger);
    }

@@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Save order button */
.btn-save-order {
    display: none;
    background: var(--accent);
    color: #000;
    font-family: 'Syne', sans-serif;
    font-weight: 700;
    font-size: .82rem;
    border: none;
    border-radius: 8px;
    padding: .45rem 1rem;
    cursor: pointer;
    transition: background .2s;
    margin-left: auto;
    align-items: center;
    gap: .4rem;
}

    .btn-save-order.show {
        display: flex;
    }

    .btn-save-order:hover {
        background: var(--accent-dim);
    }

/* Modal upload button */
.btn-do-upload {
    background: var(--accent);
    color: #000;
    font-family: 'Syne', sans-serif;
    font-weight: 700;
    border: none;
    border-radius: 8px;
    padding: .5rem 1.4rem;
    cursor: pointer;
    transition: background .2s;
}

    .btn-do-upload:disabled {
        opacity: .5;
        cursor: not-allowed;
    }

    .btn-do-upload:hover:not(:disabled) {
        background: var(--accent-dim);
    }

.btn-cancel-modal {
    background: var(--surface2);
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: .5rem 1.2rem;
    cursor: pointer;
    font-size: .85rem;
}

    .btn-cancel-modal:hover {
        border-color: #555;
        color: var(--text);
    }

/* Lightbox */
.lightbox {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.92);
    z-index: 10000;
    align-items: center;
    justify-content: center;
}

    .lightbox.active {
        display: flex;
    }

    .lightbox img {
        max-width: 90vw;
        max-height: 90vh;
        border-radius: var(--radius);
        box-shadow: 0 0 80px rgba(0,0,0,.9);
        animation: popIn .25s ease;
    }

.lightbox-close {
    position: fixed;
    top: 1rem;
    right: 1.5rem;
    font-size: 1.8rem;
    color: #fff;
    cursor: pointer;
    background: none;
    border: none;
    line-height: 1;
    opacity: .7;
    transition: opacity .2s;
}

    .lightbox-close:hover {
        opacity: 1;
    }

@@keyframes popIn {
    from {
        transform: scale(.9);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}
/* Lightbox nav buttons */
.lightbox-prev,
.lightbox-next {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255,255,255,.1);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,.15);
    color: #fff;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .2s, opacity .2s;
    z-index: 10001;
}

.lightbox-prev {
    left: 1.5rem;
}

.lightbox-next {
    right: 1.5rem;
}

    .lightbox-prev:hover,
    .lightbox-next:hover {
        background: rgba(255,255,255,.2);
    }

