/**
 * Moradiq — Formulários (modal e inline)
 */

/* ── Modal maior — uso prolongado ── */
body.mq-app .mq-modal-shell {
    width: min(1180px, 97vw) !important;
    max-height: min(calc(100vh - var(--mq-dock-h) - 1.25rem), 920px) !important;
}

body.mq-app .mq-modal-body {
    font-size: .875rem;
}

/* ── Modal: grid 2 colunas ── */
body.mq-app .mq-modal-form-inner .form-section {
    padding: 1.25rem 1.5rem !important;
    background: var(--mq-surface) !important;
    border-bottom: 1px solid var(--mq-line) !important;
}

body.mq-app .mq-modal-form-inner .form-section:nth-child(even) {
    background: var(--mq-surface) !important;
}

body.mq-app .mq-modal-form-inner .form-section-title {
    font-size: .84rem !important;
    font-weight: 600 !important;
    color: var(--mq-o) !important;
    margin-bottom: 1rem !important;
    padding-bottom: .55rem !important;
    border-bottom: 1px solid var(--mq-line) !important;
}

body.mq-app .mq-modal-form-inner .form-grid {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: .85rem 1.15rem !important;
}

body.mq-app .mq-modal-form-inner .form-grid > .form-group {
    grid-column: span 1 !important;
    min-width: 0;
}

body.mq-app .mq-modal-form-inner .form-grid > .form-group[style*="span 2"],
body.mq-app .mq-modal-form-inner .form-grid > .form-group[style*="1 / -1"],
body.mq-app .mq-modal-form-inner .form-grid > .form-group[style*="span 3"],
body.mq-app .mq-modal-form-inner .form-grid > .form-group[style*="background"],
body.mq-app .mq-modal-form-inner .form-grid > .form-group[style*="border"] {
    grid-column: 1 / -1 !important;
}

body.mq-app .mq-modal-form-inner .form-group {
    gap: .4rem !important;
}

body.mq-app .mq-modal-form-inner .form-group > label:first-child:not(:has(input)) {
    font-size: .78rem !important;
    font-weight: 600 !important;
    color: var(--mq-muted) !important;
    line-height: 1.35 !important;
}

/* Text inputs only — NÃO checkbox/radio/file */
body.mq-app .mq-modal-form-inner .form-group input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
body.mq-app .mq-modal-form-inner .form-group select,
body.mq-app .mq-modal-form-inner .form-group textarea {
    min-height: 42px !important;
    padding: .6rem .8rem !important;
    font-size: .875rem !important;
    background: var(--mq-surface-2) !important;
    border: 1px solid var(--mq-line) !important;
    border-radius: 10px !important;
    width: 100% !important;
    box-sizing: border-box !important;
    box-shadow: none !important;
}

body.mq-app .mq-modal-form-inner .form-group input[type="checkbox"],
body.mq-app .mq-modal-form-inner .form-group input[type="radio"],
body.mq-app .mq-check-toggle input[type="checkbox"],
body.mq-app .form-group label input[type="checkbox"],
body.mq-app .form-group label input[type="radio"] {
    appearance: none;
    -webkit-appearance: none;
    width: 17px !important;
    height: 17px !important;
    min-height: 17px !important;
    max-width: 17px !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 1.5px solid var(--mq-line) !important;
    border-radius: 5px !important;
    background: var(--mq-surface-2) !important;
    box-shadow: none !important;
    accent-color: var(--mq-o);
    cursor: pointer;
    flex-shrink: 0;
    transition: background .15s, border-color .15s, box-shadow .15s;
}

body.mq-app .mq-modal-form-inner .form-group input[type="radio"],
body.mq-app .form-group label input[type="radio"] {
    border-radius: 50% !important;
}

body.mq-app .mq-modal-form-inner .form-group input[type="checkbox"]:checked,
body.mq-app .mq-check-toggle input[type="checkbox"]:checked,
body.mq-app .form-group label input[type="checkbox"]:checked {
    background: var(--mq-o) !important;
    border-color: var(--mq-o) !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 10'%3E%3Cpath fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' d='M1 5l3 3 7-7'/%3E%3C/svg%3E") !important;
    background-size: 11px 9px !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
}

body.mq-app .mq-modal-form-inner .form-group input[type="radio"]:checked,
body.mq-app .form-group label input[type="radio"]:checked {
    background: var(--mq-o) !important;
    border-color: var(--mq-o) !important;
    box-shadow: inset 0 0 0 3px var(--mq-surface-2) !important;
}

