/* ================================================================
   PhotoShare — Light Mode UI
   ================================================================ */

/* ── Reset & Base ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg-deep:      #f7fbf7;
    --bg-dark:      #edf6ee;
    --bg-card:      rgba(255,255,255,0.82);
    --bg-card-hov:  rgba(255,255,255,0.97);
    --border:       rgba(60,140,70,0.14);
    --border-hov:   rgba(60,140,70,0.45);
    --accent:       #2e7d35;
    --accent-light: #acd8b0;
    --accent-glow:  rgba(46,125,53,0.18);
    --accent2:      #4caf50;
    --text-primary: #111f12;
    --text-muted:   #3d5e3f;
    --text-faint:   #7a9e7c;
    --success:      #16a34a;
    --danger:       #dc2626;
    --radius-sm:    8px;
    --radius-md:    16px;
    --radius-lg:    24px;
    --shadow-card:  0 2px 16px rgba(30,80,35,0.08), 0 1px 3px rgba(30,80,35,0.06);
    --shadow-glow:  0 0 40px var(--accent-glow);
    --transition:   0.25s ease;
    --font:         'Inter', system-ui, sans-serif;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
    font-family: var(--font);
    background: var(--bg-deep);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent2); }

/* ── Background particles ─────────────────────────────────────── */
.bg-particles {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}
.bg-particles span {
    position: absolute;
    width: 400px;
    height: 400px;
    border-radius: 50%;
    filter: blur(110px);
    opacity: 0.10;
    animation: drift 20s infinite alternate ease-in-out;
}
.bg-particles span:nth-child(1){background:#acd8b0;top:-80px;left:-80px;animation-duration:18s;}
.bg-particles span:nth-child(2){background:#6aad70;top:40%;right:-100px;animation-duration:22s;animation-delay:-5s;}
.bg-particles span:nth-child(3){background:#c5e8c8;bottom:-80px;left:30%;animation-duration:25s;animation-delay:-10s;}
.bg-particles span:nth-child(4){background:#4a9e55;top:20%;left:50%;animation-duration:19s;animation-delay:-7s;}
.bg-particles span:nth-child(5){background:#3d8a48;bottom:20%;right:20%;animation-duration:28s;animation-delay:-3s;}

@keyframes drift {
    0%   { transform: translate(0,0) scale(1); }
    100% { transform: translate(40px,30px) scale(1.15); }
}

/* ── Glassmorphism card ───────────────────────────────────────── */
.glass {
    background: var(--bg-card);
    backdrop-filter: blur(12px) saturate(1.2);
    -webkit-backdrop-filter: blur(12px) saturate(1.2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
}

/* ── Site Header ──────────────────────────────────────────────── */
.site-header {
    position: relative;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 40px;
    background: rgba(255,255,255,0.88);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 0 rgba(60,140,70,0.08);
}
.logo img {
    filter: brightness(0) saturate(100%) invert(28%) sepia(40%) saturate(500%) hue-rotate(100deg);
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

nav { display: flex; gap: 8px; }

.nav-link {
    padding: 7px 18px;
    border-radius: 50px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: var(--transition);
    border: 1px solid transparent;
}
.nav-link:hover {
    color: var(--text-primary);
    background: var(--bg-card);
    border-color: var(--border);
}
.nav-link.active {
    color: var(--accent);
    background: rgba(60,140,70,0.12);
    border-color: rgba(60,140,70,0.30);
}

/* ── Upload Page Layout ───────────────────────────────────────── */
.upload-page .main-container {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 73px);
    padding: 40px 20px;
}

.upload-card {
    width: 100%;
    max-width: 520px;
    padding: 40px;
}

.upload-title {
    font-size: 1.8rem;
    font-weight: 700;
    text-align: center;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 6px;
}

.upload-subtitle {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 28px;
}

/* ── Drop Zone ────────────────────────────────────────────────── */
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-md);
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}
.drop-zone:hover,
.drop-zone.drag-over {
    border-color: var(--accent);
    background: rgba(60,140,70,0.06);
    box-shadow: 0 0 20px var(--accent-glow);
}

.drop-icon {
    color: var(--text-faint);
    margin-bottom: 14px;
    transition: var(--transition);
}
.drop-zone:hover .drop-icon,
.drop-zone.drag-over .drop-icon { color: var(--accent); }

.drop-text {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 6px;
}
.drop-or {
    color: var(--text-faint);
    font-size: 0.8rem;
    margin: 10px 0;
}

.btn-browse {
    display: inline-block;
    padding: 9px 24px;
    background: rgba(60,140,70,0.10);
    border: 1px solid rgba(60,140,70,0.30);
    border-radius: 50px;
    color: var(--accent);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}
.btn-browse:hover {
    background: rgba(60,140,70,0.18);
    border-color: var(--accent);
}

/* ── Image Preview ────────────────────────────────────────────── */
.preview-wrapper {
    margin-top: 20px;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border);
    position: relative;
}

.image-preview {
    display: block;
    width: 100%;
    max-height: 240px;
    object-fit: cover;
}

.preview-info {
    display: flex;
    justify-content: space-between;
    padding: 10px 14px;
    background: rgba(60,140,70,0.06);
}
.preview-name {
    font-size: 0.8rem;
    color: var(--text-muted);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.preview-size {
    font-size: 0.8rem;
    color: var(--text-faint);
}

.btn-remove {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(255,255,255,0.70);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}
.btn-remove:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

/* ── Progress Bar ─────────────────────────────────────────────── */
.progress-wrapper { margin-top: 20px; }

.progress-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.progress-track {
    height: 6px;
    background: rgba(60,140,70,0.12);
    border-radius: 50px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 0%;
    border-radius: 50px;
    background: linear-gradient(90deg, var(--accent), var(--accent2));
    transition: width 0.2s ease;
    box-shadow: 0 0 10px var(--accent-glow);
}

/* ── Alerts ───────────────────────────────────────────────────── */
.alert {
    margin-top: 16px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
}
.alert-error {
    background: rgba(220,38,38,0.08);
    border: 1px solid rgba(220,38,38,0.25);
    color: #b91c1c;
}

/* ── Success State ────────────────────────────────────────────── */
.success-state {
    text-align: center;
    padding: 20px 0;
    animation: fadeInUp 0.5s ease;
}

.success-icon { display: flex; justify-content: center; margin-bottom: 16px; }

.checkmark {
    width: 64px;
    height: 64px;
}
.checkmark-circle {
    stroke: var(--success);
    stroke-dasharray: 166;
    stroke-dashoffset: 166;
    stroke-width: 2;
    animation: stroke 0.6s cubic-bezier(0.65,0,0.45,1) forwards;
}
.checkmark-path {
    stroke: var(--success);
    stroke-dasharray: 48;
    stroke-dashoffset: 48;
    stroke-width: 3;
    animation: stroke 0.4s cubic-bezier(0.65,0,0.45,1) 0.6s forwards;
}
@keyframes stroke {
    100% { stroke-dashoffset: 0; }
}

.success-msg {
    color: var(--success);
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 20px;
}

.success-actions { display: flex; gap: 12px; justify-content: center; }

/* ── Buttons ──────────────────────────────────────────────────── */
.btn-upload {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    margin-top: 24px;
    padding: 14px;
    border: none;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    color: #fff;
    font-family: var(--font);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 4px 20px rgba(60,140,70,0.30);
}
.btn-upload:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 28px rgba(60,140,70,0.45);
}
.btn-upload:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 22px;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    color: #fff;
    border: none;
    border-radius: 50px;
    font-family: var(--font);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}
.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(60,140,70,0.30);
    color: #fff;
}

.btn-secondary {
    padding: 10px 22px;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: 50px;
    font-family: var(--font);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}
.btn-secondary:hover {
    color: var(--text-primary);
    border-color: var(--text-muted);
}

.btn-full { width: 100%; justify-content: center; border-radius: var(--radius-sm); }

/* ── Gallery Page ─────────────────────────────────────────────── */
.gallery-page .gallery-main {
    position: relative;
    z-index: 1;
    max-width: 1400px;
    margin: 0 auto;
    padding: 40px 30px 80px;
}

.gallery-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 32px;
}

