/* Базові стилі калькулятора */
.barcode-calculator {
    max-width: 500px;
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    font-weight: inherit;
    font-size: 14px;
}

.barcode-calculator h2 {
    font-size: 20px;
    margin-bottom: 15px;
}

/* Групи форми */
.form-group {
    margin-bottom: 15px;
    display: flex;
    align-items: flex-start;
}

.form-group > label {
    min-width: 200px;
    padding-right: 15px;
    margin-top: 2px;
    font-weight: 600;
}

/* Радіо групи */
.radio-group {
    flex: 1;
}

.radio-group.vertical {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.radio-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 24px;
}

.radio-group label span {
    line-height: 1.2;
}

/* Стилі для радіо кнопок */
.barcode-calculator input[type="radio"] {
    appearance: none;
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    min-width: 16px;
    border-radius: 50%;
    border: 2px solid #ccc;
    outline: none;
    margin: 0;
    flex-shrink: 0;
    position: relative;
}

.barcode-calculator input[type="radio"]:checked {
    border-color: #00594d;
}

.barcode-calculator input[type="radio"]:checked::before {
    content: "";
    display: block;
    width: 8px;
    height: 8px;
    background-color: #00594d;
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    margin: 0;
}

/* Контроль кількості */
.quantity-control {
    display: flex;
    align-items: center;
    gap: 5px;
}

.quantity-control button {
    width: 30px;
    height: auto; /* Remove fixed height */
    line-height: 30px; /* Set the line height */
    padding: 0 10px; /* Add horizontal padding for better visual balance */
    background-color: #00594D;
    color: white;
    border: none;
    border-radius: 0;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
}

.quantity-control button:hover {
    background-color: #004a40;
}

.quantity-control input {
    width: 40px;
    height: 30px;
    text-align: center;
    border: 1px solid #ccc;
    border-radius: 0;
    padding: 0;
}


.quantity-control input[type="number"] {
    width: 60px;
    height: 30px;
    text-align: center;
    border: 1px solid #ccc;
    border-radius: 0;
    padding: 0 5px;
    -moz-appearance: textfield; /* Прибираємо стрілки в Firefox */
}

/* Прибираємо стрілки в Chrome, Safari, Edge, Opera */
.quantity-control input[type="number"]::-webkit-outer-spin-button,
.quantity-control input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Секція результатів */
.result {
    margin-top: 15px;
    padding: 15px;
    background-color: #f8f8f8;
    border: 1px solid #eee;
}

.result h3 {
    font-size: 16px;
    margin-bottom: 12px;
}

.result-group {
    margin-bottom: 10px;
    display: flex;
    align-items: flex-start;
}

.result-group > label {
    min-width: 200px;
    padding-right: 15px;
    margin-top: 5px;
}

.result-group input,
.result-group textarea {
    flex: 1;
    padding: 5px 8px;
    border: 1px solid #ccc;
    border-radius: 0;
    background-color: #fff;
}

.result-group textarea {
    height: 65px;
    resize: none;
}

/* Кнопка друку */
.print-button {
    width: 100%;
    max-width: 250px;
    padding: 10px;
    margin-top: 15px;
    background-color: #00594D;
    color: white;
    border: none;
    border-radius: 0;
    cursor: pointer;
    text-transform: uppercase;
    font-size: 14px;
    transition: background-color 0.2s ease;
}

.print-button:hover {
    background-color: #004a40;
}

/* Розділювач між параметрами та результатами */
.calculator-params {
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
}

/* Обов'язкові поля */
.calculator-params label[for]:after,
.calculator-params .required:after {
    content: "*";
    color: red;
    margin-left: 4px;
}

/* Фокус елементів */
.barcode-calculator input:focus,
.barcode-calculator button:focus {
    outline: none;
    border-color: #00594d;
    box-shadow: 0 0 0 1px #00594d;
}

