/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
header {
    background: linear-gradient(135deg, #07753e 0%, #63a404 100%);
    color: white;
    padding: 2rem 0;
    text-align: center;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Navigation */
.main-nav {
    background: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.main-nav .container {
    display: flex;
    gap: 0;
}

.nav-btn {
    background: none;
    border: none;
    padding: 1rem 1.5rem;
    cursor: pointer;
    font-size: 1rem;
    color: #666;
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
}

.nav-btn:hover {
    background-color: #f8f9fa;
    color: #333;
}

.nav-btn.active {
    color: #63a404;
    border-bottom-color: #63a404;
    background-color: #f2f3f3;
}

/* Main Content */
main {
    padding: 2rem 0;
    min-height: calc(100vh - 200px);
}

.view {
    display: none;
}

.view.active {
    display: block;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.stat-card {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    text-align: center;
}

.stat-card h3 {
    font-size: 2.5rem;
    color: #63a404;
    margin-bottom: 0.5rem;
}

.stat-card p {
    color: #666;
    font-size: 1.1rem;
}

/* Insights */
.insights {
    margin-top: 3rem;
}

.insights h2 {
    margin-bottom: 1.5rem;
    color: #333;
}

.insight-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.insight-card {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    border-left: 4px solid #63a404;
}

.insight-card h4 {
    color: #333;
    margin-bottom: 0.5rem;
}

.insight-card p {
    color: #666;
    line-height: 1.6;
}

/* Section Headers */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.section-header h2 {
    color: #333;
}

.filters {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.filters select,
.filters input {
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

/* Items Grid */
.items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.item-card {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
}

.item-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

.item-card-header {
    padding: 1rem;
    background: linear-gradient(135deg, #07753e 0%, #63a404 100%);
    color: white;
}

.item-card-header h3 {
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

.item-card-header p {
    opacity: 0.9;
    font-size: 0.9rem;
}

.item-card-body {
    padding: 1rem;
}

.item-card-body .meta {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: #666;
}

.item-card-body .description {
    color: #555;
    font-size: 0.9rem;
    line-height: 1.4;
}

/* Cartridge Images */
.cartridge-images {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.cartridge-image {
    width: 60px;
    height: 60px;
    border-radius: 4px;
    object-fit: cover;
    border: 2px solid #eee;
    /* Firefox fallback for object-fit */
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    flex-shrink: 0;
}

/* Firefox-specific object-fit fallback */
@supports not (object-fit: cover) {
    .cartridge-image {
        object-fit: none;
        object-position: center;
    }
}

/* Relationship Sections */
.relationship-section {
    margin-bottom: 3rem;
}

.relationship-section h3 {
    color: #333;
    margin-bottom: 1rem;
}

.relationship-section p {
    color: #666;
    margin-bottom: 1.5rem;
}

.relationship-item {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-bottom: 1rem;
}

.relationship-item h4 {
    color: #333;
    margin-bottom: 1rem;
}

.relationship-labels {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.label-tag {
    background: #63a404;
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
}

.build-info {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 0.5rem;
}

/* Search */
.search-container {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    max-width: 600px;
}

.search-container input {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

.search-container button {
    background: #63a404;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.2s ease;
}

.search-container button:hover {
    background: #07753e;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Prevent background scrolling when modal is open */
body.modal-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
}

/* Image Lightbox Modal */
#image-modal {
    z-index: 1100;
}

.image-modal-content {
    background: rgba(0,0,0,0.9);
    margin: 0;
    padding: 2rem;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-radius: 0;
    /* Firefox flexbox fixes */
    min-height: 100vh;
    box-sizing: border-box;
}

.image-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 90%;
    max-height: 70vh;
    margin-bottom: 2rem;
    /* Firefox flexbox fixes */
    flex-shrink: 0;
    width: auto;
    height: auto;
}

#modal-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    /* Firefox image display fixes */
    display: block;
    height: auto;
    width: auto;
}

.nav-arrow {
    position: absolute;
    background: rgba(255,255,255,0.9);
    color: #333;
    border: none;
    font-size: 2rem;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    border-radius: 50%;
    z-index: 1102;
    transition: all 0.2s ease;
    user-select: none;
}

.nav-arrow:hover {
    background: white;
    transform: scale(1.1);
}

.nav-arrow:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    transform: none;
}

.prev-arrow { 
    left: -60px; 
}

.next-arrow { 
    right: -60px; 
}

.image-info {
    text-align: center;
    color: white;
}

.image-info h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1.5rem;
    text-transform: capitalize;
}

.image-info p {
    margin: 0;
    opacity: 0.8;
    font-size: 1rem;
}

#image-modal .close {
    color: white;
    font-size: 2rem;
    top: 2rem;
    right: 2rem;
    z-index: 1103;
}

#image-modal .close:hover {
    color: #ccc;
}

.modal-content {
    background-color: white;
    margin: 2rem auto;
    padding: 0;
    border-radius: 8px;
    width: 90%;
    max-width: 800px;
    max-height: calc(100vh - 4rem);
    overflow-y: auto;
    position: relative;
    display: flex;
    flex-direction: column;
}

.close {
    position: absolute;
    right: 1rem;
    top: 1rem;
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    z-index: 1001;
}

.close:hover {
    color: #333;
}

.modal-header {
    background: linear-gradient(135deg, #07753e 0%, #63a404 100%);
    color: white;
    padding: 2rem;
    border-radius: 8px 8px 0 0;
}

.modal-body {
    padding: 2rem;
    overflow-y: auto;
    flex: 1;
}

.detail-section {
    margin-bottom: 2rem;
}

.detail-section h3 {
    color: #333;
    margin-bottom: 1rem;
    border-bottom: 2px solid #63a404;
    padding-bottom: 0.5rem;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.detail-item {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 4px;
}

.detail-item strong {
    color: #333;
    display: block;
    margin-bottom: 0.25rem;
}

/* Footer */
footer {
    background: #333;
    color: white;
    text-align: center;
    padding: 2rem 0;
    margin-top: 3rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 0 15px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .main-nav .container {
        flex-wrap: wrap;
    }
    
    .nav-btn {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 1rem;
    }
    
    .stat-card {
        padding: 1.5rem;
    }
    
    .stat-card h3 {
        font-size: 2rem;
    }
    
    .insight-cards {
        grid-template-columns: 1fr;
    }
    
    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .items-grid {
        grid-template-columns: 1fr;
    }
    
    .search-container {
        flex-direction: column;
    }
    
    .modal-content {
        width: 95%;
        margin: 2% auto;
    }
}

@media (max-width: 480px) {
    .main-nav .container {
        justify-content: center;
    }
    
    .nav-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
    
    .relationship-labels {
        flex-direction: column;
    }
    
    /* Image modal mobile adjustments */
    .prev-arrow { 
        left: -40px; 
        font-size: 1.5rem;
        padding: 0.4rem 0.6rem;
    }
    
    .next-arrow { 
        right: -40px; 
        font-size: 1.5rem;
        padding: 0.4rem 0.6rem;
    }
    
    .image-container {
        max-width: 95%;
        max-height: 60vh;
    }
    
    .image-modal-content {
        padding: 1rem;
    }
    
    #image-modal .close {
        top: 1rem;
        right: 1rem;
        font-size: 1.5rem;
    }
}
