/* =========================
   RESET / BASE
========================= */
* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
}

body {
    font-family: Arial, Helvetica, sans-serif;
    background: #f6f7f9;
    color: #1c1c1c;
    line-height: 1.5;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

a {
    color: #0f62fe;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* =========================
   LAYOUT
========================= */
.wrap {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px 16px;
}

.narrow {
    max-width: 760px;
}

/* =========================
   HEADER / NAV
========================= */
.site-header {
    background: #111827;
    color: #fff;
}

.site-header .wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.brand {
    font-weight: 700;
    font-size: 20px;
}

.nav {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
}

.nav a {
    color: #fff;
}

.hero {
    padding: 10px 0 24px;
}

/* =========================
   COMMON UI
========================= */
.section-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 16px;
}

.card {
    background: #fff;
    border: 1px solid #dde3ea;
    border-radius: 12px;
    padding: 18px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.button,
button,
input[type="submit"] {
    display: inline-block;
    border: 0;
    border-radius: 8px;
    background: #111827;
    color: #fff;
    padding: 10px 14px;
    cursor: pointer;
    text-decoration: none;
    font-size: 14px;
    line-height: 1.2;
}

.button:hover,
button:hover,
input[type="submit"]:hover {
    text-decoration: none;
}

.button.secondary {
    background: #e8edf3;
    color: #111827;
}

.button.small {
    padding: 8px 10px;
    font-size: 13px;
}

.button-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.alert {
    padding: 10px 12px;
    border-radius: 8px;
    margin-bottom: 14px;
}

.alert.success {
    background: #e7f8ee;
    color: #126b36;
}

.alert.error {
    background: #fdecec;
    color: #a61b1b;
}

/* =========================
   STATS
========================= */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-top: 20px;
}

.stat-card {
    background: #fff;
    border: 1px solid #dde3ea;
    border-radius: 12px;
    padding: 18px;
}

.stat-number {
    font-size: 28px;
    font-weight: 700;
}

.stat-label {
    color: #5f6b7a;
}

/* =========================
   FORMS
========================= */
.form-card label {
    display: block;
    margin: 12px 0 6px;
    font-weight: 700;
}

input[type="text"],
input[type="password"],
input[type="file"],
select,
textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #cfd6df;
    border-radius: 8px;
    background: #fff;
    color: #1c1c1c;
    font: inherit;
}

textarea {
    resize: vertical;
}

.filter-bar {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr auto auto;
    gap: 10px;
    margin-bottom: 18px;
}

.review-sort {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 16px;
    flex-wrap: wrap;
}

.review-sort label {
    font-weight: 700;
}

.review-sort select {
    max-width: 220px;
}

/* =========================
   BADGES / META
========================= */
.badge {
    display: inline-block;
    margin-left: 8px;
    padding: 4px 8px;
    border-radius: 999px;
    background: #eef2f7;
    font-size: 12px;
}

.badge-green {
    background: #daf5e4;
}

.badge-gray {
    background: #eceff3;
}

.review-meta {
    color: #5f6b7a;
    font-size: 14px;
    margin: 6px 0 10px;
}

.review-head,
.admin-card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.admin-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.inactive {
    opacity: 0.6;
}

/* =========================
   REVIEW GALLERY THUMBNAILS
========================= */
.review-images {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.review-images img {
    width: 90px;
    height: 90px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid #d8dee8;
    background: #fff;
    cursor: zoom-in;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.review-images img:hover {
    transform: scale(1.05);
    opacity: 0.95;
}

/* =========================
   EXISTING IMAGE MANAGER
========================= */
.image-preview,
.existing-images {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
}

.image-preview img,
.existing-image-card img {
    width: 110px;
    height: 110px;
    object-fit: cover;
    border-radius: 10px;
    border: 1px solid #d8dee8;
    background: #fff;
}

.existing-image-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 14px;
}

/* =========================
   PAGINATION
========================= */
.pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 0 4px;
}

.pagination a {
    display: inline-block;
    padding: 8px 12px;
    background: #fff;
    border: 1px solid #dbe2ea;
    border-radius: 8px;
}

.pagination a.active {
    background: #111827;
    color: #fff;
}

