:root {
    --bg-primary: #0a0e27;
    --bg-secondary: #151932;
    --bg-tertiary: #1e2444;
    --accent-primary: #6366f1;
    --accent-secondary: #8b5cf6;
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border-color: rgba(148, 163, 184, 0.1);
    --glass-bg: rgba(30, 36, 68, 0.8);
    --glass-border: rgba(148, 163, 184, 0.15);
    --success: #10b981;
    --error: #ef4444;
    --shadow-lg: 0 -4px 20px rgba(0, 0, 0, 0.3);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    padding-bottom: 220px;
    /* Space for fixed form */
    background-image:
        radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(139, 92, 246, 0.15) 0px, transparent 50%);
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

/* Header - Compact */
.header {
    text-align: center;
    margin-bottom: 2rem;
    animation: fadeInDown 0.6s ease-out;
}

.header__title {
    font-size: 2.5rem;
    font-weight: 700;
    color: #ffbd01;
    margin-bottom: 0.25rem;
}

.header__subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* Messages Section - Main Focus */
.messages-section {
    animation: fadeInUp 0.6s ease-out;
}

.loading {
    text-align: center;
    color: var(--text-secondary);
    padding: 2rem;
    font-size: 1rem;
}

.messages-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Messages Grid */
.messages-grid {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.message-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    padding: 1.5rem;
    animation: slideUp 0.3s ease forwards;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.2);
    border-color: rgba(99, 102, 241, 0.3);
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.message-author {
    font-weight: 600;
    color: #ffbd01;
    font-size: 1rem;
}

.message-date-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.message-date {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.delete-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.9rem;
    width: 2rem;
    height: 2rem;
    border-radius: 0.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: all 0.2s ease;
}

.delete-btn:hover {
    background: var(--error);
    border-color: var(--error);
    color: white;
    transform: scale(1.1);
}

.message-card {
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.message-content {
    color: var(--text-primary);
    line-height: 1.6;
    word-wrap: break-word;
    white-space: pre-wrap;
    font-size: 0.95rem;
}

.message-content a {
    color: white;
    text-decoration: underline;
}

.message-content a:hover {
    color: #ffbd01;
}

.message-content strong {
    font-weight: 700;
}

.message-content em {
    font-style: italic;
}

.message-gif {
    margin-top: 1rem;
    border-radius: 0.75rem;
    overflow: hidden;
    max-width: 400px;
}

.message-gif img {
    width: 100%;
    height: auto;
    display: block;
}

/* Embedded Media (Images/Videos from URLs) */
.embedded-media {
    margin-top: 1rem;
    border-radius: 0.75rem;
    overflow: hidden;
    max-width: 500px;
}

.embedded-media img {
    width: 100%;
    height: auto;
    display: block;
    max-height: 600px;
    object-fit: contain;
}

.embedded-video {
    position: relative;
    padding-bottom: 56.25%;
    /* 16:9 aspect ratio */
    height: 0;
    overflow: hidden;
    max-width: 100%;
}

.embedded-video iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 0.75rem;
}

.embedded-instagram {
    max-width: 450px;
    width: 100%;
    margin-top: 1rem;
}

.embedded-instagram iframe {
    border-radius: 0.75rem;
}

/* Pagination */
.pagination-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 2rem 0;
}

.pagination-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.pagination-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-primary);
    transform: translateY(-2px);
}

.pagination-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.page-numbers {
    display: flex;
    gap: 0.25rem;
    align-items: center;
}

.page-number-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.9rem;
    min-width: 2.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.page-number-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-primary);
}

.page-number-btn.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
    font-weight: 600;
}

.page-ellipsis {
    color: var(--text-muted);
    padding: 0 0.25rem;
}

/* Fixed Bottom Form */
.message-form-fixed {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--glass-bg);
    backdrop-filter: blur(30px);
    border-top: 1px solid var(--glass-border);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    animation: slideUp 0.4s ease-out;
}

.form-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 1rem;
}

