/* ============================================
   MemeDrop — Design tokens
   Inspiration: meme-culture stamps, sticker sheets, photo-booth strips
   ============================================ */
:root {
    --bg-void: #120318;
    --bg-card: #1c0a26;
    --bg-card-light: #271235;
    --accent-hot: #ff3d8f;
    --accent-acid: #c8ff4d;
    --accent-blue: #4dd8ff;
    --ink: #fbf6ff;
    --ink-dim: #b8a8c4;
    --stamp-yellow: #ffd23f;
    --border-soft: rgba(255, 255, 255, 0.08);
    --radius-card: 24px;
    --radius-pill: 999px;
    --font-display: 'Archivo Black', 'Arial Black', sans-serif;
    --font-body: 'Inter', -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', 'Courier New', monospace;
    --shadow-pop: 0 8px 0 rgba(0,0,0,0.4);
}

@font-face {
    font-family: 'Archivo Black';
    src: local('Archivo Black');
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg-void);
    color: var(--ink);
    font-family: var(--font-body);
    min-height: 100vh;
}

body {
    background-image:
        radial-gradient(circle at 15% 20%, rgba(255, 61, 143, 0.18), transparent 40%),
        radial-gradient(circle at 85% 75%, rgba(77, 216, 255, 0.15), transparent 45%);
}

a { color: var(--accent-acid); text-decoration: none; }
a:hover { text-decoration: underline; }

button { font-family: inherit; cursor: pointer; }

/* ---------- Auth pages ---------- */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-card);
    padding: 40px 32px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-pop);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 4px;
}

.brand-mark {
    font-size: 22px;
    transform: rotate(-4deg);
    display: inline-block;
}

.brand h1 {
    font-family: var(--font-display);
    font-size: 28px;
    margin: 0;
    letter-spacing: -0.5px;
}

.tagline {
    color: var(--ink-dim);
    margin: 4px 0 28px;
    font-size: 14px;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.auth-form label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-dim);
}

.auth-form input {
    background: var(--bg-card-light);
    border: 1px solid var(--border-soft);
    border-radius: 12px;
    padding: 12px 14px;
    color: var(--ink);
    font-size: 15px;
    font-family: var(--font-body);
}

.auth-form input:focus {
    outline: 2px solid var(--accent-hot);
    outline-offset: 1px;
}

.btn-primary {
    background: var(--accent-hot);
    color: var(--bg-void);
    border: none;
    border-radius: var(--radius-pill);
    padding: 14px;
    font-weight: 800;
    font-size: 15px;
    margin-top: 8px;
    box-shadow: var(--shadow-pop);
    transition: transform 0.1s;
}
.btn-primary:hover { transform: translateY(-2px); }
.btn-primary:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0,0,0,0.4); }

.auth-switch {
    text-align: center;
    margin-top: 24px;
    font-size: 14px;
    color: var(--ink-dim);
}

.alert {
    padding: 12px 14px;
    border-radius: 10px;
    font-size: 13px;
    margin-bottom: 18px;
}
.alert-error { background: rgba(255, 61, 143, 0.15); color: var(--accent-hot); border: 1px solid var(--accent-hot); }
.alert-success { background: rgba(200, 255, 77, 0.12); color: var(--accent-acid); border: 1px solid var(--accent-acid); }

/* ---------- Public send page ---------- */
.send-page {
    max-width: 480px;
    margin: 0 auto;
    padding: 32px 20px 60px;
}

.send-header {
    text-align: center;
    margin-bottom: 28px;
}

.send-header .stamp {
    display: inline-block;
    background: var(--stamp-yellow);
    color: var(--bg-void);
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: var(--radius-pill);
    transform: rotate(-3deg);
    margin-bottom: 14px;
    letter-spacing: 0.5px;
}

.send-header h1 {
    font-family: var(--font-display);
    font-size: 30px;
    margin: 0 0 6px;
    line-height: 1.1;
}

