/* MibiSense Custom Styles — Tab-based Layout with Sidebars */

/* Root Variables — Blue/Orange/Red palette matching MibiSens logo */
:root {
    --mibisens-primary: #0071C5;
    --mibisens-secondary: #FF7F00;
    --mibisens-accent: #E60000;
    --mibisens-dark: #1a1a2e;
    --mibisens-light: #f8f9fa;
    --sidebar-width: 220px;
}

/* No rounded corners anywhere */
*, *::before, *::after {
    border-radius: 0 !important;
}

/* General Styles */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    overflow-x: hidden;
}

/* ─── Top Navbar / Tab Bar ─── */
.navbar {
    backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, 0.97) !important;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
    padding-top: 0;
    padding-bottom: 0;
}

.navbar-brand {
    font-weight: 700;
    font-size: 1.4rem;
    padding: 0.75rem 0;
}

.navbar-brand .brand-icon {
    color: var(--mibisens-primary);
}

.hdr-home-link {
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    margin-right: 8px;
}

.hdr-home {
    background: none;
    border: none;
    cursor: pointer;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #555;
    transition: background 120ms;
    padding: 0;
    flex-shrink: 0;
    border-radius: 4px;
}

.hdr-home:hover {
    background: rgba(0,0,0,0.08);
}

.top-tab-link {
    font-weight: 500;
    padding: 0.85rem 1rem !important;
    transition: color 0.2s ease, border-color 0.2s ease;
    color: #555;
    border-bottom: 3px solid transparent;
    text-decoration: none;
    display: block;
    white-space: nowrap;
}

.top-tab-link:hover {
    color: var(--mibisens-primary);
}

.top-tab-link.active {
    color: var(--mibisens-primary) !important;
    border-bottom-color: var(--mibisens-primary);
    font-weight: 600;
}

/* ─── Layout: Sidebar + Main Content ─── */
#app-layout {
    display: flex;
    min-height: calc(100vh - 58px);
}

#sidebar-container {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: #f8f9fa;
    border-right: 1px solid #dee2e6;
    position: sticky;
    top: 58px;
    height: calc(100vh - 58px);
    overflow-y: auto;
    flex-shrink: 0;
}

#main-content {
    flex: 1;
    min-width: 0;
    padding: 1.5rem 2rem;
    background: #fff;
}

/* Sidebar panels — one per tab, toggled via JS */
.sidebar-panel {
    display: none;
    padding: 1rem 0;
}

.sidebar-panel.active {
    display: block;
}

.sidebar-panel h6 {
    padding: 0 1rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #999;
    margin-bottom: 0.5rem;
}

.sidebar-nav {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    color: #444;
    text-decoration: none;
    font-size: 0.88rem;
    border-left: 3px solid transparent;
    transition: all 0.15s ease;
}

.sidebar-nav li a:hover {
    background: rgba(0, 113, 197, 0.06);
    color: var(--mibisens-primary);
}

.sidebar-nav li a.active {
    border-left-color: var(--mibisens-primary);
    color: var(--mibisens-primary);
    background: rgba(0, 113, 197, 0.08);
    font-weight: 600;
}

.sidebar-nav li a i {
    font-size: 1rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

/* ─── Tab Panes ─── */
.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
}

/* ─── Category Cards ─── */
.category-card {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    height: 100%;
    overflow: hidden;
}

.category-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

.category-card .card-header {
    padding: 2rem;
    border-bottom: none;
}

