@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@600;700;800&display=swap');

:root {
    /* Modern Palette - Light & Airy */
    /* Primary: Soft Violet/Indigo Gradient */
    --primary-color: #6366f1;
    --primary-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    --secondary-color: #ec4899;

    /* Backgrounds */
    --bg-color: #f8fafc;
    --bg-gradient: linear-gradient(120deg, #fdfbfb 0%, #ebedee 100%);
    /* Subtle subtle */
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.5);

    /* Text */
    --text-main: #1e293b;
    --text-body: #475569;
    --text-muted: #94a3b8;

    /* Shapes */
    --border-radius-xl: 32px;
    --border-radius-lg: 24px;
    --border-radius-md: 16px;

    /* Shadows */
    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 10px 30px -5px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 20px 40px -10px rgba(99, 102, 241, 0.15);
    /* Tinted shadow */
    --shadow-inner: inset 0 2px 4px 0 rgba(0, 0, 0, 0.02);

    --font-family: 'Outfit', sans-serif;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html {
    height: 100%;
    overflow-x: hidden;
}

body {
    font-family: var(--font-family);
    background: #f0f4f8;
    /* Fallback */
    background-image:
        radial-gradient(at 0% 0%, hsla(253, 16%, 7%, 0) 0, hsla(253, 16%, 7%, 0) 50%),
        radial-gradient(at 50% 0%, hsla(225, 39%, 30%, 0) 0, hsla(225, 39%, 30%, 0) 50%),
        radial-gradient(at 100% 0%, hsla(339, 49%, 30%, 0) 0, hsla(339, 49%, 30%, 0) 50%);
    background-color: #f3f4f6;
    color: var(--text-main);
    min-height: 100vh;
    line-height: 1.6;
    position: relative;
    /* Ensure blobs stay within */
}

/* Background blob effects (Optional styling via pseudo-elements later if needed) */
body::before {
    content: '';
    position: fixed;
    top: -20%;
    left: -10%;
    width: 60%;
    height: 60%;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.15) 0%, rgba(255, 255, 255, 0) 70%);
    z-index: -1;
    animation: float 20s infinite ease-in-out;
}

body::after {
    content: '';
    position: fixed;
    bottom: -10%;
    right: -10%;
    width: 50%;
    height: 50%;
    background: radial-gradient(circle, rgba(236, 72, 153, 0.1) 0%, rgba(255, 255, 255, 0) 70%);
    z-index: -1;
    animation: float 15s infinite ease-in-out reverse;
}

/* --- Stylish Scrollbars --- */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.02);
}

::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, 0.2);
    border-radius: 99px;
    border: 2px solid transparent;
    background-clip: content-box;
    transition: background 0.3s;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(99, 102, 241, 0.5);
    border: 2px solid transparent;
    background-clip: content-box;
}

@keyframes float {

    0%,
    100% {
        transform: translate(0, 0);
    }

    50% {
        transform: translate(20px, 40px);
    }
}

/* --- Typography --- */
h1,
h2,
h3 {
    font-family: 'Playfair Display', serif;
    letter-spacing: -0.01em;
    color: #0f172a;
    /* Deep Slate */
}

/* --- Header --- */
/* --- Header --- */
.main-header {
    position: sticky;
    top: 0;
    /* Sticky to top */
    width: 100%;
    /* FULL WIDTH */
    z-index: 50;
    background: #ffffff;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid #e5e7eb;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: #4f46e5;
    letter-spacing: -0.5px;
}

.logo span {
    color: #1f2937;
    font-weight: 400;
}

