/* ============================================================
   PANELDOM Formularz Pomiarowy — Front-end Styles v2.0
   ============================================================ */

:root {
    --pdm-font:          "Inter", "Segoe UI", -apple-system, sans-serif;
    --pdm-primary:       #1d4ed8;   /* Royal blue — PANELDOM brand */
    --pdm-primary-dark:  #1e3a8a;
    --pdm-primary-light: rgba(29, 78, 216, 0.08);
    --pdm-primary-ring:  rgba(29, 78, 216, 0.2);
    --pdm-success:       #16a34a;
    --pdm-success-bg:    #f0fdf4;
    --pdm-success-border:#86efac;
    --pdm-error:         #dc2626;
    --pdm-error-bg:      #fef2f2;
    --pdm-error-border:  #fca5a5;
    --pdm-text:          #0f172a;
    --pdm-text-muted:    #64748b;
    --pdm-text-light:    #94a3b8;
    --pdm-border:        #e2e8f0;
    --pdm-border-focus:  #1d4ed8;
    --pdm-bg:            #ffffff;
    --pdm-bg-field:      #f8fafc;
    --pdm-bg-section:    #f1f5f9;
    --pdm-radius:        12px;
    --pdm-radius-sm:     8px;
    --pdm-radius-xs:     5px;
    --pdm-shadow:        0 1px 3px rgba(0,0,0,.06), 0 4px 20px rgba(0,0,0,.05);
    --pdm-shadow-focus:  0 0 0 3px var(--pdm-primary-ring);
    --pdm-transition:    .18s cubic-bezier(.4,0,.2,1);
}

/* ── Wrapper ─────────────────────────────────────────────────── */
.pdm-wrap {
    font-family: var(--pdm-font);
    -webkit-font-smoothing: antialiased;
}

/* ── Form shell ──────────────────────────────────────────────── */
.pdm-form {
    background: var(--pdm-bg);
}

/* ── Sections ────────────────────────────────────────────────── */
.pdm-section {
    margin-bottom: 36px;
}
.pdm-section:last-of-type {
    margin-bottom: 0;
}

.pdm-section__title {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--pdm-primary);
    margin: 0 0 16px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--pdm-primary-light);
    display: flex;
    align-items: center;
    gap: 8px;
}
.pdm-section__title::before {
    content: '';
    display: inline-block;
    width: 4px;
    height: 16px;
    background: var(--pdm-primary);
    border-radius: 2px;
    flex-shrink: 0;
}

/* ── Grid layout ─────────────────────────────────────────────── */
.pdm-section__grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 18px;
}

.pdm-field-wrap--w-full    { grid-column: 1 / -1; }
.pdm-field-wrap--w-half    { grid-column: span 2; }
.pdm-field-wrap--w-quarter { grid-column: span 1; }

@media (max-width: 640px) {
    .pdm-section__grid {
        grid-template-columns: 1fr 1fr;
        gap: 14px;
    }
    .pdm-field-wrap--w-half    { grid-column: 1 / -1; }
    .pdm-field-wrap--w-quarter { grid-column: span 1; }
}

@media (max-width: 400px) {
    .pdm-section__grid { grid-template-columns: 1fr; }
    .pdm-field-wrap--w-quarter { grid-column: 1 / -1; }
}

/* ── Field wrap ──────────────────────────────────────────────── */
.pdm-field-wrap {
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: relative;
}

/* ── Label ───────────────────────────────────────────────────── */
.pdm-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--pdm-text);
    letter-spacing: .01em;
    display: flex;
    align-items: center;
    gap: 3px;
    user-select: none;
}

.pdm-req {
    color: var(--pdm-error);
    font-size: 13px;
    line-height: 1;
}

/* ── Base field ──────────────────────────────────────────────── */
.pdm-field {
    width: 100%;
    padding: 10px 13px;
    font-size: 14px;
    font-family: var(--pdm-font);
    color: var(--pdm-text);
    background: var(--pdm-bg-field);
    border: 1.5px solid var(--pdm-border);
    border-radius: var(--pdm-radius-sm);
    outline: none;
    transition: border-color var(--pdm-transition), box-shadow var(--pdm-transition), background var(--pdm-transition);
    box-sizing: border-box;
    -webkit-appearance: none;
    appearance: none;
}

