/* Custom styles for Project Mycelium */

/* Global styles */
body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding-top: 56px; /* Height of fixed navbar */
}

main {
    flex: 1;
}

/* Navigation */
.navbar-brand {
    font-weight: bold;
    height: 56px;
    display: flex;
    align-items: center;
}

/* Ensure navbar has highest z-index */
.navbar {
    z-index: 1050;
}

.navbar-nav .nav-item {
    height: 56px;
}

.nav-link {
    display: flex;
    align-items: center;
    height: 100%;
}

/* Cards */
.card {
    margin-bottom: 1rem;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    transition: box-shadow 0.3s ease, transform 0.3s ease;
}

.card-main {
    height: 120px;
}

.card:hover {
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    transform: translateY(-0.25rem);
}

/* Buttons */
.btn {
    border-radius: 0.25rem;
}

/* Improve button rendering inside Bootstrap modals to avoid hover flicker */
.modal .btn {
    will-change: transform;
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* Forms */
.form-control:focus {
    border-color: #80bdff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* Footer */
.footer {
    margin-top: auto;
}

/* Marketplace styles */
.sidebar {
    min-height: calc(100vh - 112px); /* Account for navbar and footer */
    background-color: #f8f9fa;
    padding-top: 1rem;
    position: sticky;
    top: 56px; /* Height of the navbar */
}

/* Sidebar toggle button for mobile */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 76px;  /* Return to original position */
    left: 15px;
    z-index: 1045; /* Higher than sidebar */
    padding: 8px 12px;
    width: auto;
    max-width: 100px; /* Limit maximum width */
    background-color: #0d6efd;  /* Bootstrap primary color */
    color: white;
    border: none;
    border-radius: 4px;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.15);
    font-weight: 500;
    font-size: 0.9rem;
    text-align: center;
}

.sidebar-toggle:hover, .sidebar-toggle:focus {
    background-color: #0b5ed7;
    color: white;
    outline: none;
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.2);
}

.sidebar-toggle .bi {
    font-size: 1.2rem;
    margin-right: 4px;
}

.sidebar .nav-link {
    padding: 0.5rem 1rem;
    color: #333;
    border-left: 3px solid transparent;
}

.sidebar .nav-link.active {
    color: #0d6efd;
    font-weight: 600;
    border-left-color: #0d6efd;
    background-color: rgba(13, 110, 253, 0.05);
}