/* Стилі для друку */
@media print {
    @page {
        margin: 2cm;
        size: A4;
    }

    /* Приховуємо все зайве */
    body > *:not(.print-content) {
        display: none !important;
    }

    .print-content {
        font-family: Arial, sans-serif;
        font-size: 12pt;
        line-height: 1.4;
        color: #000;
        margin: 0;
        max-width: none;
    }

    /* Шапка документу */
    .print-header {
        display: grid;
        grid-template-columns: 200px 1fr 120px;
        gap: 20px;
        align-items: start;
        margin-bottom: 20px;
        padding-bottom: 15px;
        border-bottom: 1px solid #000;
        page-break-after: avoid;
    }

    /* Логотип і назва компанії */
    .company-info {
        text-align: left;
    }

    .print-logo {
        width: 100px;
        height: auto;
        margin-bottom: 5px;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .company-details h3 {
        font-size: 16pt;
        margin: 0;
    }

    /* Заголовок документа */
    .document-title {
        text-align: center;
    }

    .document-title h1 {
        font-size: 16pt;
        margin: 0 0 5px 0;
    }

    .print-date {
        font-size: 10pt;
        color: #666;
        margin: 0;
    }

    /* QR код */
    .qr-code {
        text-align: right;
    }

    .qr-code img {
        width: 120px;
        height: 120px;
    }

    .qr-code p {
        font-size: 10pt;
        color: #666;
        margin: 5px 0 0 0;
    }

    /* Основний контент */
    .print-body {
        margin: 20px 0;
    }

    .print-row {
        margin-bottom: 10px;
        display: grid;
        grid-template-columns: 250px 1fr;
        gap: 20px;
    }

    /* Підсумок */
    .print-summary {
        margin-top: 20px;
        padding-top: 15px;
        border-top: 1px solid #000;
        page-break-inside: avoid;
    }

    .print-summary h2 {
        font-size: 14pt;
        margin-bottom: 20px;
    }

    /* Контактна інформація */
    .print-footer {
        margin-top: 30px;
        padding-top: 15px;
        border-top: 1px solid #000;
    }

    .manager-info {
        font-size: 14pt;
    }

    .manager-info p {
        margin: 10px 0;
        line-height: 1.4;
    }

    .manager-info strong {
        font-size: 16pt;
    }

    /* Додаємо правило для запобігання розривів */
    .print-content {
        page-break-inside: avoid;
    }
}

/* Адаптивність */
@media screen and (max-width: 480px) {
    /* Базові стилі для мобільних */
    .barcode-calculator {
        max-width: 100%;
        padding: 0 15px;
        font-size: 16px; /* Збільшуємо розмір шрифту для кращої читабельності */
    }

    /* Заголовок */
    .barcode-calculator h2 {
        font-size: 18px;
        margin-bottom: 20px;
        text-align: center;
    }

    /* Групи форми */
    .form-group,
    .result-group {
        flex-direction: column;
        margin-bottom: 20px;
    }

    .form-group > label,
    .result-group > label {
        min-width: 100%;
        margin-bottom: 10px;
        padding-right: 0;
    }

    /* Радіо групи */
    .radio-group {
        width: 100%;
    }

    .radio-group label {
        padding: 8px 0;
    }

    .radio-group.vertical {
        gap: 12px;
    }

    /* Контроль кількості */
    .quantity-control {
        width: 100%;
        justify-content: center;
        gap: 10px;
    }

    .quantity-control button {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }

    .quantity-control input {
        width: 60px;
        height: 40px;
        font-size: 16px;
    }

    /* Результати */
    .result {
        margin-top: 25px;
        padding: 15px 12px;
    }

    .result h3 {
        text-align: center;
    }

    .result-group input,
    .result-group textarea {
        height: 100px;
        width: 100%;
        padding: 10px;
        font-size: 16px;
        line-height: 1.4;
    }

    .result-group textarea {
        height: 80px;
    }

    /* Кнопка друку */
    .print-button {
        max-width: 100%;
        height: 48px; /* Збільшуємо висоту для зручності натискання */
        margin: 20px auto;
        font-size: 16px;
    }

    /* Покращення для touch-пристроїв */
    .radio-group label,
    .quantity-control button,
    .print-button {
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    /* Збільшуємо відступи між радіо-кнопками для кращого таргетингу */
    .radio-group input[type="radio"] {
        width: 20px;
        height: 20px;
        min-width: 20px;
    }

    .radio-group input[type="radio"]:checked::before {
        width: 10px;
        height: 10px;
        margin: 3px;
    }
}

/* Додаткові медіа-запити для уже малих екранів */
@media screen and (max-width: 360px) {
    .barcode-calculator {
        font-size: 14px;
    }

    .form-group > label,
    .result-group > label {
        font-size: 15px;
    }

    .radio-group label {
        padding: 6px 0;
    }

    .result-group textarea {
        height: 110px; 
    }
}

/* Покращення для ландшафтної орієнтації */
@media screen and (max-width: 480px) and (orientation: landscape) {
    .barcode-calculator {
        max-width: 480px;
        margin: 0 auto;
    }

    .radio-group.vertical {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
}

/* 2. Покращити доступність фокусу */
.barcode-calculator input:focus-visible,
.barcode-calculator button:focus-visible {
    outline: 2px solid #00594d;
    outline-offset: 2px;
}

/* 3. Додати стилі для disabled стану */
.quantity-control button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

/* Більш специфічний селектор */
body section:has(.barcode-calculator) {
    padding-top: 0 !important;
}