body.mq-app .mq-modal-form-inner .form-group input[type="checkbox"]:focus-visible,
body.mq-app .mq-check-toggle input[type="checkbox"]:focus-visible,
body.mq-app .form-group label input[type="checkbox"]:focus-visible {
    outline: none !important;
    box-shadow: 0 0 0 3px rgba(232, 93, 4, 0.18) !important;
}

body.mq-app .mq-modal-form-inner label:has(input[type="checkbox"]):not(.mq-tipo-check),
body.mq-app .mq-modal-form-inner label:has(input[type="radio"]):not(.mq-tipo-check),
body.mq-app .mq-modal-form-inner .form-group label.mq-check-inline {
    display: inline-flex !important;
    align-items: center !important;
    gap: .5rem !important;
    width: auto !important;
    max-width: 100%;
    font-size: .8125rem !important;
    font-weight: 500 !important;
    color: var(--mq-text) !important;
    cursor: pointer;
    line-height: 1.35 !important;
}

body.mq-app .mq-modal-form-inner .form-group:has(> input[type="checkbox"]:only-child),
body.mq-app .mq-modal-form-inner .form-group:has(> label input[type="checkbox"]) {
    grid-column: 1 / -1 !important;
}

body.mq-app .mq-modal-form-inner .form-group input:focus:not([type="checkbox"]):not([type="radio"]),
body.mq-app .mq-modal-form-inner .form-group select:focus,
body.mq-app .mq-modal-form-inner .form-group textarea:focus {
    background: var(--mq-surface) !important;
    border-color: var(--mq-o) !important;
    box-shadow: 0 0 0 3px rgba(232, 93, 4, 0.12) !important;
}

body.mq-app .mq-modal-form-inner .form-group textarea {
    min-height: 88px !important;
}

body.mq-app .mq-modal-form-inner .input-icon-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

body.mq-app .mq-modal-form-inner .input-icon-wrapper i,
body.mq-app .mq-modal-form-inner .input-icon-wrapper svg {
    position: absolute;
    left: .75rem;
    width: 16px !important;
    height: 16px !important;
    color: var(--mq-muted);
    pointer-events: none;
    z-index: 1;
    padding: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-sizing: border-box !important;
}

body.mq-app .mq-modal-form-inner .input-icon-wrapper input {
    padding-left: 2.35rem !important;
}

body.mq-app .mq-modal-form-inner .mq-tipo-checks {
    display: flex;
    flex-wrap: wrap;
    gap: .55rem;
    margin-top: .15rem;
}

body.mq-app .mq-modal-form-inner .mq-tipo-check {
    display: inline-flex !important;
    align-items: center !important;
    gap: .45rem !important;
    width: auto !important;
    max-width: none !important;
    padding: .5rem .9rem !important;
    border: 1.5px solid var(--mq-line) !important;
    border-radius: 999px !important;
    background: var(--mq-surface) !important;
    cursor: pointer !important;
    font-size: .8125rem !important;
    font-weight: 600 !important;
    color: var(--mq-text) !important;
    line-height: 1.2 !important;
    transition: border-color .15s ease, background .15s ease, color .15s ease, box-shadow .15s ease;
    user-select: none;
}

body.mq-app .mq-modal-form-inner .mq-tipo-check:hover {
    border-color: rgba(232, 93, 4, 0.35) !important;
    background: var(--mq-surface-2) !important;
}

body.mq-app .mq-modal-form-inner .mq-tipo-check:has(input:checked) {
    border-color: var(--mq-o) !important;
    background: linear-gradient(135deg, #fff7ed 0%, #ffedd5 100%) !important;
    color: var(--mq-o) !important;
    box-shadow: 0 0 0 3px rgba(232, 93, 4, 0.1) !important;
}

[data-theme="dark"] body.mq-app .mq-modal-form-inner .mq-tipo-check:has(input:checked) {
    background: rgba(232, 93, 4, 0.12) !important;
    box-shadow: 0 0 0 1px rgba(232, 93, 4, 0.25) !important;
}

body.mq-app .mq-modal-form-inner .mq-tipo-check input[type="checkbox"] {
    position: absolute !important;
    opacity: 0 !important;
    width: 1px !important;
    height: 1px !important;
    min-height: 0 !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    pointer-events: none !important;
}

body.mq-app .mq-modal-form-inner .mq-tipo-check-mark {
    width: 16px;
    height: 16px;
    border-radius: 5px;
    border: 1.5px solid var(--mq-line);
    background: var(--mq-surface);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all .15s ease;
}

body.mq-app .mq-modal-form-inner .mq-tipo-check-mark::after {
    content: '';
    width: 4px;
    height: 7px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg) scale(0);
    margin-top: -2px;
    transition: transform .12s ease;
}

