/* ImageVault Mobile - TikTok-inspired Interface CSS */

/* Base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #000000; /* Fallback background */
    color: #ffffff;
    overflow-x: hidden;
}

/* Container */
.mobile-container {
    max-width: 428px;
    margin: 0 auto;
    min-height: 100vh;
    background-color: transparent; /* No background so images show through */
    position: relative;
}

/* Header */
.sticky {
    position: sticky;
}

.top-0 {
    top: 0;
}

.z-50 {
    z-index: 50;
}

.backdrop-blur-lg {
    backdrop-filter: blur(16px);
}

/* Layout */
.flex {
    display: flex;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: between;
}

.justify-center {
    justify-content: center;
}

.justify-around {
    justify-content: space-around;
}

.flex-col {
    flex-direction: column;
}

.space-x-2 > * + * {
    margin-left: 0.5rem;
}

.space-x-4 > * + * {
    margin-left: 1rem;
}

.space-x-8 > * + * {
    margin-left: 2rem;
}

.space-y-4 > * + * {
    margin-top: 1rem;
}

.space-y-6 > * + * {
    margin-top: 1.5rem;
}

/* Padding & Margins */
.p-2 {
    padding: 0.5rem;
}

.p-4 {
    padding: 1rem;
}

.p-6 {
    padding: 1.5rem;
}

.px-3 {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
}

.px-4 {
    padding-left: 1rem;
    padding-right: 1rem;
}

.px-8 {
    padding-left: 2rem;
    padding-right: 2rem;
}

.py-1 {
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
}

.py-2 {
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
}

.py-3 {
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
}

.py-4 {
    padding-top: 1rem;
    padding-bottom: 1rem;
}

.pb-20 {
    padding-bottom: 5rem;
}

.mb-1 {
    margin-bottom: 0.25rem;
}

.mb-2 {
    margin-bottom: 0.5rem;
}

.mb-4 {
    margin-bottom: 1rem;
}

.mt-1 {
    margin-top: 0.25rem;
}

.mt-2 {
    margin-top: 0.5rem;
}

.mr-2 {
    margin-right: 0.5rem;
}

.mx-auto {
    margin-left: auto;
    margin-right: auto;
}

/* Dimensions */
.w-2 {
    width: 0.5rem;
}

.w-5 {
    width: 1.25rem;
}

.w-6 {
    width: 1.5rem;
}

.w-8 {
    width: 2rem;
}

.w-16 {
    width: 4rem;
}

.w-20 {
    width: 5rem;
}

.w-full {
    width: 100%;
}

.h-2 {
    height: 0.5rem;
}

.h-5 {
    height: 1.25rem;
}

.h-6 {
    height: 1.5rem;
}

.h-8 {
    height: 2rem;
}

.h-16 {
    height: 4rem;
}

.h-20 {
    height: 5rem;
}

.h-96 {
    height: 24rem;
}

.h-full {
    height: 100%;
}

.max-w-md {
    max-width: 428px;
}

.min-h-screen {
    min-height: 100vh;
}

/* Colors */
.bg-black {
    background-color: #000000;
}

.bg-dark-bg {
    background-color: #000000;
}

.bg-dark-card {
    background-color: #161823;
}

.text-white {
    color: #ffffff;
}

.text-dark-text {
    color: #ffffff;
}

.text-dark-text-secondary {
    color: #a8a8a8;
}

.text-gray-300 {
    color: #d1d5db;
}

.text-gray-400 {
    color: #9ca3af;
}

.text-gray-500 {
    color: #6b7280;
}

.text-red-500 {
    color: #ef4444;
}

.text-yellow-500 {
    color: #eab308;
}

.placeholder-gray-400::placeholder {
    color: #9ca3af;
}

/* Gradients */
.bg-gradient-to-r {
    background-image: linear-gradient(to right, var(--tw-gradient-stops));
}

.bg-gradient-to-t {
    background-image: linear-gradient(to top, var(--tw-gradient-stops));
}

.from-black\/60 {
    --tw-gradient-from: rgba(0, 0, 0, 0.6);
    --tw-gradient-to: transparent;
    --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to);
}

.to-transparent {
    --tw-gradient-to: transparent;
}

/* TikTok Colors */
.from-tiktok-red {
    --tw-gradient-from: #ff0050;
}

.to-pink-500 {
    --tw-gradient-to: #ec4899;
}

/* Borders & Radius */
.border {
    border-width: 1px;
}

.border-t {
    border-top-width: 1px;
}

.border-b {
    border-bottom-width: 1px;
}

.border-gray-700 {
    border-color: #374151;
}

.border-gray-800 {
    border-color: #1f2937;
}

.border-tiktok-red {
    border-color: #ff0050;
}

.border-transparent {
    border-color: transparent;
}

