/* =====================================================
   CHIPTUNING CATALOG - STYLE CSS
   ===================================================== */

/* Reset i zmienne */
.chip-dropdown-wrapper,
.chip-catalog-wrapper {
    --chip-primary: #e63946;
    --chip-dark: #1d3557;
    --chip-light: #f1faee;
    --chip-gray: #457b9d;
    --chip-success: #2a9d8f;
    --chip-border: #ddd;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
    box-sizing: border-box !important;
    overflow: visible !important;
    position: relative !important;
    z-index: 10 !important;
}

.chip-dropdown-wrapper *,
.chip-catalog-wrapper * {
    box-sizing: border-box !important;
}

/* =====================================================
   WERSJA 1: DROPDOWN - Szybkie wyszukiwanie
   ===================================================== */

.chip-dropdown-wrapper {
    background: linear-gradient(135deg, var(--chip-dark) 0%, #2a4a6d 100%) !important;
    padding: 25px !important;
    border-radius: 12px !important;
    max-width: 100% !important;
    margin: 20px 0 !important;
    overflow: visible !important;
    min-height: 120px !important;
}

.chip-dropdown-title {
    color: white !important;
    font-size: 1.3em !important;
    font-weight: 600 !important;
    margin-bottom: 20px !important;
    text-align: center !important;
}

.chip-dropdown-selects {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)) !important;
    gap: 12px !important;
    overflow: visible !important;
}

.chip-select {
    width: 100% !important;
    padding: 14px 16px !important;
    font-size: 15px !important;
    border: 2px solid transparent !important;
    border-radius: 8px !important;
    background-color: white !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23333' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 12px center !important;
    height: auto !important;
    min-height: 48px !important;
    line-height: 1.4 !important;
    color: #333 !important;
}

.chip-select:hover:not(:disabled) {
    border-color: var(--chip-primary) !important;
}

.chip-select:focus {
    outline: none !important;
    border-color: var(--chip-primary) !important;
    box-shadow: 0 0 0 3px rgba(230, 57, 70, 0.2) !important;
}

.chip-select:disabled {
    background-color: #f5f5f5 !important;
    color: #999 !important;
    cursor: not-allowed !important;
}

/* Wynik dropdown */
.chip-result {
    margin-top: 20px;
    background: white;
    border-radius: 10px;
    padding: 20px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.chip-result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--chip-light);
}

.chip-result-title {
    font-size: 1.2em;
    font-weight: 600;
    color: var(--chip-dark);
}

.chip-result-fuel {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85em;
    font-weight: 500;
}

