/*!
 * UI Fixes for Social Network Platform
 * Fixes for dropdown actions, scroll button, post form icons, and other UI issues
 */

/* Fix 1: Dropdown Actions Being Cut Off */
.dropdown-menu {
    position: absolute !important;
    z-index: 9999 !important;
    min-width: 160px !important;
    max-width: 250px !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
    border: 1px solid rgba(0, 0, 0, 0.1) !important;
    border-radius: 8px !important;
    overflow: visible !important;
    margin-top: 2px !important;
}

/* Ensure dropdown parent has proper positioning */
.dropdown {
    position: relative !important;
}

/* Fix dropdown items */
.dropdown-item {
    padding: 8px 16px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    display: block !important;
    width: 100% !important;
    clear: both !important;
    font-weight: 400 !important;
    color: #212529 !important;
    text-align: inherit !important;
    text-decoration: none !important;
    background-color: transparent !important;
    border: 0 !important;
}

.dropdown-item:hover,
.dropdown-item:focus {
    background-color: #f8f9fa !important;
    color: #16181b !important;
    text-decoration: none !important;
}

/* Fix for 3-dot menu specifically */
.post-actions .dropdown-menu,
.item-actions .dropdown-menu,
.timeline-item .dropdown-menu,
.post-item .dropdown-menu {
    right: 0 !important;
    left: auto !important;
    transform: none !important;
    position: absolute !important;
    top: 100% !important;
    margin-top: 2px !important;
}

/* Ensure post action containers are properly positioned */
.post-actions,
.item-actions,
.timeline-item .dropdown,
.post-item .dropdown {
    position: relative !important;
}

/* Fix for floating delete buttons */
.dropdown-menu.show {
    position: absolute !important;
    right: 0 !important;
    left: auto !important;
    top: 100% !important;
    transform: none !important;
    margin-top: 2px !important;
}

/* Additional fixes for common post structures */
.post .dropdown,
.timeline-post .dropdown,
.feed-item .dropdown,
.stream-item .dropdown {
    position: relative !important;
}

.post .dropdown-menu,
.timeline-post .dropdown-menu,
.feed-item .dropdown-menu,
.stream-item .dropdown-menu {
    position: absolute !important;
    right: 0 !important;
    left: auto !important;
    top: 100% !important;
    margin-top: 2px !important;
    z-index: 9999 !important;
}

/* Fix for any detached dropdowns */
.dropdown-menu[style*="position: fixed"] {
    position: absolute !important;
}

/* Ensure 3-dot buttons are properly contained */
.post-options,
.item-options,
.more-options {
    position: relative !important;
    display: inline-block !important;
}

.post-options .dropdown-menu,
.item-options .dropdown-menu,
.more-options .dropdown-menu {
    position: absolute !important;
    right: 0 !important;
    left: auto !important;
    top: 100% !important;
    margin-top: 2px !important;
}

/* Fix 2: Scroll to Top Button Positioning */
.scroll-to-top,
.back-to-top,
.btn-scroll-top {
    position: fixed !important;
    bottom: 20px !important;
    right: 20px !important;
    z-index: 9998 !important;
    width: 50px !important;
    height: 50px !important;
    border-radius: 50% !important;
    background-color: #007bff !important;
    color: white !important;
    border: none !important;
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3) !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 18px !important;
}

.scroll-to-top:hover,
.back-to-top:hover,
.btn-scroll-top:hover {
    background-color: #0056b3 !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 16px rgba(0, 123, 255, 0.4) !important;
}

/* Remove any middle positioning */
.scroll-to-top.middle,
.back-to-top.middle,
.btn-scroll-top.middle {
    left: auto !important;
    right: 20px !important;
    top: auto !important;
    bottom: 20px !important;
    transform: none !important;
}

/* Fix 3: Post Form Icons Being Cut Off */
.item-actions {
    position: relative !important;
    min-height: 50px !important;
    padding: 8px !important;
    overflow: visible !important;
}

