/* Hybrid Twitter/TikTok-style Composer Styles */

/* Enhanced Composer Layout */
.hybrid-composer {
    background: linear-gradient(135deg, rgba(15,15,15,0.95), rgba(8,8,8,0.95));
    border: 1px solid rgba(255,255,255,0.05);
    padding: 20px;
    border-radius: 16px;
    margin-bottom: 24px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.3);
    position: relative;
    overflow: hidden;
}

.composer-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.composer-avatar {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 800;
    font-size: 1.2em;
    background: linear-gradient(135deg, #ff69b4, #8b00ff);
    box-shadow: 0 4px 15px rgba(255,105,180,0.3);
    overflow: hidden;
    flex-shrink: 0;
}
.composer-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.composer-avatar-initials {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.composer-content {
    flex: 1;
    min-width: 0;
}

/* Twitter-style Text Input */
.composer-textarea {
    width: 100%;
    min-height: 100px;
    resize: vertical;
    background: transparent;
    border: 1px solid rgba(255,255,255,0.06);
    padding: 14px;
    border-radius: 12px;
    color: var(--color-text);
    font-size: 1.1em;
    font-family: inherit;
    line-height: 1.5;
    transition: all 0.3s ease;
    box-sizing: border-box;
}

.composer-textarea:focus {
    outline: none;
    border-color: rgba(255,105,180,0.4);
    box-shadow: 0 0 0 3px rgba(255,105,180,0.1);
    background: rgba(255,255,255,0.02);
}

/* Character Counter (Twitter-style) */
.char-counter {
    text-align: right;
    font-size: 0.8em;
    color: rgba(255,255,255,0.6);
    margin-top: 4px;
    height: 16px;
}

.char-counter.warning {
    color: #ffd9f7;
    font-weight: 600;
}

.char-counter.error {
    color: #ff69b4;
    font-weight: 700;
}

/* Enhanced Media Actions */
.composer-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    margin: 16px 0;
    flex-wrap: wrap;
}

/* Visibility selector + NSFW toggle — matching pill style so they read as
   a paired control group at the end of the composer actions row. */
.composer-visibility-pill {
    appearance: none;
    -webkit-appearance: none;
    padding: 6px 26px 6px 12px;
    background: rgba(255,255,255,0.04) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%23ff69b4' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>") no-repeat right 8px center;
    border: 1px solid rgba(255,105,180,0.3);
    border-radius: 999px;
    color: #fff;
    font-size: 0.85em;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s, background-color 0.15s, box-shadow 0.15s;
}
.composer-visibility-pill:hover,
.composer-visibility-pill:focus {
    border-color: rgba(255,105,180,0.55);
    background-color: rgba(255,105,180,0.08);
    outline: none;
    box-shadow: 0 0 0 2px rgba(255,105,180,0.12);
}
.composer-visibility-pill option {
    background: #141420;
    color: #fff;
}
.composer-nsfw-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 999px;
    color: rgba(255,255,255,0.55);
    font-size: 0.85em;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
    user-select: none;
}
.composer-nsfw-toggle:hover {
    background: rgba(255,182,213,0.08);
    border-color: rgba(255,182,213,0.4);
    color: #ffb6d5;
}
/* `:has(input:checked)` lights the pill when NSFW is on. Modern Safari/Chrome/
   Firefox all support :has() — older browsers degrade to the unchecked style,
   which is acceptable since the form-level value still posts correctly. */
.composer-nsfw-toggle:has(input:checked) {
    background: rgba(255,154,193,0.18);
    border-color: rgba(255,154,193,0.7);
    color: #ff9ec7;
    box-shadow: 0 0 14px rgba(255,154,193,0.3);
}
.composer-nsfw-toggle i {
    font-size: 0.85em;
}

.media-btn {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.08);
    color: #ffd9f7;
    padding: 8px 12px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.95em;
}

.media-btn:hover {
    background: rgba(255,105,180,0.1);
    border-color: rgba(255,105,180,0.3);
    transform: translateY(-1px);
}

.media-btn:active {
    transform: translateY(0);
}

/* TikTok-style Aspect Ratio Toggle */
.aspect-toggle {
    display: flex;
    gap: 8px;
    background: rgba(255,255,255,0.03);
    padding: 4px;
    border-radius: 20px;
    border: 1px solid rgba(255,255,255,0.05);
}