.send-header .owner-name {
    color: var(--accent-hot);
}

.send-header p {
    color: var(--ink-dim);
    font-size: 14px;
    margin: 0;
}

/* Tabs to choose meme source */
.tab-bar {
    display: flex;
    background: var(--bg-card);
    border-radius: var(--radius-pill);
    padding: 4px;
    margin-bottom: 22px;
    border: 1px solid var(--border-soft);
}

.tab-btn {
    flex: 1;
    background: none;
    border: none;
    color: var(--ink-dim);
    padding: 10px 12px;
    border-radius: var(--radius-pill);
    font-size: 13px;
    font-weight: 700;
}

.tab-btn.active {
    background: var(--accent-hot);
    color: var(--bg-void);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.panel-card {
    background: var(--bg-card);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-card);
    padding: 22px;
    margin-bottom: 18px;
}

.field-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--ink-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    display: block;
}

.upload-drop {
    border: 2px dashed var(--border-soft);
    border-radius: 16px;
    padding: 28px 16px;
    text-align: center;
    color: var(--ink-dim);
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}
.upload-drop:hover, .upload-drop.dragover {
    border-color: var(--accent-blue);
    background: rgba(77, 216, 255, 0.06);
}
.upload-drop input { display: none; }
.upload-drop .upload-icon { font-size: 32px; display: block; margin-bottom: 8px; }

/* Template grid */
.template-search {
    width: 100%;
    background: var(--bg-card-light);
    border: 1px solid var(--border-soft);
    border-radius: 12px;
    padding: 10px 14px;
    color: var(--ink);
    margin-bottom: 14px;
    font-size: 14px;
}

.template-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    max-height: 320px;
    overflow-y: auto;
    padding-right: 4px;
}

.template-item {
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    aspect-ratio: 1;
    background: var(--bg-card-light);
}
.template-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.template-item.selected { border-color: var(--accent-acid); }

.template-text-inputs {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
}
.template-text-inputs input {
    background: var(--bg-card-light);
    border: 1px solid var(--border-soft);
    border-radius: 10px;
    padding: 10px 12px;
    color: var(--ink);
    font-size: 14px;
}

.preview-box {
    text-align: center;
    margin-top: 16px;
}
.preview-box img {
    max-width: 100%;
    border-radius: 12px;
    border: 1px solid var(--border-soft);
}

.caption-input {
    width: 100%;
    background: var(--bg-card-light);
    border: 1px solid var(--border-soft);
    border-radius: 12px;
    padding: 12px 14px;
    color: var(--ink);
    font-size: 14px;
    resize: vertical;
    min-height: 70px;
    font-family: var(--font-body);
}

.send-btn {
    width: 100%;
    background: var(--accent-acid);
    color: var(--bg-void);
    border: none;
    border-radius: var(--radius-pill);
    padding: 16px;
    font-weight: 800;
    font-size: 16px;
    box-shadow: var(--shadow-pop);
    margin-top: 10px;
}
.send-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.send-btn:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0,0,0,0.4); }

.disclosure {
    font-size: 11px;
    color: var(--ink-dim);
    text-align: center;
    margin-top: 18px;
    line-height: 1.5;
    opacity: 0.7;
}

.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--accent-acid);
    color: var(--bg-void);
    padding: 14px 24px;
    border-radius: var(--radius-pill);
    font-weight: 700;
    font-size: 14px;
    box-shadow: var(--shadow-pop);
    transition: transform 0.3s ease;
    z-index: 999;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--accent-hot); }