.item-image-action-button {
    position: relative !important;
    display: inline-block !important;
    margin-right: 8px !important;
    padding: 8px 12px !important;
    border-radius: 6px !important;
    background-color: #f8f9fa !important;
    border: 1px solid #dee2e6 !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    overflow: visible !important;
    min-width: 44px !important;
    min-height: 44px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.item-image-action-button:hover {
    background-color: #e9ecef !important;
    border-color: #adb5bd !important;
    transform: translateY(-1px) !important;
}

.item-image-action-button input[type="file"] {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    opacity: 0 !important;
    cursor: pointer !important;
    z-index: 2 !important;
}

.item-image-action-button i {
    font-size: 18px !important;
    color: #6c757d !important;
    pointer-events: none !important;
    z-index: 1 !important;
}

.item-image-action-button:hover i {
    color: #495057 !important;
}

/* Fix positioning of action buttons */
.item-actions > div[style*="position: absolute"] {
    position: relative !important;
    left: auto !important;
    bottom: auto !important;
    right: auto !important;
    display: inline-flex !important;
    gap: 8px !important;
    align-items: center !important;
}

/* Fix 4: File Selection Type Filtering - Enhanced styling */
.item-add-image input[type="file"] {
    accept: "image/*" !important;
}

.item-add-video input[type="file"] {
    accept: "video/*" !important;
}

/* Visual indicators for file types */
.item-add-image::after {
    content: "Images" !important;
    position: absolute !important;
    bottom: -20px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    font-size: 10px !important;
    color: #6c757d !important;
    white-space: nowrap !important;
    pointer-events: none !important;
}

.item-add-video::after {
    content: "Videos" !important;
    position: absolute !important;
    bottom: -20px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    font-size: 10px !important;
    color: #6c757d !important;
    white-space: nowrap !important;
    pointer-events: none !important;
}

/* Fix 5: Double Arrows in Dropdown */
.dropdown-toggle::after {
    display: inline-block !important;
    margin-left: 0.255em !important;
    vertical-align: 0.255em !important;
    content: "" !important;
    border-top: 0.3em solid !important;
    border-right: 0.3em solid transparent !important;
    border-bottom: 0 !important;
    border-left: 0.3em solid transparent !important;
}

/* Remove duplicate arrows */
.dropdown-toggle .fa-chevron-down,
.dropdown-toggle .fa-caret-down,
.dropdown-toggle .icofont-simple-down {
    display: none !important;
}

/* Ensure only one arrow shows */
.dropdown-toggle i + .dropdown-toggle::after {
    display: none !important;
}

/* Fix 6: General Improvements */
.card {
    border-radius: 12px !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
    border: 1px solid #e9ecef !important;
    overflow: visible !important;
}

.card-header {
    border-radius: 12px 12px 0 0 !important;
    background-color: #f8f9fa !important;
    border-bottom: 1px solid #e9ecef !important;
}

/* Form improvements */
.profile_question_form {
    overflow: visible !important;
}

.form_actions {
    overflow: visible !important;
    position: relative !important;
}

/* Button improvements */
.primary_btn {
    border-radius: 6px !important;
    padding: 8px 16px !important;
    font-weight: 500 !important;
    transition: all 0.2s ease !important;
}

.primary_btn:hover {
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15) !important;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .dropdown-menu {
        min-width: 140px !important;
        font-size: 14px !important;
    }
    
    .item-image-action-button {
        min-width: 40px !important;
        min-height: 40px !important;
        padding: 6px 8px !important;
    }
    
    .item-image-action-button i {
        font-size: 16px !important;
    }
    
    .scroll-to-top,
    .back-to-top,
    .btn-scroll-top {
        width: 45px !important;
        height: 45px !important;
        bottom: 15px !important;
        right: 15px !important;
        font-size: 16px !important;
    }
}

/* Fix for specific post actions */
.post-item .dropdown-menu,
.timeline-item .dropdown-menu {
    right: 0 !important;
    left: auto !important;
    min-width: 150px !important;
}

/* Ensure dropdowns don't get clipped by containers */
.container,
.container-fluid,
.main-content,
.content-wrapper {
    overflow: visible !important;
}

/* Fix z-index stacking */
.navbar {
    z-index: 1030 !important;
}

.modal {
    z-index: 1050 !important;
}

.dropdown-menu {
    z-index: 9999 !important;
}

.scroll-to-top,
.back-to-top,
.btn-scroll-top {
    z-index: 9998 !important;
}

/* Additional fixes for common issues */
.overflow-hidden {
    overflow: visible !important;
}

.position-relative {
    overflow: visible !important;
}

/* Smooth animations */
* {
    transition: transform 0.2s ease, box-shadow 0.2s ease !important;
}

/* Fix for select dropdowns with double arrows */
select.form-control {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m1 6 7 7 7-7'/%3e%3c/svg%3e") !important;
    background-repeat: no-repeat !important;
    background-position: right 0.75rem center !important;
    background-size: 16px 12px !important;
    padding-right: 2.25rem !important;
}

/* Remove default select arrow on webkit browsers */
select.form-control::-webkit-outer-spin-button,
select.form-control::-webkit-inner-spin-button {
    -webkit-appearance: none !important;
    margin: 0 !important;
}

select.form-control {
    -moz-appearance: none !important;
    -webkit-appearance: none !important;
    appearance: none !important;
}