.category-card.mibisens .card-header {
    background: linear-gradient(135deg, var(--mibisens-primary) 0%, #005a9e 100%);
}

.category-card.mibigro .card-header {
    background: linear-gradient(135deg, var(--mibisens-secondary) 0%, #e06c00 100%);
}

.category-card.community .card-header {
    background: linear-gradient(135deg, var(--mibisens-accent) 0%, #c00 100%);
}

.category-card .card-icon {
    font-size: 3rem;
    color: white;
    margin-bottom: 1rem;
}

.category-card .card-title {
    color: white;
    font-weight: 600;
    margin: 0;
}

.category-card .stats-number {
    font-size: 2rem;
    font-weight: 700;
}

/* Database Cards */
.database-card {
    transition: all 0.3s ease;
    border: 1px solid #e0e0e0;
}

.database-card:hover {
    border-color: var(--mibisens-primary);
    box-shadow: 0 4px 15px rgba(0, 113, 197, 0.2);
}

/* Section Headers */
.section-header {
    margin-bottom: 2rem;
}

.section-header h2 {
    font-weight: 700;
    position: relative;
    display: inline-block;
}

.section-header h2::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 0;
    width: 50px;
    height: 3px;
    background: var(--mibisens-primary);
}

/* Data Tables */
.table-container {
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.table thead th {
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
    border-bottom: 2px solid;
}

.table-success thead th {
    border-bottom-color: var(--mibisens-primary);
}

.table-info thead th {
    border-bottom-color: var(--mibisens-secondary);
}

.table-warning thead th {
    border-bottom-color: var(--mibisens-accent);
}

/* Chart Containers */
.chart-container {
    position: relative;
    background: white;
    padding: 1.5rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    height: 300px;
}

/* ─── Footer ─── */
.footer {
    background: var(--mibisens-dark);
    color: rgba(255, 255, 255, 0.8);
    padding: 1rem 0;
    font-size: 0.85rem;
}

.footer a {
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
}

.footer a:hover {
    color: white;
}

/* Badges */
.badge {
    font-weight: 500;
    padding: 0.4em 0.8em;
}

/* Buttons */
.btn-primary {
    background: var(--mibisens-primary);
    border-color: var(--mibisens-primary);
}

.btn-primary:hover {
    background: #005a9e;
    border-color: #005a9e;
}

/* Inner Tabs (within Tools, Sensors etc.) */
.nav-tabs .nav-link {
    border: none;
    color: #666;
    font-weight: 500;
}

.nav-tabs .nav-link.active {
    color: var(--mibisens-primary);
    border-bottom: 3px solid var(--mibisens-primary);
    background: transparent;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
}

.stat-item {
    text-align: center;
    padding: 1.25rem;
    background: white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.stat-item .stat-number {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--mibisens-primary);
}

.stat-item .stat-label {
    color: #666;
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

/* Search Input */
.search-input {
    padding-left: 2.5rem;
    border: 2px solid #e0e0e0;
    transition: border-color 0.3s ease;
}

.search-input:focus {
    border-color: var(--mibisens-primary);
    box-shadow: 0 0 0 0.2rem rgba(0, 113, 197, 0.15);
}

.search-wrapper {
    position: relative;
}

.search-wrapper .search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
}

/* Animations */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-fade-in-up {
    animation: fadeInUp 0.4s ease forwards;
}

/* Publication cards */
.publication-card {
    transition: box-shadow 0.2s ease, border-left-color 0.2s ease;
    border-left: 3px solid transparent;
}

.publication-card:hover {
    box-shadow: 0 2px 8px rgba(102, 16, 242, 0.12);
    border-left-color: #6610f2;
}

/* Purple badge for publications */
.bg-purple {
    background-color: #6610f2 !important;
    color: #fff;
}

.bg-purple-subtle {
    background-color: #f8f5ff !important;
}

.text-purple {
    color: #6610f2 !important;
}

/* Teal badge for Fe2+ / iron sensors */
.bg-teal {
    background-color: #20c997 !important;
    color: #fff;
}

/* Purple border for publications card */
.border-purple {
    border-color: #6610f2 !important;
}

/* Feature navigation cards on home tab */
.feature-nav-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
}

.feature-nav-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.feature-nav-card .feature-card-header {
    height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    color: white;
    overflow: hidden;
    position: relative;
}

.feature-nav-card .feature-card-header img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    position: absolute;
    inset: 0;
}

.feature-nav-card .feature-card-header .fallback-icon {
    position: relative;
    z-index: 1;
    opacity: 0.9;
}

/* Others dropdown active state */
.top-tab-link.dropdown-toggle.active,
.top-tab-link.dropdown-toggle.others-active {
    color: var(--mibisens-primary) !important;
    border-bottom-color: var(--mibisens-primary);
    font-weight: 600;
}

/* Dropdown styling matching nav */
.navbar .dropdown-menu {
    border-top: 3px solid var(--mibisens-primary);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    min-width: 180px;
}

.navbar .dropdown-item {
    font-weight: 500;
    font-size: 0.9rem;
    padding: 0.6rem 1rem;
    color: #555;
}

.navbar .dropdown-item:hover {
    background: rgba(0, 113, 197, 0.06);
    color: var(--mibisens-primary);
}

/* Quiz */
.quiz-option-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border: 2px solid transparent;
    background: white;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    font-size: 1rem;
    color: #fff;
}

.quiz-option-btn:hover {
    filter: brightness(0.95);
}

.quiz-option-btn.selected {
    border-color: #fff;
    box-shadow: 0 0 0 3px rgba(255,255,255,0.5);
    font-weight: 600;
}

.quiz-option-btn i {
    font-size: 1.3rem;
    flex-shrink: 0;
}

.quiz-option-btn:disabled,
.quiz-option-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(0.5);
}