body.mq-app .mq-modal-form-inner .mq-tipo-check:has(input:checked) .mq-tipo-check-mark {
    background: var(--mq-o);
    border-color: var(--mq-o);
}

body.mq-app .mq-modal-form-inner .mq-tipo-check:has(input:checked) .mq-tipo-check-mark::after {
    transform: rotate(45deg) scale(1);
}

body.mq-app .mq-modal-form-inner .mq-tipo-check-icon {
    width: 15px !important;
    height: 15px !important;
    flex-shrink: 0;
    opacity: .75;
}

body.mq-app .mq-modal-form-inner .mq-tipo-check:has(input:checked) .mq-tipo-check-icon {
    opacity: 1;
    color: var(--mq-o);
}

body.mq-app .mq-modal-form-inner .form-actions {
    padding: 1rem 1.5rem !important;
    gap: .65rem !important;
    background: var(--mq-surface-2) !important;
    border-top: 1px solid var(--mq-line) !important;
}

body.mq-app .mq-modal-form-inner .form-section .form-group[style*="background"],
body.mq-app .mq-modal-form-inner .form-section .form-group[style*="border"] {
    padding: 1rem 1.1rem !important;
    border-radius: 12px !important;
    border: 1px solid var(--mq-line) !important;
    background: var(--mq-surface-2) !important;
}

/* ── File upload ── */
body.mq-app .mq-file-wrap {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: .45rem;
    padding: .85rem 1rem;
    border: 1.5px dashed rgba(232, 93, 4, 0.25);
    border-radius: 12px;
    background: var(--primary-lighter);
    transition: border-color .2s, background .2s;
    width: 100%;
    box-sizing: border-box;
    min-height: 72px;
}

body.mq-app .mq-file-wrap:hover {
    border-color: rgba(232, 93, 4, 0.5);
    background: rgba(232, 93, 4, 0.06);
}

[data-theme="dark"] body.mq-app .mq-file-wrap {
    background: rgba(232, 93, 4, 0.05);
}

[data-theme="dark"] body.mq-app .mq-file-wrap:hover {
    background: rgba(232, 93, 4, 0.1);
}

body.mq-app .mq-file-pick {
    position: relative;
    display: inline-flex;
    align-items: center;
    z-index: 1;
}

body.mq-app .mq-file-list {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    width: 100%;
    position: relative;
    z-index: 3;
}