/* =========================
   LIGHTBOX
   Hidden by default.
   JS toggles .active
========================= */
.lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.96);
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.lightbox.active {
    display: flex;
    opacity: 1;
    visibility: visible;
}

/* Top bar */
.lightbox-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: #fff;
    flex-shrink: 0;
    min-height: 56px;
}

.lightbox-counter {
    font-size: 14px;
    line-height: 1.2;
}

.lightbox-close {
    font-size: 32px;
    line-height: 1;
    cursor: pointer;
    user-select: none;
}

/* Main stage */
.lightbox-main {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    padding: 8px 56px;
    touch-action: none;
}

/* Lightbox image */
.lightbox-main img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
    transform-origin: center center;
    transition: transform 0.25s ease, opacity 0.25s ease;
    touch-action: none;
    cursor: grab;
    user-select: none;
    -webkit-user-drag: none;
}

/* Used by JS during image fade transition */
.lightbox-img-fade {
    opacity: 0;
}

/* Caption */
.lightbox-caption {
    color: #fff;
    text-align: center;
    padding: 8px 14px;
    font-size: 14px;
    flex-shrink: 0;
    min-height: 42px;
}

/* Prev / next buttons */
.lightbox-prev,
.lightbox-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    border: none;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.35);
    color: #fff;
    font-size: 32px;
    line-height: 1;
    padding: 10px 12px;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
}

.lightbox-prev:hover,
.lightbox-next:hover {
    background: rgba(255, 255, 255, 0.18);
}

.lightbox-prev {
    left: 12px;
}

.lightbox-next {
    right: 12px;
}

/* Thumbnail rail */
.lightbox-thumbs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 10px 12px 14px;
    background: #111;
    flex-shrink: 0;
    min-height: 82px;
    justify-content: center;
    scroll-behavior: smooth;
}

.lightbox-thumbs img {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 6px;
    opacity: 0.55;
    cursor: pointer;
    border: 2px solid transparent;
    flex-shrink: 0;
    transition: opacity 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}

.lightbox-thumbs img:hover {
    opacity: 0.9;
    transform: scale(1.05);
}

.lightbox-thumbs img.active {
    opacity: 1;
    border-color: #fff;
}

/* =========================
   RESPONSIVE
========================= */
@media (max-width: 900px) {
    .filter-bar {
        grid-template-columns: 1fr 1fr;
    }

    .lightbox-main {
        padding: 8px 48px;
    }
}

@media (max-width: 768px) {
    .wrap {
        padding: 18px 14px;
    }

    .review-images img {
        width: 78px;
        height: 78px;
    }

    .image-preview img,
    .existing-image-card img {
        width: 90px;
        height: 90px;
    }

    .lightbox-top {
        padding: 10px 12px;
        min-height: 48px;
    }

    .lightbox-counter,
    .lightbox-caption {
        font-size: 13px;
    }

    .lightbox-main {
        padding: 6px 42px;
    }

    .lightbox-prev,
    .lightbox-next {
        font-size: 26px;
        padding: 8px 10px;
    }

    .lightbox-thumbs {
        gap: 6px;
        padding: 8px 10px 10px;
        min-height: 72px;
    }

    .lightbox-thumbs img {
        width: 48px;
        height: 48px;
    }
}

@media (max-width: 560px) {
    .site-header .wrap {
        align-items: flex-start;
    }

    .nav {
        gap: 10px;
    }

    .section-head {
        align-items: flex-start;
    }

    .filter-bar {
        grid-template-columns: 1fr;
    }

    .lightbox-main {
        padding: 6px 10px;
    }

    .lightbox-prev,
    .lightbox-next {
        display: none;
    }

    .lightbox-caption {
        padding: 8px 10px;
    }

    .lightbox-thumbs {
        justify-content: flex-start;
    }
}

@media (max-width: 420px) {
    .review-images img {
        width: 68px;
        height: 68px;
    }

    .lightbox-close {
        font-size: 28px;
    }

    .lightbox-counter {
        font-size: 12px;
    }

    .lightbox-thumbs img {
        width: 42px;
        height: 42px;
    }
}