.main-header nav {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.nav-btn {
    padding: 0.6rem 1.25rem;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.9rem;
    border: 1px solid transparent;
    transition: all 0.2s ease;
    cursor: pointer;
    background: transparent;
    color: #4b5563;
}

.nav-btn:hover {
    background: #f9fafb;
    color: #111827;
}

.gallery-nav-active {
    background: #e0e7ff !important;
    color: #4338ca !important;
    border: 1px solid #c7d2fe !important;
    font-weight: 600;
}

/* Main Content Area - ADAPTIVE FULL WIDTH */
main {
    width: 100%;
    max-width: 100%;
    /* Ensure no constraint */
    margin: 0;
    padding: 2rem 3rem;
    /* Spacious sides */
    /* Spacious sides */
}

/* Mobile Admin Adjustments */
/* Mobile Admin Adjustments */
@media (max-width: 640px) {
    .main-header {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }

    .main-header nav {
        width: 100%;
        overflow-x: auto;
        padding-bottom: 5px;
        /* Scrollbar space */
        justify-content: center;
    }

    main {
        padding: 1rem !important;
        overflow-x: hidden;
        /* Prevent horizontal scroll from breakout */
    }

    .feed-container {
        grid-template-columns: 1fr;
        /* Single column */
    }

    .gallery-grid-admin {
        grid-template-columns: 1fr !important;
        /* Single column for better visibility */
        gap: 16px;
    }

    .gallery-item-admin {
        aspect-ratio: 4 / 3;
        /* Slightly rectangular for better photo view */
        width: 100%;
    }

    /* Keep header title top, actions below */
    .gallery-group-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.8rem;
        padding-left: 1rem;
        padding-right: 1rem;
    }

    /* Actions horizontal */
    .gallery-group-actions {
        width: 100%;
        display: flex;
        flex-direction: row;
        /* Horizontal */
        flex-wrap: wrap;
        /* Wrap if needed but try row */
        gap: 8px;
        padding-left: 1rem;
        padding-right: 1rem;
        margin-bottom: 1rem;
        /* Spacing before grid */
    }

    .btn-add-group,
    .btn-edit,
    .btn-delete-group,
    .btn-clear-photos {
        flex: 1;
        /* Distribute space */
        min-width: fit-content;
        padding: 0.6rem 0.5rem;
        font-size: 0.8rem;
        /* Smaller text to fit */
        justify-content: center;
    }

    /* Full width album card on mobile */
    /* Full width album card on mobile - Robust Breakout */
    .gallery-group-card {
        width: 100vw !important;
        position: relative;
        left: 50%;
        right: 50%;
        margin-left: -50vw !important;
        margin-right: -50vw !important;
        border-radius: 0 !important;
        border-left: none !important;
        border-right: none !important;
        padding: 1.5rem 0 !important;
        /* No side padding on card itself, handled by inner elements */
        /* Add horizontal padding back to keep content safe */
        box-shadow: none !important;
        border-bottom: 8px solid #f1f5f9;
        /* Thicker divider */
        margin-bottom: 0 !important;
        background: white;
    }

    /* Ensure styles inside usage of padding */
    .gallery-grid-admin {
        padding: 0 1rem;
        /* Add padding to grid so images don't touch edges */
    }
}

/* Feed Container */
.feed-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    /* Clean Grid */
    gap: 1.5rem;
}

/* Card Styling Update */
.card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
    overflow: hidden;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    border-color: #d1d5db;
}

.card-image {
    width: 100%;
    height: 180px;
    object-fit: cover;
    border-radius: 8px;
    margin: 1rem 0;
}

.card-title {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: #111827;
    line-height: 1.4;
}

.card-story {
    font-size: 0.95rem;
    color: #4b5563;
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-header {
    display: flex;
    align-items: center;
    margin-bottom: 1rem;
}

.author-circle {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.8rem;
    margin-right: 0.75rem;
}

.meta-info {
    display: flex;
    flex-direction: column;
}

.author-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: #374151;
}

.post-date {
    font-size: 0.75rem;
    color: #9ca3af;
}

/* --- Editor Panel (Fixed Centered Modal) --- */
.editor-panel {
    position: fixed;
    inset: 0;
    /* Full screen */
    z-index: 9999;
    /* Highest priority */
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease;
}

.editor-panel:not(.hidden) {
    opacity: 1;
    pointer-events: auto;
}

.editor-card {
    width: 100%;
    max-width: 600px;
    background: white;
    border-radius: 28px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    max-height: 85vh;
    animation: bounceIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 1px solid rgba(255, 255, 255, 0.5);
}