.gallery-header h1 {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--text-primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.live-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    background: rgba(22,163,74,0.10);
    border: 1px solid rgba(22,163,74,0.25);
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #15803d;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.live-dot {
    width: 7px;
    height: 7px;
    background: var(--success);
    border-radius: 50%;
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0%,100% { opacity: 1; transform: scale(1); }
    50%      { opacity: 0.4; transform: scale(0.8); }
}

/* ── Gallery Grid ─────────────────────────────────────────────── */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 20px;
}

.gallery-item {
    overflow: hidden;
    cursor: pointer;
    transition: var(--transition);
    animation: fadeInUp 0.4s ease;
    background: #fff;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    box-shadow: 0 1px 4px rgba(30,80,35,0.07);
}
.gallery-item:hover {
    transform: translateY(-4px);
    border-color: var(--border-hov);
    box-shadow: 0 8px 28px rgba(30,80,35,0.14);
}

.gallery-img-wrap {
    position: relative;
    aspect-ratio: 1;
    overflow: hidden;
}

.gallery-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.4s ease;
}
.gallery-item:hover .gallery-img { transform: scale(1.07); }

.gallery-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.32);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: var(--transition);
    backdrop-filter: blur(2px);
}
.gallery-item:hover .gallery-overlay { opacity: 1; }

