/* ============================================================
   SCDev Stories — Frontend Styles
   ============================================================ */

/* ── Stories Bar ─────────────────────────────────────────── */

/* Outer wrapper — centers the bar and constrains its width */
.scdev-stories-bar-wrap {
    display: flex;
    justify-content: center;
    margin: 0 auto 12px auto;
    max-width: 80%;
}

/* Inner container — shrinks to fit bubbles, adds border */
.scdev-stories-bar {
    display: inline-flex;
    gap: 2px;
    padding: 8px 10px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    background: #fff;
    /* Shrink to content width, but never exceed the wrap */
    max-width: 100%;
}

.scdev-stories-bar::-webkit-scrollbar {
    display: none;
}

/* Mobile: 95% width */
@media (max-width: 768px) {
    .scdev-stories-bar-wrap {
        max-width: 95%;
    }
}

/* ── Sidebar widget variant ───────────────────────────────── */
/* When the bar is inside a widget area, fill the full widget width */
.widget .scdev-stories-bar-wrap,
.sidebar .scdev-stories-bar-wrap,
[class*="widget_scdev_stories"] .scdev-stories-bar-wrap {
    max-width: 100%;
    margin: 0 0 8px 0;
    justify-content: flex-start;
}

.widget .scdev-stories-bar,
.sidebar .scdev-stories-bar,
[class*="widget_scdev_stories"] .scdev-stories-bar {
    width: 100%;
    max-width: 100%;
}

/* Loading spinner */
.scdev-stories-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    color: #999;
    font-size: 13px;
}

.scdev-stories-loading::after {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid #ddd;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: scdev-spin 0.7s linear infinite;
    display: inline-block;
}

@keyframes scdev-spin {
    to { transform: rotate(360deg); }
}

/* Error message */
.scdev-stories-error {
    padding: 10px 12px;
    font-size: 13px;
    color: #999;
    text-align: center;
}

/* Login prompt */
.scdev-stories-login-prompt {
    padding: 10px 12px;
    font-size: 13px;
    color: #666;
}

/* ── Story Bubble ─────────────────────────────────────────── */

.scdev-story-bubble {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    flex-shrink: 0;
    width: 68px;
    transition: transform 0.15s;
    user-select: none;
}

.scdev-story-bubble:hover {
    transform: scale(1.05);
}

.scdev-story-add {
    margin-right: 12px;
}

.scdev-story-add .scdev-story-name {
    max-width: 80px;
    font-size: 10px;
}

.scdev-story-bubble-preview {
    width: 120px;
    gap: 2px;
}

/* Avatar ring container */
.scdev-story-avatar-ring {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    padding: 3px;
    position: relative;
    flex-shrink: 0;
}

/* Ring states */
.scdev-ring-unseen {
    background: linear-gradient(135deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
}

.scdev-ring-seen {
    background: #c0c0c0;
}

.scdev-ring-add {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

/* Avatar image */
.scdev-story-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #fff;
    display: block;
    background: #eee;
}

/* Story preview tile for users (instead of avatar + name) */
.scdev-story-preview-ring {
    width: 120px;
    height: 60px;
    border-radius: 10px;
    padding: 2px;
    position: relative;
    flex-shrink: 0;
    overflow: hidden;
}

.scdev-story-preview-media {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid #fff;
    display: block;
    background: #eee;
}

/* "+" badge on Add Story bubble */
.scdev-story-add-icon {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 20px;
    height: 20px;
    background: #3897f0;
    color: #fff;
    border-radius: 50%;
    font-size: 16px;
    line-height: 20px;
    text-align: center;
    border: 2px solid #fff;
    font-weight: bold;
}

/* Username label */
.scdev-story-name {
    font-size: 11px;
    text-align: center;
    max-width: 64px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #333;
    line-height: 1.2;
}

.scdev-story-name-tiny {
    font-size: 9px;
    max-width: 116px;
}

/* Dark / night mode */
body.night-mode .scdev-stories-bar,
body.dark-mode .scdev-stories-bar {
    background: #1a1a1a;
    border-color: #444;
}

body.night-mode .scdev-story-name,
body.dark-mode .scdev-story-name {
    color: #ccc;
}

/* ── Story Viewer Overlay ─────────────────────────────────── */

.scdev-stories-viewer {
    position: fixed;
    inset: 0;
    background: #000;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* ── Progress Bar ─────────────────────────────────────────── */

.scdev-viewer-progress {
    position: absolute;
    top: 8px;
    left: 8px;
    right: 8px;
    display: flex;
    gap: 4px;
    z-index: 10;
}

.scdev-progress-segment {
    flex: 1;
    height: 3px;
    background: rgba(255, 255, 255, 0.35);
    border-radius: 2px;
    overflow: hidden;
}

.scdev-progress-fill {
    height: 100%;
    width: 0%;
    background: #fff;
    border-radius: 2px;
}

.scdev-progress-fill.scdev-progress-completed {
    width: 100%;
    transition: none;
}

/* ── Viewer Header ────────────────────────────────────────── */

.scdev-viewer-header {
    position: absolute;
    top: 20px;
    left: 12px;
    right: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 10;
}

.scdev-viewer-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #fff;
    flex-shrink: 0;
    background: #333;
}

.scdev-viewer-username {
    color: #fff;
    font-weight: 600;
    font-size: 14px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

.scdev-viewer-timestamp {
    color: rgba(255, 255, 255, 0.7);
    font-size: 12px;
    margin-left: 2px;
}

.scdev-viewer-close {
    margin-left: auto;
    background: none;
    border: none;
    color: #fff;
    font-size: 28px;
    cursor: pointer;
    line-height: 1;
    padding: 4px 8px;
    opacity: 0.85;
    transition: opacity 0.2s;
    flex-shrink: 0;
}

.scdev-viewer-close:hover {
    opacity: 1;
}

/* ── Media Area ───────────────────────────────────────────── */

.scdev-viewer-media {
    max-width: 100%;
    max-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 1;
}

.scdev-viewer-media img,
.scdev-viewer-media video {
    max-width: 100vw;
    max-height: 100vh;
    object-fit: contain;
    display: block;
}

/* Error placeholder */
.scdev-viewer-media-error {
    color: rgba(255, 255, 255, 0.6);
    font-size: 14px;
    text-align: center;
    padding: 40px 20px;
}

/* ── Caption Overlay ──────────────────────────────────────── */

.scdev-viewer-caption {
    position: absolute;
    bottom: 40px;
    left: 16px;
    right: 16px;
    color: #fff;
    font-size: 15px;
    text-align: center;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.45));
    padding: 20px 12px 10px;
    border-radius: 8px;
    z-index: 10;
    pointer-events: none;
    line-height: 1.4;
}