@keyframes bounceIn {
    from {
        transform: scale(0.9) translateY(20px);
        opacity: 0;
    }

    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

.editor-header {
    padding: 1.5rem 2rem;
    border-bottom: 2px solid #f1f5f9;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    border-radius: 28px 28px 0 0;
    flex-shrink: 0;
    /* Never shrink header */
}

.editor-header h2 {
    font-size: 1.75rem;
    font-weight: 800;
    background: linear-gradient(135deg, #4f46e5 0%, #ec4899 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 0;
    letter-spacing: -0.5px;
}

/* Vibrant Close Button */
.icon-btn {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: none;
    background: #f1f5f9;
    color: #475569;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 1.25rem;
}

.icon-btn:hover {
    background: #ef4444;
    color: white;
    transform: rotate(90deg) scale(1.1);
    box-shadow: 0 10px 15px -3px rgba(239, 68, 68, 0.3);
}

/* Scrollable Form Area with Custom Scrollbar */
.editor-card form {
    padding: 2rem;
    overflow-y: auto;
    flex-grow: 1;
}

/* Custom Scrollbar for Form */
.editor-card form::-webkit-scrollbar {
    width: 8px;
}

.editor-card form::-webkit-scrollbar-track {
    background: transparent;
}

.editor-card form::-webkit-scrollbar-thumb {
    background-color: #cbd5e1;
    border-radius: 20px;
    border: 3px solid transparent;
    background-clip: content-box;
}

/* Vibrant Inputs */
.form-group label {
    color: #334155;
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-control,
.form-group input[type="text"],
.form-group textarea {
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 16px;
    padding: 1.1rem 1.25rem;
    font-size: 1.05rem;
    color: #1e293b;
    transition: all 0.2s ease;
    width: 100%;
    font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus {
    background: white;
    border-color: #6366f1;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15);
    outline: none;
    transform: translateY(-1px);
}

/* Photo Upload Fancy */
.image-upload-label {
    background: #f8fafc;
    border: 2px dashed #cbd5e1;
    border-radius: 16px;
    padding: 2rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    justify-content: center;
    min-height: 180px;
}

.image-upload-label:hover {
    background: #f0fdfa;
    border-color: #6366f1;
    transform: translateY(-2px);
}

.icon-box {
    width: 56px;
    height: 56px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: #6366f1;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.image-upload-label:hover .icon-box {
    background: #6366f1;
    color: white;
    transform: scale(1.1);
}

/* HIDE the upload box when preview is active */
/* We use the sibling selector or JS toggle. 
   Since JS toggles 'hidden' on preview, we can use :not(.hidden) logic or just handle it in JS. 
   BUT User wants it "properly" set.
   Let's add a class 'has-preview' to the parent container via JS, OR
   Use the fact that they are siblings.
   
   Better approach: When preview is visible, hide the label.
*/
/* HIDE the upload box when preview is active */
.form-group:has(#gallery-preview-container:not(.hidden)) .image-upload-label {
    display: none !important;
}

/* Previews & Image Controls */
#image-preview-container,
#gallery-preview-container {
    margin-top: 1.5rem;
    position: relative;
    width: 100%;
    animation: fadeUp 0.3s ease;
    display: flex !important;
    /* Force flex */
    visibility: visible !important;
    opacity: 1 !important;
    min-height: 120px;
    /* Ensure height */
    flex-direction: column;
    align-items: center;
    background: #f8fafc;
    padding: 1.5rem 1rem;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    z-index: 100;
}

/* The Change Button Style */
.btn-change-photo {
    background: #eff6ff !important;
    /* Light Indigo */
    color: #4f46e5 !important;
    border: 1px solid #c7d2fe !important;
    padding: 0.75rem 1.25rem !important;
    border-radius: 10px !important;
    font-weight: 700 !important;
    font-size: 0.95rem !important;
    cursor: pointer !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 0.5rem !important;
    transition: all 0.2s ease !important;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05) !important;
}

.btn-change-photo:hover {
    background: #4f46e5 !important;
    color: white !important;
    transform: translateY(-2px);
}

/* Fallback for older browsers if :has isn't supported, 
   we will add a specific class in JS as well in next step. */
.upload-box-hidden {
    display: none !important;
}

/* Previews & Image Controls */
#image-preview-container,
#gallery-preview-container {
    margin-top: 1.5rem;
    position: relative;
    width: 100%;
    animation: fadeUp 0.3s ease;
    display: flex !important;
    /* Force flex to override hidden */
    visibility: visible !important;
    opacity: 1 !important;
    flex-direction: column;
    align-items: center;
    background: #f8fafc;
    padding: 1rem;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    z-index: 100;
    /* Ensure on top */
}

#image-preview {
    width: 100%;
    max-height: 250px;
    object-fit: cover;
    border-radius: 8px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    display: block;
    margin-bottom: 1rem;
    /* Space for buttons */
}

/* Remove 'X' button in corner since we have Replace/Remove below now? 
   Actually, keep it as quick remove, but the new buttons are primary. */