.btn-view {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255,255,255,0.30);
    border: 2px solid rgba(255,255,255,0.70);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    transform: scale(0.8);
}
.gallery-item:hover .btn-view { transform: scale(1); }
.btn-view:hover { background: var(--accent); }

.gallery-meta {
    padding: 10px 14px;
    background: #fff;
}
.gallery-filename {
    font-size: 0.75rem;
    color: var(--text-faint);
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* New image badge animation */
.gallery-item.new-upload {
    animation: newPop 0.6s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes newPop {
    0%   { transform: scale(0.6) translateY(20px); opacity: 0; }
    100% { transform: scale(1) translateY(0); opacity: 1; }
}

/* ── Empty State ──────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-faint);
}
.empty-state svg { margin-bottom: 20px; opacity: 0.3; }
.empty-state p { font-size: 1rem; }

/* ── Image count ──────────────────────────────────────────────── */
.image-count {
    margin-top: 28px;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-faint);
}

/* ── Modal ────────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10,30,12,0.50);
    backdrop-filter: blur(6px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
.modal-overlay.open {
    opacity: 1;
    pointer-events: all;
}

.modal {
    width: 100%;
    max-width: 880px;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: var(--radius-lg);
    transform: scale(0.9) translateY(20px);
    transition: transform 0.35s cubic-bezier(0.34,1.56,0.64,1);
    position: relative;
}
.modal-overlay.open .modal { transform: scale(1) translateY(0); }

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 10;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,0.60);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}
.modal-close:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

.modal-body {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 0;
}

.modal-img-wrap {
    max-height: 80vh;
    overflow: hidden;
    border-radius: var(--radius-lg) 0 0 var(--radius-lg);
}
.modal-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #f0f7f1;
    display: block;
}

.modal-sidebar {
    padding: 32px 24px;
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.modal-filename {
    font-size: 0.875rem;
    color: var(--text-muted);
    word-break: break-all;
    font-weight: 500;
}

.qr-box {
    background: rgba(60,140,70,0.06);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    text-align: center;
}
.qr-label {
    font-size: 0.75rem;
    color: var(--text-faint);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.qr-img {
    width: 180px;
    height: 180px;
    border-radius: var(--radius-sm);
    display: block;
    margin: 0 auto;
    background: #fff;
}

/* ── Pagination ───────────────────────────────────────────────── */
.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 14px;
    margin-top: 36px;
    padding: 16px 20px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-page {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 8px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 50px;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    text-decoration: none;
    transition: var(--transition);
}
.btn-page:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(60,140,70,0.08);
}

.page-numbers {
    display: flex;
    align-items: center;
    gap: 4px;
}

.btn-page-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    text-decoration: none;
    transition: var(--transition);
}
.btn-page-num:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(60,140,70,0.08);
}
.btn-page-num.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    font-weight: 700;
    box-shadow: 0 0 12px rgba(60,140,70,0.30);
}

/* ── Animations ───────────────────────────────────────────────── */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 720px) {
    .site-header { padding: 14px 20px; }
    .upload-card  { padding: 28px 20px; }
    .gallery-main { padding: 24px 16px 60px; }
    .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }

    .modal-body {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto;
    }
    .modal-img-wrap { border-radius: var(--radius-lg) var(--radius-lg) 0 0; max-height: 55vw; }
    .modal-sidebar  { border-left: none; border-top: 1px solid var(--border); padding: 20px; }
}