.sidebar .nav-link:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.dashboard-section {
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border-radius: 0.25rem;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

.marketplace-item {
    height: 100%;
    border: 1px solid #dee2e6;
    border-radius: 0.25rem;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    transition: box-shadow 0.3s ease, transform 0.3s ease;
}

.marketplace-item:hover {
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    transform: translateY(-0.25rem);
}

.spec-item {
    margin-bottom: 0.5rem;
}

.badge-category {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    margin-right: 0.5rem;
}

.gateway-status-indicator {
    width: 0.75rem;
    height: 0.75rem;
    border-radius: 50%;
    display: inline-block;
}

.service-item {
    height: 100%;
    padding: 1.25rem;
    border: 1px solid #dee2e6;
    border-radius: 0.25rem;
    transition: box-shadow 0.3s ease, transform 0.3s ease;
}

.service-item:hover {
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

/* CTA Buttons styles */
.cta-primary {
    font-size: 1.2rem;
    padding: 0.75rem 2rem;
    transition: background-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.cta-secondary {
    font-size: 1.2rem;
    padding: 0.75rem 2rem;
    transition: background-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

/* Home page styles */
.hero-section {
    padding: 5rem 0;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
}

/* When modal is open, suppress background hover transitions to avoid backdrop repaint flicker */
body.modal-open .card:hover,
body.modal-open .marketplace-item:hover,
body.modal-open .service-item:hover,
body.modal-open .table-hover tbody tr:hover {
    transform: none !important;
    box-shadow: inherit !important;
    background-color: inherit !important;
}

.hero-section h1 {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
}

.marketplace-preview {
    padding: 4rem 0;
    background-color: #ffffff;
}

.faq-section {
    padding: 4rem 0;
    background-color: #f5f7fa;
}

.faq-item {
    margin-bottom: 1rem;
}

.faq-question {
    font-weight: 600;
    cursor: pointer;
    padding: 1rem;
    background-color: #fff;
    border-radius: 0.25rem;
    border: 1px solid #dee2e6;
}

.faq-answer {
    padding: 1rem;
    background-color: #f8f9fa;
    border-radius: 0 0 0.25rem 0.25rem;
    border: 1px solid #dee2e6;
    border-top: none;
}

/* Legal pages styles */
.legal-content {
    font-size: 0.9rem;
    line-height: 1.6;
}

.legal-content h2 {
    font-size: 1.5rem;
    margin-top: 2rem;
    margin-bottom: 1rem;
}

.legal-content h3 {
    font-size: 1.2rem;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
}

/* Media queries for responsive layout */
@media (max-width: 767.98px) {
    /* Mobile sidebar approach - completely different approach */
    .sidebar {
        display: none; /* Hidden by default instead of off-screen */
        position: fixed;
        left: 0;
        top: 66px; /* Back to original position */
        width: 80%;
        max-width: 280px;
        height: auto;
        max-height: calc(100vh - 66px); /* Original calculation */
        overflow-y: auto; /* Enable scrolling within sidebar */
        z-index: 1040;
        background-color: #ffffff;
        box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
        padding: 7rem 1rem 1.25rem 1rem; /* Substantially more top padding */
        border-right: 1px solid #dee2e6;
        pointer-events: auto !important; /* Ensure clicks work */
    }
    
    /* When sidebar is shown */
    .sidebar.show {
        display: block;
    }
    
    /* Enhanced mobile sidebar styles */
    .sidebar .nav-link {
        padding: 0.75rem 1rem;
        border-radius: 0.375rem;
        margin-bottom: 0.25rem;
        font-size: 1rem;
    }
    
    .sidebar .nav-link:hover {
        background-color: rgba(13, 110, 253, 0.1);
    }
    
    .sidebar .nav-link.active {
        background-color: rgba(13, 110, 253, 0.15);
    }
    
    .sidebar .sidebar-heading {
        font-size: 0.85rem;
        padding: 0.5rem 1rem;
        margin-top: 0.5rem;
        margin-bottom: 0.5rem;
        position: relative; /* For positioning consistency */
    }
    
    /* Position the first heading down from the top */
    .sidebar .position-sticky > h5.sidebar-heading:first-of-type {
        margin-top: 2rem;
    }
    
    /* Add extra space above all sidebar content */
    .sidebar .position-sticky {
        padding-top: 2rem;
    }
    
    .sidebar-toggle {
        display: block;
    }
    
    .hero-section h1 {
        font-size: 2rem;
    }
    
    body {
        padding-top: 66px; /* Slightly taller navbar on mobile */
    }
    
    /* Fix for CTA buttons being too close to logo in mobile view */
    .hero-section .d-flex.flex-wrap {
        margin-bottom: 2rem; /* Add spacing between CTA buttons and logo */
    }
    
    /* Fix spacing for dashboard welcome page */
    .row.mb-5.align-items-center .col-md-6:first-child {
        margin-bottom: 2rem;
    }
    
    .d-grid.gap-3 {
        margin-bottom: 1.5rem;
    }
    
    /* Add overlay when sidebar is shown */
    .sidebar-backdrop {
        display: none;
        position: fixed;
        top: 66px; /* Back to original position */
        left: 0; /* Start at left edge */
        width: 100%; /* Full width */
        height: calc(100vh - 66px); /* Original calculation */
        background-color: rgba(0,0,0,0.5);
        z-index: 1030; /* Lower than sidebar */
    }
    
    /* When backdrop is shown */
    .sidebar-backdrop.show {
        display: block;
        right: 0;
        bottom: 0;
        z-index: 1035; /* Between sidebar and toggle button */
    }
    
    /* Ensure the sidebar can be clicked */
    .sidebar.show {
        display: block;
        z-index: 1040; /* Above backdrop */
        pointer-events: auto !important;
    }
    
    /* Ensure links in sidebar can be clicked */
    .sidebar.show .nav-link {
        pointer-events: auto !important;
        position: relative;
        z-index: 1045;
    }
    
    /* Adjust main content when sidebar is toggled */
    .main-content-wrapper {
        transition: margin-left 0.3s ease;
    }
}

/* Ensure Bootstrap modal always appears above custom navbar/sidebar/backdrops */
.modal-backdrop {
    z-index: 1070 !important; /* Above navbar (1050) and sidebar overlay (1035/1040) */
}

.modal {
    z-index: 1080 !important; /* Above backdrop */
}