/**
 * Filename: style.css
 * Version: 1.12.1
 * Description: Added scoped grid overrides for .upload-page to enforce 3-column layout on Index only.
 */

/* Global Reset */
* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Poppins', sans-serif; }

html { height: 100%; }
body { min-height: 100%; }

/* --- UPLOAD PAGE (Fixed App Layout) --- */
body.upload-page {
    height: 100%;
    overflow: hidden; /* Prevent body scroll, handle internally */
    background: #f0f2f5;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Header Branding - Fixed at top */
.app-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    width: 100%;
    padding: 12px;
    text-align: center;
    color: white;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    flex-shrink: 0; 
    z-index: 20;
}

.app-header .brand {
    font-size: clamp(0.85rem, 3.8vw, 1.1rem);
    font-weight: 700;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Main Wrapper - Takes remaining height */
.main-wrapper {
    width: 100%;
    max-width: 600px; /* Constrain on desktop */
    height: 100%;
    display: flex;
    flex-direction: column;
    background: #f0f2f5;
    position: relative;
}

/* --- COMPACT UPLOAD CONTAINER (Fixed below header) --- */
.upload-container {
    background: white;
    padding: 10px;
    border-bottom: 1px solid #ddd;
    flex-shrink: 0; /* Don't shrink */
    z-index: 10;
}

/* Desktop view - identical to mobile screen app rendering */
@media (min-width: 768px) {
    body.upload-page {
        background: #f0f2f5;
        min-height: 100vh;
        padding: 0;
        display: flex;
        flex-direction: column;
        align-items: center;
    }
    
    .upload-page .app-header {
        display: block;
        width: 100%;
    }

    .main-wrapper {
        background: #f0f2f5;
        border-radius: 0;
        box-shadow: none;
        height: auto;
        min-height: calc(100vh - 50px);
        max-width: 600px;
        width: 100%;
        margin: 0 auto;
    }
    
    .upload-container::before {
        content: none;
    }
}

input[type="file"] { display: none; }

/* COMPACT BUTTON STYLES */
.btn-select.compact-btn {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 10px 15px;
    background: #f8f9fa;
    border: 1px solid #d1d8e0;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    gap: 12px;
}

.btn-select.compact-btn:active {
    background: #e2e6ea;
}

.icon-circle.small {
    width: 32px;
    height: 32px;
    background: #eef2ff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #667eea;
    font-size: 1rem;
}

.btn-text {
    display: flex;
    flex-direction: column;
    text-align: left;
}

.btn-text .primary {
    font-size: 0.95rem;
    font-weight: 600;
    color: #333;
}

.btn-text .secondary {
    font-size: 0.75rem;
    color: #888;
}

.btn-text .red-notif {
    font-size: 0.75rem;
    color: #d24a4a;
}

/* Preview & Action Areas */
.preview-wrapper {
    position: relative;
    margin-bottom: 10px;
}

#image-preview {
    width: 100%;
    max-height: 200px;
    object-fit: contain;
    background: #000;
    border-radius: 8px;
}

.btn-remove {
    position: absolute;
    top: 5px;
    right: 5px;
    background: white;
    color: #333;
    border: none;
    width: 25px;
    height: 25px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.btn-upload {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px;
    width: 100%;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
}

/* Loading */
#loading {
    text-align: center;
    padding: 10px;
}
.spinner {
    width: 25px;
    height: 25px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #764ba2;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 5px;
}

@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* Alerts */
.alert { padding: 8px; border-radius: 6px; margin-bottom: 8px; font-size: 0.85rem; text-align: center;}
.alert.success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert.error { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }

/* --- FEED AREA (Scrollable) --- */
.gallery-section {
    padding: 10px;
    background: #f0f2f5;
    flex: 1; /* Take remaining space */
    overflow-y: auto; /* Internal Scroll */
    -webkit-overflow-scrolling: touch; /* Smooth iOS scroll */
}

@media (min-width: 768px) {
    .gallery-section { background: white; }
}

.section-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding: 0 5px;
}

