/* Reset i baza */
* { box-sizing: border-box; } /* Ważne: padding nie powiększa elementu */
body { 
    font-family: 'Segoe UI', sans-serif; 
    margin: 0; 
    padding: 0; 
    background-color: #f4f6f8; 
    color: #333;
    display: flex;
    justify-content: center;
}

/* Główny kontener - na telefonie zajmie całą szerokość, na PC max 450px */
.app-container {
    width: 100%;
    max-width: 480px; /* Limit szerokości na PC */
    background: white;
    min-height: 100vh;
    padding: 20px;
    box-shadow: 0 0 15px rgba(0,0,0,0.05);
}

h3 { margin-top: 0; color: #2c3e50; text-align: center; }

/* Formularz - przyjazny dla palców */
.form-group { margin-bottom: 15px; }

label { 
    display: block; 
    margin-bottom: 5px; 
    font-weight: 600; 
    font-size: 1rem;
    color: #555;
    text-align: center;
}

input, select { 
    width: 100%; 
    padding: 12px; /* Większy padding dla dotyku */
    border: 1px solid #ddd; 
    border-radius: 8px; 
    font-size: 16px; /* Zapobiega zoomowaniu na iPhone przy kliknięciu */
    background-color: #fff;
}

input:focus, select:focus {
    border-color: #3498db;
    outline: none;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}
.input-error {
    border: 2px solid #e74c3c !important; /* Czerwony */
    background-color: #fceae9;
}
/* Klasa pomocnicza do ukrywania */
.hidden {
    display: none !important;
}
.unhidden {
    display: block !important;
}

/* Opcjonalnie: Animacja pojawiania się pól */
#conditionalFields {
    display: block;
    transition: opacity 0.3s ease;
}

/* Przycisk - duży i wyraźny */
button { 
    width: 100%; 
    padding: 15px; 
    background-color: #2980b9; 
    color: white; 
    border: none; 
    border-radius: 8px; 
    font-size: 1.3rem; 
    font-weight: bold; 
    cursor: pointer; 
    margin-top: 10px;
    transition: background 0.2s;
    /* Cień dla efektu "przycisku" */
    box-shadow: 0 4px 6px rgba(41, 128, 185, 0.2);
}

button:active { transform: translateY(2px); box-shadow: none; }
.btn-gen { background-color: #2980b9; }
.btn-gen:active { background-color: #2471a3; transform: scale(0.98); }

/* Przycisk zapisu (zielony) */
.btn-save { 
    background-color: #27ae60; 
    margin-top: 15px; 
    display: none; /* Ukryty domyślnie */
}
.btn-save:active { background-color: #219150; transform: scale(0.98); }
/* Sekcja z wynikiem */
#result-area {
    margin-top: 30px;
    text-align: center;
    padding-top: 20px;
    border-top: 2px dashed #eee;
    display: none; /* Ukryte na start */
    animation: fadeIn 0.5s ease;
}
#result-msg{
    font-size: 1.2em; 
    text-align: center;
    margin-bottom: 10px; 
    color: #34495e; 
    font-weight: bold;
}

.status-msg { font-size: 0.9em; color: #27ae60; font-weight: bold; }

#qrcode {
    width: 50%;
    margin: 15px auto; padding: 10px; 
    background: white; border: 1px solid #eee; border-radius: 8px; 
    display: inline-block;
    cursor: zoom-in; /* Kursor lupy */
    transition: transform 0.2s;
    max-width: 100%;
    box-sizing: border-box; /* Żeby padding nie powiększał szerokości */
}
#qrcode:active { transform: scale(0.95); }

#qrcode img,
#qrcode canvas {
    display: block;

    /* To jest kluczowe naprawienie błędu: */
    max-width: 100% !important; /* Nigdy nie szerszy niż rodzic */
    height: auto !important;    /* Wysokość dostosuj proporcjonalnie */

    /* Opcjonalnie: możemy ograniczyć go do np. 250px na ekranie,
       mimo że oryginał ma 400px */
    width: 250px;
    margin: 0 auto; /* Centrowanie */
}

/* --- MODAL (OKNO PEŁNOEKRANOWE) --- */
.modal-overlay {
    display: none; /* Domyślnie ukryty */
    position: fixed; 
    top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0,0,0,0.85); /* Ciemne tło */
    z-index: 999;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background: white;
    padding: 20px;
    border-radius: 10px;
    max-width: 90%;
    text-align: center;
    position: relative;
}

.modal-content img,
.modal-content canvas {
    max-width: 100%;
    height: auto;
    display: block;
}

.close-hint {
    color: white; margin-top: 20px; font-size: 0.9em; opacity: 0.8;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
