/* Qorrum theme colors */
:root {
    --qorrum-primary: #6f42c1;
    --qorrum-secondary: #563d7c;
    --qorrum-light: #f8f9fa;
    --qorrum-dark: #343a40;
}

/* Navbar styling */
.navbar {
    background: var(--qorrum-primary) !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.navbar-brand {
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.qorrum-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: white;
    color: var(--qorrum-primary);
    border-radius: 50%;
    font-weight: bold;
    font-size: 1rem;
    margin-right: 0.25rem;
}

/* Button styling */
.btn-primary {
    background: linear-gradient(to bottom right, var(--qorrum-primary), var(--qorrum-secondary));
    border: none;
    color: white !important;
}

.btn-primary:hover {
    background: linear-gradient(to bottom right, var(--qorrum-secondary), #452c63);
    transform: translateY(-1px);
}

/* Browse Users button specific styles to ensure white text on all devices */
.browse-users-btn,
a.browse-users-btn,
.container .browse-users-btn,
.btn-primary[href*="users"],
a.btn-primary[href*="users"] {
    color: #ffffff !important;
    -webkit-text-fill-color: #ffffff !important;
}

.browse-users-btn:hover,
a.browse-users-btn:hover,
.container .browse-users-btn:hover,
.btn-primary[href*="users"]:hover,
a.btn-primary[href*="users"]:hover {
    color: #ffffff !important;
    -webkit-text-fill-color: #ffffff !important;
}

/* Mobile-specific overrides with ultra-high specificity to ensure white text in buttons */
@media (max-width: 767px) {
    html[class] body .card-body .browse-users-btn,
    html[class] body .card-body a.browse-users-btn,
    html[class] body .container .browse-users-btn,
    html[class] body .btn-primary[href*="users"],
    html[class] body a.btn-primary[href*="users"],
    html[class] body .btn-primary[href*="register"],
    html[class] body a.btn-primary[href*="register"],
    html[class] body .d-flex .btn-primary,
    html[class] body a.btn.btn-primary,
    html[class] body div.d-flex a.btn.btn-primary,
    html[class] body div.card-body a.btn.btn-primary,
    html[class] body div.card div.card-body a.btn.btn-primary,
    html[class] body div.container div.card div.card-body a.btn.btn-primary,
    html[class] body div.container div.mb-4 div.card div.card-body a.btn.btn-primary,
    html[class] body div.container div.mb-4 div.card div.card-body div.d-flex a.btn.btn-primary,
    html[class] body .container .btn.btn-primary,
    html[class] body div.container a.btn.btn-primary,
    html[class] body div.container div.mb-4 a.btn.btn-primary,
    html[class] body div.container div.d-flex a.btn.btn-primary {
        color: #ffffff !important;
        -webkit-text-fill-color: #ffffff !important;
        text-shadow: 0px 0px 1px rgba(0,0,0,0.3) !important;
    }
    
    /* Direct approach to target all primary buttons */
    .btn-primary, 
    a.btn-primary, 
    .btn.btn-primary, 
    a.btn.btn-primary {
        color: #ffffff !important;
        -webkit-text-fill-color: #ffffff !important;
    }
    
    /* Mobile-specific magazine styles */
    html[class] body .magazines-list .list-group-item,
    html[class] body .card .magazines-list .list-group-item,
    html[class] body .card-body .magazines-list .list-group-item,
    html[class] body .list-group-item.magazine-row {
        background: linear-gradient(to right, #6f42c1, #563d7c) !important;
        color: #ffffff !important;
        border: 1px solid rgba(255, 255, 255, 0.1) !important;
        border-radius: 0 !important;
        margin: 0 !important;
    }

    html[class] body .magazines-list .list-group-item a,
    html[class] body .magazines-list .magazine-link,
    html[class] body .list-group-item.magazine-row a,
    html[class] body .list-group-item.magazine-row a.magazine-link {
        color: #ffffff !important;
        -webkit-text-fill-color: #ffffff !important;
        text-decoration: none !important;
        display: block !important;
        width: 100% !important;
    }

    html[class] body .magazines-list .post-count,
    html[class] body .list-group-item.magazine-row .post-count {
        background-color: rgba(255, 255, 255, 0.2) !important;
        color: white !important;
        font-weight: 500 !important;
        font-size: 0.85rem !important;
    }
    
    /* Fix for horizontal overflow on mobile */
    html[class] body .post-content,
    html[class] body .card .post-content,
    html[class] body .card-body .post-content {
        overflow-wrap: break-word !important;
        word-wrap: break-word !important;
        word-break: break-word !important;
        -ms-word-break: break-all !important;
        -ms-hyphens: auto !important;
        -moz-hyphens: auto !important;
        -webkit-hyphens: auto !important;
        hyphens: auto !important;
        max-width: 100% !important;
        overflow-x: hidden !important;
    }
    
    /* Ensure content inside post stays within bounds */
    html[class] body .post-content p,
    html[class] body .post-content span,
    html[class] body .post-content div,
    html[class] body .post-content code,
    html[class] body .post-content pre {
        max-width: 100% !important;
        overflow-wrap: break-word !important;
        word-wrap: break-word !important;
        word-break: break-word !important;
    }
    
    /* Special handling for links to preserve styling */
    html[class] body .post-content a {
        max-width: 100% !important;
        overflow-wrap: break-word !important;
        word-wrap: break-word !important;
        word-break: break-word !important;
        color: #007bff !important;
        text-decoration: underline !important;
        display: inline !important;
    }
    
    /* Set appropriate spacing for post content - preserve list indentation */
    html[class] body .post-content {
        padding-right: 0 !important;
        margin-right: 0 !important;
    }
    
    /* Optimize spacing for posts on mobile */
    html[class] body .card {
        margin-bottom: 1rem !important;
    }
    
    html[class] body .card-body {
        padding: 0.75rem !important;
        padding-left: 0.5rem !important;
        padding-right: 0.25rem !important;
    }
    
    /* Reduce whitespace for nested posts but preserve list formatting */
    html[class] body .nested-posts {
        margin-top: 0.5rem !important;
        margin-left: 0 !important;
    }
    
    html[class] body .nested-posts .card.ms-4,
    html[class] body .nested-post .card.ms-4,
    html[class] body .ms-4,
    html[class] body .nested-posts .ms-4,
    html[class] body .nested-post .ms-4 {
        margin-left: 0 !important;
    }
    
    /* Force override Bootstrap's ms-4 class */
    .ms-4 {
        margin-left: 0 !important;
    }
    
    /* Visual distinction for nested posts without using space */
    html[class] body .nested-post .card {
        border-left: 2px solid #6f42c1 !important;
        border-radius: 0.25rem !important;
        background-color: rgba(111, 66, 193, 0.03) !important;
    }
    
    html[class] body .nested-post .card-body {
        padding: 0.5rem !important;
        padding-left: 0.2rem !important;
        padding-right: 0.2rem !important;
    }
    
    /* Ensure video containers in nested posts have adequate space */
    html[class] body .nested-post .video-container {
        margin: 0.5rem 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }
    
    html[class] body .nested-post .video-container video {
        width: 100% !important;
        display: block !important;
        background: red !important;
        min-height: 280px !important;
    }
    
    /* Fix list styling for mobile - ultra high specificity for bullets */
    html[class] body .post-content ul,
    html[class] body .card .post-content ul,
    html[class] body .nested-post .post-content ul,
    html[class] body .card-body .post-content ul {
        list-style-type: disc !important;
        list-style-position: outside !important;
        padding-left: 2.5em !important;
        margin: 0.5em 0 !important;
        display: block !important;
    }
    
    html[class] body .post-content ol,
    html[class] body .card .post-content ol,
    html[class] body .nested-post .post-content ol,
    html[class] body .card-body .post-content ol {
        list-style-type: decimal !important;
        list-style-position: outside !important;
        padding-left: 2.5em !important;
        margin: 0.5em 0 !important;
        display: block !important;
    }
    
    html[class] body .post-content ul > li,
    html[class] body .card .post-content ul > li,
    html[class] body .nested-post .post-content ul > li,
    html[class] body .card-body .post-content ul > li {
        display: list-item !important;
        list-style-type: disc !important;
        list-style-position: outside !important;
        visibility: visible !important;
        margin: 0.25em 0 !important;
    }
    
    html[class] body .post-content ol > li,
    html[class] body .card .post-content ol > li,
    html[class] body .nested-post .post-content ol > li,
    html[class] body .card-body .post-content ol > li {
        display: list-item !important;
        list-style-type: decimal !important;
        list-style-position: outside !important;
        visibility: visible !important;
        margin: 0.25em 0 !important;
    }
}

/* Link styling for post content across all pages */
.post-content a,
.card-body .post-content a,
.nested-post .post-content a {
    color: #007bff !important;
    text-decoration: underline !important;
    display: inline !important;
    font-weight: normal !important;
}

.post-content a:hover,
.card-body .post-content a:hover,
.nested-post .post-content a:hover {
    color: #0056b3 !important;
    text-decoration: underline !important;
}

/* Ensure links work on bulletin/magazine pages specifically */
.container .card .card-body .post-content a,
.w-100 .container .card .card-body .post-content a {
    color: #007bff !important;
    text-decoration: underline !important;
    display: inline !important;
    font-weight: normal !important;
}

/* Card styling */
.card {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* Username link styling */
.username-link {
    color: white !important;
    text-decoration: none;
    transition: color 0.2s ease;
    display: inline-flex;
    align-items: center;
}

.username-link:hover {
    text-decoration: underline;
    opacity: 0.9;
}

/* List group styling */
.list-group-item {
    background: linear-gradient(to right, var(--qorrum-primary), var(--qorrum-secondary)) !important;
    color: white !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

.list-group-item a {
    color: white !important;
    text-decoration: none;
}

.list-group-item a:hover {
    text-decoration: underline;
    opacity: 0.9;
}

/* Profile styles */
.profile-header {
    padding: 2rem;
    margin-bottom: 2rem;
    border-radius: 0.5rem;
    background: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* General list styling (not media-specific) */
.post-content ul {
    list-style-type: disc !important;
    list-style-position: outside !important;
    padding-left: 2.5em !important;
    margin: 0.5em 0 !important;
    display: block !important;
}

.post-content ol {
    list-style-type: decimal !important;
    list-style-position: outside !important;
    padding-left: 2.5em !important;
    margin: 0.5em 0 !important;
    display: block !important;
}

.post-content ul > li {
    display: list-item !important;
    list-style-type: disc !important;
    list-style-position: outside !important;
    visibility: visible !important;
    margin: 0.25em 0 !important;
}

.post-content ol > li {
    display: list-item !important;
    list-style-type: decimal !important;
    list-style-position: outside !important;
    visibility: visible !important;
    margin: 0.25em 0 !important;
}

/* Media styles */
.image-container {
    position: relative;
    overflow: visible; /* Changed from hidden to allow full image display */
    width: 100%;
    margin-bottom: 1rem;
    min-height: 100px;
    background-color: rgba(0, 0, 0, 0.05);
    border-radius: 5px;
}

.image-container img {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
    object-fit: contain; /* This ensures the image is shown completely without cropping */
    max-height: none; /* Remove any height restriction */
    transition: opacity 0.3s ease-in-out;
}

.loading-indicator {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: rgba(0, 0, 0, 0.05);
}

/* Video container styles */
.video-container {
    position: relative;
    width: 100%;
    margin-bottom: 1rem;
    background-color: #000;
    border-radius: 0.25rem;
    overflow: hidden;
}

.video-container video {
    width: 100%;
    height: auto;
    max-height: 60vh;
    background-color: #000;
}

.video-error-message {
    margin-top: 0.5rem;
    display: flex;
    align-items: center;
}

.video-error-message i {
    margin-right: 0.5rem;
}

/* Post styles */
.post-card {
    margin-bottom: 1.5rem;
    border-radius: 0.5rem;
    overflow: hidden;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

.post-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.125);
    display: flex;
    align-items: center;
}

.profile-picture {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    margin-right: 0.75rem;
}