/* CSS Variables */
:root {
    --primary-red: #c41e3a;
    --primary-green: #165b33;
    --dark-green: #0d3b22;
    --gold: #d4af37;
    --light-gold: #f5e6c8;
    --white: #ffffff;
    --off-white: #f8f9fa;
    --gray-light: #e9ecef;
    --gray: #6c757d;
    --gray-dark: #343a40;
    --shadow: rgba(0, 0, 0, 0.1);
    --shadow-strong: rgba(0, 0, 0, 0.2);
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(135deg, var(--off-white) 0%, var(--light-gold) 100%);
    min-height: 100vh;
    color: var(--gray-dark);
    line-height: 1.5;
}

/* Header */
header {
    background: linear-gradient(135deg, var(--primary-green) 0%, var(--dark-green) 100%);
    color: var(--white);
    padding: 1.5rem 1rem;
    text-align: center;
    box-shadow: 0 4px 12px var(--shadow-strong);
}

.header-content h1 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.subtitle {
    font-size: 0.9rem;
    opacity: 0.9;
    margin-top: 0.25rem;
    color: var(--light-gold);
}

.total-pixels {
    margin-top: 0.75rem;
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    display: inline-block;
    font-size: 0.9rem;
    color: var(--light-gold);
}

.total-pixels span {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--white);
}

/* Tab Navigation */
.tab-nav {
    display: flex;
    background: var(--white);
    box-shadow: 0 2px 8px var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.tab-btn {
    flex: 1;
    padding: 1rem;
    border: none;
    background: transparent;
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray);
    cursor: pointer;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
}

.tab-btn.active {
    color: var(--primary-green);
    border-bottom-color: var(--primary-green);
    background: var(--off-white);
}

.tab-btn:hover:not(.active) {
    background: var(--gray-light);
}

/* Main Content */
main {
    padding: 1rem;
    max-width: 1200px;
    margin: 0 auto;
}

/* Search */
.search-container {
    position: relative;
    margin-bottom: 1rem;
}

#searchInput {
    width: 100%;
    padding: 1rem 3rem 1rem 1rem;
    font-size: 1rem;
    border: 2px solid var(--gray-light);
    border-radius: 12px;
    background: var(--white);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

#searchInput:focus {
    outline: none;
    border-color: var(--primary-green);
    box-shadow: 0 0 0 3px rgba(22, 91, 51, 0.15);
}

.clear-btn {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    background: var(--gray-light);
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 1.25rem;
    color: var(--gray);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.clear-btn:hover {
    background: var(--gray);
    color: var(--white);
}

/* Year Toggle */
.year-toggle {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: var(--white);
    border-radius: 10px;
    box-shadow: 0 2px 6px var(--shadow);
}

.year-toggle label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-weight: 500;
    color: var(--gray-dark);
}

.year-toggle input[type="radio"] {
    accent-color: var(--primary-green);
    width: 18px;
    height: 18px;
}

/* Stats Bar */
.stats-bar {
    padding: 0.75rem 1rem;
    background: var(--white);
    border-radius: 8px;
    margin-bottom: 1rem;
    font-weight: 500;
    color: var(--gray);
    box-shadow: 0 1px 4px var(--shadow);
}

/* Tab Content */
.tab-content {
    display: none;
}

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

/* Controller List */
.controller-list {
    display: grid;
    gap: 0.75rem;
}

.controller-card {
    background: var(--white);
    border-radius: 12px;
    padding: 1rem;
    box-shadow: 0 2px 8px var(--shadow);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border-left: 4px solid var(--primary-green);
}

.controller-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px var(--shadow-strong);
}

.controller-card:active {
    transform: translateY(0);
}

.controller-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--gray-dark);
    margin-bottom: 0.5rem;
}

.controller-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    font-size: 0.85rem;
    color: var(--gray);
}

.controller-meta span {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-type {
    background: var(--light-gold);
    color: var(--gray-dark);
}

.badge-box {
    background: var(--primary-red);
    color: var(--white);
}

/* Prop Results */
.prop-results {
    display: grid;
    gap: 0.75rem;
}

.prop-card {
    background: var(--white);
    border-radius: 12px;
    padding: 1rem;
    box-shadow: 0 2px 8px var(--shadow);
    border-left: 4px solid var(--gold);
}

.prop-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-dark);
    margin-bottom: 0.5rem;
}

.prop-location {
    font-size: 0.9rem;
    color: var(--gray);
}

.prop-location strong {
    color: var(--primary-green);
}

.prop-pixels {
    font-size: 0.85rem;
    color: var(--gray);
    margin-top: 0.25rem;
}

.prop-card.has-daisy-chain {
    border-left-color: #ff9800;
}

.prop-chain-warning {
    background: #ff9800;
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    margin-top: 0.5rem;
    text-align: center;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    overflow-y: auto;
    padding: 1rem;
}

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

.modal-content {
    background: var(--white);
    border-radius: 16px;
    width: 100%;
    max-width: 600px;
    margin: 1rem auto;
    box-shadow: 0 8px 32px var(--shadow-strong);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem;
    border-bottom: 1px solid var(--gray-light);
    background: linear-gradient(135deg, var(--primary-green) 0%, var(--dark-green) 100%);
    border-radius: 16px 16px 0 0;
    color: var(--white);
}

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--white);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.modal-actions {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--gray-light);
    background: var(--off-white);
}

.print-btn {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--primary-red);
    color: var(--white);
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
}

.print-btn:hover {
    background: #a31830;
}

.modal-body {
    padding: 1.25rem;
    max-height: 60vh;
    overflow-y: auto;
}

/* Controller Details */
.detail-section {
    margin-bottom: 1.5rem;
}