/* Ligand color backgrounds for quiz options */
.quiz-option-bg-success { background-color: #198754 !important; }
.quiz-option-bg-warning { background-color: #ffc107 !important; color: #212529 !important; }
.quiz-option-bg-danger { background-color: #dc3545 !important; }
.quiz-option-bg-primary { background-color: #0d6efd !important; }
.quiz-option-bg-info { background-color: #0dcaf0 !important; color: #212529 !important; }
.quiz-option-bg-secondary { background-color: #6c757d !important; }
.quiz-option-bg-dark { background-color: #212529 !important; }
.quiz-option-bg-purple { background-color: #6610f2 !important; }
.quiz-option-bg-teal { background-color: #20c997 !important; }

.progress-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    background: #e0e0e0;
    margin-left: 4px;
}

.progress-dot.active {
    background: var(--mibisens-primary);
}

.comparison-table td, .comparison-table th {
    font-size: 0.85rem;
}

/* Tutorial */
.tutorial-step {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    align-items: flex-start;
}

.step-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    min-width: 36px;
    background: var(--mibisens-primary);
    color: white;
    font-weight: 700;
    font-size: 0.9rem;
}

.accordion-button:not(.collapsed) {
    background: rgba(0, 113, 197, 0.08);
    color: var(--mibisens-primary);
}

.accordion-button:focus {
    box-shadow: 0 0 0 0.2rem rgba(0, 113, 197, 0.15);
}

/* Gallery */
.gallery-card {
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

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

.gallery-img {
    height: 220px;
    object-fit: cover;
    cursor: pointer;
    transition: opacity 0.3s ease;
    background: #1a1a2e;
}

.gallery-img:hover {
    opacity: 0.9;
}

.gallery-item {
    transition: opacity 0.3s ease;
}

.gallery-item.hidden {
    display: none;
}

/* Custom badge colors */
.bg-purple {
    background-color: #9c27b0 !important;
}

/* Sortable table headers */
.sortable-th {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.sortable-th:hover {
    background: rgba(0, 113, 197, 0.1);
}

/* Sensor table row highlight */
#mibisens-sensor-table-container .table tbody tr {
    cursor: default;
}

#mibisens-sensor-table-container .table tbody tr:hover {
    background-color: rgba(0, 113, 197, 0.06);
}

/* Filter row alignment */
#mibisens-sensor-tab .form-select {
    border: 2px solid #e0e0e0;
}

#mibisens-sensor-tab .form-select:focus {
    border-color: var(--mibisens-primary);
    box-shadow: 0 0 0 0.2rem rgba(0, 113, 197, 0.15);
}

/* Dropdown menu styling */
.dropdown-menu {
    border: none;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
}

.dropdown-item {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

.dropdown-item:hover {
    background: rgba(0, 113, 197, 0.08);
    color: var(--mibisens-primary);
}

/* Utilities */
.section-padding {
    padding: 2rem 0;
}

.bg-light-gray {
    background: #f8f9fa;
}

/* Loading Spinner */
.spinner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

/* Code styling */
code {
    background: #f5f5f5;
    padding: 0.2em 0.4em;
    font-size: 0.9em;
}

/* btn-success overrides to use primary blue */
.btn-success {
    background-color: var(--mibisens-primary);
    border-color: var(--mibisens-primary);
}
.btn-success:hover {
    background-color: #005a9e;
    border-color: #005a9e;
}
.btn-outline-success {
    color: var(--mibisens-primary);
    border-color: var(--mibisens-primary);
}
.btn-outline-success:hover,
.btn-outline-success.active {
    background-color: var(--mibisens-primary);
    border-color: var(--mibisens-primary);
    color: #fff;
}
.btn-outline-success:focus {
    box-shadow: 0 0 0 0.2rem rgba(0, 113, 197, 0.25);
}

/* bg-success overrides */
.bg-success {
    background-color: var(--mibisens-primary) !important;
}
.bg-opacity-10.bg-success,
.bg-success.bg-opacity-10 {
    background-color: rgba(0, 113, 197, 0.1) !important;
}
.bg-success.bg-opacity-25 {
    background-color: rgba(0, 113, 197, 0.25) !important;
}
.text-success {
    color: var(--mibisens-primary) !important;
}
.border-success {
    border-color: var(--mibisens-primary) !important;
}

.table-success {
    --bs-table-bg: rgba(0, 113, 197, 0.08);
    --bs-table-border-color: rgba(0, 113, 197, 0.15);
}

/* ─── Responsive: sidebar collapse ─── */
@media (max-width: 991px) {
    #sidebar-container {
        display: none;
    }

    #main-content {
        padding: 1rem;
    }

    .section-header h2 {
        font-size: 1.5rem;
    }

    .chart-container {
        height: 250px;
    }

    .quiz-option-btn {
        font-size: 0.8rem;
        padding: 0.5rem 0.75rem;
    }

    .gallery-img {
        height: 160px;
    }
}

@media (max-width: 576px) {
    #main-content {
        padding: 0.75rem;
    }
}

/* ─── Login Protection Styles ─── */
.gallery-item-protected {
    display: none !important;
}

#gallery-login-message {
    animation: fadeIn 0.3s ease-in;
}

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

/* Toast container */
#toastContainer {
    z-index: 9999;
}
