/* 
 * IAVS Open Data Index - Custom Styles
 * Designed to complement the IAVS.org website design
 */

/* Color scheme matching IAVS */
:root {
    --iavs-primary: #33a54e;      /* Green */
    --iavs-primary-dark: #2a8a40;
    --iavs-secondary: #33a54e;
    --iavs-accent: #8bc34a;
    --iavs-text: #333333;
    --iavs-light: #f5f5f5;
    --iavs-border: #e0e0e0;
    --iavs-footer: #082b08;       /* Dark green footer */
}

/* Custom blue badge (Bootstrap primary blue) */
.badge.bg-blue,
.bg-blue {
    background-color: #0d6efd !important;
    color: #fff !important;
}

/* Override Bootstrap primary */
.bg-primary {
    background-color: var(--iavs-primary) !important;
}

.btn-primary {
    background-color: var(--iavs-primary);
    border-color: var(--iavs-primary);
}

.btn-primary:hover,
.btn-primary:focus {
    background-color: var(--iavs-primary-dark);
    border-color: var(--iavs-primary-dark);
}

.btn-outline-primary {
    color: var(--iavs-primary);
    border-color: var(--iavs-primary);
}

.btn-outline-primary:hover {
    background-color: var(--iavs-primary);
    border-color: var(--iavs-primary);
}

.text-primary {
    color: var(--iavs-primary) !important;
}

a {
    color: var(--iavs-primary);
}

a:hover {
    color: var(--iavs-primary-dark);
}

/* Body */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--iavs-text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding-top: 185px; /* Space for fixed header (135px) + nav (50px) */
}

main {
    flex: 1;
}

/* Page Headers */
.page-header {
    font-size: 1.9rem;
    font-weight: 500;
    margin-bottom: 1rem;
}

@media (max-width: 767.98px) {
    .page-header {
        font-size: 1.4rem;
    }
}

/* IAVS Header Banner */
.main-header {
    background: rgb(255 255 255 / 92%);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    box-shadow: 0 3px 3px rgb(0 0 0 / 20%);
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 20;
    height: 135px;
}

.main-header .container {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    height: 100%;
    position: relative;
}

.header-logo {
    display: block;
    position: absolute;
    left: 0;
    bottom: 0;
}

.header-logo img {
    height: auto;
    max-height: 122px;
    width: auto;
}

/* App Navigation Bar */
.app-nav {
    position: fixed;
    top: 135px;
    width: 100%;
    z-index: 19;
    background: var(--iavs-primary);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.app-nav .nav-link {
    color: rgba(255,255,255,0.9);
    font-weight: 400;
    font-size: 1.1rem;
    padding-top: 0.6rem;
    padding-bottom: 0.4rem;
    position: relative;
    transition: color 0.2s ease;
}

.app-nav .nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0.5rem;
    right: 0.5rem;
    height: 2px;
    background-color: #fff;
    transform: scaleX(0);
    transition: transform 0.2s ease;
}

.app-nav .nav-link:hover::after,
.app-nav .nav-link:focus::after {
    transform: scaleX(1);
}

.app-nav .navbar-toggler {
    border-color: rgba(255,255,255,0.5);
}

.app-nav .navbar-toggler-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255, 255, 255, 0.75%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

.navbar-brand {
    font-size: 1.9rem;
    font-weight: 400;
    color: #fff !important;
    letter-spacing: 0.5px;
}

.navbar-separator {
    color: rgba(255, 255, 255, 0.6);
    margin: 0 0.75rem;
    font-weight: 300;
}

/* Hero section */
.hero {
    background: linear-gradient(135deg, var(--iavs-primary) 0%, var(--iavs-secondary) 100%);
    color: white;
    padding: 3rem 0;
    margin-bottom: 2rem;
}

.hero h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.hero .lead {
    font-size: 1.25rem;
    opacity: 0.9;
}