.ratio-btn {
    background: transparent;
    border: none;
    color: rgba(255,255,255,0.7);
    padding: 6px 10px;
    border-radius: 16px;
    cursor: pointer;
    font-size: 1.1em;
    transition: all 0.3s ease;
}

.ratio-btn.active {
    background: linear-gradient(135deg, #ff69b4, #8b00ff);
    color: #000;
    box-shadow: 0 2px 8px rgba(255,105,180,0.3);
}

/* Twitter-style Emoji Button */
.emoji-btn {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.08);
    color: #ffd9f7;
    padding: 5px 9px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.9em;
}

.emoji-btn:hover {
    background: rgba(187, 95, 255, 0.1);
    border-color: rgba(187, 95, 255, 0.3);
}

/* GIF Button */
.gif-btn {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.08);
    color: #ffd9f7;
    padding: 5px 9px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.82em;
}

.gif-btn:hover {
    background: rgba(76, 175, 80, 0.1);
    border-color: rgba(76, 175, 80, 0.3);
}

/* Submit Button */
.composer-submit {
    margin-left: auto;
    padding: 12px 24px;
    border-radius: 20px;
    background: linear-gradient(90deg, #ff69b4, #bf5fff);
    color: #000;
    border: 0;
    cursor: pointer;
    font-weight: 700;
    font-size: 1.05em;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(255,105,180,0.4);
}

.composer-submit:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(255,105,180,0.6);
}

.composer-submit:disabled {
    background: rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.5);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Media Preview Grid (Instagram-style) */
.media-preview-container {
    margin-top: 16px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
    max-height: 300px;
    overflow-y: auto;
}

.media-preview-item {
    position: relative;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
    aspect-ratio: 16/9; /* Default aspect ratio */
}

.media-preview-item.vertical {
    aspect-ratio: 9/16;
}

.media-preview-item.square {
    aspect-ratio: 1/1;
}

.media-preview-item:hover {
    transform: scale(1.02);
    border-color: rgba(255,105,180,0.3);
}

.media-preview-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.media-preview-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    background: #000;
}

/* Media Overlay Info */
.media-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0,0,0,0.8));
    padding: 8px;
    color: #fff;
    font-size: 0.75em;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.media-size {
    background: rgba(0,0,0,0.5);
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
}

.media-duration {
    background: rgba(0,0,0,0.5);
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
}

.aspect-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0,0,0,0.7);
    color: #fff;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.75em;
    font-weight: 700;
    border: 1px solid rgba(255,255,255,0.2);
}

/* Remove Button */
.remove-media-btn {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(255, 255, 255, 0.9);
    color: #000;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.8em;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.remove-media-btn:hover {
    background: #ff69b4;
    color: #fff;
    transform: scale(1.1);
}

/* File Input Styling */
.file-input-wrapper {
    position: relative;
    display: inline-block;
}

.file-input-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: 1px solid rgba(255,255,255,0.08);
    color: #ffd9f7;
    padding: 8px 12px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
}

.file-input-label:hover {
    background: rgba(255,105,180,0.1);
    border-color: rgba(255,105,180,0.3);
}

.file-input-hidden {
    position: absolute;
    left: -9999px;
    opacity: 0;
    pointer-events: none;
}

/* Emoji Picker */
.emoji-picker {
    position: absolute;
    top: 100%;
    right: 0;
    background: rgba(15,15,15,0.95);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.5);
    display: none;
    z-index: 1000;
    max-width: 300px;
    max-height: 300px;
    overflow: hidden;
}

.emoji-picker.active {
    display: block;
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
    max-height: 200px;
    overflow-y: auto;
}

.emoji-btn-grid {
    background: transparent;
    border: none;
    padding: 6px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.2em;
    transition: all 0.2s ease;
}

.emoji-btn-grid:hover {
    background: rgba(255,105,180,0.1);
}

/* GIF Picker */
.gif-picker {
    position: absolute;
    top: 100%;
    right: 0;
    background: rgba(15,15,15,0.95);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.5);
    display: none;
    z-index: 1000;
    width: 400px;
    max-height: 400px;
}

.gif-picker.active {
    display: block;
}