.rounded {
    border-radius: 0.25rem;
}

.rounded-lg {
    border-radius: 0.5rem;
}

.rounded-full {
    border-radius: 9999px;
}

/* Positioning */
.relative {
    position: relative;
}

.absolute {
    position: absolute;
}

.fixed {
    position: fixed;
}

.inset-0 {
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
}

.bottom-0 {
    bottom: 0;
}

.bottom-4 {
    bottom: 1rem;
}

.bottom-24 {
    bottom: 6rem;
}

.left-0 {
    left: 0;
}

.left-4 {
    left: 1rem;
}

.left-1\/2 {
    left: 50%;
}

.right-0 {
    right: 0;
}

.right-4 {
    right: 1rem;
}

.right-16 {
    right: 4rem;
}

.top-4 {
    top: 1rem;
}

.transform {
    transform: translateX(-50%);
}

/* Display */
.hidden {
    display: none;
}

.block {
    display: block;
}

.grid {
    display: grid;
}

.grid-cols-2 {
    grid-template-columns: repeat(2, 1fr);
}

.gap-2 {
    gap: 0.5rem;
}

.gap-4 {
    gap: 1rem;
}

/* Typography */
.text-xs {
    font-size: 0.75rem;
}

.text-sm {
    font-size: 0.875rem;
}

.text-lg {
    font-size: 1.125rem;
}

.text-xl {
    font-size: 1.25rem;
}

.text-2xl {
    font-size: 1.5rem;
}

.font-medium {
    font-weight: 500;
}

.font-semibold {
    font-weight: 600;
}

.font-bold {
    font-weight: 700;
}

.text-center {
    text-align: center;
}

.leading-relaxed {
    line-height: 1.625;
}

/* Shadows */
.shadow-lg {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* Overflow */
.overflow-hidden {
    overflow: hidden;
}

/* Images */
.object-cover {
    object-fit: cover;
}

/* Animations */
.animate-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.animate-spin {
    animation: spin 1s linear infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.animate-like-bounce {
    animation: like-bounce 0.6s ease-in-out;
}

.animate-float {
    animation: float 3s ease-in-out infinite;
}

@keyframes like-bounce {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.3);
    }
}

@keyframes float {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-10px);
    }
}

/* Transitions */
.transition-all {
    transition-property: all;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 200ms;
}

.transition-colors {
    transition-property: color, background-color, border-color;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 200ms;
}

.transition-transform {
    transition-property: transform;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 200ms;
}

.duration-200 {
    transition-duration: 200ms;
}

.duration-300 {
    transition-duration: 300ms;
}

/* Component Styles */
.feed-card {
    background-color: #161823;
    border-radius: 0.5rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    position: relative;
    overflow: hidden;
}

/* Vertical paging container */
.tiktok-feed {
    height: 100dvh;
    overflow-y: scroll;
    overflow: hidden; /* disable native momentum */
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
    overscroll-behavior: contain; /* Prevent bounce */
    touch-action: none; /* custom gesture */
}

.tiktok-feed::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

/* Each post fills the *real* viewport height; bottom nav is overlayed via position:fixed */
.feed-item {
    height: 100dvh;
    width: 100%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.feed-image {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    object-position: center;
    display: block;
}

.viewer-image {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
    margin: 0 auto;
}

.image-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.6), transparent);
    pointer-events: none;
}

.image-info {
    position: absolute;
    bottom: 90px; /* Adjusted for new layout */
    left: 20px;
    right: 80px;
    color: white;
    z-index: 10;
}

.creator-name {
    font-size: 0.875rem;
    color: #d1d5db;
    margin-bottom: 0.25rem;
    font-weight: 500;
}

.image-prompt {
    font-size: 0.75rem;
    color: #9ca3af;
    line-height: 1.4;
}

.image-prompt.collapsed {
    position: relative;
}

.image-prompt.collapsed .prompt-text {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-right: 50px; /* Space for more button */
    min-height: 3.6em; /* Ensure consistent height for button positioning */
}

.image-prompt.expanded .prompt-text {
    display: block;
    margin-right: 0; /* No space needed when expanded or no button */
}

.more-button {
    color: #ffffff;
    background: none;
    border: none;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    padding: 2px 6px;
    margin-left: 4px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
    position: absolute;
    bottom: 0;
    right: 0;
    background: linear-gradient(to left, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0.7) 40%, transparent 100%);
    padding-left: 15px;
    border-radius: 2px;
}

.image-prompt.expanded .more-button {
    position: static;
    background: none;
    padding: 2px 4px;
}

.timestamp {
    font-size: 0.75rem;
    color: #6b7280;
    margin-top: 0.25rem;
}