.pdm-field::placeholder { color: var(--pdm-text-light); }
.pdm-field:hover         { border-color: #93c5fd; background: #fff; }
.pdm-field:focus         { border-color: var(--pdm-border-focus); background: #fff; box-shadow: var(--pdm-shadow-focus); }

/* State: valid */
.pdm-field-wrap--valid .pdm-field,
.pdm-field-wrap--valid .pdm-phone-prefix,
.pdm-field-wrap--valid .pdm-phone-number {
    border-color: var(--pdm-success);
    background: var(--pdm-success-bg);
}

/* State: error */
.pdm-field-wrap--error .pdm-field,
.pdm-field-wrap--error .pdm-phone-prefix,
.pdm-field-wrap--error .pdm-phone-number {
    border-color: var(--pdm-error);
    background: var(--pdm-error-bg);
    box-shadow: 0 0 0 3px rgba(220,38,38,.1);
}

/* Error message */
.pdm-field-error {
    font-size: 12px;
    color: var(--pdm-error);
    min-height: 0;
    display: none;
    line-height: 1.4;
}
.pdm-field-wrap--error .pdm-field-error { display: block; }

/* ── Textarea ────────────────────────────────────────────────── */
.pdm-field--textarea {
    resize: vertical;
    min-height: 120px;
    line-height: 1.6;
}

.pdm-textarea-wrap {
    position: relative;
}

.pdm-char-count {
    position: absolute;
    bottom: 8px;
    right: 10px;
    font-size: 11px;
    color: var(--pdm-text-muted);
    pointer-events: none;
    background: var(--pdm-bg-field);
    padding: 1px 4px;
    border-radius: 3px;
}

.pdm-char-count--warn {
    color: #d97706;
    font-weight: 600;
}

/* ── Select ──────────────────────────────────────────────────── */
.pdm-select-wrap { position: relative; }

.pdm-field--select {
    padding-right: 38px;
    cursor: pointer;
}

.pdm-select-arrow {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%) rotate(0deg);
    pointer-events: none;
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid var(--pdm-text-muted);
    transition: transform var(--pdm-transition);
}

.pdm-field--select:focus + .pdm-select-arrow {
    border-top-color: var(--pdm-primary);
}

/* ── Phone ───────────────────────────────────────────────────── */
.pdm-phone-wrap {
    display: flex;
    gap: 0;
    border: 1.5px solid var(--pdm-border);
    border-radius: var(--pdm-radius-sm);
    overflow: hidden;
    background: var(--pdm-bg-field);
    transition: border-color var(--pdm-transition), box-shadow var(--pdm-transition), background var(--pdm-transition);
}

.pdm-phone-wrap:focus-within {
    border-color: var(--pdm-border-focus);
    background: #fff;
    box-shadow: var(--pdm-shadow-focus);
}

.pdm-field-wrap--valid .pdm-phone-wrap {
    border-color: var(--pdm-success);
    background: var(--pdm-success-bg);
}

.pdm-field-wrap--error .pdm-phone-wrap {
    border-color: var(--pdm-error);
    background: var(--pdm-error-bg);
    box-shadow: 0 0 0 3px rgba(220,38,38,.1);
}

.pdm-phone-prefix {
    width: 72px;
    flex-shrink: 0;
    padding: 10px 10px;
    font-size: 14px;
    font-family: var(--pdm-font);
    font-weight: 600;
    color: var(--pdm-primary);
    background: transparent;
    border: none;
    border-right: 1.5px solid var(--pdm-border);
    outline: none;
    text-align: center;
    -webkit-appearance: none;
}

.pdm-phone-number {
    flex: 1;
    padding: 10px 13px;
    font-size: 14px;
    font-family: var(--pdm-font);
    color: var(--pdm-text);
    background: transparent;
    border: none;
    outline: none;
    -webkit-appearance: none;
}
.pdm-phone-number::placeholder { color: var(--pdm-text-light); }

/* ── Multi-select checkboxes ─────────────────────────────────── */
.pdm-multicheck {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
    padding: 14px;
    background: var(--pdm-bg-section);
    border: 1.5px solid var(--pdm-border);
    border-radius: var(--pdm-radius-sm);
    transition: border-color var(--pdm-transition);
}

.pdm-field-wrap--error .pdm-multicheck {
    border-color: var(--pdm-error);
    background: var(--pdm-error-bg);
}

/* ── Checkbox + check-box (shared) ───────────────────────────── */
.pdm-check-label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    font-size: 13.5px;
    color: var(--pdm-text);
    user-select: none;
    line-height: 1.4;
}

.pdm-check-label:hover .pdm-check-box {
    border-color: var(--pdm-primary);
    background: var(--pdm-primary-light);
}

.pdm-checkbox { display: none; }

.pdm-check-box {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    margin-top: 1px;
    border: 2px solid var(--pdm-border);
    border-radius: 4px;
    background: var(--pdm-bg);
    transition: all var(--pdm-transition);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pdm-checkbox:checked + .pdm-check-box {
    border-color: var(--pdm-primary);
    background: var(--pdm-primary);
}

.pdm-checkbox:checked + .pdm-check-box::after {
    content: '';
    display: block;
    width: 4px;
    height: 8px;
    border: 2px solid #fff;
    border-top: none;
    border-left: none;
    transform: rotate(45deg) translate(0, -1px);
}

.pdm-check-text { flex: 1; }

/* Consent checkbox */
.pdm-check-label--consent {
    padding: 14px 16px;
    background: var(--pdm-bg-section);
    border: 1.5px solid var(--pdm-border);
    border-radius: var(--pdm-radius-sm);
    font-size: 13px;
    transition: border-color var(--pdm-transition);
}

.pdm-check-label--consent:hover {
    border-color: var(--pdm-primary);
}

.pdm-field-wrap--error .pdm-check-label--consent {
    border-color: var(--pdm-error);
    background: var(--pdm-error-bg);
}

.pdm-check-label--consent a {
    color: var(--pdm-primary);
    text-decoration: underline;
}

/* ── File drop zone ──────────────────────────────────────────── */
.pdm-dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 28px 20px;
    border: 2px dashed var(--pdm-border);
    border-radius: var(--pdm-radius-sm);
    background: var(--pdm-bg-section);
    cursor: pointer;
    transition: border-color var(--pdm-transition), background var(--pdm-transition);
    text-align: center;
    min-height: 110px;
}