/* ---------- Editor (canvas) ---------- */
.editor-wrap {
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.editor-canvas-container {
    position: relative;
    background: #000;
    border-radius: 14px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 280px;
}
#editorCanvas { max-width: 100%; display: block; touch-action: none; }

.editor-toolbar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.tool-btn {
    background: var(--bg-card-light);
    border: 1px solid var(--border-soft);
    color: var(--ink);
    border-radius: 10px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 600;
}
.tool-btn.active { background: var(--accent-blue); color: var(--bg-void); }

.editor-text-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}
.editor-text-controls input[type="text"] {
    flex: 1;
    background: var(--bg-card-light);
    border: 1px solid var(--border-soft);
    border-radius: 10px;
    padding: 10px;
    color: var(--ink);
}
.editor-text-controls input[type="color"] {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    border: none;
    background: none;
    padding: 0;
}

.filter-row {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
}
.filter-chip {
    flex-shrink: 0;
    background: var(--bg-card-light);
    border: 1px solid var(--border-soft);
    color: var(--ink-dim);
    border-radius: var(--radius-pill);
    padding: 8px 16px;
    font-size: 12px;
    font-weight: 600;
}
.filter-chip.active { background: var(--stamp-yellow); color: var(--bg-void); }

/* ---------- Inbox / Dashboard ---------- */
.dash-page {
    max-width: 900px;
    margin: 0 auto;
    padding: 28px 20px 60px;
}

.dash-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 28px;
}

.dash-top h1 {
    font-family: var(--font-display);
    font-size: 26px;
    margin: 0 0 4px;
}

.dash-top p { color: var(--ink-dim); font-size: 14px; margin: 0; }

.btn-logout {
    background: var(--bg-card);
    border: 1px solid var(--border-soft);
    color: var(--ink-dim);
    border-radius: var(--radius-pill);
    padding: 10px 18px;
    font-size: 13px;
    font-weight: 600;
}

.link-box {
    background: var(--bg-card);
    border: 1px solid var(--border-soft);
    border-radius: 16px;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 28px;
    flex-wrap: wrap;
}
.link-box code {
    flex: 1;
    font-family: var(--font-mono);
    color: var(--accent-blue);
    font-size: 14px;
    overflow-x: auto;
    white-space: nowrap;
}
.copy-btn {
    background: var(--accent-hot);
    color: var(--bg-void);
    border: none;
    border-radius: var(--radius-pill);
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 700;
}

.stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 28px;
}
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-soft);
    border-radius: 16px;
    padding: 18px;
    text-align: center;
}
.stat-card .num {
    font-family: var(--font-display);
    font-size: 28px;
    color: var(--accent-acid);
    display: block;
}
.stat-card .label {
    font-size: 12px;
    color: var(--ink-dim);
    margin-top: 4px;
}

.meme-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

.meme-card {
    background: var(--bg-card);
    border: 1px solid var(--border-soft);
    border-radius: 16px;
    overflow: hidden;
}
.meme-card img { width: 100%; display: block; aspect-ratio: 1; object-fit: cover; }
.meme-card-body { padding: 12px 14px; }
.meme-card .caption { font-size: 13px; margin: 0 0 8px; color: var(--ink); }
.meme-card .meta {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--ink-dim);
    font-family: var(--font-mono);
}
.meme-card .sender-tag {
    background: var(--bg-card-light);
    border-radius: var(--radius-pill);
    padding: 3px 10px;
    font-size: 10px;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--ink-dim);
}
.empty-state .big { font-size: 40px; display: block; margin-bottom: 12px; }

/* Sender detail expand */
.sender-detail {
    font-size: 11px;
    color: var(--ink-dim);
    margin-top: 6px;
    font-family: var(--font-mono);
}

@media (max-width: 480px) {
    .stats-row { grid-template-columns: repeat(3, 1fr); gap: 8px; }
    .stat-card { padding: 12px 8px; }
    .stat-card .num { font-size: 20px; }
    .template-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ============ NEW ADDITIONS ============ */

/* Profile avatar on send page */
.profile-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    margin: 0 auto 14px;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    border: 3px solid rgba(255,255,255,0.15);
}
.profile-avatar img {
    width: 100%; height: 100%;
    object-fit: cover;
    border-radius: 50%;
}
.owner-handle {
    color: var(--ink-dim);
    font-size: 13px;
    margin: -6px 0 4px;
    font-family: var(--font-mono);
}

