/* ─── RZ MEDFORM — style formularza publicznego ─── */
/* ─── Własność autorska: Radosław Żebrowski ─── */
/* ─── Mobile-first: 90%+ traffic = telefon ─── */

/* ── Reset & base ─────────────────────────────────── */
.rz-medform { max-width: 720px; margin: 0 auto; padding: 0 12px; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%; }
.rz-medform *, .rz-medform *::before, .rz-medform *::after { box-sizing: border-box; }

/* ── Sections ─────────────────────────────────────── */
.rzmf-form fieldset { border: 1px solid #e2e2e2; border-radius: 12px; padding: 16px; margin: 0 0 16px; background: #fafafa; }
.rzmf-form legend { font-size: 1.05em; font-weight: 700; padding: 0 8px; color: #222; }

/* ── Form fields ──────────────────────────────────── */
.rzmf-row { display: flex; gap: 12px; flex-wrap: wrap; }
.rzmf-row .rzmf-field { flex: 1; min-width: 0; } /* min-width:0 prevents overflow on mobile */
.rzmf-field, .rzmf-full { margin-bottom: 12px; }
.rzmf-field label { display: block; margin-bottom: 4px; font-weight: 600; font-size: 14px; color: #333; }

/* CRITICAL: font-size 16px prevents iOS auto-zoom on focus */
.rzmf-field input,
.rzmf-field textarea,
.rzmf-field select {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid #ccc;
    border-radius: 8px;
    font-size: 16px;
    line-height: 1.4;
    background: #fff;
    transition: border-color .2s, box-shadow .2s;
    -webkit-appearance: none;
    appearance: none;
}
.rzmf-field input:focus,
.rzmf-field textarea:focus {
    border-color: #0073aa;
    outline: none;
    box-shadow: 0 0 0 3px rgba(0,115,170,.15);
}

/* Error display */
.rzmf-error {
    color: #c00;
    font-size: 13px;
    font-weight: 500;
    display: block;
    min-height: 0;
    margin-top: 4px;
}
.rzmf-error:empty { display: none; }

/* Hint texts */
.rzmf-hint {
    display: block;
    font-size: 12px;
    color: #777;
    margin-top: 4px;
    line-height: 1.4;
}

/* Pre-submit info */
.rzmf-pre-submit-info {
    font-size: 13px;
    color: #555;
    line-height: 1.6;
    text-align: center;
    margin: 0 0 14px;
    padding: 12px;
    background: #f5f9fc;
    border-radius: 8px;
    border: 1px solid #d6e6f0;
}

/* Global error banner */
.rzmf-global-error {
    text-align: center;
    padding: 14px 16px;
    background: #fff0f0;
    border: 1.5px solid #e53935;
    border-radius: 10px;
    margin: 0 0 16px;
    font-weight: 600;
    font-size: 15px;
    color: #c62828;
}

/* ── Instructions ─────────────────────────────────── */
.rzmf-instructions-text { font-size: 14px; line-height: 1.7; color: #444; }
.rzmf-instructions-text ul { padding-left: 20px; margin: 8px 0; }
.rzmf-instructions-text li { margin-bottom: 4px; }

.rzmf-sample-images { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.rzmf-sample-images img { height: 72px; width: auto; border-radius: 6px; border: 1px solid #ddd; }

.rzmf-heic-notice {
    background: #fff8e1;
    border-left: 4px solid #f9a825;
    padding: 10px 14px;
    border-radius: 0 8px 8px 0;
    margin-top: 12px;
    font-size: 14px;
    line-height: 1.5;
}
.rzmf-heic-notice.rzmf-heic-info {
    background: #e3f2fd;
    border-left-color: #1976d2;
}

/* HEIC converting animation */
.rzmf-photo-field.rzmf-converting {
    border-color: #f9a825;
    background: #fffde7;
}
.rzmf-photo-field.rzmf-converting .rzmf-file-name {
    color: #e65100;
    font-weight: 600;
}

/* ── Photo fields ─────────────────────────────────── */
.rzmf-photos-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }

.rzmf-photo-field {
    border: 1.5px solid #e0e0e0;
    border-radius: 10px;
    padding: 12px;
    background: #fff;
    transition: border-color .2s;
}
.rzmf-photo-field.rzmf-has-file {
    border-color: #4caf50;
    background: #f8fdf8;
}
.rzmf-photo-field label {
    font-weight: 700;
    font-size: 14px;
    margin-bottom: 8px;
    display: block;
    color: #333;
}

/* Camera/Gallery buttons — BIG touch targets */
.rzmf-photo-actions { display: flex; gap: 8px; margin-bottom: 8px; }

.rzmf-btn-camera,
.rzmf-btn-gallery {
    flex: 1;
    /* Min 48px height for touch — Google recommends 48px */
    min-height: 52px;
    padding: 12px 8px;
    font-size: 15px;
    font-weight: 600;
    border: 2px dashed #bbb;
    border-radius: 10px;
    background: #f5f5f5;
    color: #333;
    cursor: pointer;
    text-align: center;
    transition: all .15s;
    /* Prevent text selection on double-tap */
    -webkit-user-select: none;
    user-select: none;
    /* Prevent ghost click delay on mobile */
    touch-action: manipulation;
}
.rzmf-btn-camera:hover, .rzmf-btn-gallery:hover { border-color: #0073aa; background: #eef6fc; }
.rzmf-btn-camera:active, .rzmf-btn-gallery:active { background: #d8edf8; transform: scale(0.97); }

/* Preview */
.rzmf-photo-preview { position: relative; text-align: center; margin-top: 8px; }
.rzmf-photo-preview img { max-width: 100%; max-height: 180px; border-radius: 8px; object-fit: contain; border: 1px solid #ddd; }

.rzmf-photo-preview .rzmf-btn-remove {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: rgba(0,0,0,.65);
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    line-height: 32px;
    padding: 0;
    touch-action: manipulation;
}

/* HEIC placeholder */
.rzmf-photo-preview.rzmf-heic-placeholder img { display: none; }
.rzmf-photo-preview.rzmf-heic-placeholder::before {
    content: '📄 HEIC';
    display: block;
    padding: 24px;
    color: #888;
    font-size: 16px;
    background: #f5f5f5;
    border-radius: 8px;
    border: 1px dashed #ccc;
}

/* File name display */
.rzmf-file-name {
    display: block;
    font-size: 12px;
    color: #666;
    margin-top: 6px;
    word-break: break-all;
    line-height: 1.4;
}

/* ── PDF fields ───────────────────────────────────── */
.rzmf-pdf-field {
    margin-bottom: 12px;
    padding: 10px 12px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: #fff;
}
.rzmf-pdf-field label { font-weight: 600; display: block; margin-bottom: 6px; font-size: 14px; }
.rzmf-pdf-field input[type="file"] { font-size: 15px; width: 100%; }
.rzmf-pdf-info { margin-top: 6px; font-size: 13px; color: #555; display: flex; align-items: center; gap: 8px; }
.rzmf-pdf-info .rzmf-btn-remove {
    background: none; border: 1px solid #ccc; border-radius: 4px;
    padding: 2px 8px; font-size: 13px; cursor: pointer; color: #c00;
    touch-action: manipulation;
}

/* ── Legal ────────────────────────────────────────── */
.rzmf-legal-block {
    margin-bottom: 10px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    box-sizing: border-box;
    width: 100%;
}
.rzmf-legal-block summary {
    padding: 12px 14px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    background: #f5f5f5;
    list-style: none;
    /* Touch target */
    min-height: 48px;
    display: flex;
    align-items: center;
    touch-action: manipulation;
    box-sizing: border-box;
    width: 100%;
}
.rzmf-legal-block summary::before { content: '▸ '; margin-right: 6px; transition: transform .2s; }
.rzmf-legal-block[open] summary::before { content: '▾ '; }
.rzmf-legal-block summary::-webkit-details-marker { display: none; }

.rzmf-legal-content {
    padding: 14px;
    font-size: 13px;
    line-height: 1.7;
    max-height: 250px;
    overflow-y: auto;
    overflow-x: hidden;
    color: #444;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
    width: 100%;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
}
.rzmf-legal-content * {
    max-width: 100%;
    box-sizing: border-box;
}

.rzmf-consent {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-top: 14px;
    font-size: 14px;
    line-height: 1.5;
    cursor: pointer;
    /* Larger tap target */
    padding: 8px 0;
}
.rzmf-consent input[type="checkbox"] {
    margin-top: 2px;
    min-width: 22px;
    min-height: 22px;
    accent-color: #0073aa;
}

/* ── Submit ───────────────────────────────────────── */
.rzmf-submit-area { text-align: center; margin-top: 20px; padding: 0 0 12px; }

.rzmf-submit {
    display: block;
    width: 100%;
    background: #0073aa;
    color: #fff;
    border: none;
    padding: 16px 24px;
    font-size: 18px;
    font-weight: 700;
    border-radius: 12px;
    cursor: pointer;
    transition: background .2s, transform .1s;
    touch-action: manipulation;
    -webkit-appearance: none;
}
.rzmf-submit:hover { background: #005a87; }
.rzmf-submit:active { transform: scale(0.98); }
.rzmf-submit:disabled, .rzmf-submit-loading {
    background: #94c7de;
    cursor: not-allowed;
    position: relative;
}

/* ── Progress ─────────────────────────────────────── */
.rzmf-progress { margin-top: 16px; text-align: center; padding: 0 4px; }
.rzmf-progress-track { height: 10px; background: #e0e0e0; border-radius: 5px; overflow: hidden; }
.rzmf-progress-bar { height: 100%; width: 0; background: linear-gradient(90deg, #0073aa, #00a0d2); border-radius: 5px; transition: width .3s; }
.rzmf-progress-text { font-size: 15px; font-weight: 600; margin-top: 8px; display: inline-block; color: #333; }

/* ── Success ──────────────────────────────────────── */
.rzmf-success {
    text-align: center;
    padding: 32px 20px;
    background: #e8f5e9;
    border: 1.5px solid #66bb6a;
    border-radius: 12px;
    margin-top: 16px;
}
.rzmf-success h3 { color: #2e7d32; margin: 0 0 8px; font-size: 20px; }
.rzmf-success p { color: #444; font-size: 16px; margin: 0; }
.rzmf-success strong { color: #1b5e20; }

.rzmf-error-msg { color: #c00; padding: 20px; text-align: center; font-size: 16px; }

/* ── Tablet+ (2 columns for photos) ───────────────── */
@media (min-width: 540px) {
    .rzmf-photos-grid { grid-template-columns: 1fr 1fr; }
    .rzmf-row .rzmf-field { min-width: 200px; }
    .rzmf-submit { width: auto; min-width: 280px; display: inline-block; }
}

@media (min-width: 768px) {
    .rz-medform { padding: 0; }
    .rzmf-form fieldset { padding: 20px; }
}

/* ── Accessibility: focus visible ─────────────────── */
.rzmf-btn-camera:focus-visible,
.rzmf-btn-gallery:focus-visible,
.rzmf-submit:focus-visible,
.rzmf-consent input:focus-visible {
    outline: 3px solid #0073aa;
    outline-offset: 2px;
}

/* Zakaz dystrybucji i modyfikacji bez zgody autora. */