/* Statistics numbers */
.stat-number {
    font-size: 2rem;
    font-weight: 700;
    color: var(--iavs-primary);
}

/* Search box */
.search-box {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.search-box .form-control {
    font-size: 1.1rem;
    padding: 0.75rem 1rem;
}

/* Cards */
.card {
    border: none;
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
    transition: box-shadow 0.2s ease;
}

.card:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.12);
}

.card-header {
    background-color: var(--iavs-light);
    border-bottom: 1px solid var(--iavs-border);
}

/* Dataset cards */
.dataset-card {
    margin-bottom: 1.5rem;
}

.dataset-card .card-title {
    color: var(--iavs-primary);
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.dataset-card .metadata {
    font-size: 0.875rem;
    color: #666;
}

.dataset-card .badge {
    font-weight: normal;
}

/* Tables */
.table {
    margin-bottom: 0;
}

.table th {
    background-color: var(--iavs-light);
    border-bottom: 2px solid var(--iavs-border);
    font-weight: 600;
}

/* Forms */
.form-label {
    font-weight: 500;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--iavs-accent);
    box-shadow: 0 0 0 0.2rem rgba(46, 125, 50, 0.25);
}

/* Alerts */
.alert-dismissible .btn-close {
    padding: 1rem;
}

/* Badges */
.badge.bg-success {
    background-color: var(--iavs-primary) !important;
}

/* Pagination */
.pagination .page-link {
    color: var(--iavs-primary);
}

.pagination .page-item.active .page-link {
    background-color: var(--iavs-primary);
    border-color: var(--iavs-primary);
}

/* Filter sidebar */
.filter-sidebar {
    background: var(--iavs-light);
    padding: 1.5rem;
    border-radius: 8px;
}

.filter-sidebar h5 {
    color: var(--iavs-primary);
    border-bottom: 2px solid var(--iavs-primary);
    padding-bottom: 0.5rem;
}

/* Filter checkbox groups */
.filter-checkboxes {
    max-height: 150px;
    overflow-y: auto;
    border: 1px solid var(--iavs-border);
    border-radius: 4px;
    padding: 0.5rem;
    background: #fff;
}

.filter-checkboxes .form-check {
    margin-bottom: 0.25rem;
}

.filter-checkboxes .form-check-label {
    font-size: 0.875rem;
}

/* Collapsible filter toggles */
.filter-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
    color: var(--iavs-text);
    text-decoration: none;
    cursor: pointer;
}

.filter-toggle:hover {
    color: var(--iavs-primary);
}

.filter-toggle .bi-chevron-right {
    transition: transform 0.2s ease;
}

.filter-toggle[aria-expanded="true"] .bi-chevron-right {
    transform: rotate(90deg);
}

.filter-toggle .badge {
    font-size: 0.7rem;
    margin-left: auto;
}

/* Dashboard stats */
.stat-card {
    text-align: center;
    padding: 1.5rem;
}

.stat-card .stat-number {
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--iavs-primary);
}

.stat-card .stat-label {
    color: #666;
    text-transform: uppercase;
    font-size: 0.875rem;
}

/* Compact stat cards for mobile */
@media (max-width: 575.98px) {
    .stat-card-compact {
        padding: 0.75rem 0.5rem;
    }
    .stat-card-compact .stat-number {
        font-size: 1.5rem;
    }
    .stat-card-compact .stat-label {
        font-size: 0.7rem;
    }
}

/* Admin sidebar */
.admin-sidebar {
    background: var(--iavs-light);
    min-height: calc(100vh - 200px);
    padding: 1.5rem 0;
}

.admin-sidebar .nav-link {
    color: var(--iavs-text);
    padding: 0.75rem 1.5rem;
    border-radius: 0;
}

.admin-sidebar .nav-link:hover {
    background-color: rgba(46, 125, 50, 0.1);
}

.admin-sidebar .nav-link.active {
    background-color: var(--iavs-primary);
    color: white;
}