.pdm-dropzone:hover,
.pdm-dropzone:focus-visible {
    border-color: var(--pdm-primary);
    background: var(--pdm-primary-light);
    outline: none;
}

.pdm-dropzone--over {
    border-color: var(--pdm-primary);
    background: var(--pdm-primary-light);
    box-shadow: var(--pdm-shadow-focus);
}

.pdm-field-wrap--error .pdm-dropzone {
    border-color: var(--pdm-error);
    background: var(--pdm-error-bg);
}

.pdm-dropzone__icon {
    font-size: 28px;
    line-height: 1;
    pointer-events: none;
}

.pdm-dropzone__text {
    font-size: 14px;
    color: var(--pdm-text);
    pointer-events: none;
}

.pdm-dropzone__hint {
    font-size: 12px;
    color: var(--pdm-text-muted);
    pointer-events: none;
}

/* File list */
.pdm-file-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 4px;
}

.pdm-file-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--pdm-bg-section);
    border: 1px solid var(--pdm-border);
    border-radius: var(--pdm-radius-xs);
    font-size: 13px;
}

.pdm-file-icon { font-size: 16px; flex-shrink: 0; }

.pdm-file-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--pdm-text);
}

.pdm-file-size {
    flex-shrink: 0;
    color: var(--pdm-text-muted);
    font-size: 12px;
}

.pdm-file-remove {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    border-radius: 50%;
    color: var(--pdm-text-muted);
    font-size: 16px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    transition: color var(--pdm-transition), background var(--pdm-transition);
}

.pdm-file-remove:hover {
    color: var(--pdm-error);
    background: var(--pdm-error-bg);
}

.pdm-file-counter {
    font-size: 12px;
    color: var(--pdm-text-muted);
    margin-top: 4px;
    display: block;
}

/* ── Submit button ───────────────────────────────────────────── */
.pdm-form__footer { margin-top: 32px; }

.pdm-btn-submit {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 15px 32px;
    font-size: 15.5px;
    font-weight: 700;
    font-family: var(--pdm-font);
    letter-spacing: .02em;
    color: #fff;
    background: linear-gradient(135deg, var(--pdm-primary) 0%, var(--pdm-primary-dark) 100%);
    border: none;
    border-radius: var(--pdm-radius-sm);
    cursor: pointer;
    transition: transform var(--pdm-transition), box-shadow var(--pdm-transition), opacity var(--pdm-transition);
    box-shadow: 0 4px 16px rgba(29,78,216,.35);
    overflow: hidden;
}

.pdm-btn-submit::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(255,255,255,.12) 0%, transparent 100%);
    pointer-events: none;
}

.pdm-btn-submit:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(29,78,216,.45);
}

.pdm-btn-submit:active:not(:disabled) {
    transform: translateY(0);
}

.pdm-btn-submit:disabled {
    cursor: not-allowed;
    opacity: .72;
}

.pdm-btn-submit__spinner {
    display: none;
    width: 17px;
    height: 17px;
    border: 2.5px solid rgba(255,255,255,.35);
    border-top-color: #fff;
    border-radius: 50%;
}

.pdm-btn-submit.pdm-loading .pdm-btn-submit__spinner {
    display: inline-block;
    animation: pdm-spin .65s linear infinite;
}

.pdm-btn-submit.pdm-loading .pdm-btn-submit__label {
    opacity: .75;
}

@keyframes pdm-spin {
    to { transform: rotate(360deg); }
}

/* ── Messages ────────────────────────────────────────────────── */
.pdm-message {
    display: none;
    opacity: 0;
    transform: translateY(-6px);
    transition: opacity .3s ease, transform .3s ease;
    margin-top: 18px;
    padding: 16px 20px;
    border-radius: var(--pdm-radius-sm);
    font-size: 14px;
    font-weight: 500;
    line-height: 1.5;
}

.pdm-message--success {
    background: var(--pdm-success-bg);
    border: 1px solid var(--pdm-success-border);
    color: #14532d;
}

.pdm-message--error {
    background: var(--pdm-error-bg);
    border: 1px solid var(--pdm-error-border);
    color: #7f1d1d;
}

/* ── Notice (no fields configured) ──────────────────────────── */
.pdm-notice {
    font-size: 14px;
    color: var(--pdm-text-muted);
    padding: 14px 18px;
    background: #f8fafc;
    border: 1px dashed var(--pdm-border);
    border-radius: var(--pdm-radius-sm);
}
