/* My Event Gallery – Guest Upload App */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --blue: #1e5fa8;
    --blue-light: #d6e4f5;
    --green: #27ae60;
    --red: #e74c3c;
    --amber: #f39c12;
    --text: #2c3e50;
    --muted: #7f8c8d;
    --border: #dde3ec;
    --bg: #f0f4fa;
    --card-bg: #fff;
    --radius: 16px;
    --shadow: 0 4px 20px rgba(30,95,168,.12);
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html, body { height: 100%; background: var(--bg); font-family: var(--font); color: var(--text); }

#meg-app {
    max-width: 560px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding-bottom: env(safe-area-inset-bottom);
}

/* ── Header ────────────────────────────────────── */
.meg-app-header {
    background: linear-gradient(135deg, var(--blue) 0%, #2980b9 100%);
    color: #fff;
    padding: 24px 20px 20px;
    text-align: center;
}
.meg-app-header__event { font-size: .85rem; opacity: .8; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 4px; }
.meg-app-header__title { font-size: 1.5rem; font-weight: 700; }

/* ── Tabs ──────────────────────────────────────── */
.meg-app-tabs {
    display: flex;
    background: var(--blue);
    border-bottom: 3px solid rgba(255,255,255,.2);
}
.meg-app-tab {
    flex: 1;
    background: none;
    border: none;
    color: rgba(255,255,255,.7);
    font-size: .85rem;
    font-weight: 600;
    padding: 12px 4px;
    cursor: pointer;
    transition: .2s;
    border-bottom: 3px solid transparent;
    margin-bottom: -3px;
}
.meg-app-tab.active { color: #fff; border-bottom-color: #fff; }
.meg-app-tab:hover:not(.active) { color: rgba(255,255,255,.9); }

/* ── Tab content ───────────────────────────────── */
.meg-tab-content { display: none; flex: 1; padding: 16px; }
.meg-tab-content.active { display: block; }

/* ── Form card ─────────────────────────────────── */
.meg-form-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.meg-section-title { font-size: 1.1rem; color: var(--blue); margin-bottom: 16px; }

/* ── Fields ────────────────────────────────────── */
.meg-field { margin-bottom: 16px; }
.meg-field label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 6px; color: var(--text); }
.meg-field input[type="text"],
.meg-field textarea {
    width: 100%;
    border: 2px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px;
    font-size: 1rem;
    font-family: var(--font);
    color: var(--text);
    transition: border-color .2s;
    resize: vertical;
}
.meg-field input[type="text"]:focus,
.meg-field textarea:focus { outline: none; border-color: var(--blue); }
.meg-required { color: var(--red); }
.meg-hint { font-size: .8rem; color: var(--muted); margin-top: 6px; }
.meg-char-counter { text-align: right; font-size: .78rem; color: var(--muted); margin-top: 4px; }

/* ── Add photos button ─────────────────────────── */
.meg-add-photo-btn-wrap { margin-bottom: 16px; }
.meg-add-photo-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border: 2.5px dashed var(--blue);
    background: var(--blue-light);
    color: var(--blue);
    border-radius: 12px;
    padding: 18px;
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    transition: .2s;
}
.meg-add-photo-btn:hover { background: #c2d8f0; }
.meg-add-photo-btn__icon { font-size: 1.6rem; line-height: 1; }

/* ── Photo queue ───────────────────────────────── */
.meg-queue {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.meg-queue-item {
    border: 2px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    background: #fff;
}
.meg-queue-item__thumb {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    display: block;
    cursor: pointer;
}
.meg-queue-item__remove {
    position: absolute;
    top: 6px; right: 6px;
    width: 26px; height: 26px;
    background: rgba(0,0,0,.6);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 14px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.meg-queue-item__caption {
    border: none;
    border-top: 1px solid var(--border);
    padding: 6px 8px;
    font-size: .78rem;
    width: 100%;
    font-family: var(--font);
    color: var(--text);
    background: #fafbff;
}
.meg-queue-item__caption:focus { outline: none; background: #f0f4fa; }

.meg-queue-item__progress {
    height: 4px;
    background: var(--green);
    width: 0%;
    transition: width .3s;
}

/* ── Send button ───────────────────────────────── */
.meg-send-btn {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, var(--blue) 0%, #2980b9 100%);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: .2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}
.meg-send-btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(30,95,168,.4); }
.meg-send-btn:disabled { opacity: .5; cursor: not-allowed; }

.meg-btn-outline {
    background: none;
    border: 2px solid var(--blue);
    color: var(--blue);
    border-radius: 10px;
    padding: 10px 24px;
    font-size: .95rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 12px;
    transition: .2s;
}
.meg-btn-outline:hover { background: var(--blue-light); }

/* ── Spinner ───────────────────────────────────── */
.meg-spinner {
    width: 20px; height: 20px;
    border: 3px solid rgba(255,255,255,.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: meg-spin .6s linear infinite;
    display: inline-block;
}
@keyframes meg-spin { to { transform: rotate(360deg); } }

/* ── Success ───────────────────────────────────── */
.meg-success {
    text-align: center;
    padding: 24px 16px;
    animation: meg-pop .4s ease;
}
@keyframes meg-pop { from { transform: scale(.8); opacity:0; } to { transform: scale(1); opacity:1; } }
.meg-success__icon { font-size: 3rem; margin-bottom: 12px; }
.meg-success__text { font-size: 1rem; color: var(--text); line-height: 1.5; }

/* ── My Photos grid ────────────────────────────── */
.meg-my-photos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 10px;
    margin-top: 12px;
}
.meg-my-photo-card {
    border: 1.5px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
}
.meg-my-photo-card img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    display: block;
    cursor: pointer;
}
.meg-my-photo-card__info { padding: 6px 8px; }
.meg-my-photo-card__name { font-size: .75rem; font-weight: 600; }
.meg-my-photo-card__cap  { font-size: .72rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meg-my-photo-card__status { font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.status-pending  { color: var(--amber); }
.status-approved { color: var(--green); }
.status-rejected { color: var(--muted); }
.meg-my-photo-card__actions { padding: 0 8px 8px; }
.meg-delete-btn {
    background: none;
    border: 1px solid var(--red);
    color: var(--red);
    border-radius: 6px;
    padding: 3px 10px;
    font-size: .72rem;
    cursor: pointer;
    width: 100%;
}
.meg-delete-btn:hover { background: #fde8e6; }

/* ── Loading ───────────────────────────────────── */
.meg-loading { color: var(--muted); font-style: italic; text-align: center; padding: 24px; }

/* ── Lightbox ──────────────────────────────────── */


/* ── v1.9 additions ─────────────────────────────────────────────── */

/* Header date line */
.meg-app-header__date {
    font-size: .82rem;
    opacity: .85;
    margin-bottom: 4px;
}

/* Lightbox — definitive styles */
/* ── Lightbox ─────────────────────────────────────────────────────
   Sits outside #meg-app so it covers the full viewport.
   Everything uses position:absolute inside the fixed overlay.
   No mixed fixed/absolute stacking — avoids black-screen bugs.
─────────────────────────────────────────────────────────────── */
.meg-lightbox {
    display: none;                   /* JS: lb.style.display = 'flex' */
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0; /* inset fallback for older iOS */
    z-index: 999999;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 64px 56px 20px; /* top: clear close btn; sides: clear prev/next */
    background: rgba(0,0,0,.95);
    -webkit-transform: translateZ(0); /* force GPU layer on iOS */
    transform: translateZ(0);
    overflow: hidden;
}
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .meg-lightbox { padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
}
/* Backdrop removed — lightbox bg handles it */
.meg-lightbox__backdrop { display: none; }

/* Content box — fills available space between padding edges */
.meg-lightbox__content {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    min-height: 0;
}
.meg-lightbox__content img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 6px;
}

/* Close — fixed to viewport top-right, always visible */
.meg-lightbox__close {
    position: fixed;
    top: 12px; right: 12px;
    z-index: 1000001;
    background: rgba(255,255,255,.15);
    color: #fff;
    border: 1px solid rgba(255,255,255,.3);
    border-radius: 50%;
    width: 44px; height: 44px;
    font-size: 20px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    -webkit-tap-highlight-color: transparent;
}
.meg-lightbox__close:active { background: rgba(255,255,255,.3); }

/* Download — fixed top-right next to close */
.meg-lightbox__download {
    position: fixed;
    top: 12px; right: 64px;
    z-index: 1000001;
    background: rgba(255,255,255,.15);
    color: #fff;
    border: 1px solid rgba(255,255,255,.3);
    border-radius: 50%;
    width: 44px; height: 44px;
    font-size: 18px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}

/* Prev / Next — fixed to viewport sides, vertically centred */
.meg-lightbox__prev,
.meg-lightbox__next {
    position: fixed;
    top: 50%; transform: translateY(-50%);
    z-index: 1000001;
    background: rgba(0,0,0,.45);
    color: #fff;
    border: 1px solid rgba(255,255,255,.2);
    border-radius: 50%;
    width: 44px; height: 44px;
    font-size: 22px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    -webkit-tap-highlight-color: transparent;
}
.meg-lightbox__prev:active,
.meg-lightbox__next:active { background: rgba(255,255,255,.25); }
.meg-lightbox__prev { left: 6px; }
.meg-lightbox__next { right: 6px; }

.meg-lightbox__caption {
    margin-top: 10px;
    color: rgba(255,255,255,.9);
    font-size: .85rem;
    text-align: center;
    max-width: 100%;
    text-shadow: 0 1px 3px rgba(0,0,0,.6);
    flex-shrink: 0;
}