.social-actions {
    position: absolute;
    right: 15px;
    bottom: 90px; /* Adjusted to match text positioning */
    display: flex;
    flex-direction: column;
    gap: 20px;
    z-index: 10;
}

.header-icon-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.2s;
    filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.5));
}

.header-icon-btn:active {
    transform: scale(0.9);
    background: rgba(255, 255, 255, 0.1);
}

.profile-icon-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    transition: transform 0.2s;
    padding: 0;
    min-width: 44px;
    min-height: 44px;
    justify-content: center;
}

.profile-icon-btn:active {
    transform: scale(0.9);
}

.profile-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid white;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
    background: linear-gradient(45deg, #ff0050, #ec4899);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
}

.social-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    transition: transform 0.2s;
    padding: 0;
    min-width: 44px;
    min-height: 44px;
    justify-content: center;
}

.social-btn:active {
    transform: scale(0.9);
}

.social-icon {
    width: 32px;
    height: 32px;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
}

.social-count {
    font-size: 0.75rem;
    margin-top: 4px;
    text-align: center;
    font-weight: 500;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
}

.social-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    border-radius: 9999px;
    transition: all 0.2s;
}

.social-button:active {
    transform: scale(0.95);
}

.generate-button {
    background: linear-gradient(to right, #ff0050, #ec4899);
    color: white;
    font-weight: 700;
    padding: 1rem 2rem;
    border-radius: 9999px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s;
    border: none;
    cursor: pointer;
}

.generate-button:active {
    transform: scale(0.95);
}

.generate-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.nav-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    color: #a8a8a8;
    transition: colors 0.2s;
    cursor: pointer;
    background: none;
    border: none;
}

.nav-tab.active {
    color: #ffffff;
}

.nav-tab-create {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: none;
    border: none;
    position: relative;
    margin-bottom: 8px; /* Raise it up slightly */
}

.create-button-bg {
    width: 56px;
    height: 56px;
    background: linear-gradient(45deg, #ff0050, #ec4899);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(255, 0, 80, 0.3);
}

.nav-tab-create:active .create-button-bg {
    transform: scale(0.95);
    box-shadow: 0 2px 8px rgba(255, 0, 80, 0.4);
}

.image-card {
    position: relative;
    border-radius: 0.5rem;
    overflow: hidden;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.floating-action {
    position: fixed;
    bottom: 6rem;
    right: 1rem;
    background: linear-gradient(to right, #ff0050, #ec4899);
    color: white;
    padding: 1rem;
    border-radius: 9999px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    animation: float 3s ease-in-out infinite;
}

.section {
    transition: all 0.3s;
}

.section.hidden {
    opacity: 0;
    pointer-events: none;
}

.section.active {
    opacity: 1;
    pointer-events: auto;
}

.style-tag {
    padding: 0.25rem 0.75rem;
    background-color: #161823;
    color: white;
    border-radius: 9999px;
    font-size: 0.875rem;
    border: 1px solid #374151;
    transition: all 0.2s;
    cursor: pointer;
}

.style-tag:hover,
.style-tag:active {
    background-color: #ff0050;
    border-color: #ff0050;
}

.aspect-btn {
    padding: 0.25rem 0.75rem;
    background-color: #000000;
    color: white;
    border-radius: 0.25rem;
    font-size: 0.875rem;
    border: 1px solid #374151;
    transition: all 0.2s;
    cursor: pointer;
}

.aspect-btn.active {
    background-color: #ff0050;
    border-color: #ff0050;
}

/* Form Elements */
textarea,
input,
select {
    background-color: #161823;
    color: white;
    border: 1px solid #374151;
    border-radius: 0.5rem;
    padding: 1rem;
    font-size: 1rem;
    width: 100%;
    resize: none;
}

textarea:focus,
input:focus,
select:focus {
    outline: none;
    border-color: #ff0050;
    box-shadow: 0 0 0 2px rgba(255, 0, 80, 0.2);
}

/* Flex Wrap */
.flex-wrap {
    flex-wrap: wrap;
}

/* Backdrop Blur */
.backdrop-blur-sm {
    backdrop-filter: blur(4px);
}

/* Opacity */
.opacity-0 {
    opacity: 0;
}

.opacity-100 {
    opacity: 1;
}

/* Pointer Events */
.pointer-events-none {
    pointer-events: none;
}

.pointer-events-auto {
    pointer-events: auto;
}

/* Scale */
.scale-95 {
    transform: scale(0.95);
}

/* Active states */
.active\:scale-95:active {
    transform: scale(0.95);
}

/* Responsive */
@media (min-width: 768px) {
    .mobile-container {
        max-width: 400px;
    }
}

@media (min-width: 1024px) {
    .mobile-container {
        max-width: 400px;
    }
}

/* Mobile touch optimization for collection grids */
.touch-action-manipulation {
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
}

/* Collection grid mobile fixes */
#collection-full-grid {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 4px !important;
    width: 100% !important;
}

#collection-full-grid > div {
    width: 100% !important;
    min-height: 44px !important; /* Minimum touch target size */
    min-width: 44px !important;
    touch-action: manipulation !important;
    -webkit-tap-highlight-color: rgba(255, 255, 255, 0.1) !important;
    -webkit-user-select: none !important;
    user-select: none !important;
}

#collection-full-grid img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    display: block !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    pointer-events: none !important; /* Prevent image from intercepting clicks */
} 