.scdev-viewer-caption:empty {
    display: none;
}

/* ── Tap Zones ────────────────────────────────────────────── */

.scdev-viewer-tap-left,
.scdev-viewer-tap-right {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 50%;
    z-index: 5;
    cursor: pointer;
}

.scdev-viewer-tap-left  { left: 0; }
.scdev-viewer-tap-right { right: 0; }

/* ── Upload Modal ─────────────────────────────────────────── */

.scdev-upload-modal {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
}

.scdev-upload-modal-inner {
    background: #fff;
    border-radius: 12px;
    padding: 16px;
    width: 100%;
    max-width: 320px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.scdev-upload-modal-inner h3 {
    margin: 0;
    font-size: 15px;
    color: #333;
}

.scdev-upload-modal-inner input[type="file"] {
    font-size: 12px;
    width: 100%;
}

.scdev-upload-modal-inner textarea {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    resize: none;
    height: 52px;
    box-sizing: border-box;
}

.scdev-upload-modal-inner textarea:focus {
    outline: none;
    border-color: #667eea;
}

/* Upload preview — compact thumbnail grid */
.scdev-upload-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    max-height: 140px;
    overflow-y: auto;
    border-radius: 8px;
    background: #f5f5f5;
    padding: 6px;
}

.scdev-preview-item {
    position: relative;
    flex: 0 0 auto;
    width: 60px;
    height: 60px;
    border-radius: 6px;
    overflow: visible;
    background: #ddd;
}

.scdev-preview-item img,
.scdev-preview-item video {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 6px;
    display: block;
}

/* Delete (×) button on each thumbnail */
.scdev-preview-delete {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 18px;
    height: 18px;
    background: #e74c3c;
    color: #fff;
    border: 2px solid #fff;
    border-radius: 50%;
    font-size: 11px;
    line-height: 14px;
    text-align: center;
    cursor: pointer;
    padding: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
}

.scdev-preview-delete:hover {
    background: #c0392b;
}

.scdev-upload-preview:empty {
    display: none;
}

/* Upload action buttons */
.scdev-upload-actions {
    display: flex;
    gap: 8px;
}

.scdev-btn-primary {
    flex: 1;
    padding: 9px 12px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}

.scdev-btn-primary:hover {
    opacity: 0.9;
}

.scdev-btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.scdev-btn-secondary {
    padding: 9px 12px;
    background: #f0f0f0;
    color: #333;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.scdev-btn-secondary:hover {
    background: #e0e0e0;
}

/* Upload error message */
.scdev-upload-error {
    color: #e74c3c;
    font-size: 12px;
    min-height: 16px;
}

.scdev-upload-error:empty {
    display: none;
}

/* ── Responsive ───────────────────────────────────────────── */

@media (max-width: 480px) {
    .scdev-story-bubble {
        width: 58px;
    }

    .scdev-story-bubble-preview {
        width: 120px;
    }

    .scdev-story-avatar-ring {
        width: 48px;
        height: 48px;
    }

    .scdev-upload-modal-inner {
        padding: 16px;
    }
}
