/* ==========================================================================
   Klimek Electric Motor Corp - Winding & Re-Design Department Stylesheet
   ========================================================================== */

:root {
    --primary: #0f172a;
    --accent: #2563eb;
    --bg-main: #f8fafc;
    --card-bg: #ffffff;
    --border: #e2e8f0;
    --text-main: #334155;
    --text-muted: #64748b;
    --danger: #ef4444;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    padding: 20px 10px;
    display: flex;
    justify-content: center;
}

.container {
    width: 100%;
    max-width: 680px;
    background: var(--card-bg);
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    border: 1px solid var(--border);
}

/* Przełącznik języków na górze */
.lang-switcher {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-bottom: 15px;
}
.lang-btn {
    display: inline-block;
    padding: 6px 12px;
    font-size: 0.8rem;
    font-weight: bold;
    text-decoration: none;
    color: var(--text-muted);
    background: #e2e8f0;
    border-radius: 4px;
    transition: all 0.2s;
}
.lang-btn.active {
    background: var(--accent);
    color: white;
}

/* Nagłówek firmowy */
.company-header {
    display: flex;
    align-items: center;
    gap: 20px;
    border-bottom: 2px solid var(--primary);
    padding-bottom: 15px;
    margin-bottom: 20px;
}
.logo-wrapper img {
    height: 60px;
    width: auto;
    display: block;
}
.company-details h2 {
    font-size: 1.2rem;
    color: var(--primary);
    font-weight: 800;
}
.company-details p {
    font-size: 0.85rem;
    color: var(--text-muted);
}
.dept-tag {
    margin-top: 2px;
    font-weight: 700;
    color: var(--accent) !important;
}

.report-title {
    font-size: 1.35rem;
    font-weight: 800;
    text-align: center;
    margin-bottom: 25px;
    color: var(--primary);
}

.section-subtitle {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 8px;
}
.results-title-spacing {
    margin-top: 25px;
}

.summary-box {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
}
.section-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 12px;
}

/* Przyciskowe regulatory (Steppery) */
.mobile-stepper-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.stepper-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--card-bg);
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid var(--border);
}
.stepper-label {
    font-weight: 700;
    font-size: 0.95rem;
}
.stepper-controls {
    display: flex;
    align-items: center;
    gap: 2px;
}
.step-btn {
    width: 38px;
    height: 38px;
    background: #e2e8f0;
    border: none;
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--primary);
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.step-btn:active {
    background: #cbd5e1;
}
.stepper-controls input {
    width: 45px;
    height: 38px;
    text-align: center;
    border: none;
    font-size: 1.05rem;
    font-weight: 700;
    background: transparent;
}

/* Siatka pól dla zwojów i tolerancji */
.form-grid-turns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}
@media (max-width: 480px) {
    .form-grid-turns { grid-template-columns: 1fr; }
}
.input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.input-group label {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-muted);
}
.size-large .step-btn { width: 45px; height: 42px; }
.size-large input { width: 100%; height: 42px; background: var(--card-bg); border: 1px solid var(--border); border-radius: 6px; }

