
:root {
    /* Colors */
    --bg-base: #0f0f0f;
    --bg-surface: #1a1a1a;
    --bg-elevated: #242424;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --text-primary: #f5f5f5;
    --text-secondary: #a1a1a1;
    --border: #2a2a2a;
    --rating: #fbbf24;

    /* Legacy aliases (for compatibility during migration) */
    --bg-color: var(--bg-base);
    --card-bg: var(--bg-surface);
    --hover: var(--bg-elevated);

    /* Spacing & Layout */
    --header-height: 60px;
    --sidebar-width: 280px;
    --sidebar-width-tablet: 240px;
    --radius: 12px;
    --radius-sm: 6px;
    --transition: 200ms ease;
}

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

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

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

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

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

/* Focus visible for keyboard navigation */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Smooth scroll behavior */
html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

header {
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    padding: 0 2rem;
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 50;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--accent);
    flex-shrink: 0;
}

.logo h1 {
    font-size: 1.25rem;
    font-weight: 600;
}

.logo svg {
    flex-shrink: 0;
}

.search-bar {
    flex: 1;
    max-width: 400px;
}

.search-bar input {
    width: 100%;
    background: var(--bg-base);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.625rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.search-bar input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.search-bar input::placeholder {
    color: var(--text-secondary);
}

main {
    display: flex;
    flex: 1;
    overflow: hidden;
    height: calc(100vh - var(--header-height));
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    height: calc(100vh - var(--header-height));
    overflow-y: auto;
    position: sticky;
    top: var(--header-height);
    flex-shrink: 0;
}

/* Sidebar section headers */
.sidebar h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.filter-group {
    margin-bottom: 1.25rem;
}

.filter-group label {
    display: block;
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-bottom: 0.5rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Select inputs */
select {
    width: 100%;
    background: var(--bg-base);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.625rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    min-height: 44px;
    transition: border-color var(--transition), box-shadow var(--transition);
}

select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

select[multiple] {
    padding: 0.5rem;
    font-size: 0.875rem;
}

/* Range inputs */
.range-inputs {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.range-inputs span {
    color: var(--text-secondary);
}

.range-inputs input {
    width: 100%;
    background: var(--bg-base);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.625rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    min-height: 44px;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.range-inputs input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.range-inputs input::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

/* Custom checkboxes */
.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-primary);
    min-height: 44px;
    padding: 0.5rem 0;
    transition: color var(--transition);
}

.checkbox-group label:hover {
    color: var(--accent);
}

.checkbox-group input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-radius: 4px;
    background: var(--bg-base);
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
    transition: all var(--transition);
}

.checkbox-group input[type="checkbox"]:checked {
    background: var(--accent);
    border-color: var(--accent);
}

.checkbox-group input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 2px;
    width: 6px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.checkbox-group input[type="checkbox"]:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
}

/* Reset button */
#resetBtn {
    padding: 0.75rem 1rem;
    background: var(--bg-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border);
    cursor: pointer;
    border-radius: var(--radius-sm);
    width: 100%;
    font-size: 0.875rem;
    font-weight: 500;
    min-height: 44px;
    transition: all var(--transition);
}

#resetBtn:hover {
    background: var(--accent);
    border-color: var(--accent);
}

/* Details/summary for advanced filters */
details {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

details summary {
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.85rem;
    padding: 0.5rem 0;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: color var(--transition);
}

details summary::-webkit-details-marker {
    display: none;
}

details summary::before {
    content: '▶';
    font-size: 0.6rem;
    transition: transform var(--transition);
}

details[open] summary::before {
    transform: rotate(90deg);
}

details summary:hover {
    color: var(--accent);
}

details .filter-group {
    margin-top: 1rem;
}

.content {
    flex: 1;
    padding: 1.5rem 2rem;
    overflow-y: auto;
    min-width: 0;
}

/* Content Header */
.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

#lensCount {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.view-toggle {
    display: flex;
    gap: 0.25rem;
}

.view-btn {
    background: var(--bg-base);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    transition: all var(--transition);
}

.view-btn:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

.view-btn:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
}

.view-btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.view-btn.active:hover {
    background: var(--accent-hover);
}