#remove-image-btn {
    position: absolute;
    top: -10px;
    right: -10px;
    background: #ef4444;
    /* Red for remove */
    color: white;
    border: 2px solid white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

#gallery-previews {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-top: 1rem;
    padding: 12px;
    background: #f1f5f9;
    border-radius: 16px;
    width: 100%;
}

.gallery-preview-item {
    width: 100%;
    aspect-ratio: 3/2;
    object-fit: cover;
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    border: 2px solid white;
    transition: transform 0.2s;
}

.gallery-preview-item:hover {
    transform: scale(1.02);
}

/* Mobile Adaptation */
@media (max-width: 640px) {
    .editor-panel {
        padding: 0;
        align-items: flex-end;
        /* Bottom sheet on mobile */
    }

    .editor-card {
        border-radius: 24px 24px 0 0;
        max-height: 90vh;
        /* Leave top gap */
        transform: translateY(100%);
    }

    .editor-panel:not(.hidden) .editor-card {
        transform: translateY(0);
    }
}

.form-group {
    margin-bottom: 1.75rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text-main);
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 1.25rem;
    border: 2px solid transparent;
    /* No border default */
    border-radius: var(--border-radius-md);
    background: white;
    box-shadow: var(--shadow-sm);
    font-family: inherit;
    font-size: 1.1rem;
    color: var(--text-main);
    transition: var(--transition);
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15);
    background: white;
}

/* Image Upload (Dashed) */
.image-upload-label {
    width: 100%;
    /* FULL WIDTH */
    border: 3px dashed #cbd5e1;
    border-radius: var(--border-radius-md);
    padding: 2.5rem;
    text-align: center;
    cursor: pointer;
    background: #f8fafc;
    transition: var(--transition);
    color: var(--text-muted);
    font-weight: 500;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    min-height: 200px;
    box-sizing: border-box;
    /* IMPORTANT */
}

.image-upload-label:hover {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.05);
    color: var(--primary-color);
    transform: translateY(-2px);
}

.image-upload-label input {
    display: none;
}

/* Submit Button */
/* Submit Button - Vibrant */
.submit-btn {
    width: 100%;
    padding: 1.25rem;
    background: linear-gradient(to right, #6366f1, #8b5cf6);
    color: white;
    border: none;
    border-radius: 16px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 10px 20px -5px rgba(99, 102, 241, 0.3);
    transition: all 0.2s;
    margin-top: 2rem;
}

.submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 30px -5px rgba(139, 92, 246, 0.4);
    filter: brightness(1.05);
}

.submit-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
    filter: grayscale(1);
}

/* Delete Button (News Section) */
.btn-delete-post {
    padding: 8px 16px;
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 4px 6px -1px rgba(239, 68, 68, 0.2);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-delete-post:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 10px 15px -3px rgba(220, 38, 38, 0.3);
    background: linear-gradient(135deg, #f87171 0%, #ef4444 100%);
}

.btn-delete-post:active {
    transform: scale(0.95);
}

/* --- Utilities --- */
/* FAB (Add Button) - Modern Squircle */
.fab {
    position: fixed;
    bottom: 2.5rem;
    right: 2.5rem;
    width: 64px;
    height: 64px;
    border-radius: 22px;
    /* Squircle */
    background: linear-gradient(135deg, #4f46e5 0%, #ec4899 100%);
    /* Indigo -> Pink */
    color: white !important;
    /* Ensure icon is white */
    border: none;
    box-shadow: 0 15px 35px -5px rgba(79, 70, 229, 0.45);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 900;
    /* High z-index */
}

.fab:hover {
    transform: translateY(-6px) scale(1.05);
    box-shadow: 0 25px 50px -10px rgba(236, 72, 153, 0.5);
}

.fab svg {
    width: 28px;
    height: 28px;
    stroke-width: 2.5px;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(99, 102, 241, 0.1);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 4rem auto;
}

@keyframes spin {
    100% {
        transform: rotate(360deg);
    }
}

.hidden {
    display: none !important;
}

.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(30, 41, 59, 0.9);
    color: white;
    padding: 1rem 2rem;
    border-radius: 99px;
    font-weight: 600;
    box-shadow: var(--shadow-lg);
    z-index: 2000;
    backdrop-filter: blur(8px);
    animation: toastSlide 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes toastSlide {
    from {
        transform: translate(-50%, 100%);
        opacity: 0;
    }

    to {
        transform: translate(-50%, 0);
        opacity: 1;
    }
}

@media (max-width: 640px) {
    .main-header {
        width: 95%;
        padding: 0.75rem 1rem;
        top: 0.5rem;
    }

    .card-image {
        height: 200px;
    }

    .fab {
        width: 60px;
        height: 60px;
    }

    .editor-panel {
        padding: 1.5rem 1rem;
    }
}

/* --- Image Preview Widget --- */
#image-preview-container {
    margin-top: 1.5rem;
    position: relative;
    width: 100%;
    animation: fadeUp 0.3s ease;
}

#image-preview {
    width: 100%;
    max-height: 250px;
    /* Limit height so it doesn't take over screen */
    object-fit: cover;
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-md);
    display: block;
}

