/* JangoSocial Base Styles - Extracted from inline CSS for better performance */

/* CRITICAL CSS: Prevent FOUC and Layout Shifts */
* {
    box-sizing: border-box;
}

/* Prevent Alpine.js FOUC */
[x-cloak] {
    display: none !important;
}

/* Critical layout stabilization */
.header-container,
.sidebar-logo,
.notification-container,
.profile-container {
    min-height: 40px;
    contain: layout style;
    will-change: auto;
}

/* Loading states for critical UI elements */
.loading-skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Prevent layout shift during dropdown loading */
.notifications-dropdown,
.profile-dropdown {
    position: absolute;
    z-index: 1000;
    transform-origin: top right;
    will-change: transform, opacity;
    contain: layout style;
}

/* Critical performance optimizations */
.performance-optimized {
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
}

/* Brand Gradients and Colors */
.gradient-brand {
    background: rgb(0 51 111 / var(--tw-text-opacity, 1));
}

.gradient-brand-reverse {
    background: rgb(0 51 111 / var(--tw-text-opacity, 1));
}

.text-gradient {
    background: rgb(0 51 111 / var(--tw-text-opacity, 1));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Animations */
.floating-animation {
    animation: float 6s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-20px); }
}

.fade-in-up {
    animation: fadeInUp 0.8s ease-out;
}

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

.whatsapp-shadow {
    box-shadow: 0 10px 25px rgba(0, 51, 111, 0.3);
}

/* Dashboard Layout Optimizations */
.dashboard-layout {
    display: flex;
    min-height: 100vh;
    position: relative;
}

.main-content {
    flex: 1;
    margin-left: 80px; /* Compact sidebar width + padding */
    margin-top: 64px; /* Header height */
    min-height: calc(100vh - 64px);
    background: #f8fafc;
    transition: margin-left 0.3s ease;
}

.main-content.expanded {
    margin-left: 250px; /* Expanded sidebar width */
}

.content-wrapper {
    padding: 1rem;
    max-width: 100%;
}

/* Fullscreen Layout - for messaging interfaces */
.fullscreen-page {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.fullscreen-content {
    flex: 1;
    margin-top: 64px; /* Header height */
    min-height: calc(100vh - 64px);
    position: relative;
    z-index: 1;
    padding: 0;
}

/* Optimized Messages Container */
.messages-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1001;
    padding: 1rem;
    pointer-events: none; /* Allow clicks to pass through container */
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.messages-container > div {
    pointer-events: auto; /* Re-enable clicks on actual messages */
    max-width: 600px;
    margin: 0 auto;
    backdrop-filter: blur(10px);
    border-radius: 0.75rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

/* Dynamic content adjustment */
.dashboard-layout.has-messages .main-content {
    margin-top: 140px; /* Increased to accommodate messages + header */
    transition: margin-top 0.3s ease;
}

.dashboard-layout.has-messages .dashboard-navbar {
    margin-top: 70px; /* Space for messages above */
    transition: margin-top 0.3s ease;
}

/* History page specific notification positioning */
.history-page .messages-container {
    position: fixed !important;
    top: 20px !important;
    right: 20px !important;
    left: auto !important;
    z-index: 10000 !important;
    max-width: 400px !important;
    padding: 1rem !important;
}

.history-page .messages-container > div {
    margin: 0;
}

/* Alpine.js optimization */
[x-cloak] { 
    display: none !important; 
}

/* WhatsApp Brand Notifications - Optimized */
.alert-success,
.whatsapp-success {
    background-color: #25d366 !important;
    border-color: #25d366 !important;
    color: white !important;
}

.toast-success,
.notification-success,
.bg-green-500 {
    background-color: #25d366 !important;
}

/* Performance-optimized notification targeting */
#toast-container div,
#toastContainer div,
.toast-notification div {
    background-color: #25d366 !important;
}

#toast-container .bg-blue-500,
#toastContainer .bg-blue-500,
.toast-notification .bg-blue-500 {
    background-color: #25d366 !important;
}

/* Responsive optimizations */
@media (max-width: 768px) {
    .messages-container {
        padding: 0.75rem;
    }
    
    .messages-container > div {
        max-width: 95%;
    }
    
    .dashboard-layout.has-messages .main-content {
        margin-top: 130px;
    }
    
    .dashboard-layout.has-messages .dashboard-navbar {
        margin-top: 65px;
    }
    
    .main-content {
        margin-left: 0;
        padding-left: 1rem;
    }
}

/* Loading states for better perceived performance */
.loading-skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Optimize heavy elements */
.message-bubble {
    will-change: transform;
    transform: translateZ(0);
}

/* Critical above-the-fold optimization */
.hero-section {
    contain: layout style paint;
}

/* Reduced motion for performance */
@media (prefers-reduced-motion: reduce) {
    .floating-animation,
    .fade-in-up,
    .loading-skeleton {
        animation: none;
    }
    
    .main-content,
    .dashboard-layout.has-messages .main-content,
    .dashboard-layout.has-messages .dashboard-navbar {
        transition: none;
    }
}

/* ========================================
   USER DROPDOWN STYLING
   ======================================== */

.dropdown-header {
    padding: 16px;
    border-bottom: 1px solid #e5e7eb;
    background-color: #f9fafb;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgb(0, 51, 111), rgb(59, 130, 246));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: white;
    font-size: 14px;
    flex-shrink: 0;
}

.user-details {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: #111827;
    margin: 0 0 2px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-email {
    font-size: 0.75rem;
    color: #6b7280;
    margin: 0 0 4px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role-detail {
    font-size: 0.6875rem;
    color: #059669;
    font-weight: 600;
    margin: 0;
    padding: 2px 8px;
    background-color: #ecfdf5;
    border-radius: 12px;
    display: inline-block;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border: 1px solid #a7f3d0;
}