/* ===========================
   PEEPSO REEL - CSS
   =========================== */

:root {
    --reel-bg: #0a0a0a;
    --reel-card-bg: #1a1a1a;
    --reel-accent: #ff2d55;
    --reel-gold: #f0c040;
    --reel-text: #ffffff;
    --reel-muted: #aaaaaa;
    --reel-border: #2a2a2a;
    --reel-radius: 16px;
}

.psreel-wrap {
    max-width: 520px;
    margin: 0 auto;
    padding: 16px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ---- UPLOAD BOX ---- */
.psreel-upload-box {
    background: var(--reel-card-bg);
    border: 1px solid var(--reel-border);
    border-radius: var(--reel-radius);
    padding: 20px;
    margin-bottom: 24px;
    color: var(--reel-text);
}

.psreel-upload-box h3 {
    margin: 0 0 16px;
    font-size: 16px;
    color: var(--reel-text);
}

.psreel-upload-options {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

/* ---- BUTTONS ---- */
.psreel-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 50px;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s ease;
    text-decoration: none;
}

.psreel-btn-upload {
    background: var(--reel-gold);
    color: #000;
}

.psreel-btn-upload:hover {
    background: #d4a800;
    transform: translateY(-1px);
}

.psreel-btn-record {
    background: var(--reel-accent);
    color: #fff;
}

.psreel-btn-record:hover {
    background: #d4002d;
    transform: translateY(-1px);
}

.psreel-btn-publish {
    background: var(--reel-accent);
    color: #fff;
    flex: 1;
}

.psreel-btn-cancel {
    background: var(--reel-border);
    color: var(--reel-muted);
}

.psreel-btn-loadmore {
    background: var(--reel-card-bg);
    color: var(--reel-text);
    border: 1px solid var(--reel-border);
    width: 100%;
    justify-content: center;
    padding: 14px;
    border-radius: var(--reel-radius);
}

/* ---- PREVIEW VIDEO ---- */
.psreel-preview-wrap {
    margin: 12px 0;
    border-radius: 12px;
    overflow: hidden;
    background: #000;
    position: relative;
}

.psreel-wrap .psreel-preview-wrap video,
.psreel-wrap .psreel-camera-wrap video {
    width: 100% !important;
    height: 70vw !important;
    max-height: 75vh !important;
    min-height: 300px !important;
    object-fit: cover !important;
    display: block !important;
    border-radius: 0 !important;
}

.psreel-preview-info {
    padding: 8px 12px;
    font-size: 13px;
    color: var(--reel-muted);
}

/* ---- CAMERA LIVE ---- */
.psreel-camera-wrap {
    margin: 0;
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    background: #000;
    width: 100%;
}

.psreel-record-controls {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    z-index: 10;
}

.psreel-flip-btn {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 20;
    background: rgba(0,0,0,0.55);
    border: none;
    color: #fff;
    font-size: 22px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    transition: background 0.2s;
}
.psreel-flip-btn:hover { background: rgba(255,255,255,0.2); }

.psreel-record-timer {
    background: rgba(0,0,0,0.7);
    color: #fff;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 16px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.psreel-btn-stop {
    background: var(--reel-accent);
    color: #fff;
    border: none;
    padding: 12px 24px;
    border-radius: 50px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
}

.psreel-record-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: rgba(255,255,255,0.2);
}

.psreel-record-progress {
    height: 100%;
    background: var(--reel-accent);
    width: 0%;
    transition: width 1s linear;
}

/* ---- CAPTION ---- */
.psreel-caption-wrap {
    margin-top: 12px;
}

.psreel-caption-wrap textarea {
    width: 100%;
    background: #111;
    border: 1px solid var(--reel-border);
    color: var(--reel-text);
    border-radius: 10px;
    padding: 12px;
    font-size: 14px;
    resize: none;
    height: 80px;
    box-sizing: border-box;
}

.psreel-upload-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

/* ---- PROGRESS BAR ---- */
.psreel-progress-bar {
    margin-top: 10px;
    background: var(--reel-border);
    border-radius: 10px;
    height: 6px;
    position: relative;
    overflow: hidden;
}

.psreel-progress-fill {
    height: 100%;
    background: var(--reel-accent);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 10px;
}

#psreel-progress-text {
    font-size: 12px;
    color: var(--reel-muted);
    display: block;
    text-align: center;
    margin-top: 4px;
}