.gif-search {
    width: 100%;
    padding: 8px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.08);
    background: transparent;
    color: var(--color-text);
    margin-bottom: 8px;
}

.gif-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    max-height: 250px;
    overflow-y: auto;
}

.gif-item {
    aspect-ratio: 1/1;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid rgba(255,255,255,0.05);
}

.gif-item:hover {
    transform: scale(1.05);
    border-color: rgba(255,105,180,0.3);
}

.gif-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}


/* Progress Indicators */
.upload-progress {
    width: 100%;
    height: 4px;
    background: rgba(255,255,255,0.1);
    border-radius: 2px;
    overflow: hidden;
    margin: 8px 0;
    display: none;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #ff69b4, #bf5fff);
    width: 0%;
    transition: width 0.3s ease;
}

/* Error Messages */
.error-message {
    color: #ff69b4;
    font-size: 0.9em;
    margin-top: 8px;
    display: none;
}

.error-message.active {
    display: block;
}

/* Success Messages */
.success-message {
    color: #4ade80;
    font-size: 0.9em;
    margin-top: 8px;
    display: none;
}

.success-message.active {
    display: block;
}

/* Responsive Design */
@media (max-width: 768px) {
    .hybrid-composer {
        padding: 16px;
    }

    /* Previously this stacked the entire action row vertically — every
       button on its own line, lots of wasted height. Now we just allow
       wrap, keep alignment center, and let pills flow naturally; the
       600px breakpoint below handles the tighter phone-width adjustments
       (rating widget on its own row, submit full-width). */
    .composer-actions {
        align-items: center;
        flex-wrap: wrap;
    }

    .aspect-toggle {
        margin-bottom: 8px;
    }
    
    .media-preview-container {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 8px;
    }
    
    .gif-picker {
        width: 100%;
        right: 0;
    }
}

/* Animation Classes */
.fade-in {
    animation: fadeIn 0.3s ease-in;
}

.fade-out {
    animation: fadeOut 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeOut {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(10px); }
}

/* Loading Spinner */
.loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: #ff69b4;
    animation: spin 1s ease-in-out infinite;
}

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

/* ── Song Search & Rating Widget ── */
.rating-creation-container {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 0;
    background: rgba(255,255,255,0.035);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 999px;
    padding: 0;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
    flex: 1 1 280px;
    min-width: 200px;
    max-width: 420px;
    overflow: visible;
    position: relative;
}

/* Softer focus — was a thick saturated pink ring that read as "harsh". This
   keeps a clear focus signal without the high-contrast pop. */
.rating-creation-container:focus-within {
    border-color: rgba(255,154,193,0.45);
    background: rgba(255,154,193,0.04);
    box-shadow: 0 0 0 2px rgba(255,154,193,0.08);
}

.rating-creation-container .rating-search-group {
    border-right: 1px solid rgba(255,255,255,0.06);
}
.rating-creation-container:focus-within .rating-search-group {
    border-right-color: rgba(255,154,193,0.22);
}

.rating-search-group {
    position: relative;
    flex: 1;
    min-width: 0;
}

.song-search-input {
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    color: #fff;
    padding: 8px 12px 8px 32px;
    font-size: 0.86rem;
    font-family: inherit;
    font-weight: 500;
    transition: color 0.2s;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='rgba(255,105,180,0.7)' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 12px center;
    background-size: 14px;
    box-sizing: border-box;
}