.chip-fuel-benzyna { background: #ffeaa7; color: #b8860b; }
.chip-fuel-diesel { background: #dfe6e9; color: #2d3436; }
.chip-fuel-hybryda { background: #d4f1c4; color: #27ae60; }

/* Tabela mocy */
.chip-power-table {
    width: 100%;
    margin: 15px 0;
}

.chip-power-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    gap: 10px;
    margin-bottom: 8px;
}

.chip-power-cell {
    text-align: center;
    padding: 12px;
    border-radius: 8px;
}

.chip-power-header {
    font-weight: 600;
    font-size: 0.85em;
    color: #666;
    text-transform: uppercase;
}

.chip-power-value {
    background: var(--chip-light);
}

.chip-power-orig { background: #f8f9fa; }
.chip-power-stage1 { background: #d4edda; }
.chip-power-stage2 { background: #cce5ff; }
.chip-power-gain { 
    background: var(--chip-success); 
    color: white;
    font-weight: 600;
}

.chip-power-number {
    font-size: 1.4em;
    font-weight: 700;
    color: var(--chip-dark);
}

.chip-power-unit {
    font-size: 0.8em;
    color: #666;
}

/* Sekcje szczegółów */
.chip-details-section {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #eee;
}

.chip-details-title {
    font-weight: 600;
    color: var(--chip-dark);
    margin-bottom: 10px;
    font-size: 0.95em;
}

.chip-details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 8px;
}

.chip-detail-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 6px;
    font-size: 0.9em;
}

.chip-detail-label {
    color: #666;
}

.chip-detail-value {
    font-weight: 500;
    color: var(--chip-dark);
}

.chip-detail-yes { color: var(--chip-success); }
.chip-detail-no { color: #999; }

/* Narzędzia */
.chip-tools-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chip-tool-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--chip-dark);
    color: white;
    border-radius: 20px;
    font-size: 0.85em;
}

.chip-tool-note {
    font-size: 0.75em;
    opacity: 0.8;
    font-style: italic;
}

/* Uwagi */
.chip-warning {
    margin-top: 15px;
    padding: 12px 15px;
    background: #fff3cd;
    border-left: 4px solid #ffc107;
    border-radius: 0 8px 8px 0;
    font-size: 0.9em;
    color: #856404;
}

/* =====================================================
   WERSJA 2: PEŁNA LISTA - Responsywna siatka
   ===================================================== */

.chip-catalog-wrapper {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

.chip-catalog-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 15px;
}

.chip-catalog-header h2 {
    margin: 0;
    color: var(--chip-dark);
    font-size: 1.8em;
}

.chip-search-box input {
    padding: 12px 20px;
    font-size: 15px;
    border: 2px solid var(--chip-border);
    border-radius: 25px;
    width: 280px;
    transition: all 0.2s;
}

.chip-search-box input:focus {
    outline: none;
    border-color: var(--chip-primary);
    box-shadow: 0 0 0 3px rgba(230, 57, 70, 0.1);
}

/* Siatka marek */
.chip-brands-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 15px;
}

.chip-brand-card {
    background: white;
    border: 2px solid #eee;
    border-radius: 12px;
    padding: 20px 15px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chip-brand-card:hover {
    border-color: var(--chip-primary);
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
}

.chip-brand-card.hidden {
    display: none;
}

.chip-brand-logo {
    width: 60px;
    height: 60px;
    object-fit: contain;
    margin-bottom: 10px;
}

.chip-brand-logo-placeholder {
    width: 60px;
    height: 60px;
    background: var(--chip-dark);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2em;
    font-weight: 600;
    margin: 0 auto 10px;
}

.chip-brand-name {
    font-weight: 600;
    color: var(--chip-dark);
    margin-bottom: 5px;
    font-size: 0.95em;
}

.chip-brand-count {
    font-size: 0.8em;
    color: #888;
}

/* Breadcrumb */
.chip-breadcrumb {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    padding: 12px 15px;
    background: #f8f9fa;
    border-radius: 8px;
    font-size: 0.95em;
    flex-wrap: wrap;
}

.chip-breadcrumb a {
    color: var(--chip-primary);
    text-decoration: none;
    font-weight: 500;
}

.chip-breadcrumb a:hover {
    text-decoration: underline;
}

.chip-separator {
    color: #ccc;
}

.chip-current-brand,
.chip-current-model {
    font-weight: 600;
    color: var(--chip-dark);
}

/* Lista modeli */
.chip-models-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}

.chip-model-card {
    background: white;
    border: 2px solid #eee;
    border-radius: 10px;
    padding: 18px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chip-model-card:hover {
    border-color: var(--chip-primary);
    background: #fef9f9;
}

.chip-model-name {
    font-weight: 600;
    color: var(--chip-dark);
}

.chip-model-count {
    font-size: 0.85em;
    color: #888;
    background: #f1f1f1;
    padding: 4px 10px;
    border-radius: 12px;
}

/* Lista silników */
.chip-engines-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chip-gen-header {
    padding: 12px 0 8px;
    font-weight: 600;
    color: #666;
    border-bottom: 2px solid #eee;
    margin-top: 10px;
}

.chip-gen-header:first-child {
    margin-top: 0;
}

.chip-engine-item {
    border: 2px solid #eee;
    border-radius: 10px;
    overflow: hidden;
    transition: all 0.2s;
}

.chip-engine-item:hover {
    border-color: #ccc;
}

.chip-engine-item.expanded {
    border-color: var(--chip-primary);
    box-shadow: 0 4px 15px rgba(230, 57, 70, 0.15);
}

.chip-engine-card {
    background: white;
    padding: 15px 20px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.chip-engine-card:hover {
    background: #fafafa;
}

.chip-engine-card.expanded {
    background: #fef9f9;
}

.chip-engine-name {
    font-weight: 600;
    color: var(--chip-dark);
    flex: 1;
    min-width: 180px;
}

.chip-engine-fuel {
    font-size: 0.85em;
    padding: 4px 12px;
    border-radius: 15px;
}

.chip-engine-power {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95em;
}

.chip-power-orig {
    color: #666;
}

.chip-power-arrow {
    color: #ccc;
}

.chip-power-stage1 {
    font-weight: 600;
    color: var(--chip-success);
}

.chip-engine-gain {
    background: var(--chip-success);
    color: white;
    padding: 5px 12px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9em;
}

.chip-engine-expand {
    color: #ccc;
    font-size: 0.8em;
    transition: transform 0.2s;
    margin-left: auto;
}

.chip-engine-card.expanded .chip-engine-expand {
    transform: rotate(180deg);
    color: var(--chip-primary);
}

/* Szczegóły silnika - inline */
.chip-engine-details {
    background: #f8f9fa;
    border-top: 1px solid #eee;
}

.chip-details-inner {
    padding: 20px;
}

.chip-inline-details {
    background: white;
    border-radius: 8px;
    padding: 20px;
}

.chip-inline-details .chip-power-table {
    margin-bottom: 15px;
    border: 1px solid #eee;
    border-radius: 8px;
    overflow: hidden;
}

.chip-inline-details .chip-power-row {
    display: grid;
    grid-template-columns: 100px repeat(auto-fit, minmax(100px, 1fr));
    gap: 0;
    margin: 0;
    border-bottom: 1px solid #eee;
}

.chip-inline-details .chip-power-row:last-child {
    border-bottom: none;
}

.chip-inline-details .chip-power-row > div {
    padding: 12px 15px;
    text-align: center;
}

.chip-inline-details .chip-power-header-row {
    background: var(--chip-dark);
    color: white;
    font-weight: 600;
    font-size: 0.85em;
}

.chip-inline-details .chip-power-header-row > div:first-child {
    background: transparent;
}

.chip-inline-details .chip-power-label {
    background: #f8f9fa;
    font-weight: 600;
    color: #666;
    text-align: left !important;
}

.chip-inline-details .chip-power-orig {
    background: white;
    color: #666;
}

.chip-inline-details .chip-power-stage1 {
    background: #d4edda;
    color: #155724;
    font-weight: 600;
}

.chip-inline-details .chip-power-stage2 {
    background: #cce5ff;
    color: #004085;
    font-weight: 600;
}

.chip-inline-details .chip-gain {
    font-size: 0.8em;
    opacity: 0.8;
}

.chip-inline-details .chip-details-section {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #eee;
}

.chip-inline-details .chip-details-title {
    font-weight: 600;
    color: var(--chip-dark);
    margin-bottom: 10px;
    font-size: 0.9em;
}

.chip-inline-details .chip-details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 8px;
}

.chip-inline-details .chip-detail-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 6px;
    font-size: 0.9em;
}

.chip-inline-details .chip-tools-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chip-inline-details .chip-tool-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--chip-dark);
    color: white;
    border-radius: 20px;
    font-size: 0.85em;
}