.gallery-section h3 {
    margin-bottom: 0;
    color: #333;
    font-size: 0.9rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge {
    background: #e0e0e0;
    color: #555;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* --- GRID & CARD STYLES --- */

/* Organic Grid System (Default / Wall) */
.grid { 
    margin: 0 auto; /* Center the grid */
    padding: 10px 0;
}

/* Base Unit: Roughly 260px wide (Used by Wall) */
.grid-sizer, 
.grid-item { 
    width: 48%; /* Fallback for mobile (2 columns with gap) */
    margin-bottom: 10px;
}

@media (min-width: 500px) {
    .grid-sizer, 
    .grid-item { 
        width: 260px; /* Base unit */
        padding: 8px; 
        margin-bottom: 0;
    }
}

/* Asymmetric Modifier (Used by Wall) */
.grid-item--wide {
    width: 100%; /* Mobile full width */
}

@media (min-width: 500px) {
    .grid-item--wide {
        width: 520px; /* 2x base unit */
    }
}

/* --- UPLOAD PAGE OVERRIDES (FORCE 3 COLUMNS) --- */
.upload-page .grid-sizer,
.upload-page .grid-item {
    width: 33.333%; /* Always 3 columns (Mobile & Desktop) */
    padding: 4px;   /* Tighter padding */
    margin-bottom: 0;
}

.upload-page .grid-item--wide {
    width: 33.333%; /* Disable asymmetric sizing on index */
}


/* Photo Card Styling */
.photo-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    transition: transform 0.4s ease;
}

.photo-card:hover { transform: translateY(-5px); z-index: 10; }

.photo-card img {
    width: 100%;
    display: block;
    height: auto;
}

.likes {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(255,255,255,0.95);
    color: #333;
    padding: 6px 14px;
    border-radius: 30px;
    font-size: 0.9rem;
    font-weight: 700;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}
.likes i { color: #e74c3c; }

/* No photos state */
.no-photos {
    width: 100%;
    text-align: center;
    color: #bbb;
    padding: 40px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

/* --- LIGHTBOX --- */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 2000; /* Above everything */
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 10px;
    backdrop-filter: blur(5px);
}

.lightbox.active {
    display: flex;
}

/* Constraints to prevent blowout */
.lightbox img {
    max-width: 95vw;
    max-height: 85vh; /* Take up maximum screen height while leaving space for like button */
    object-fit: contain; /* Keeps aspect ratio within screen */
    border-radius: 6px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.7);
    transition: transform 0.2s ease;
    margin-bottom: 20px;
}

/* Lightbox Like Button */
.lightbox-like-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid white;
    color: white;
    padding: 10px 25px;
    border-radius: 30px;
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: all 0.2s;
    backdrop-filter: blur(5px);
}

.lightbox-like-btn:hover, .lightbox-like-btn:active {
    background: white;
    color: #e74c3c;
    transform: scale(1.05);
}

.lightbox-like-btn i {
    font-size: 1.2rem;
}

/* --- HEART POP ANIMATION --- */
.heart-pop {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    color: white;
    font-size: 3rem;
    z-index: 10;
    text-shadow: 0 0 10px rgba(0,0,0,0.5);
    pointer-events: none; /* Let clicks pass through */
    animation: popFade 0.8s ease-out forwards;
}

@keyframes popFade {
    0% { transform: translate(-50%, -50%) scale(0); opacity: 0; }
    50% { transform: translate(-50%, -50%) scale(1.5); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(2); opacity: 0; }
}

/* --- WALL PAGE SPECIFIC --- */
body.wall-page {
    height: auto;
    overflow-y: auto;
    background: #1a1a1a;
    color: white;
    display: block; /* Reset flex */
}

.wall-page .header {
    padding: 20px 40px;
    background: rgba(0,0,0,0.6);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.wall-page .header h1 {
    font-size: clamp(1.2rem, 4vw, 2.5rem);
    font-weight: 800;
    letter-spacing: -1px;
    text-transform: uppercase;
    word-break: break-word;
}

.wall-page .qr-code { text-align: center; }
.wall-page .qr-code img { height: 100px; width: 100px; border-radius: 8px; border: 3px solid white; box-shadow: 0 4px 15px rgba(0,0,0,0.3); }
.wall-page .qr-code p { font-size: 0.9rem; margin-top: 8px; font-weight: 600; opacity: 0.9; }

/* --- Pinned Photo Visual Cue --- */
.photo-card.pinned {
    border: 2px solid #667eea; /* A distinct border color */
    box-shadow: 0 0 10px rgba(102, 126, 234, 0.5); /* A subtle glow */
    position: relative; /* For absolute positioning of the indicator */
}

.pin-indicator {
    position: absolute;
    top: 5px;
    left: 5px;
    background-color: rgba(102, 126, 234, 0.9); /* Blue background */
    color: white;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 5px;
    z-index: 10; /* Ensure it's above the image */
}

.pin-indicator .fas.fa-thumbtack {
    font-size: 0.8rem;
}

/* --- DATA & PRIVACY STATEMENT PAGE --- */
body.privacy-page {
    font-family: 'Poppins', sans-serif;
    background-color: #f0f2f5;
    color: #333;
    line-height: 1.6;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
}

.privacy-container {
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    max-width: 800px;
    width: 100%;
}

.privacy-container h1 {
    color: #34495e;
    margin-bottom: 20px;
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 10px;
}

.privacy-container h4 {
    color: #555;
    margin-top: 25px;
    margin-bottom: 10px;
}

.privacy-container ul {
    list-style-type: disc;
    margin-left: 20px;
    margin-bottom: 15px;
}

.privacy-container ul li {
    margin-bottom: 5px;
}

.privacy-container p {
    margin-bottom: 15px;
}

/* Back link for privacy page */
.back-link {
    display: inline-block;
    margin-top: 20px;
    padding: 10px 15px;
    background-color: #667eea;
    color: white;
    text-decoration: none;
    border-radius: 8px;
    transition: background-color 0.3s ease;
}

.back-link:hover {
    background-color: #5a67d8;
}

/* --- PRIVACY WATERMARK --- */
#privacy-watermark {
    position: fixed;
    bottom: 10px;
    left: 10px;
    font-size: 10px;
    color: #aaa;
    opacity: 0.6;
    cursor: pointer;
    z-index: 1000;
}