/* BattleTech Minis - Dark Theme */

:root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --bg-hover: #30363d;
    --border: #30363d;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --accent: #58a6ff;
    --accent-hover: #79c0ff;
    --radius: 8px;
    --shadow: 0 2px 8px rgba(0,0,0,0.3);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
}

/* Header */
header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 100;
}

header h1 {
    font-size: 1.4rem;
    font-weight: 600;
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
}

.version {
    font-size: 0.7rem;
    font-weight: 400;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    padding: 2px 8px;
    border-radius: 4px;
}

.stats {
    display: flex;
    gap: 16px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Controls */
.controls {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    position: sticky;
    top: 57px;
    z-index: 99;
}

.search-box {
    flex: 1;
    min-width: 200px;
}

.search-box input {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.9rem;
}

.search-box input:focus {
    outline: none;
    border-color: var(--accent);
}

.base-search {
    max-width: 100px;
    flex: 0 0 100px;
}

.filters {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

select {
    padding: 6px 28px 6px 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.8rem;
    cursor: pointer;
    max-width: 140px;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238b949e' d='M6 8L2 4h8z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
}

select:focus {
    outline: none;
    border-color: var(--accent);
}

/* Card Grid */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    padding: 24px;
}

/* Card */
.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
    cursor: pointer;
    position: relative;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    border-color: var(--bg-hover);
}

.card-image {
    width: 100%;
    height: 160px;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.card-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.card-info {
    padding: 10px 12px;
}

.card-name {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 2px;
    color: var(--text-primary);
}

.card-source {
    font-size: 0.72rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
    line-height: 1.3;
}

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    padding: 20px;
    overflow-y: auto;
}

.modal-overlay.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
    z-index: 10;
}

.modal-close:hover {
    color: var(--text-primary);
}

/* Detail Modal Content */
.detail-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    gap: 12px;
}

.nav-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 6px 14px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.85rem;
    transition: background 0.15s, border-color 0.15s;
}

.nav-btn:hover:not(:disabled) {
    background: var(--bg-hover);
    border-color: var(--accent);
}

.nav-btn:disabled {
    opacity: 0.35;
    cursor: default;
}

.nav-counter {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Side navigation arrows */
.detail-image-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius);
}

.detail-image {
    max-width: 100%;
    max-height: 400px;
    object-fit: contain;
    border-radius: var(--radius);
}

.detail-no-image {
    width: 100%;
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    color: var(--text-secondary);
}

.side-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0,0,0,0.5);
    border: none;
    color: #fff;
    font-size: 2rem;
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 4px;
    opacity: 0.6;
    transition: opacity 0.2s, background 0.2s;
    z-index: 5;
}

.side-nav:hover:not(:disabled) {
    opacity: 1;
    background: rgba(0,0,0,0.7);
}

.side-nav:disabled {
    opacity: 0.2;
    cursor: default;
}

.side-nav-prev { left: 8px; }
.side-nav-next { right: 8px; }

.detail-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.detail-label {
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    font-size: 0.75rem;
}

.detail-sources {
    list-style: none;
    margin-top: 12px;
}

.detail-sources li {
    padding: 4px 0;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border);
}

.detail-sources li:last-child {
    border-bottom: none;
}

/* Empty State */
.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 48px 24px;
    color: var(--text-secondary);
}

/* Responsive */
@media (max-width: 768px) {
    .controls {
        position: static;
        flex-direction: column;
        align-items: stretch;
        padding: 8px 12px;
        gap: 6px;
    }
    header {
        position: static;
        padding: 8px 12px;
    }
    .filters {
        gap: 4px;
    }
    .filters select {
        max-width: none;
        flex: 1;
        font-size: 0.72rem;
        padding: 6px 24px 6px 8px;
    }
    .search-box {
        min-width: auto;
    }
    .card-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 10px;
        padding: 10px;
    }
    .card-image {
        height: 110px;
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-hover);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}
