/* ═══════════════════════════════════════════════════════════════════════════
   Sunector — Wyszukiwarka produktów
   ═══════════════════════════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    margin: 0;
    background: #f3f4f6;
    color: #1f2937;
    line-height: 1.5;
}

/* ─── Layout ────────────────────────────────────────────────────────────── */

.container {
    max-width: 1100px;
    margin: 20px auto;
    padding: 0 16px;
}

.header {
    background: #1a5f2a;
    color: white;
}

.header-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.header h1 {
    margin: 0;
    font-size: 17px;
    flex: 1;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 4px;
}

.header-link {
    color: rgba(255,255,255,.8);
    text-decoration: none;
    font-size: 13px;
    white-space: nowrap;
    padding: 4px 10px;
    border-radius: 4px;
    transition: background .2s, color .2s;
}

.header-link:hover { color: white; background: rgba(255,255,255,.15); }
.header-link.active { color: white; background: rgba(255,255,255,.2); }

.header-user {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 8px;
}

.header-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,.3);
}

.header-username {
    font-size: 12px;
    color: rgba(255,255,255,.9);
    white-space: nowrap;
}

/* ─── Cards ─────────────────────────────────────────────────────────────── */

.card {
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
    margin-bottom: 16px;
}

.card h2 {
    margin: 0 0 14px;
    font-size: 15px;
    color: #111;
}

/* ─── Search box ────────────────────────────────────────────────────────── */

.search-card { position: relative; }

.search-box {
    display: flex;
    gap: 10px;
}

.search-input {
    flex: 1;
    padding: 12px 16px;
    font-size: 15px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    outline: none;
    transition: border-color .2s;
}

.search-input:focus {
    border-color: #1a5f2a;
}

/* ─── Suggestions ───────────────────────────────────────────────────────── */

.suggestions {
    position: absolute;
    top: calc(100% - 8px);
    left: 20px;
    right: 20px;
    background: white;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,.15);
    z-index: 100;
    max-height: 300px;
    overflow-y: auto;
}

.suggestion {
    padding: 10px 14px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #f3f4f6;
}

.suggestion:hover { background: #f0fdf4; }

.sug-name { font-size: 13px; }
.sug-cat  { font-size: 11px; color: #888; }

/* ─── Buttons ───────────────────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
    transition: background .15s;
}

.btn-primary   { background: #1a5f2a; color: white; }
.btn-primary:hover { background: #155224; }

.btn-secondary { background: #e5e7eb; color: #374151; }
.btn-secondary:hover { background: #d1d5db; }

/* ─── Filters panel ─────────────────────────────────────────────────────── */

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.toggle-icon { font-size: 12px; color: #888; }

.filters-panel { margin-top: 14px; }

.filter-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.filter-row label {
    min-width: 160px;
    font-size: 13px;
    color: #555;
    text-align: right;
}

.filter-row select,
.input-sm {
    padding: 7px 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 13px;
    outline: none;
}

.filter-row select:focus,
.input-sm:focus { border-color: #1a5f2a; }

.range-inputs {
    display: flex;
    align-items: center;
    gap: 6px;
}

.range-inputs .input-sm { width: 90px; }

.filter-actions {
    margin-top: 16px;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* ─── Results ───────────────────────────────────────────────────────────── */

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 10px;
}

.results-header h2 { font-size: 15px; margin: 0; }

.results-count {
    font-size: 13px;
    color: #666;
}

.results-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.result-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    background: white;
    border-radius: 10px;
    padding: 14px 18px;
    text-decoration: none;
    color: inherit;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
    border: 1px solid #f0f0f0;
    transition: border-color .15s, box-shadow .15s;
}

.result-card:hover {
    border-color: #1a5f2a;
    box-shadow: 0 2px 8px rgba(26,95,42,.12);
}

.result-main { flex: 1; min-width: 0; }

.result-top {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.result-name {
    font-size: 14px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.result-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.result-side {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}

.match-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    padding: 2px 8px;
    background: #1a5f2a;
    color: white;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

.match-badge.small { font-size: 11px; min-width: 32px; padding: 1px 6px; }

.cat-label {
    display: inline-block;
    padding: 2px 8px;
    background: #f0fdf4;
    color: #166534;
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
}

.cat-label.small { font-size: 10px; padding: 1px 6px; }

.param-tag {
    display: inline-block;
    padding: 1px 7px;
    background: #f3f4f6;
    border-radius: 4px;
    font-size: 11px;
    color: #555;
}

.price {
    font-weight: 700;
    color: #1a5f2a;
    font-size: 15px;
    white-space: nowrap;
}

.avail  { font-size: 11px; color: #888; }
.has-pdf { font-size: 12px; }

.no-results {
    text-align: center;
    padding: 40px 20px;
    color: #888;
    font-size: 14px;
}

/* ─── Product page ──────────────────────────────────────────────────────── */

.product-header { }

.product-title-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.product-name {
    font-size: 18px;
    margin: 0 0 6px;
    word-break: break-word;
}

.product-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.info-item {
    padding: 10px 12px;
    background: #f9fafb;
    border-radius: 8px;
}

.info-label {
    display: block;
    font-size: 11px;
    color: #888;
    margin-bottom: 2px;
}

.info-value {
    font-size: 15px;
    font-weight: 500;
}

/* ─── Params table ──────────────────────────────────────────────────────── */

.params-table {
    width: 100%;
    border-collapse: collapse;
}

.params-table th {
    text-align: left;
    padding: 8px 12px;
    background: #f5f5f5;
    font-size: 12px;
    font-weight: 600;
}

.params-table td {
    padding: 8px 12px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 13px;
}

.params-table tr:hover td { background: #fafafa; }

.param-key {
    color: #555;
    text-transform: capitalize;
}

.param-val { font-weight: 500; }

/* ─── Similar products ──────────────────────────────────────────────────── */

.similar-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.similar-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: #f9fafb;
    border-radius: 8px;
    text-decoration: none;
    color: inherit;
    border: 1px solid transparent;
    transition: border-color .15s;
}

.similar-card:hover { border-color: #1a5f2a; }

.similar-name {
    font-size: 13px;
    font-weight: 500;
}

.similar-meta {
    display: flex;
    gap: 10px;
    align-items: center;
    font-size: 12px;
    color: #666;
}

/* ─── Loading spinner ───────────────────────────────────────────────────── */

.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 30px;
    color: #666;
    font-size: 14px;
}

.spinner {
    width: 22px;
    height: 22px;
    border: 3px solid #e5e7eb;
    border-top-color: #1a5f2a;
    border-radius: 50%;
    animation: spin .7s linear infinite;
}

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

/* ─── Responsive ────────────────────────────────────────────────────────── */

@media (max-width: 640px) {
    .filter-row {
        flex-direction: column;
        align-items: stretch;
    }
    .filter-row label {
        text-align: left;
        min-width: 0;
    }
    .result-card { flex-direction: column; align-items: stretch; }
    .result-side { flex-direction: row; gap: 10px; }
    .product-title-row { flex-direction: column; }
}