.message-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Compact Form Row */
.form-row {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.form-input-compact {
    width: 100%;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 0.625rem 0.75rem;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s ease;
}

.form-input-compact:focus {
    border-color: var(--accent-primary);
}

.form-textarea-compact {
    flex: 1;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 0.625rem 0.75rem;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    outline: none;
    resize: none;
    min-height: 38px;
    max-height: 120px;
    transition: border-color 0.2s ease;
}

.form-textarea-compact:focus {
    border-color: var(--accent-primary);
}

/* Form Actions */
.form-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.toolbar-buttons {
    display: flex;
    gap: 0.375rem;
}

.toolbar-btn-sm {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    padding: 0.375rem 0.625rem;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.85rem;
    font-weight: 500;
}

.toolbar-btn-sm:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent-primary);
}

.toolbar-btn-sm.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

.submit-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.char-counter {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.submit-btn-compact {
    background: var(--accent-gradient);
    border: none;
    border-radius: 0.5rem;
    padding: 0.5rem 1.25rem;
    color: white;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.submit-btn-compact:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.submit-btn-compact:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Picker Popups */
.picker-popup {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    margin-bottom: 0.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: 0.75rem;
    padding: 0.75rem;
    max-height: 300px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: slideDown 0.3s ease-out;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.2);
}

.picker-header {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.75rem;
}

.picker-search {
    flex: 1;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    padding: 0.375rem 0.5rem;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.85rem;
    outline: none;
}

.search-btn {
    background: var(--accent-primary);
    border: none;
    border-radius: 0.375rem;
    padding: 0.375rem 0.75rem;
    color: white;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.search-btn:hover {
    background: var(--accent-secondary);
}

.close-btn-sm {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 1.5rem;
    height: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn-sm:hover {
    color: var(--text-primary);
}

/* GIF Results */
.gif-results {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 0.375rem;
    overflow-y: auto;
    max-height: 220px;
}

.gif-item {
    cursor: pointer;
    border-radius: 0.375rem;
    overflow: hidden;
    transition: transform 0.2s ease;
    aspect-ratio: 1;
}

.gif-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.gif-item:hover {
    transform: scale(1.05);
}

.gif-placeholder {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--text-muted);
    padding: 2rem;
    font-size: 0.85rem;
}

/* Emoji Grid */
.emoji-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(35px, 1fr));
    gap: 0.25rem;
    overflow-y: auto;
    max-height: 220px;
}

.emoji-btn {
    background: transparent;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 0.25rem;
    transition: all 0.2s ease;
}

.emoji-btn:hover {
    background: var(--bg-tertiary);
    transform: scale(1.15);
}

/* Selected GIF Preview */
.selected-gif-preview {
    position: relative;
    max-width: 200px;
    border-radius: 0.5rem;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.selected-gif-preview img {
    width: 100%;
    height: auto;
    display: block;
}

.remove-preview-btn {
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
    background: rgba(0, 0, 0, 0.7);
    border: none;
    color: white;
    font-size: 1.25rem;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.remove-preview-btn:hover {
    background: var(--error);
}

/* Messages/Alerts */
.message-alert {
    padding: 0.625rem 0.875rem;
    border-radius: 0.5rem;
    font-size: 0.85rem;
    font-weight: 500;
}

.message-alert.error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

.message-alert.success {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #6ee7b7;
}

/* Utility */
.hidden {
    display: none !important;
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }

    to {
        transform: translateY(0);
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        max-height: 0;
    }

    to {
        opacity: 1;
        max-height: 300px;
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-primary);
}

/* Lightbox for image zoom */
.lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.lightbox.active {
    display: flex;
}

.lightbox-content {
    position: relative;
    max-width: 95%;
    max-height: 95%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-image {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 0.5rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    animation: zoomIn 0.3s ease;
}

.lightbox-close {
    position: absolute;
    top: -3rem;
    right: 0;
    color: white;
    font-size: 3rem;
    font-weight: 300;
    cursor: pointer;
    background: rgba(0, 0, 0, 0.5);
    width: 3rem;
    height: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
    line-height: 1;
}

.lightbox-close:hover {
    background: var(--error);
    transform: scale(1.1);
}

@keyframes zoomIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Responsive */
@media (max-width: 768px) {
    body {
        padding-bottom: 200px;
    }

    .container {
        padding: 1rem 0.75rem;
    }

    .header__title {
        font-size: 2rem;
    }

    .form-actions {
        flex-direction: column;
        gap: 0.5rem;
        align-items: stretch;
    }

    .submit-wrapper {
        justify-content: space-between;
    }

    .message-form-fixed {
        padding: 0.75rem;
    }
}