/**
 * BN Konwerter – Frontend Styles
 * Design: dark theme matching Biblioteka Naturopatii / Lugol calculator
 */

/* ── Reset & Container ─────────────────────────────────── */
.bn-konwerter {
    max-width: 900px;
    margin: 2rem auto;
    padding: 0 20px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: #333;
    line-height: 1.6;
}

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

/* ── Search ────────────────────────────────────────────── */
.bn-konwerter__search {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border-radius: 16px;
    padding: 24px 30px;
    margin-bottom: 20px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
}

.bn-konwerter__search-label {
    display: block;
    color: #bdc3c7;
    font-weight: 500;
    margin-bottom: 10px;
    font-size: 1.9rem;
    text-align: center;
}

.bn-konwerter__search-input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.3);
    color: #ffffff !important;
    -webkit-text-fill-color: #ffffff;
    font-size: 1.1rem;
    font-family: inherit;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    line-height: 1.2;
}

.bn-konwerter__search-input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 15px rgba(52, 152, 219, 0.3);
    color: #ffffff !important;
    -webkit-text-fill-color: #ffffff;
}

.bn-konwerter__search-input::placeholder {
    color: rgba(255, 255, 255, 0.55) !important;
    -webkit-text-fill-color: rgba(255, 255, 255, 0.55);
}

/* ── Category filter ───────────────────────────────────── */
.bn-konwerter__categories {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
    padding: 20px 24px;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border-radius: 16px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
}

.bn-konwerter__cat-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 0.85rem;
    font-weight: 500;
    font-family: inherit;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.3);
    color: #bdc3c7;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.bn-konwerter__cat-btn:hover {
    border-color: #3498db;
    color: #5dade2;
    background: rgba(52, 152, 219, 0.1);
}

.bn-konwerter__cat-btn.is-active {
    background: linear-gradient(135deg, #3498db, #2980b9);
    border-color: #3498db;
    color: #fff;
}

.bn-konwerter__cat-count {
    font-size: 0.75rem;
    opacity: 0.7;
}

/* ── Grid ──────────────────────────────────────────────── */
.bn-konwerter__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: 20px;
}

/* ── Card ──────────────────────────────────────────────── */
.bn-konwerter__card {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border: none;
    border-radius: 16px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    color: #e8e8e8;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.bn-konwerter__card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}

/* ── Card header ───────────────────────────────────────── */
.bn-konwerter .bn-konwerter__card-header {
    padding: 22px 24px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    text-align: center !important;
}

.bn-konwerter .bn-konwerter__card .bn-konwerter__card-title,
.bn-konwerter__card-title {
    margin: 0 !important;
    font-size: 1.725rem !important;
    font-weight: 600 !important;
    color: #3498db !important;
    line-height: 1.3 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    text-align: center !important;
    padding: 0 !important;
    border: none !important;
    background: none !important;
}

.bn-konwerter__card-icon {
    font-size: 1.6rem;
    line-height: 1;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
}

.bn-konwerter__card-link {
    color: #3498db !important;
    text-decoration: none !important;
    transition: color 0.2s ease;
}

.bn-konwerter__card-link:hover {
    color: #5dade2 !important;
    text-decoration: underline !important;
}

/* ── Card body ─────────────────────────────────────────── */
.bn-konwerter__card-body {
    padding: 18px 24px 22px;
}

/* ── Input groups ──────────────────────────────────────── */
.bn-konwerter__input-group {
    margin-bottom: 16px;
}

.bn-konwerter__label {
    display: block;
    font-size: 1.275rem;
    font-weight: 500;
    color: #bdc3c7;
    margin-bottom: 6px;
}

.bn-konwerter__value-input,
.bn-konwerter__unit-from,
.bn-konwerter__unit-to {
    width: 100%;
    padding: 14px 16px;
    font-size: 1.1rem;
    font-family: inherit;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.3);
    color: #ffffff !important;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    line-height: 1.2;
    height: auto;
    -webkit-text-fill-color: #ffffff;
}

.bn-konwerter__value-input:focus,
.bn-konwerter__unit-from:focus,
.bn-konwerter__unit-to:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 15px rgba(52, 152, 219, 0.3);
    color: #ffffff !important;
    -webkit-text-fill-color: #ffffff;
}

.bn-konwerter__value-input::placeholder {
    color: rgba(255, 255, 255, 0.55) !important;
    -webkit-text-fill-color: rgba(255, 255, 255, 0.55);
}