/* Utility classes */
.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cursor-pointer {
    cursor: pointer;
}

/* Loading spinner */
.spinner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

/* Responsive adjustments */
@media (max-width: 991.98px) {
    .navbar-separator {
        display: none;
    }
}

@media (max-width: 768px) {
    .main-header {
        display: none;
    }
    
    .app-nav {
        top: 0;
    }
    
    body {
        padding-top: 56px !important;
    }
    
    /* Mobile menu alignment */
    .app-nav .navbar-collapse {
        padding-top: 0.5rem;
    }
    
    .navbar-brand {
        font-size: 1.25rem;
    }
    
    .hero h1 {
        font-size: 1.75rem;
    }
    
    .hero {
        padding: 2rem 0;
    }
    
    .stat-card .stat-number {
        font-size: 1.75rem;
    }
    
    .stat-number {
        font-size: 1.5rem;
    }
    
    /* Search box stacked layout */
    .search-box .input-group {
        flex-direction: column;
    }
    
    .search-box .input-group .form-control {
        border-radius: 0.375rem !important;
        margin-bottom: 0.5rem;
        width: 100%;
    }
    
    .search-box .input-group .btn {
        border-radius: 0.375rem !important;
        width: 100%;
    }
}

/* Extra small screens */
@media (max-width: 480px) {
    /* Header already hidden from 768px breakpoint */
}

/* IAVS Footer */
.iavs-footer {
    background-color: var(--iavs-footer);
    color: #eee;
    padding: 2rem 0;
    text-align: center;
    font-family: 'Lato', sans-serif;
    font-size: 14px;
    line-height: 1.42857143;
}

.iavs-footer h5 {
    color: #eee;
    margin-bottom: 0.5rem;
    font-weight: 700;
    font-size: 14px;
}

.iavs-footer p {
    margin-bottom: 0.25rem;
    font-size: 14px;
    color: #eee;
    font-weight: 400;
}

.iavs-footer .footer-links {
    margin-top: 1rem;
    padding-top: 1rem;
}

.iavs-footer .footer-links a {
    color: #eee;
    text-decoration: none;
    padding: 0 0.5rem;
    border-right: 1px solid rgba(255,255,255,0.5);
    font-size: 14px;
    font-weight: 700;
}

.iavs-footer .footer-links a:last-child {
    border-right: none;
}

.iavs-footer .footer-links a:hover {
    text-decoration: underline;
    color: #fff;
}

.iavs-footer .social-icons {
    margin-top: 1rem;
}

.iavs-footer .social-icons a {
    color: #eee;
    font-size: 1.25rem;
    margin: 0 0.5rem;
    text-decoration: none;
}

.iavs-footer .social-icons a:hover {
    color: #fff;
}

/* Fix dropdown menus clipped by table-responsive */
.table-responsive {
    overflow: visible;
}

.table-responsive .dropdown-menu {
    position: absolute;
    z-index: 1050;
}

/* Only scroll horizontally on small screens */
@media (max-width: 991.98px) {
    .table-responsive {
        overflow-x: auto;
        overflow-y: visible;
    }
}

/* Flash toast messages */
.flash-container {
    position: fixed;
    top: 195px; /* Below header + nav */
    right: 1rem;
    z-index: 1060;
    max-width: 400px;
    width: calc(100% - 2rem);
}

.flash-toast {
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    animation: flashSlideIn 0.3s ease-out;
}

.flash-toast.fade-out {
    animation: flashFadeOut 0.3s ease-out forwards;
}

@keyframes flashSlideIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes flashFadeOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(20px);
    }
}

@media (max-width: 767.98px) {
    .flash-container {
        top: auto;
        bottom: 1rem;
        right: 0.5rem;
        left: 0.5rem;
        width: auto;
        max-width: none;
    }
}

/* Print styles */
@media print {
    .navbar,
    footer,
    .no-print,
    .flash-container {
        display: none !important;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}