.chip-inline-details .chip-warning {
    margin-top: 15px;
    padding: 12px 15px;
    background: #fff3cd;
    border-left: 4px solid #ffc107;
    border-radius: 0 8px 8px 0;
    font-size: 0.9em;
    color: #856404;
}

.chip-error {
    padding: 20px;
    text-align: center;
    color: #dc3545;
}

/* Modal */
.chip-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    padding: 20px;
}

.chip-modal-content {
    background: white;
    border-radius: 15px;
    max-width: 700px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    animation: modalIn 0.3s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.chip-modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 35px;
    height: 35px;
    border: none;
    background: #f1f1f1;
    border-radius: 50%;
    font-size: 1.5em;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.chip-modal-close:hover {
    background: var(--chip-primary);
    color: white;
}

#chip-modal-body {
    padding: 25px;
}

/* Loading */
.chip-loading {
    text-align: center;
    padding: 40px;
    color: #888;
}

.chip-loading::after {
    content: '';
    display: inline-block;
    width: 25px;
    height: 25px;
    border: 3px solid #eee;
    border-top-color: var(--chip-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-left: 10px;
    vertical-align: middle;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* =====================================================
   RESPONSYWNOŚĆ
   ===================================================== */

@media (max-width: 768px) {
    .chip-dropdown-selects {
        grid-template-columns: 1fr;
    }
    
    .chip-catalog-header {
        flex-direction: column;
        text-align: center;
    }
    
    .chip-search-box input {
        width: 100%;
    }
    
    .chip-brands-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 10px;
    }
    
    .chip-brand-card {
        padding: 15px 10px;
    }
    
    .chip-brand-logo,
    .chip-brand-logo-placeholder {
        width: 45px;
        height: 45px;
    }
    
    .chip-engine-card {
        grid-template-columns: 1fr;
        gap: 10px;
        text-align: center;
    }
    
    .chip-power-row {
        grid-template-columns: 1fr 1fr;
    }
    
    .chip-modal-content {
        margin: 10px;
        max-height: calc(100vh - 40px);
    }
}

@media (max-width: 480px) {
    .chip-brands-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .chip-brand-name {
        font-size: 0.8em;
    }
    
    .chip-brand-count {
        font-size: 0.7em;
    }
}