#remove-image-btn {
    position: absolute;
    top: -12px;
    right: -12px;
    background: var(--secondary-color);
    color: white;
    border: 2px solid white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

#remove-image-btn:hover {
    transform: scale(1.1);
    background: #be123c;
}

/* Ensure mobile scrolling is smooth */
@media (max-width: 1200px) {
    .feed-container {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 850px) {
    .feed-container {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 640px) {
    .main-header {
        width: 95%;
        padding: 0.75rem 1rem;
        top: 0.5rem;
    }

    .card-image {
        height: 180px;
    }

    .fab {
        width: 60px;
        height: 60px;
    }

    .editor-panel {
        padding-bottom: 5rem;
    }

    .feed-container {
        grid-template-columns: 1fr;
        /* Single column on mobile */
    }
}

/* --- Single Post View (post.html) --- */

/* --- Admin Gallery Manager Styles --- */
.gallery-group-card {
    background: white;
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    border: 1px solid #e2e8f0;
}

.gallery-group-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #f1f5f9;
}

.gallery-group-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 0.25rem;
}

.gallery-count {
    font-size: 0.85rem;
    color: #94a3b8;
    font-weight: 500;
}

.gallery-group-actions {
    display: flex;
    gap: 0.75rem;
}

.btn-edit,
.btn-delete-group {
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.btn-edit {
    background: #eff6ff;
    color: #3b82f6;
}

.btn-edit:hover {
    background: #dbeafe;
    color: #2563eb;
}

.btn-delete-group {
    background: #fef2f2;
    color: #ef4444;
}

.btn-delete-group:hover {
    background: #fee2e2;
    color: #dc2626;
}



.delete-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
    cursor: pointer;
    color: white;
    backdrop-filter: blur(2px);
}

.gallery-item-admin:hover .delete-overlay {
    opacity: 1;
}

.delete-overlay svg {
    background: rgba(239, 68, 68, 0.9);
    padding: 6px;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s;
}

.delete-overlay:hover svg {
    transform: scale(1.1);
    background: #dc2626;
}

.single-post-card {
    background: white;
    border-radius: var(--border-radius-xl);
    padding: 3rem;
    max-width: 900px;
    margin: 0 auto;
    box-shadow: var(--shadow-lg);
}

.post-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 1.5rem;
}

.nav-arrow {
    background: white;
    border: 1px solid #e2e8f0;
    padding: 0.5rem 1.25rem;
    border-radius: 99px;
    color: var(--text-main);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.9rem;
}

.nav-arrow:hover:not(.disabled) {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: #f5f3ff;
}

.nav-arrow.disabled {
    opacity: 0.5;
    cursor: default;
    background: #f8fafc;
}

.nav-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    font-weight: 700;
}

.large-header {
    margin-bottom: 1.5rem;
}

.large-circle {
    width: 48px;
    height: 48px;
    font-size: 1.25rem;
}

