/* ==========================================================================
   K-Tech Gallery - Styles
   ========================================================================== */

.ktech-gallery-page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px 0;
}

.ktech-gallery-wrapper {
    position: relative;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.ktech-gallery-title {
    margin-bottom: 24px;
    font-size: 28px;
}

/* ----- Grid mode: 4 cột 1 hàng ----- */
.ktech-gallery-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

.ktech-gallery-grid .gallery-item {
    position: relative;
    border-radius: 6px;
    will-change: transform;
    transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.ktech-gallery-grid .gallery-item:hover {
    transform: scale(1.03);
}

.ktech-gallery-grid .gallery-item img {
    width: 100%;
    height: auto;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: 6px;
    display: block;
}

.ktech-gallery-grid .gallery-item .caption {
    position: absolute;
    top: 10px;
    right: 10px;
    margin: 0;
    padding: 4px 10px;
    max-width: calc(100% - 20px);
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 13px;
    line-height: 1.3;
    border-radius: 4px;
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

@media (max-width: 576px) {
    .ktech-gallery-grid {
        grid-template-columns: 1fr;
    }
}

/* ----- Slider mode (Swiper) ----- */
.ktech-gallery-slider {
    padding-bottom: 50px; /* chừa chỗ cho pagination */
}

.ktech-gallery-slider .swiper-slide {
    position: relative;
}

.ktech-gallery-slider .swiper-slide img {
    width: 100%;
    height: auto;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: 6px;
    display: block;
}

.ktech-gallery-slider .swiper-slide .caption {
    position: absolute;
    top: 10px;
    right: 10px;
    margin: 0;
    padding: 4px 10px;
    max-width: calc(100% - 20px);
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 13px;
    line-height: 1.3;
    border-radius: 4px;
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ktech-gallery-slider .swiper-button-next,
.ktech-gallery-slider .swiper-button-prev {
    color: #333;
}

.ktech-gallery-slider .swiper-pagination-bullet-active {
    background: #333;
}

/* ----- Con trỏ tay khi hover ảnh, gợi ý bấm vào để xem to ----- */
.ktech-gallery-grid .gallery-item img,
.ktech-gallery-slider .swiper-slide img {
    cursor: zoom-in;
}

/* ==========================================================================
   Lightbox (xem ảnh to, kéo qua/kéo lại)
   ========================================================================== */
.ktech-lightbox {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.9);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.ktech-lightbox.is-open {
    display: flex;
    opacity: 1;
}

.ktech-lightbox-swiper {
    width: 100%;
    height: 100%;
}

.ktech-lightbox-swiper .swiper-slide {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.ktech-lightbox-swiper .swiper-slide img {
    max-width: 90vw;
    max-height: 85vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 4px;
    cursor: default;
}

.ktech-lightbox-caption {
    margin-top: 14px;
    color: #fff;
    font-size: 15px;
    text-align: center;
    max-width: 80vw;
}

.ktech-lightbox-close {
    position: absolute;
    top: 20px;
    right: 30px;
    z-index: 100000;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 42px;
    line-height: 1;
    cursor: pointer;
    padding: 4px 10px;
    opacity: 0.85;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.ktech-lightbox-close:hover {
    opacity: 1;
    transform: scale(1.1);
}

.ktech-lightbox .swiper-button-next,
.ktech-lightbox .swiper-button-prev {
    color: #fff;
    width: 44px;
    height: 44px;
    background: rgba(0, 0, 0, 0.35);
    border-radius: 50%;
    z-index: 100000; /* đảm bảo luôn nằm trên ảnh + curation controls */
}

.ktech-lightbox .swiper-button-next::after,
.ktech-lightbox .swiper-button-prev::after {
    font-size: 20px;
    font-weight: 700;
}

@media (max-width: 576px) {
    .ktech-lightbox .swiper-button-next,
    .ktech-lightbox .swiper-button-prev {
        width: 38px;
        height: 38px;
    }

    .ktech-lightbox .swiper-button-next::after,
    .ktech-lightbox .swiper-button-prev::after {
        font-size: 16px;
    }
}

@media (max-width: 576px) {
    .ktech-lightbox-close {
        top: 10px;
        right: 15px;
        font-size: 34px;
    }
}

/* ==========================================================================
   Curation controls: tick chọn ảnh + badge số + nút note
   ========================================================================== */
.ktech-image-frame {
    position: relative;
}

.ktech-curation-controls {
    position: absolute;
    top: -15px;
    left: 15px;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Trong lightbox: giữ badge nằm gọn bên trong ảnh, không nhô ra ngoài,
   để tránh đè lên vùng bấm của nút mũi tên trái/phải (đặc biệt trên mobile). */
.ktech-lightbox-frame .ktech-curation-controls {
    top: 12px;
    left: 12px;
}

/* ----- Badge tick / số thứ tự ----- */
.ktech-tick-badge {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.85);
    background: rgba(0, 0, 0, 0.35);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.ktech-tick-badge:hover {
    transform: scale(1.08);
}

.ktech-tick-badge.is-ticked {
    background: #22c55e; /* xanh lá */
    border-color: #22c55e;
}

.ktech-tick-badge.is-readonly {
    cursor: default;
}

.ktech-tick-badge.is-readonly:hover {
    transform: none;
}

.ktech-tick-number {
    line-height: 1;
}

/* ----- Nút Note ----- */
.ktech-note-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.85);
    background: rgba(0, 0, 0, 0.35);
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    transition: transform 0.2s ease, background 0.2s ease;
}

.ktech-note-btn:hover {
    transform: scale(1.08);
}

.ktech-note-btn.has-note {
    background: #f59e0b; /* cam, báo hiệu đã có note */
    border-color: #f59e0b;
}

/* ==========================================================================
   Note modal (popup nhập / xem ghi chú)
   ========================================================================== */
.ktech-note-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
}

.ktech-note-modal-overlay.is-open {
    display: flex;
}

.ktech-note-modal {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    width: 90%;
    max-width: 420px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.ktech-note-modal h4 {
    margin: 0 0 12px;
    font-size: 16px;
}

.ktech-note-modal textarea {
    width: 100%;
    min-height: 120px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-family: inherit;
    font-size: 14px;
    resize: vertical;
    box-sizing: border-box;
}

.ktech-note-modal .ktech-note-readonly-text {
    white-space: pre-wrap;
    font-size: 14px;
    color: #333;
    line-height: 1.5;
}

.ktech-note-modal-actions {
    margin-top: 14px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.ktech-note-modal-actions button {
    padding: 8px 16px;
    border-radius: 6px;
    border: none;
    font-size: 14px;
    cursor: pointer;
}

.ktech-note-modal-actions .ktech-note-save {
    background: #2563eb;
    color: #fff;
}

.ktech-note-modal-actions .ktech-note-cancel {
    background: #eee;
    color: #333;
}

/* ==========================================================================
   Toast thông báo (vd: đạt giới hạn 31 ảnh)
   ========================================================================== */
.ktech-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #1f2937;
    color: #fff;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 9999999;
    opacity: 0;
    transition: opacity 0.25s ease, transform 0.25s ease;
    pointer-events: none;
    max-width: 90%;
    text-align: center;
}

.ktech-toast.is-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