/* ---- MESSAGE ---- */
.psreel-message {
    margin-top: 12px;
    padding: 10px 16px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
}

.psreel-message.success {
    background: #0d2e1a;
    color: #4caf50;
    border: 1px solid #4caf50;
}

.psreel-message.error {
    background: #2e0d0d;
    color: #f44336;
    border: 1px solid #f44336;
}

/* ---- FEED ---- */
.psreel-feed {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ---- REEL CARD ---- */
.psreel-card {
    background: var(--reel-card-bg);
    border: 1px solid var(--reel-border);
    border-radius: var(--reel-radius);
    overflow: hidden;
    position: relative;
}

.psreel-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
}

.psreel-card-header img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--reel-accent);
}

.psreel-author-info {
    flex: 1;
}

.psreel-author-name {
    font-weight: 700;
    font-size: 14px;
    color: var(--reel-text);
    text-decoration: none;
}

.psreel-author-name:hover {
    color: var(--reel-gold);
}

.psreel-date {
    font-size: 12px;
    color: var(--reel-muted);
}

/* ---- VIDEO ---- */
.psreel-video-wrap {
    position: relative;
    background: #000;
    cursor: pointer;
}

.psreel-video-wrap video {
    width: 100%;
    max-height: 560px;
    object-fit: cover;
    display: block;
}

.psreel-play-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.3);
    opacity: 0;
    transition: opacity 0.2s;
}

.psreel-video-wrap:hover .psreel-play-overlay,
.psreel-video-wrap.paused .psreel-play-overlay {
    opacity: 1;
}

.psreel-play-icon {
    width: 60px;
    height: 60px;
    background: rgba(255,255,255,0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

/* ---- CARD FOOTER ---- */
.psreel-card-footer {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.psreel-caption {
    padding: 0 16px 12px;
    font-size: 14px;
    color: var(--reel-text);
    line-height: 1.4;
}

.psreel-like-btn {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--reel-muted);
    font-size: 15px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 20px;
    transition: all 0.2s;
}

.psreel-like-btn:hover,
.psreel-like-btn.liked {
    color: var(--reel-accent);
    background: rgba(255,45,85,0.1);
}

.psreel-like-btn.liked .psreel-heart {
    animation: heartbeat 0.3s ease;
}

@keyframes heartbeat {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.4); }
    100% { transform: scale(1); }
}

.psreel-delete-btn {
    margin-left: auto;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--reel-muted);
    font-size: 13px;
    padding: 4px 8px;
    border-radius: 6px;
    transition: color 0.2s;
}

.psreel-delete-btn:hover {
    color: var(--reel-accent);
}

/* ---- LOGIN NOTICE ---- */
.psreel-login-notice {
    background: var(--reel-card-bg);
    border: 1px solid var(--reel-border);
    border-radius: var(--reel-radius);
    padding: 20px;
    text-align: center;
    color: var(--reel-muted);
    margin-bottom: 24px;
}

.psreel-login-notice a {
    color: var(--reel-gold);
    font-weight: 700;
}

/* ---- LOADING ---- */
.psreel-loading {
    display: flex;
    justify-content: center;
    padding: 40px;
}

.psreel-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--reel-border);
    border-top-color: var(--reel-accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.psreel-empty {
    text-align: center;
    color: var(--reel-muted);
    padding: 40px;
    font-size: 15px;
}

.psreel-load-more-wrap {
    margin-top: 16px;
}

/* ---- PROFILO GRID ---- */
.psreel-profile-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
}

.psreel-profile-item {
    position: relative;
    aspect-ratio: 9/16;
    overflow: hidden;
    cursor: pointer;
    border-radius: 8px;
    background: #000;
}

.psreel-profile-item video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.psreel-profile-likes {
    position: absolute;
    bottom: 6px;
    left: 6px;
    font-size: 12px;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
    font-weight: 600;
}

/* ---- RESPONSIVE ---- */
@media (max-width: 480px) {
    .psreel-wrap {
        padding: 8px;
    }

    .psreel-upload-options {
        flex-direction: column;
    }

    .psreel-btn-upload,
    .psreel-btn-record {
        justify-content: center;
        width: 100%;
    }
}