/* Feed frame adds subtle black gap (top & bottom) like TikTok */
.feed-frame {
    height: 100%;
    box-sizing: border-box;
    padding-block: 8px; /* 8px top + bottom gap */
    background: #000;   /* ensures gap is dark even if image fails */
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
} 

/* Comments overlay & bottom-sheet */
#comments-overlay { background: rgba(0,0,0,0.6); }
#comments-panel {
  transform: translateY(100%);
  height: 60vh;            /* fixed height: ~60% of the viewport */
  display: flex;           /* enforce flex column even without utility classes */
  flex-direction: column;
}
#comments-panel.show { transform: translateY(0) !important; }

/* Bottom-sheet sections: fixed header and input, scrolling list */
#comments-panel .comments-header,
#comments-panel .comments-input-row { flex: 0 0 auto; }
#comments-list { flex: 1 1 auto; overflow-y: auto; }

/* Input should not grow the sheet height */
#comment-input { max-height: 3.25rem; overflow-y: auto; }

/* Replies indentation: separate from utility classes to ensure consistency */
.replies { margin-top: 0.5rem; padding-left: 1.75rem; border-left: 1px solid #1f2937; }
.reply-item { margin-bottom: 0.75rem; }

/* Timestamp styling: smaller and grey for both comments and replies */
.comment-time { font-size: 0.6em; color: #9ca3af !important; margin-left: 0.25rem; display: inline-block; }
#comments-panel .comment-time { color: #9ca3af !important; font-size: 0.6em; }

/* Header rows for name + time to ensure side-by-side alignment regardless of utilities */
.comment-row-header, .reply-row-header { display: flex; align-items: center; gap: 0.5rem; }

/* Color tokens defined earlier */
/* -------------------------------------------------- */
/* Global reusable UI components                      */
/* -------------------------------------------------- */

/* Icon-only close / dismiss button */
.btn-close{
    padding:0.25rem; /* 4px each side => 24×24 hit area */
    border:1px solid #374151; /* same as vault borders */
    border-radius:9999px;
    color:#9ca3af !important; /* enforce grey even if parent sets color */
    display:inline-flex;
    align-items:center;
    justify-content:center;
    background:transparent;
    transition:background-color .15s ease;
}
.btn-close:hover{ background:#1f2937; }
.btn-close svg{ width:16px; height:16px; }
/* Force stroke colour regardless of Lucide defaults or inheritance */
.btn-close svg{ stroke:#9ca3af !important; stroke-width:2; } 

.comment-actions button{ opacity:1 !important; } 

/* Reusable dark button to match generator buttons */
.btn-dark {
    background-color: #374151;
    color: #ffffff;
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
}
.btn-dark:hover { background-color: #475569; }

/* Metadata popup layout */
.iv-meta-card { background:#161823; border:1px solid #374151; border-radius:12px; padding:16px; max-width:92vw; }
.iv-meta-title { color:#e5e7eb; font-weight:600; font-size:14px; margin-bottom:8px; }
.iv-meta-section { border-top:1px solid #374151; padding-top:8px; margin-top:8px; }
.iv-meta-grid { display:grid; grid-template-columns: 120px 1fr; gap:8px 12px; align-items:start; }
.iv-meta-label { color:#9ca3af; font-size:12px; }
.iv-meta-value { color:#e5e7eb; font-size:13px; word-break:break-word; white-space:pre-wrap; }

/* Edit Post Modal must overlay all content */
#edit-post-modal {
  z-index: 10000;
} 

/* Repost modal above all */
#repost-modal{ z-index:10000; } 

/* Aspect utilities */
.aspect-4-3 { position: relative; }
.aspect-4-3::before { content: ""; display: block; padding-top: 75%; }
.aspect-4-3 > img, .aspect-4-3 > video { position: absolute; inset: 0; }

/* Portrait tiles 3:4 (width:height) */
.aspect-3-4 { position: relative; }
.aspect-3-4::before { content: ""; display: block; padding-top: 133.333%; }
.aspect-3-4 > img, .aspect-3-4 > video { position: absolute; inset: 0; }

/* Make profile section scrollable within fixed container */
#profile-section {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    max-height: calc(100dvh - 100px); /* leave room for header + bottom nav */
}