/* Row Header */
.row-header {
    display: grid;
    grid-template-columns: 90px 1fr 70px 50px 60px 55px 50px 50px 45px;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Sortable Column Headers */
.rh-col {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sortable {
    cursor: pointer;
    user-select: none;
    transition: color 0.15s;
}

.sortable:hover {
    color: var(--accent);
}

.sort-arrow {
    display: inline-block;
    width: 0.8em;
    text-align: center;
}

.sort-asc .sort-arrow::after {
    content: '↑';
}

.sort-desc .sort-arrow::after {
    content: '↓';
}

.sort-asc, .sort-desc {
    color: var(--accent);
}

/* Row View */
.row-view {
    display: flex;
    flex-direction: column;
}

.lens-row {
    display: grid;
    grid-template-columns: 90px 1fr 70px 50px 60px 55px 50px 50px 45px;
    gap: 0.5rem;
    align-items: center;
    padding: 0.625rem 1rem;
    border: 1px solid var(--border);
    border-top: none;
    background: var(--bg-surface);
    cursor: pointer;
    font-size: 0.8rem;
    transition: background var(--transition), transform var(--transition);
}

.lens-row:last-child {
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}

.lens-row:hover {
    background: var(--bg-elevated);
}

.lens-row:active {
    transform: scale(0.995);
}

.row-manu {
    color: var(--accent);
    font-weight: 500;
    font-size: 0.7rem;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.row-model {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.row-spec {
    color: var(--text-secondary);
    text-align: center;
    font-size: 0.75rem;
}

.row-rating {
    color: #fbbf24;
}

.row-year {
    color: var(--text-secondary);
    text-align: right;
    font-size: 0.7rem;
}

/* Grid View */
.grid-view {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
}

.grid-view .row-header {
    display: none;
}

.lens-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0;
    cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
    overflow: hidden;
}

.lens-card:hover {
    transform: translateY(-4px);
    border-color: var(--accent);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.4);
}

.lens-card-body {
    padding: 1.25rem;
}

.lens-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 0.75rem;
}

.lens-manu {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--accent);
    font-weight: 600;
    letter-spacing: 0.5px;
    margin-bottom: 0.25rem;
}

.lens-model {
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-primary);
}

.lens-badge {
    background: var(--bg-elevated);
    color: var(--text-secondary);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.7rem;
    font-weight: 500;
}

.lens-specs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.spec-pill {
    background: var(--bg-elevated);
    color: var(--text-secondary);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
}

.spec-pill span {
    color: var(--text-primary);
}

.lens-rating {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(251, 191, 36, 0.15);
    color: var(--rating);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.lens-rating svg {
    width: 12px;
    height: 12px;
    fill: currentColor;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition), visibility var(--transition);
}

.modal:not(.hidden) {
    opacity: 1;
    visibility: visible;
}

.hidden { display: none !important; }

.modal-content {
    background: var(--bg-surface);
    width: 700px;
    max-width: 90%;
    max-height: 85vh;
    border-radius: var(--radius);
    padding: 0;
    overflow: hidden;
    position: relative;
    border: 1px solid var(--border);
    transform: translateY(20px);
    transition: transform var(--transition);
}

.modal:not(.hidden) .modal-content {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-surface);
    position: sticky;
    top: 0;
    z-index: 10;
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    max-height: calc(85vh - 70px);
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    line-height: 1;
}

.close-btn:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

.detail-header { margin-bottom: 2rem; border-bottom: 1px solid var(--border); padding-bottom: 1rem; }
.manufacturer-link {
    display: inline-block;
    color: var(--accent);
    font-size: 0.85rem;
    margin-top: 0.5rem;
    text-decoration: none;
}
.manufacturer-link:hover { text-decoration: underline; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 2rem; }
.detail-row { display: flex; justify-content: space-between; border-bottom: 1px solid var(--border); padding: 0.5rem 0; }
.detail-label { color: var(--text-secondary); }

.review-card {
    background: var(--bg-color);
    padding: 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    border: 1px solid var(--border);
}
.review-source { color: var(--accent); font-weight: 600; font-size: 0.9rem; }
.review-rating { float: right; font-weight: bold; }

/* Card Image Styles */
.lens-image-container {
    width: 100%;
    height: 160px;
    position: relative;
    overflow: hidden;
    background: var(--bg-base);
    display: flex;
    align-items: center;
    justify-content: center;
}