/* Hide number input spinners */
.bn-konwerter__value-input::-webkit-outer-spin-button,
.bn-konwerter__value-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.bn-konwerter__value-input {
    -moz-appearance: textfield;
}

/* Custom select arrow */
.bn-konwerter__unit-from,
.bn-konwerter__unit-to {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    cursor: pointer;
    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='%23ffffff' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 40px;
}

.bn-konwerter__unit-from option,
.bn-konwerter__unit-to option {
    background: #1a1a2e;
    color: #fff;
}

/* ── Results ───────────────────────────────────────────── */
.bn-konwerter__results {
    min-height: 2rem;
}

.bn-konwerter__result-item {
    padding: 14px 18px;
    margin-bottom: 8px;
    background: rgba(46, 204, 113, 0.1);
    border: 1px solid rgba(46, 204, 113, 0.3);
    border-radius: 10px;
    animation: bn-fade-in 0.4s ease;
    display: flex;
    align-items: baseline;
    gap: 10px;
}

.bn-konwerter__result-item--empty {
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.1);
    color: #7f8c8d;
    font-size: 0.9rem;
    justify-content: center;
}

.bn-konwerter__result-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: #f39c12;
    font-variant-numeric: tabular-nums;
}

.bn-konwerter__result-unit {
    font-size: 0.95rem;
    color: #bdc3c7;
    font-weight: 500;
}

/* ── Notes ──────────────────────────────────────────────── */
.bn-konwerter__notes {
    margin-top: 12px;
    padding: 12px 16px;
    background: rgba(243, 156, 18, 0.08);
    border-left: 3px solid #f39c12;
    border-radius: 0 10px 10px 0;
    font-size: 0.85rem;
    color: #f0c27a;
    line-height: 1.5;
}

.bn-konwerter__notes small {
    font-size: inherit;
}

/* ── Formula ───────────────────────────────────────────── */
.bn-konwerter__formula {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 0.8rem;
    color: #5a6a7a;
    text-align: center;
    line-height: 1.5;
    font-family: 'Consolas', 'Courier New', monospace;
}

/* ── Factor info below results ─────────────────────────── */
.bn-konwerter__factor-info {
    margin-top: 8px;
    font-size: 0.8rem;
    color: #5a6a7a;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

/* ── Empty state ───────────────────────────────────────── */
.bn-konwerter__empty {
    text-align: center;
    padding: 3rem 1rem;
    color: #7f8c8d;
    font-size: 1.05rem;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border-radius: 16px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
}

/* ── Error ──────────────────────────────────────────────── */
.bn-konwerter-error {
    padding: 16px 20px;
    background: linear-gradient(135deg, #ffebee 0%, #ffcdd2 100%);
    border: 1px solid #e57373;
    border-radius: 10px;
    color: #b71c1c;
    box-shadow: 0 4px 15px rgba(229, 115, 115, 0.2);
}

.bn-konwerter-error code {
    background: rgba(0, 0, 0, 0.06);
    padding: 2px 6px;
    border-radius: 4px;
}

/* ── Animation ─────────────────────────────────────────── */
@keyframes bn-fade-in {
    from { opacity: 0; transform: translateY(-10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 640px) {
    .bn-konwerter {
        padding: 0 12px;
    }

    .bn-konwerter__grid {
        grid-template-columns: 1fr;
    }

    .bn-konwerter__card-body {
        padding: 16px 18px 20px;
    }

    .bn-konwerter__card-header {
        padding: 14px 18px 12px;
    }

    .bn-konwerter__search {
        padding: 18px 20px;
        border-radius: 12px;
    }

    .bn-konwerter__card {
        border-radius: 12px;
    }

    .bn-konwerter__categories {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding: 16px 18px;
        border-radius: 12px;
    }

    .bn-konwerter__categories::-webkit-scrollbar {
        display: none;
    }

    .bn-konwerter__result-value {
        font-size: 1.3rem;
    }

    .bn-konwerter__value-input,
    .bn-konwerter__unit-from {
        padding: 12px 14px;
        font-size: 1rem;
    }
}

/* ── Auto-inject wrapper ───────────────────────────────── */
.bn-konwerter-auto-inject {
    margin-top: 2rem;
    padding-top: 2rem;
}

.bn-konwerter-auto-inject::before {
    content: '🔬 Kalkulator przeliczania jednostek';
    display: block;
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: #3498db;
}

/* ── Single param mode – centered card ─────────────────── */
.bn-konwerter--single .bn-konwerter__grid {
    grid-template-columns: 1fr;
    max-width: 500px;
    margin: 0 auto;
}
