/* ===== Global Styles ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #8b5cf6;
    --primary-dark: #7c3aed;
    --secondary: #ec4899;
    --background: #fafafa;
    --surface: #ffffff;
    --text: #1f2937;
    --text-light: #6b7280;
    --border: #e5e7eb;
    --error: #ef4444;
    --success: #10b981;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.15);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: 
        radial-gradient(circle at 20% 50%, rgba(139, 92, 246, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(236, 72, 153, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 40% 20%, rgba(168, 85, 247, 0.1) 0%, transparent 50%),
        linear-gradient(135deg, #fafafa 0%, #f0f0f5 100%);
    background-attachment: fixed;
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

.board-page {
    padding-bottom: 80px;
}

/* ===== Header ===== */
.board-header {
    background: linear-gradient(135deg, var(--primary) 0%, #a855f7 50%, var(--secondary) 100%);
    color: white;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}

.board-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 20% 50%, rgba(255, 255, 255, 0.1) 0%, transparent 30%),
        radial-gradient(circle at 80% 20%, rgba(255, 255, 255, 0.08) 0%, transparent 30%);
    pointer-events: none;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    z-index: 1;
}

.board-header h1 {
    font-size: 1.4rem;
    text-align: center;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

/* Removed share button styles */

/* ===== Main Container ===== */
.board-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    min-height: calc(100vh - 100px);
}

.loading-state,
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-light);
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

.empty-icon {
    font-size: 4rem;
    margin-bottom: 16px;
}

.empty-state h2 {
    color: var(--text);
    margin-bottom: 8px;
}

/* ===== Masonry Grid ===== */
.masonry-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    grid-auto-rows: auto;
}

@media (min-width: 640px) {
    .masonry-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 16px;
    }
}

@media (min-width: 1024px) {
    .masonry-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

.grid-item {
    position: relative;
    cursor: pointer;
    border-radius: 12px;
    overflow: hidden;
    background: var(--surface);
    box-shadow: var(--shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
}

.grid-item:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 12px 30px rgba(139, 92, 246, 0.2);
}

.grid-item img {
    width: 100%;
    height: auto;
    display: block;
}

.grid-item-caption {
    padding: 12px;
    background: var(--surface);
    font-size: 0.9rem;
    color: var(--text);
    line-height: 1.4;
    word-wrap: break-word;
}

.grid-item.loading {
    aspect-ratio: 1;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ===== Floating Action Button ===== */
.fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, #a855f7 50%, var(--secondary) 100%);
    color: white;
    border: none;
    box-shadow: 0 4px 20px rgba(139, 92, 246, 0.5), 0 0 0 0 rgba(139, 92, 246, 0.4);
    cursor: pointer;
    transition: all 0.3s;
    z-index: 50;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 4px 20px rgba(139, 92, 246, 0.5), 0 0 0 0 rgba(139, 92, 246, 0.4);
    }
    50% {
        box-shadow: 0 4px 20px rgba(139, 92, 246, 0.5), 0 0 0 8px rgba(139, 92, 246, 0);
    }
}

.fab:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.5);
}

.fab:active {
    transform: scale(0.95);
}

.fab-icon {
    font-size: 2rem;
    line-height: 1;
}

/* ===== Modal ===== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--surface);
    border-radius: 16px;
    padding: 24px;
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content h2 {
    margin-bottom: 16px;
    font-size: 1.3rem;
}

.preview-container {
    margin-bottom: 16px;
    border-radius: 12px;
    overflow: hidden;
    background: var(--background);
}

.preview-image {
    width: 100%;
    height: auto;
    display: block;
}

input[type="text"] {
    width: 100%;
    padding: 14px 16px;
    font-size: 1rem;
    border: 2px solid var(--border);
    border-radius: 12px;
    margin-bottom: 16px;
    transition: border-color 0.2s;
    font-family: inherit;
}

input[type="text"]:focus {
    outline: none;
    border-color: var(--primary);
}

.modal-actions {
    display: flex;
    gap: 12px;
}

.btn {
    flex: 1;
    padding: 14px 24px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    min-height: 48px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border: 2px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--background);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ===== Lightbox ===== */
.lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.lightbox.active {
    display: flex;
}

.lightbox-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 90%;
    max-height: 90%;
}

.lightbox-image {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
    margin-bottom: 16px;
}

.lightbox-caption {
    color: white;
    font-size: 1.1rem;
    text-align: center;
    max-width: 600px;
    padding: 0 20px;
    line-height: 1.5;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    transition: background 0.2s;
    line-height: 1;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.lightbox-download {
    position: absolute;
    top: 20px;
    right: 80px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(139, 92, 246, 0.8);
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.2s;
    line-height: 1;
}

.lightbox-download:hover {
    background: rgba(139, 92, 246, 1);
    transform: scale(1.1);
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    font-size: 2.5rem;
    cursor: pointer;
    transition: background 0.2s;
    line-height: 1;
}

.lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.2);
}

.lightbox-prev {
    left: 20px;
}

.lightbox-next {
    right: 20px;
}

.lightbox-counter {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
}

/* ===== Upload Progress ===== */
.upload-progress {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface);
    padding: 16px 24px;
    border-radius: 50px;
    box-shadow: var(--shadow-lg);
    display: none;
    align-items: center;
    gap: 12px;
    z-index: 100;
}

.upload-progress.active {
    display: flex;
}

.upload-spinner {
    width: 20px;
    height: 20px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ===== Toast ===== */
.toast {
    position: fixed;
    top: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text);
    color: white;
    padding: 12px 24px;
    border-radius: 50px;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
    z-index: 200;
    max-width: 90%;
    text-align: center;
}

.toast.show {
    opacity: 1;
}

/* ===== Responsive ===== */
@media (max-width: 640px) {
    .header-content {
        padding: 16px;
    }

    .board-header h1 {
        font-size: 1rem;
    }
    
    .lightbox-download {
        top: 16px;
        right: 68px;
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }

    .fab {
        width: 56px;
        height: 56px;
        bottom: 20px;
        right: 20px;
    }

    .fab-icon {
        font-size: 1.8rem;
    }

    .lightbox-nav {
        width: 48px;
        height: 48px;
        font-size: 2rem;
    }

    .lightbox-close {
        width: 40px;
        height: 40px;
        font-size: 1.8rem;
        top: 16px;
        right: 16px;
    }

    .modal-content {
        padding: 20px;
    }
}