.lens-image-container::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40px;
    background: linear-gradient(to top, var(--bg-surface), transparent);
    pointer-events: none;
}

.lens-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: transform var(--transition);
}

.lens-card:hover .lens-image {
    transform: scale(1.05);
}

.lens-image-placeholder {
    color: var(--text-secondary);
    font-size: 0.8rem;
    text-align: center;
}

.lens-image-placeholder svg {
    display: block;
    margin: 0 auto 0.5rem;
    opacity: 0.3;
}

/* Detail Modal Images */
.detail-images {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
}

.detail-image-thumb {
    width: 80px;
    height: 80px;
    border-radius: 4px;
    object-fit: cover;
    border: 2px solid transparent;
    cursor: pointer;
    flex-shrink: 0;
}

.detail-image-thumb:hover,
.detail-image-thumb.active {
    border-color: var(--accent);
}

.detail-image-main {
    width: 100%;
    max-height: 300px;
    object-fit: contain;
    margin-bottom: 1rem;
    border-radius: 6px;
    background: var(--bg-color);
}

/* Average Rating Display */
.detail-rating {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.rating-stars {
    color: #fbbf24;
    font-size: 1.2rem;
}

.rating-value {
    font-weight: 600;
    font-size: 1.1rem;
}

.rating-count {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* Card Rating */
.card-rating {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    color: #fbbf24;
    font-size: 0.85rem;
    margin-top: 0.75rem;
}

.card-rating span {
    color: var(--text-primary);
}

/* ===========================================
   RESPONSIVE STYLES
   =========================================== */

/* Hamburger Menu Button (hidden on desktop) */
.hamburger-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
}

.hamburger-btn:hover {
    background: var(--bg-elevated);
}

/* Sidebar backdrop (for mobile drawer) */
.sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 99;
    opacity: 0;
    transition: opacity var(--transition);
}

.sidebar-backdrop.visible {
    opacity: 1;
}

/* Sidebar close button (hidden on desktop) */
.sidebar-close {
    display: none;
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
}

.sidebar-close:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

/* Tablet breakpoint (768px - 1023px) */
@media (max-width: 1023px) {
    .sidebar {
        width: var(--sidebar-width-tablet);
    }

    header {
        padding: 0 1.5rem;
    }

    .content {
        padding: 1.25rem 1.5rem;
    }

    .search-bar input {
        width: 250px;
    }
}

/* Mobile breakpoint (< 768px) */
@media (max-width: 767px) {
    /* Show hamburger */
    .hamburger-btn {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Header layout for mobile */
    header {
        padding: 0 1rem;
    }

    .logo h1 {
        font-size: 1.1rem;
    }

    .search-bar {
        flex: 1;
        margin: 0 1rem;
    }

    .search-bar input {
        width: 100%;
    }

    /* Sidebar becomes drawer */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 85%;
        max-width: 320px;
        height: 100vh;
        z-index: 100;
        transform: translateX(-100%);
        transition: transform var(--transition);
        padding-top: 4rem;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-close {
        display: block;
    }

    .sidebar-backdrop.visible {
        display: block;
    }

    /* Content full width */
    .content {
        width: 100%;
        padding: 1rem;
    }

    /* Force card view on mobile */
    .view-toggle {
        display: none;
    }

    .row-view {
        display: grid !important;
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .row-view .row-header {
        display: none;
    }

    .row-view .lens-row {
        display: none;
    }

    /* Grid view adjustments */
    .grid-view {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .lens-card {
        padding: 1rem;
    }

    /* Modal full-screen on mobile */
    .modal {
        align-items: flex-end;
    }

    .modal-content {
        width: 100%;
        max-width: 100%;
        max-height: 95vh;
        border-radius: var(--radius) var(--radius) 0 0;
        padding: 0;
        transform: translateY(100%);
    }

    .modal:not(.hidden) .modal-content {
        transform: translateY(0);
    }

    .modal-header {
        position: sticky;
        top: 0;
        padding: 1rem 1.25rem;
    }

    .modal-header h2 {
        font-size: 1rem;
    }

    .modal-body {
        padding: 1rem 1.25rem;
        max-height: calc(95vh - 60px);
    }

    .detail-grid {
        grid-template-columns: 1fr;
    }

    .detail-images {
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
    }
}