/* ===== REEL v2 - EDITOR =====  */
.psreel-editor-tabs { display:flex; gap:4px; margin:12px 0 10px; overflow-x:auto; scrollbar-width:none; }
.psreel-editor-tabs::-webkit-scrollbar { display:none; }
.psreel-tab { flex:1; padding:8px 4px; background:#222; border:1px solid #333; color:#aaa; border-radius:8px; cursor:pointer; font-size:12px; white-space:nowrap; transition:all .2s; }
.psreel-tab.active { background:#2a2600; border-color:#f0c040; color:#f0c040; }
.psreel-tab-pane { display:none; }
.psreel-tab-pane.active { display:block; }

/* Filtri */
.psreel-filters-grid { display:grid; grid-template-columns:repeat(3,1fr); gap:8px; margin-bottom:10px; }
.psreel-filter { display:flex; flex-direction:column; align-items:center; gap:4px; cursor:pointer; padding:6px; border-radius:8px; border:2px solid transparent; transition:border-color .2s; }
.psreel-filter.active { border-color:#f0c040; }
.psreel-filter-prev { width:56px; height:56px; border-radius:8px; background:linear-gradient(135deg,#ff6b6b,#feca57,#48dbfb,#ff9ff3); }
.psreel-filter small { font-size:11px; color:#aaa; }

/* Testo */
#psreel-text-inp { width:100%; padding:10px 12px; background:#222; border:1px solid #333; color:#fff; border-radius:8px; font-size:14px; box-sizing:border-box; margin-bottom:8px; }
.psreel-colors { display:flex; align-items:center; gap:7px; margin-bottom:10px; flex-wrap:wrap; }
.psreel-color { width:26px; height:26px; border-radius:50%; cursor:pointer; border:2px solid transparent; transition:border-color .2s; flex-shrink:0; }
.psreel-color.active { border-color:#fff; transform:scale(1.1); }
#psreel-text-sz { flex:1; background:#222; border:1px solid #333; color:#fff; border-radius:8px; padding:6px; font-size:13px; }
#psreel-add-text { width:100%; padding:10px; background:#333; border:1px solid #444; color:#fff; border-radius:8px; cursor:pointer; font-size:13px; font-weight:600; }
#psreel-add-text:hover { background:#444; }

/* Sticker */
.psreel-stickers-grid { display:grid; grid-template-columns:repeat(5,1fr); gap:6px; }
.psreel-sticker { font-size:28px; cursor:pointer; padding:6px; border-radius:8px; transition:transform .2s; text-align:center; }
.psreel-sticker:hover { transform:scale(1.3); background:#222; }

/* Musica */
.psreel-music-search-row { display:flex; gap:8px; margin-bottom:10px; }
#psreel-music-q { flex:1; padding:9px 12px; background:#222; border:1px solid #333; color:#fff; border-radius:8px; font-size:13px; }
#psreel-music-search { padding:9px 14px; background:#f0c040; color:#000; border:none; border-radius:8px; font-size:16px; cursor:pointer; font-weight:700; }
#psreel-music-results { max-height:200px; overflow-y:auto; }
.psreel-hint { color:#555; font-size:13px; padding:10px 0; }
.psreel-track { display:flex; align-items:center; gap:10px; padding:8px 10px; background:#222; border-radius:8px; margin-bottom:6px; border:1px solid transparent; transition:border-color .2s; }
.psreel-track:hover { border-color:#444; }
.psreel-track.selected { border-color:#f0c040; background:#2a2600; }
.psreel-track-cover { width:40px; height:40px; border-radius:6px; object-fit:cover; flex-shrink:0; }
.psreel-track-ph { background:#333; display:flex; align-items:center; justify-content:center; font-size:18px; }
.psreel-track-info { flex:1; text-align:left; min-width:0; }
.psreel-track-title { font-size:13px; font-weight:600; color:#fff; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.psreel-track-dur { font-size:11px; color:#666; }
.psreel-track-actions { display:flex; gap:6px; flex-shrink:0; }
.psreel-track-prev { width:30px; height:30px; border-radius:50%; background:#333; border:none; color:#fff; font-size:13px; cursor:pointer; display:flex; align-items:center; justify-content:center; transition:background .2s; }
.psreel-track-prev:hover { background:#555; }
.psreel-track-prev.playing { background:#ff2d55; }
.psreel-track-sel { padding:5px 10px; border-radius:20px; background:#333; border:1px solid #444; color:#ccc; font-size:12px; cursor:pointer; transition:all .2s; }
.psreel-track-sel:hover { background:#f0c040; color:#000; border-color:#f0c040; }
.psreel-track.selected .psreel-track-sel { background:#f0c040; color:#000; border-color:#f0c040; }
#psreel-music-chosen { display:flex; align-items:center; gap:8px; padding:8px 12px; background:#2a2600; border:1px solid #f0c040; border-radius:8px; color:#f0c040; font-size:13px; font-weight:600; margin-top:8px; justify-content:space-between; }
#psreel-music-remove { background:none; border:none; color:#888; cursor:pointer; font-size:16px; }

/* Preview con overlay */
.psreel-preview-wrap { position:relative; }
.psreel-preview-text-overlay {
    position:absolute; bottom:20%; left:50%; transform:translateX(-50%);
    font-weight:900; text-shadow:0 2px 8px rgba(0,0,0,.9);
    white-space:nowrap; pointer-events:none; z-index:5;
    max-width:90%; text-align:center;
}
.psreel-preview-sticker-overlay {
    position:absolute; top:10%; left:50%; transform:translateX(-50%);
    font-size:52px; pointer-events:none; z-index:5;
}

/* Card overlay nel feed */
.psreel-card-text-overlay {
    position:absolute; bottom:20%; left:50%; transform:translateX(-50%);
    font-weight:900; text-shadow:0 2px 8px rgba(0,0,0,.9);
    white-space:nowrap; pointer-events:none; z-index:5;
    max-width:90%; text-align:center;
}
.psreel-card-sticker-overlay {
    position:absolute; top:10%; left:50%; transform:translateX(-50%);
    font-size:52px; pointer-events:none; z-index:5;
}
.psreel-card-music {
    position:absolute; bottom:6%; left:50%; transform:translateX(-50%);
    background:rgba(0,0,0,.6); color:#fff; padding:5px 14px;
    border-radius:20px; font-size:12px; z-index:5;
    backdrop-filter:blur(4px); white-space:nowrap;
    max-width:85%; overflow:hidden; text-overflow:ellipsis;
}

/* ---- STICKY BAR ---- */
.reel-sticky-bar {
    position: sticky;
    top: 0;
    z-index: 99;
    display: flex;
    gap: 8px;
    padding: 10px 16px;
    background: rgba(10,10,10,0.92);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid #2a2a2a;
    justify-content: center;
    flex-wrap: wrap;
}

.reel-sticky-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: 50px;
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.reel-sticky-home {
    background: #1a1a1a;
    color: #fff;
    border: 1px solid #2a2a2a;
}
.reel-sticky-home:hover { background: #2a2a2a; color: #fff; }

.reel-sticky-upload {
    background: #f0c040;
    color: #000;
}
.reel-sticky-upload:hover { background: #d4a800; transform: translateY(-1px); color: #000; }

.reel-sticky-record {
    background: #ff2d55;
    color: #fff;
}
.reel-sticky-record:hover { background: #d4002d; transform: translateY(-1px); color: #fff; }

/* ---- Music drawer ---- */
#psreel-music-drawer {
    background: #161616;
    border: 1px solid #2a2a2a;
    border-radius: 12px;
    margin-top: 10px;
    overflow: hidden;
}
.psreel-music-drawer-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid #2a2a2a;
    background: #1a1a1a;
}
.psreel-music-drawer-header input[type="text"] {
    flex: 1;
    background: #111;
    border: 1px solid #2a2a2a;
    border-radius: 8px;
    padding: 7px 12px;
    color: #fff;
    font-size: 13px;
    outline: none;
}
.psreel-music-drawer-header input[type="text"]:focus { border-color: #f97316; }
.psreel-music-drawer-header button {
    background: none;
    border: none;
    color: #888;
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: color .15s;
}
.psreel-music-drawer-header button:hover { color: #fff; }
#psreel-music-list {
    max-height: 260px;
    overflow-y: auto;
    padding: 4px 0;
}
#psreel-music-list::-webkit-scrollbar { width: 4px; }
#psreel-music-list::-webkit-scrollbar-track { background: transparent; }
#psreel-music-list::-webkit-scrollbar-thumb { background: #333; border-radius: 2px; }