/* Magazyn przewodów */
.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}
@media (max-width: 480px) {
    .checkbox-grid { grid-template-columns: repeat(2, 1fr); }
}
.checkbox-container {
    display: flex;
    align-items: center;
    position: relative;
    padding-left: 30px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    height: 34px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    user-select: none;
}
.checkbox-container input { position: absolute; opacity: 0; cursor: pointer; height: 0; width: 0; }
.checkmark { position: absolute; top: 8px; left: 8px; height: 18px; width: 18px; background-color: #e2e8f0; border-radius: 4px; }
.checkbox-container:hover input ~ .checkmark { background-color: #cbd5e1; }
.checkbox-container input:checked ~ .checkmark { background-color: var(--accent); }
.checkmark:after { content: ""; position: absolute; display: none; }
.checkbox-container input:checked ~ .checkmark:after { display: block; }
.checkbox-container .checkmark:after { left: 6px; top: 2px; width: 4px; height: 9px; border: solid white; border-width: 0 2px 2px 0; transform: rotate(45deg); }

/* Przyciski */
.btn-primary, .btn-pdf {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 700;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    display: block;
    transition: background 0.2s;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: #1e293b; }
.btn-pdf { background: var(--accent); color: white; }
.btn-pdf:hover { background: #1d4ed8; }
.action-buttons { margin-top: 25px; }

/* Górna metryka na stronie wyników */
.queried-wires-line { font-size: 1rem; margin-bottom: 12px; }
.query-badge { background: var(--primary); color: white; padding: 3px 8px; border-radius: 4px; font-weight: 700; font-size: 0.85rem; }
.meta-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; font-size: 0.85rem; border-top: 1px solid var(--border); padding-top: 10px; }
@media (max-width: 550px) { .meta-grid { grid-template-columns: 1fr; gap: 4px; } }

/* Stopka raportu */
.report-footer-note { margin-top: 25px; padding-top: 15px; border-top: 1px dashed var(--border); font-size: 0.78rem; color: var(--text-muted); text-align: center; line-height: 1.4; }

/* ==========================================================================
   STYLIZACJA TABELI WYNIKÓW (DESKTOP)
   ========================================================================== */
.results-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-top: 20px;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    border: 1px solid #e2e8f0;
}
.results-table th {
    background-color: #f8fafc;
    color: #64748b;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 12px 14px;
    font-weight: 700;
    border-bottom: 2px solid #e2e8f0;
}
.results-table td {
    padding: 14px 14px;
    color: #334155;
    font-size: 0.9rem;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}
.results-table tr:last-child td { border-bottom: none; }

/* Szerokości kolumn dla dużych ekranów */
.results-table th:nth-child(1), .results-table td:nth-child(1) { text-align: center; width: 6%; color: #94a3b8; }
.results-table th:nth-child(2), .results-table td:nth-child(2) { text-align: left; }
.results-table th:nth-child(3), .results-table td:nth-child(3) { text-align: right; font-variant-numeric: tabular-nums; width: 18%; }
.results-table th:nth-child(4), .results-table td:nth-child(4) { text-align: right; font-variant-numeric: tabular-nums; width: 16%; }
.results-table th:nth-child(5), .results-table td:nth-child(5) { text-align: center; width: 18%; }

/* Odznaki i statusy */
.wire-badge {
    background: #f1f5f9;
    color: #1e293b;
    padding: 4px 8px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.8rem;
    margin: 2px;
    display: inline-block;
    border: 1px solid #cbd5e1;
}
.badge-exact, .badge-ok {
    padding: 5px 12px;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 700;
    display: inline-block;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    white-space: nowrap;
}
.badge-exact { background: #dcfce7; color: #166534; }
.badge-ok { background: #fef9c3; color: #854d0e; }

.diff-zero { color: #166534; font-weight: 600; }
.diff-pos { color: #991b1b; font-weight: 600; }
.diff-neg { color: #1e40af; font-weight: 600; }

/* ==========================================================================
   CHIRURGICZNA RESPONSYWNOŚĆ MOBILNA (ZERO NAKŁADANIA SIĘ)
   ========================================================================== */
@media (max-width: 600px) {
    .container { 
        padding: 8px !important; 
    }
    
    /* 1. Wyłączamy sztywny podział - pozwalamy przeglądarce samej dbać o szerokość */
    .results-table {
        table-layout: auto !important;
        width: 100% !important;
    }

    /* 2. Resetujemy wszystkie narzucone z góry szerokości procentowe */
    .results-table th:nth-child(1), .results-table td:nth-child(1),
    .results-table th:nth-child(2), .results-table td:nth-child(2),
    .results-table th:nth-child(3), .results-table td:nth-child(3),
    .results-table th:nth-child(4), .results-table td:nth-child(4),
    .results-table th:nth-child(5), .results-table td:nth-child(5) { 
        width: auto !important; 
    }

    /* 3. Agresywne mikro-paddingi i optymalizacja fontu chroniąca przed ściskiem */
    .results-table th, .results-table td {
        padding: 10px 4px !important; 
        font-size: 0.72rem !important;
        line-height: 1.2 !important;
    }

    /* 4. Środkujemy problematyczne kolumny, tworząc dla nich bezpieczny bufor */
    .results-table th:nth-child(3), .results-table td:nth-child(3),
    .results-table th:nth-child(4), .results-table td:nth-child(4) { 
        text-align: center !important; 
    }

    /* 5. Miniaturyzacja elementów wewnątrz komórek, aby idealnie pasowały do wiersza */
    .wire-badge {
        padding: 2px 4px !important;
        font-size: 0.7rem !important;
        margin: 1px !important;
    }
    
    .badge-exact, .badge-ok {
        padding: 3px 6px !important;
        font-size: 0.65rem !important;
    }
}

/* Formatowanie wydruku PDF */
@media print {
    body { background: white; padding: 0; }
    .container { box-shadow: none; border: none; max-width: 100%; padding: 0; }
    .action-buttons, .lang-switcher { display: none !important; }
    .results-table { box-shadow: none; page-break-inside: auto; }
    tr { page-break-inside: avoid; page-break-after: auto; }
}