body.mq-app .mq-file-chip {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    max-width: 100%;
    padding: 0.25rem 0.35rem 0.25rem 0.55rem;
    border-radius: 6px;
    background: var(--mq-surface, #fff);
    border: 1px solid var(--mq-line, #e2e8f0);
}

body.mq-app .mq-file-chip-name {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--mq-o, #e85d04);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

body.mq-app .mq-file-chip-remove {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    padding: 0;
    border: none;
    border-radius: 5px;
    background: transparent;
    color: var(--mq-muted, #64748b);
    cursor: pointer;
}

body.mq-app .mq-file-chip-remove:hover {
    background: rgba(220, 38, 38, 0.1);
    color: #dc2626;
}

body.mq-app .mq-file-chip-remove i,
body.mq-app .mq-file-chip-remove svg {
    width: 13px;
    height: 13px;
}

body.mq-app .mq-file-clear {
    position: relative;
    z-index: 3;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.25rem 0.55rem;
    border: 1px solid rgba(220, 38, 38, 0.25);
    border-radius: 6px;
    background: rgba(220, 38, 38, 0.06);
    color: #b91c1c;
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
}

body.mq-app .mq-file-clear:hover {
    background: rgba(220, 38, 38, 0.12);
}

body.mq-app .mq-file-clear i,
body.mq-app .mq-file-clear svg {
    width: 12px;
    height: 12px;
}

/* ── Painéis e blocos opcionais (dark-safe) ── */
body.mq-app .mq-form-panel {
    background: var(--mq-surface-2) !important;
    border: 1px solid var(--mq-line) !important;
    border-radius: 10px !important;
    padding: 1rem 1.1rem !important;
}

body.mq-app .mq-optional-block {
    margin-top: 10px;
    padding: 1rem;
    border-radius: 10px;
    border: 1px solid var(--mq-line);
    display: grid;
    gap: 1rem;
    grid-template-columns: 1fr 1fr;
}

body.mq-app .mq-optional-block--hidden {
    display: none !important;
}

body.mq-app #section-primeiro-aluguel.mq-optional-block--hidden,
body.mq-app #section-primeiro-aluguel[hidden] {
    display: none !important;
}

body.mq-app .mq-optional-block--carencia:not(.mq-optional-block--hidden) {
    grid-template-columns: 1fr;
}

body.mq-app .mq-commission-panel:not(.mq-optional-block--hidden) {
    grid-column: 1 / -1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    background: rgba(249, 115, 22, 0.06) !important;
    border-color: rgba(249, 115, 22, 0.2) !important;
}

body.mq-app .mq-optional-block--discount {
    background: rgba(34, 197, 94, 0.08) !important;
    border-color: rgba(34, 197, 94, 0.22) !important;
}

body.mq-app .mq-optional-block--carencia {
    background: rgba(59, 130, 246, 0.08) !important;
    border-color: rgba(59, 130, 246, 0.22) !important;
}

body.mq-app .mq-form-hint-box {
    padding: .75rem 1rem !important;
    border-radius: 10px !important;
    border: 1px solid var(--mq-line) !important;
}

body.mq-app .mq-form-hint-box--warn {
    background: rgba(245, 158, 11, 0.1) !important;
    border-color: rgba(245, 158, 11, 0.28) !important;
}

body.mq-app .mq-form-hint-box--warn > label,
body.mq-app .mq-form-hint-box--warn .mq-form-hint-box__title {
    color: #b45309 !important;
    font-weight: 700 !important;
}

body.mq-app .mq-form-hint-box--warn small,
body.mq-app .mq-form-hint-box--warn .mq-form-hint-box__text {
    color: #d97706 !important;
}

body.mq-app .mq-form-hint-box--info {
    background: rgba(59, 130, 246, 0.08) !important;
    border-color: rgba(59, 130, 246, 0.22) !important;
}

body.mq-app .mq-form-hint-box--info > label,
body.mq-app .mq-form-hint-box--info .mq-form-hint-box__title {
    color: #1d4ed8 !important;
    font-weight: 700 !important;
}

body.mq-app .mq-form-hint-box--info small,
body.mq-app .mq-form-hint-box--info .mq-form-hint-box__text,
body.mq-app .mq-form-hint-box--info #hint-vcto-seguros {
    color: #2563eb !important;
}

[data-theme="dark"] body.mq-app .mq-form-hint-box--warn > label,
[data-theme="dark"] body.mq-app .mq-form-hint-box--warn .mq-form-hint-box__title {
    color: #fbbf24 !important;
}

[data-theme="dark"] body.mq-app .mq-form-hint-box--warn small,
[data-theme="dark"] body.mq-app .mq-form-hint-box--warn .mq-form-hint-box__text {
    color: #fcd34d !important;
}

[data-theme="dark"] body.mq-app .mq-form-hint-box--info > label,
[data-theme="dark"] body.mq-app .mq-form-hint-box--info .mq-form-hint-box__title {
    color: #93c5fd !important;
}

[data-theme="dark"] body.mq-app .mq-form-hint-box--info small,
[data-theme="dark"] body.mq-app .mq-form-hint-box--info .mq-form-hint-box__text,
[data-theme="dark"] body.mq-app .mq-form-hint-box--info #hint-vcto-seguros {
    color: #bfdbfe !important;
}

body.mq-app .mq-commission-panel {
    gap: 1rem;
    margin-top: .5rem;
    padding: 1.25rem !important;
}

body.mq-app .mq-form-panel--dashed {
    border-style: dashed !important;
    padding: 1.25rem 1.5rem !important;
}

/* ── Gerenciador de arquivos inline ── */
body.mq-app .file-manager-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

body.mq-app .file-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

body.mq-app .file-item {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: var(--mq-surface-2);
    border: 1px solid var(--mq-line);
    border-radius: 8px;
    font-size: .75rem;
}

body.mq-app .file-item a {
    color: var(--mq-o);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 4px;
}

body.mq-app .file-item a i,
body.mq-app .file-item a svg {
    width: 14px !important;
    height: 14px !important;
}

body.mq-app .file-item button {
    background: none;
    border: none;
    color: #ef4444;
    cursor: pointer;
    padding: 2px;
    display: flex;
    align-items: center;
}

body.mq-app .file-item button:hover {
    color: #dc2626;
}

body.mq-app .file-list-empty {
    font-size: .75rem;
    color: var(--mq-muted);
    font-style: italic;
}

body.mq-app .btn-add-file {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: .75rem;
    color: var(--mq-text);
    background: var(--mq-surface-2);
    padding: 8px 12px;
    border-radius: 10px;
    border: 1.5px dashed rgba(232, 93, 4, 0.35);
    transition: border-color .15s, background .15s;
    width: 100%;
    justify-content: center;
}

body.mq-app .btn-add-file:hover {
    border-color: rgba(232, 93, 4, 0.55);
    background: rgba(232, 93, 4, 0.06);
}

body.mq-app .btn-add-file i,
body.mq-app .btn-add-file svg {
    width: 14px !important;
    height: 14px !important;
    color: var(--mq-o);
}

body.mq-app .btn-add-file input[type="file"] {
    display: none;
}

body.mq-app .mq-file-wrap input[type="file"] {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    opacity: 0 !important;
    cursor: pointer !important;
    min-height: 0 !important;
    padding: 0 !important;
    border: none !important;
    z-index: 2;
}

body.mq-app .mq-file-btn {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    padding: .5rem .9rem;
    border-radius: 10px;
    background: var(--mq-surface);
    border: 1px solid var(--mq-line);
    font-size: .8125rem;
    font-weight: 600;
    color: var(--mq-text);
    pointer-events: none;
    box-shadow: 0 1px 3px rgba(18, 18, 26, 0.06);
}

body.mq-app .mq-file-hint {
    font-size: .75rem;
    color: var(--mq-muted);
    line-height: 1.35;
    word-break: break-word;
}

body.mq-app .mq-file-hint.has-files {
    color: var(--mq-o);
    font-weight: 500;
}

body.mq-app .form-group input[type="file"]:not([data-mq-enhanced]) {
    padding: .5rem !important;
    font-size: .8125rem !important;
    min-height: auto !important;
    width: 100% !important;
}

body.mq-app .form-group input[type="file"]::file-selector-button {
    margin-right: .75rem;
    padding: .45rem .85rem;
    border: none;
    border-radius: 8px;
    background: var(--mq-grad);
    color: #fff;
    font-family: inherit;
    font-size: .78rem;
    font-weight: 600;
    cursor: pointer;
}

/* Configurações — pins grid */
body.mq-app .mq-pins-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: .5rem;
    margin-top: .75rem;
}