.print-info-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.print-info-row .detail-section {
    margin-bottom: 1rem;
}

.port-section {
    width: 100%;
}

.port-section .detail-label {
    margin-bottom: 0.75rem;
}

.detail-section:last-child {
    margin-bottom: 0;
}

.detail-label {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--gray);
    margin-bottom: 0.25rem;
    letter-spacing: 0.5px;
}

.detail-value {
    font-size: 1rem;
    color: var(--gray-dark);
}

.port-list {
    display: grid;
    gap: 0.75rem;
}

.port-item {
    background: var(--off-white);
    border-radius: 10px;
    padding: 1rem;
    border: 1px solid var(--gray-light);
}

.port-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.port-number {
    font-weight: 700;
    color: var(--primary-green);
    font-size: 1rem;
}

.port-pixels {
    font-size: 0.85rem;
    color: var(--gray);
}

.model-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.model-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    background: var(--white);
    border-radius: 6px;
    border-left: 3px solid var(--gold);
}

/* Daisy Chain Styles */
.daisy-chained {
    background: #fff3e0;
    border: 2px dashed #ff9800;
    border-radius: 8px;
    padding: 0.5rem;
}

.daisy-chain-label {
    background: #ff9800;
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.35rem 0.75rem;
    border-radius: 4px;
    margin-bottom: 0.5rem;
    text-align: center;
    letter-spacing: 0.5px;
}

.model-item.chained {
    border-left: 3px solid #ff9800;
    position: relative;
}

.model-item.chained:not(:last-child)::after {
    content: '';
    position: absolute;
    left: 1rem;
    bottom: -0.5rem;
    width: 2px;
    height: 0.5rem;
    background: #ff9800;
}

.chain-order {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    background: #ff9800;
    color: white;
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 700;
    margin-right: 0.5rem;
    flex-shrink: 0;
}

.model-item.chained .model-name {
    flex: 1;
}

.model-name {
    font-weight: 500;
    color: var(--gray-dark);
}

.model-pixels {
    font-size: 0.85rem;
    color: var(--gray);
    white-space: nowrap;
}

/* Footer */
footer {
    text-align: center;
    padding: 1.5rem;
    color: var(--gray);
    font-size: 0.85rem;
}

/* No Results */
.no-results {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--gray);
}

.no-results-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Print Styles */
@media print {
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    body {
        background: white;
        font-size: 9pt;
        line-height: 1.2;
    }

    header, footer, .tab-nav, .search-container, .year-toggle,
    .stats-bar, .modal-actions, .close-btn,
    .tab-content, .controller-list, .prop-results {
        display: none !important;
    }

    .modal {
        position: static;
        background: none;
        padding: 0;
        display: block !important;
    }

    .modal-content {
        box-shadow: none;
        margin: 0;
        max-width: none;
        border-radius: 0;
    }

    .modal-header {
        background: #165b33 !important;
        color: white !important;
        border-radius: 0;
        padding: 8px 12px;
        margin-bottom: 8px;
    }

    .modal-header h2 {
        font-size: 14pt;
        margin: 0;
    }

    .modal-body {
        padding: 0;
        max-height: none;
        overflow: visible;
    }

    .controller-details {
        font-size: 9pt;
    }

    .detail-section {
        margin-bottom: 6px;
        display: inline-block;
        margin-right: 20px;
    }

    .detail-label {
        font-size: 7pt;
        margin-bottom: 1px;
    }

    .detail-value {
        font-size: 9pt;
    }

    /* Compact port list */
    .port-list {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
        margin-top: 10px;
    }

    .port-item {
        break-inside: avoid;
        page-break-inside: avoid;
        border: 1px solid #999;
        padding: 4px 6px;
        border-radius: 3px;
        background: #f9f9f9 !important;
    }

    .port-header {
        margin-bottom: 3px;
        padding-bottom: 2px;
        border-bottom: 1px solid #ddd;
    }

    .port-number {
        font-size: 9pt;
        font-weight: bold;
    }

    .port-pixels {
        font-size: 7pt;
    }

    .model-list {
        gap: 2px;
    }

    .model-item {
        padding: 2px 4px;
        border-left: 2px solid #333;
        font-size: 8pt;
        background: white !important;
    }

    .model-name {
        font-size: 8pt;
    }

    .model-pixels {
        font-size: 7pt;
    }

    /* Daisy chain print styles */
    .daisy-chained {
        background: #fff3e0 !important;
        border: 1px dashed #ff9800 !important;
        padding: 3px;
    }

    .daisy-chain-label {
        font-size: 7pt;
        padding: 2px 4px;
        margin-bottom: 3px;
        background: #ff9800 !important;
        color: white !important;
    }

    .chain-order {
        width: 14px;
        height: 14px;
        font-size: 7pt;
        margin-right: 3px;
        background: #ff9800 !important;
        color: white !important;
    }

    .model-item.chained {
        border-left-color: #ff9800;
    }

    .model-item.chained:not(:last-child)::after {
        display: none;
    }

    /* Print header info inline */
    .print-info-row {
        display: flex;
        flex-wrap: wrap;
        gap: 15px;
        border-bottom: 1px solid #ccc;
        padding-bottom: 6px;
        margin-bottom: 8px;
    }
}

/* Desktop Enhancements */
@media (min-width: 768px) {
    header {
        padding: 2rem;
    }

    .header-content h1 {
        font-size: 2.5rem;
    }

    .subtitle {
        font-size: 1.1rem;
    }

    main {
        padding: 2rem;
    }

    .controller-list {
        grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    }

    .prop-results {
        grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    }

    .modal-body {
        max-height: 70vh;
    }
}