/* Profile avatar small (inbox) */
.profile-avatar-sm {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    overflow: hidden;
    flex-shrink: 0;
    border: 2px solid rgba(255,255,255,0.12);
}
.profile-avatar-sm img { width:100%; height:100%; object-fit:cover; border-radius:50%; }
.dash-top-left { display:flex; align-items:center; gap:14px; }
.handle-text { color:var(--ink-dim); font-size:12px; font-family:var(--font-mono); margin:2px 0 0; }

/* Upload box fix - no scrollbar */
.upload-drop {
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}
.upload-drop .upload-icon { font-size: 28px; margin-bottom: 4px; }

/* Filter row - remove scrollbar on filter */
.filter-row::-webkit-scrollbar { display: none; }
.filter-row { -ms-overflow-style: none; scrollbar-width: none; }

/* Unseen meme card */
.meme-card.unseen { cursor: pointer; }
.unseen-overlay {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 140px;
    background: linear-gradient(135deg, rgba(255,61,143,0.15), rgba(77,216,255,0.1));
    border-radius: 12px 12px 0 0;
    font-size: 14px;
    color: var(--ink-dim);
    text-align: center;
    padding: 20px;
}

/* Instagram posted badge */
.ig-posted-badge {
    margin-top: 6px;
    font-size: 11px;
    color: var(--accent-acid);
    font-family: var(--font-mono);
}

/* Meme Modal */
.meme-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.85);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.meme-modal.open { display: flex; }
.meme-modal-inner {
    background: var(--bg-card);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-card);
    padding: 20px;
    max-width: 480px;
    width: 100%;
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}
.meme-modal-inner img {
    width: 100%;
    border-radius: 12px;
    margin-bottom: 12px;
    display: block;
}
.modal-close {
    position: absolute;
    top: 12px; right: 14px;
    background: var(--bg-card-light);
    border: 1px solid var(--border-soft);
    color: var(--ink);
    border-radius: 50%;
    width: 32px; height: 32px;
    font-size: 14px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.modal-caption { font-size: 14px; color: var(--ink); margin-bottom: 8px; }
.modal-meta { font-size: 11px; color: var(--ink-dim); font-family: var(--font-mono); margin-bottom: 14px; }
.modal-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.ig-share-btn {
    background: linear-gradient(135deg, #833ab4, #fd1d1d, #fcb045);
    color: #fff;
    border: none;
    border-radius: var(--radius-pill);
    padding: 12px 20px;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    flex: 1;
    transition: opacity 0.2s;
}
.ig-share-btn.posted {
    background: var(--bg-card-light);
    color: var(--accent-acid);
    border: 1px solid var(--accent-acid);
    cursor: default;
}

/* Copy btn inline change */
.copy-btn { transition: background 0.2s, color 0.2s; }

/* Signup profile pic + icon selector */
.profile-pic-upload {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}
.pic-preview {
    width: 80px; height: 80px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 36px;
    overflow: hidden;
    border: 3px solid rgba(255,255,255,0.15);
    background: #FF6B6B;
}
.pic-preview img { width:100%; height:100%; object-fit:cover; border-radius:50%; }
.pic-upload-btn {
    background: var(--bg-card-light);
    border: 1px solid var(--border-soft);
    color: var(--ink-dim);
    border-radius: var(--radius-pill);
    padding: 8px 16px;
    font-size: 13px;
    cursor: pointer;
    font-family: var(--font-body);
}

.icon-selector { margin-bottom: 4px; }
.icon-grid {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 8px;
}
.icon-option { cursor: pointer; }
.icon-option input { display: none; }
.icon-circle {
    width: 38px; height: 38px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
    border: 3px solid transparent;
    transition: border-color 0.15s;
}
.icon-option.selected .icon-circle { border-color: var(--accent-acid); }