body.mq-app .mq-pin-option {
    display: flex;
    align-items: center;
    gap: .55rem;
    padding: .65rem .75rem;
    border: 1px solid var(--mq-line);
    border-radius: 12px;
    background: var(--mq-surface-2);
    cursor: pointer;
    font-size: .8125rem;
    transition: border-color .15s, background .15s;
}

body.mq-app .mq-pin-option:has(input:checked) {
    border-color: rgba(232, 93, 4, 0.45);
    background: var(--primary-lighter);
}

body.mq-app .mq-pin-option input {
    width: 16px !important;
    height: 16px !important;
    min-height: 16px !important;
    margin: 0 !important;
    accent-color: var(--mq-o);
}

@media (max-width: 768px) {
    body.mq-app .mq-modal-form-inner .form-grid {
        grid-template-columns: 1fr !important;
    }
}

/* Ícone dentro do input — especificidade acima de .form-group input (evita sobreposição) */
body.mq-app .mq-modal-form-inner .form-group .input-icon-wrapper > input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
body.mq-app .form-container .form-group .input-icon-wrapper > input:not([type="checkbox"]):not([type="radio"]):not([type="file"]) {
    padding-left: 2.5rem !important;
}

body.mq-app .mq-modal-form-inner .form-group .input-icon-wrapper > i,
body.mq-app .mq-modal-form-inner .form-group .input-icon-wrapper > svg,
body.mq-app .mq-modal-form-inner .form-group .input-icon-wrapper .input-icon-wrapper__icon,
body.mq-app .form-container .form-group .input-icon-wrapper > i,
body.mq-app .form-container .form-group .input-icon-wrapper > svg,
body.mq-app .form-container .form-group .input-icon-wrapper .input-icon-wrapper__icon {
    position: absolute !important;
    left: .75rem !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    width: 16px !important;
    height: 16px !important;
    margin: 0 !important;
    pointer-events: none !important;
    z-index: 2 !important;
}