.song-search-input::placeholder { color: rgba(255,255,255,0.35); font-size: 0.8rem; }
.song-search-input:focus { color: #fff; }

.song-search-results {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: #1a1a24;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 14px;
    max-height: 260px;
    overflow-y: auto;
    z-index: 1100;
    display: none;
    box-shadow: 0 12px 36px rgba(0,0,0,0.6);
    padding: 6px;
    /* Firefox scrollbar — thin, themed colors instead of the default chunky
       gray rail that read as "harsh" against the dark dropdown. */
    scrollbar-width: thin;
    scrollbar-color: rgba(255,105,180,0.35) transparent;
}
/* Webkit/Chrome/Safari — match Firefox styling. Default scrollbar uses
   system colors which look out of place on a dark neon-pink dropdown. */
.song-search-results::-webkit-scrollbar {
    width: 6px;
}
.song-search-results::-webkit-scrollbar-track {
    background: transparent;
    margin: 6px 0;
}
.song-search-results::-webkit-scrollbar-thumb {
    background: rgba(255,105,180,0.3);
    border-radius: 999px;
    transition: background 0.15s;
}
.song-search-results::-webkit-scrollbar-thumb:hover {
    background: rgba(255,105,180,0.5);
}

.song-search-results.active { display: block; }

.song-search-result-item {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    cursor: pointer;
    border-radius: 10px;
    transition: background 0.12s;
}

.song-search-result-item:hover { background: rgba(255,105,180,0.10); }

.song-search-result-text {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.song-search-result-item .song-title {
    font-weight: 700;
    font-size: 0.88rem;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.song-search-result-item .artist-name {
    color: rgba(255,255,255,0.55);
    font-size: 0.75rem;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* "You rated 9.5" chip on songs the user already rated — gives at-a-glance
   feedback in the search dropdown so they can pick a song they've already
   scored without having to remember. Number auto-fills the rating input on
   select. */
.song-search-result-item .song-search-result-rating {
    flex-shrink: 0;
    padding: 3px 9px;
    border-radius: 999px;
    background: rgba(255,105,180,0.14);
    border: 1px solid rgba(255,105,180,0.4);
    color: #ff9ec7;
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

/* Divider handled via .rating-search-group border-right (set in the
   .rating-creation-container block above) — old ::after divider removed. */

.rating-input-group {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    padding: 0 4px;
}

.rating-input {
    width: 64px !important;
    background: transparent;
    border: none;
    outline: none;
    color: #ff93d6;
    font-size: 0.95rem;
    font-weight: 700;
    font-family: inherit;
    text-align: center;
    padding: 8px 6px;
    -moz-appearance: textfield;
}

.rating-input::-webkit-outer-spin-button,
.rating-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.rating-input::placeholder { color: rgba(255,105,180,0.45); font-size: 0.95rem; }

/* Selected song chip */
.selected-song-display {
    display: none;
    align-items: center;
    gap: 8px;
    background: rgba(255,105,180,0.12);
    border-radius: 999px;
    padding: 6px 12px 6px 14px;
    flex: 1;
    min-width: 0;
    min-height: 32px;
}

.selected-song-display.active,
.selected-song-display[style*="flex"],
.selected-song-display[style*="inline"] { display: flex !important; }

.selected-song-text {
    font-size: 0.86rem;
    font-weight: 600;
    color: #ffd9f7;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

/* Music-note emoji prefix removed — read as gimmicky; the pink chip
   styling already signals "music selection" without needing the icon. */

/* Rating chip on the selected-song display — separate element so it stays
   visible even when the song title gets ellipsis-truncated for long names. */
.selected-song-rating {
    flex-shrink: 0;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(255,105,180,0.18);
    border: 1px solid rgba(255,105,180,0.45);
    color: #ff9ec7;
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    line-height: 1.4;
}

.clear-rating-btn {
    background: transparent;
    border: none;
    color: rgba(255,105,180,0.7);
    width: 16px;
    height: 16px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.65rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s, background 0.15s;
    flex-shrink: 0;
    padding: 0;
    line-height: 1;
}

.clear-rating-btn:hover { color: #ff69b4; background: rgba(255,105,180,0.15); }

@media (max-width: 600px) {
    /* The composer actions row gets cramped on narrow screens — let the
       rating-attach widget take a full row to itself instead of squeezing
       between Add Media and the visibility/NSFW pills. */
    .rating-creation-container {
        width: 100%;
        flex: 1 1 100%;
        max-width: none;
        min-width: 0;
    }
    .song-search-input { font-size: 0.82rem; }
    .song-search-results {
        /* On mobile the dropdown should stretch the full width of the parent
           container rather than the (narrow) input width. */
        left: -1px;
        right: -1px;
    }
    /* Stack the action buttons cleanly. Submit moves to its own row at full
       width — easier tap target on phones. */
    .composer-actions {
        gap: 8px;
    }
    .composer-actions > * {
        flex-shrink: 0;
    }
    .file-input-wrapper,
    .composer-visibility-pill,
    .composer-nsfw-toggle {
        flex: 0 0 auto;
    }
    .composer-submit {
        order: 99;       /* always last */
        flex: 1 1 100%;  /* full width row */
        margin-top: 4px;
    }
}