.large-title {
    font-family: 'Playfair Display', serif;
    font-size: 3rem;
    line-height: 1.1;
    margin-bottom: 2rem;
    background: linear-gradient(135deg, #1e3a8a 0%, #06b6d4 100%);
    /* Royal Blue to Cyan */
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 800;
}

.fullscreen-image-container {
    width: 100%;
    margin-bottom: 2.5rem;
    border-radius: var(--border-radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.large-post-image {
    width: auto;
    max-width: 100%;
    height: auto;
    max-height: 80vh;
    /* Fit within screen height */
    object-fit: contain;
    /* Show FULL image, no cropping */
    display: block;
    margin: 0 auto;
    /* Center it */
    border-radius: var(--border-radius-md);
}

.large-story {
    font-size: 1.15rem;
    line-height: 1.8;
    color: var(--text-body);
}

@media (max-width: 768px) {
    .single-post-card {
        padding: 1.5rem;
        background: transparent;
        /* Seamless on mobile */
        box-shadow: none;
    }

    .large-title {
        font-size: 2rem;
    }

    .large-post-image {
        max-height: 400px;
    }
}

/* --- Photo Gallery Section (User Requested Clone) --- */
.photo-section {
    background-color: #e9e9e9;
    max-width: 1500px;
    margin: 100px auto;
    padding: 2rem 30px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.section-heading {
    text-align: center;
    font-size: 1.8rem;
    margin-bottom: 2rem;
    color: #ff0000;
    font-weight: 600;
}

.section-heading::after {
    display: none;
}

.rows-container {
    display: block;
    max-width: 100%;
}

.group-heading {
    font-size: 1.8rem;
    margin: 30px 0 15px;
    color: #34495e;
    font-weight: 600;
    border-left: 5px solid #3498db;
    padding-left: 15px;
    display: block;
    height: auto;
}

/* Each row block with heading and photos */
.photo-row-block {
    margin-bottom: 50px;
}

/* The photo row with images horizontally */
.photo-row {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: nowrap;
}

/* New Image Styles - DIRECT IMG TAGS */
.photo-row img {
    width: 18%;
    /* Five photos horizontally */
    border-radius: 10px;
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
    height: 200px;
    /* Added fixed height for consistency */
    object-fit: cover;
}

.photo-row img:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 25px rgba(0, 0, 0, 0.18);
}

/* Responsive adjustments */
@media (max-width: 900px) {
    .photo-row {
        flex-wrap: wrap;
    }

    .photo-row img {
        width: 45%;
        /* 2 photos per row */
        margin-bottom: 15px;
    }
}

@media (max-width: 480px) {
    .photo-row img {
        width: 100%;
        /* 1 photo per row */
    }
}

/* Clean up old styles */
.gallery-img-card,
.gallery-img-card:hover,
.gallery-img-card img,
.gallery-img-card:hover img {
    all: unset;
    display: none;
}

.group-heading span.count {
    display: none;
}

/* Admin Gallery Grid */
/* Admin Gallery Grid Container (Holds Group Cards) */
.gallery-grid {
    display: flex;
    flex-direction: column;
    gap: 3rem;
    padding: 1.5rem;
    width: 100%;
}

.gallery-item {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    aspect-ratio: 1;
    box-shadow: var(--shadow-md);
    background: white;
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gallery-item-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 0.75rem;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
    color: white;
    font-size: 0.8rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.gallery-delete-btn {
    background: white;
    color: #ef4444;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

/* --- Custom Modal --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 50000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    animation: fadeIn 0.3s forwards;
}

.modal-container {
    background: white;
    width: 90%;
    max-width: 400px;
    border-radius: 20px;
    padding: 1.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    transform: scale(0.95);
    animation: popIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes fadeIn {
    to {
        opacity: 1;
    }
}

@keyframes popIn {
    to {
        transform: scale(1);
    }
}

.modal-header h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1.25rem;
    color: var(--text-main);
}

.modal-body {
    margin-bottom: 1.5rem;
    color: var(--text-body);
}

.modal-input-field {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    margin-top: 0.5rem;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.modal-input-field:focus {
    border-color: var(--primary-color);
    outline: none;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

.modal-btn {
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: transform 0.1s;
}

.modal-btn:hover {
    transform: translateY(-1px);
}

.btn-secondary {
    background: #f1f5f9;
    color: var(--text-body);
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
}

/* --- Admin Layout Overhaul --- */

/* Header Refinement */
.main-header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid #e2e8f0;
    padding: 1rem 5%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.main-header nav {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.nav-btn {
    padding: 0.6rem 1.25rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    border: 1px solid transparent;
    transition: all 0.2s ease;
    cursor: pointer;
    background: transparent;
    color: var(--text-body);
}

.nav-btn:hover {
    background: #f1f5f9;
    color: var(--text-main);
}

.gallery-nav-active {
    background: #e0e7ff !important;
    color: var(--primary-color) !important;
    border: 1px solid #c7d2fe !important;
}

/* --- Gallery Admin Section --- */
/* Final Refined Layout: Text -> Buttons -> Horizontal Scroll Images (Single Row) */

/* --- Gallery Admin Section --- */
/* User Requested: Specific 5-column Layout with Blue Border Heading */

.gallery-group-card {
    /* Acts as .photo-row-block */
    background: white;
    border-radius: 20px;
    padding: 4rem;
    margin-bottom: 60px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
    border: 1px solid #e2e8f0;
    width: 100%;
    /* Ensure full width */
    box-sizing: border-box;
    /* Include padding in width */
}

/* Header with Blue Left Border */
.gallery-group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 10px 0 30px 0;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 15px;
}

.gallery-group-title {
    /* Acts as .group-heading */
    font-size: 1.8rem;
    color: #34495e;
    font-weight: 600;
    border-left: 5px solid #3498db;
    padding-left: 15px;
    margin: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    /* User preference */
    line-height: 1.2;
}

.gallery-count {
    font-size: 0.9rem;
    color: #64748b;
    font-weight: 600;
    padding-left: 15px;
}

.gallery-group-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}

/* Actions Buttons */
/* Actions Buttons */
.btn-add-group {
    background: #4f46e5;
    color: white;
    border: 1px solid #4f46e5;
    padding: 0.5rem 1.25rem;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 4px 6px rgba(79, 70, 229, 0.2);
}

.btn-add-group:hover {
    background: #4338ca;
    transform: translateY(-1px);
    box-shadow: 0 6px 10px rgba(79, 70, 229, 0.3);
}

.btn-edit {
    background: white;
    color: #3498db;
    border: 1px solid #3498db;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-edit:hover {
    background: #3498db;
    color: white;
}

.btn-clear-photos {
    background: white;
    color: #f59e0b;
    /* Amber 500 */
    border: 1px solid #f59e0b;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-clear-photos:hover {
    background: #f59e0b;
    color: white;
}

.btn-delete-group {
    background: #ef4444;
    color: white;
    border: 1px solid #ef4444;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-delete-group:hover {
    background: #dc2626;
    border-color: #dc2626;
    color: white;
    box-shadow: 0 4px 10px rgba(239, 68, 68, 0.3);
}

/* Admin Gallery Grid - The 5-Column Row */
.gallery-grid-admin {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    width: 100%;
}

/* Items - Grid Item */
.gallery-item-admin {
    width: 100%;
    /* Fill the grid cell */
    position: relative;
    border-radius: 10px;
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
    background: white;
    aspect-ratio: 1 / 1;
}

/* Image to fill container */
.gallery-item-admin img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* Fill the square */
    border-radius: 10px;
    display: block;
}

.gallery-item-admin:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 25px rgba(0, 0, 0, 0.18);
    z-index: 10;
}

/* Overlay Actions */
.delete-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    /* Slightly darker for visibility */
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    /* Space between buttons */
    opacity: 0;
    transition: all 0.2s;
    z-index: 20;
    /* Ensure clickable */
    pointer-events: auto;
}

.gallery-item-admin:hover .delete-overlay {
    opacity: 1;
}

/* Action Buttons in Overlay */
.overlay-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    border: none;
    color: white;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.btn-del-img {
    background: #ef4444;
}

.btn-del-img:hover {
    background: #dc2626;
    transform: scale(1.1);
}

.btn-replace-img {
    background: #3b82f6;
    /* Blue for replace */
}

.btn-replace-img:hover {
    background: #2563eb;
    transform: scale(1.1);
}

/* Responsive adjustments from user request */
@media (max-width: 900px) {
    .gallery-grid-admin {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .gallery-grid-admin {
        grid-template-columns: 1fr;
    }
}

/* Empty State */
.text-muted {
    width: 100%;
    text-align: center;
    padding: 2rem;
    color: #94a3b8;
}

/* --- FORCE FULL WIDTH RESOLUTION --- */
html,
body {
    overflow-x: hidden;
    /* Prevent scrollbar flicker */
}

@media (min-width: 641px) {
    main {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        padding: 2rem 4rem !important;
        /* Spacious */
    }

    #gallery-manager {
        width: 100% !important;
        max-width: 100% !important;
        padding: 0 !important;
    }

    .gallery-grid {
        width: 100% !important;
        max-width: 100% !important;
    }

    .gallery-group-card {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
}

/* Ensure no blank collapse */
.photo-row-block {
    min-height: 100px;
    width: 100%;
}

.gallery-page-container {
    min-height: 60vh;
}