/* ==========================================================================
   圆梦鸿途 · 企业管理后台  ·  Form Paradigm
   Owned by: form workstream (task-4)
   Covers:
     1. Page form layout (系统配置 / 个人资料) — 左侧分组导航 + 右侧表单卡 + 吸底操作栏
     2. Form rows & field widgets (all config field types)
     3. Profile layout
     4. Dialog (add / edit) forms under body.is-dialog — layer iframe pages
     5. Layer chrome for form dialogs (title / footer)
     6. Responsive (<=1024 / <=640)
   Loaded after backend.css + console/base.css on every admin page.
   ========================================================================== */

/* ==========================================================================
   1. Page form layout
   ========================================================================== */
.form-page { max-width: none; }

.form-grid {
    display: grid;
    grid-template-columns: 200px minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}

/* left group navigation card */
.fnav {
    position: sticky;
    top: 112px;
    padding: 8px;
    align-self: start;
    z-index: 5;
}
/* content pages live inside the tab iframe: no outer topbar to compensate */
body.inside-header .fnav { top: 16px; }

.fnav a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: var(--r);
    color: var(--ink-2);
    font-size: 13px;
    font-weight: 400;
    line-height: 18px;
    text-decoration: none;
    cursor: pointer;
    transition: background-color .12s, color .12s;
    white-space: nowrap;
}
.fnav a:hover { background: var(--bg); color: var(--ink); }
.fnav a.on { background: var(--pri-2); color: var(--pri-ink); font-weight: 500; }
.fnav a .fa { font-size: 12px; }
.fnav .fnav-sep { height: 1px; background: var(--line-2); margin: 8px 8px; }
.fnav a.fnav-add { color: var(--pri); }
.fnav a.fnav-add:hover { background: var(--pri-2); color: var(--pri-ink); }

/* right column of form cards */
.fcol { min-width: 0; display: flex; flex-direction: column; gap: 0; }
.fcard { min-width: 0; }
.fcard + .fcard { margin-top: 16px; }
.fcard .card-h { padding: 14px 24px; }

/* empty group */
.fempty {
    padding: 32px 24px;
    text-align: center;
    color: var(--ink-3);
    font-size: 12.5px;
}

/* ==========================================================================
   2. Form rows
   ========================================================================== */
.fsec { padding: 4px 0; }

.frow {
    position: relative;
    display: grid;
    grid-template-columns: 180px minmax(0, 560px);
    gap: 24px;
    padding: 16px 24px;
    border-bottom: 1px solid var(--line-2);
    align-items: start;
}
.frow:last-child { border-bottom: 0; }
.frow.hidden { display: none !important; }

.frow > .flabel {
    font-size: 13px;
    font-weight: 500;
    color: var(--ink);
    padding-top: 7px;
    margin: 0;
    line-height: 1.5;
    word-break: break-word;
}
.frow > .flabel em {
    color: var(--err);
    font-style: normal;
    margin-left: 2px;
}
.frow > .flabel small {
    display: block;
    font-weight: 400;
    color: var(--ink-3);
    font-size: 12px;
    margin-top: 4px;
    line-height: 1.5;
}
.frow > .flabel .fkey {
    display: table;
    margin-top: 6px;
    font-family: var(--mono);
    font-size: 11px;
    line-height: 16px;
    color: var(--ink-3);
    background: #FAFBFC;
    border: 1px solid var(--line-2);
    border-radius: 4px;
    padding: 0 6px;
    letter-spacing: 0;
    white-space: nowrap;
}

.frow > .fctl { min-width: 0; }

/* inline delete (debug mode) */
.frow > .btn-delcfg {
    position: absolute;
    right: 14px;
    top: 13px;
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    color: var(--ink-3);
    text-decoration: none;
    opacity: 0;
    transition: opacity .12s, background-color .12s, color .12s;
}
.frow:hover > .btn-delcfg { opacity: 1; }
.frow > .btn-delcfg:hover { background: var(--err-bg); color: var(--err); }

/* generic controls inside a field cell */
.fctl > .form-control,
.fctl > .input-group,
.fctl > .fupload,
.fctl > .fopts,
.fctl > .fieldlist,
.fctl > .selectpage,
.fctl > .sp_container { max-width: 560px; }
.fctl .form-control { width: 100%; }
.fctl .input-group { width: 100%; }
.fctl .input-group .form-control { width: 100%; }
.fctl textarea.form-control {
    height: 84px;
    padding: 8px 10px;
    resize: vertical;
    line-height: 1.6;
}
.fctl textarea.editor { min-height: 140px; }
.fctl select.form-control { padding-right: 28px; }
.fctl .hint { font-size: 12px; color: var(--ink-3); margin-top: 6px; line-height: 1.5; }
.fctl .fextra { margin-top: 8px; display: flex; gap: 8px; flex-wrap: wrap; }
.fctl .fextra .btn { height: 28px; line-height: 26px; font-size: 12.5px; }

/* field with addon prefix (https://) */
.fctl .faddon { display: flex; max-width: 560px; }
.fctl .faddon > span {
    height: 32px;
    display: inline-flex;
    align-items: center;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-right: 0;
    border-radius: var(--r) 0 0 var(--r);
    background: #FAFBFC;
    color: var(--ink-3);
    font-family: var(--mono);
    font-size: 12px;
    white-space: nowrap;
}
.fctl .faddon > .form-control { border-radius: 0 var(--r) var(--r) 0; }

/* checkbox / radio groups */
.fopts {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 18px;
    padding-top: 7px;
}
.fopts > label,
.fopts .fopt {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    padding: 0;
    font-weight: 400;
    color: var(--ink-2);
    font-size: 13px;
    cursor: pointer;
    line-height: 18px;
}
.fopts > label:hover { color: var(--ink); }
.fopts input[type="radio"],
.fopts input[type="checkbox"] { margin: 0; position: static; }

/* native <div class="radio"> / <div class="checkbox"> from helper functions */
.fctl > .radio,
.fctl > .checkbox,
.fctl > div > .radio,
.fctl > div > .checkbox {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 18px;
    margin: 0;
    padding-top: 7px;
}
.fctl > .radio label,
.fctl > .checkbox label,
.fctl > div > .radio label,
.fctl > div > .checkbox label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    padding: 0;
    font-weight: 400;
    color: var(--ink-2);
    cursor: pointer;
}

/* switch (design pill) */
.fctl .fswitch { padding-top: 4px; line-height: 0; }
.fctl .btn-switcher.switch {
    width: 36px;
    height: 20px;
    border-radius: 10px;
    background: var(--pri);
    display: inline-block;
    margin: 0;
    text-decoration: none;
    border: 0;
}
.fctl .btn-switcher.switch > i { display: none; }
.fctl .btn-switcher.switch.off { background: #C9D1DD; }

/* bool radios */
.fctl .fbool { padding-top: 7px; display: flex; gap: 18px; }
.fctl .fbool label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 400;
    color: var(--ink-2);
    margin: 0;
    cursor: pointer;
}

/* array fieldlist */
.fieldlist { margin: 0; padding: 0; }
.fieldlist dd {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 0 0 8px;
    padding: 0;
}
.fieldlist dd:first-child { margin-bottom: 4px; }
.fieldlist dd:last-child { margin-bottom: 0; }
.fieldlist dd ins {
    width: 148px;
    flex: 0 0 148px;
    display: inline-block;
    text-decoration: none;
    color: var(--ink-3);
    font-size: 12px;
    font-style: normal;
}
.fieldlist dd input.form-control {
    display: inline-block;
    width: auto;
    flex: 1 1 0;
    min-width: 0;
    max-width: 190px;
    height: 32px;
}
.fieldlist dd .btn {
    flex: none;
    height: 28px;
    line-height: 26px;
    font-size: 12.5px;
    padding: 0 10px;
}
.fieldlist dd .btn-remove,
.fieldlist dd .btn-dragsort { width: 28px; padding: 0; justify-content: center; }
.fieldlist dd .btn-dragsort { cursor: move; }

/* upload widgets */
.fupload {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    flex-wrap: wrap;
}
.fupload .fupload-main { flex: 1 1 260px; min-width: 0; }
.fupload .fupload-main > .form-control { width: 100%; }
.fupload .fupload-btns { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.fupload .fupload-btns .btn { height: 28px; line-height: 26px; font-size: 12.5px; }

/* upload / choose buttons: design secondary style everywhere (overrides legacy btn-danger/btn-primary) */
.btn.faupload,
.btn.fachoose,
body.is-dialog .form-horizontal .btn.faupload,
body.is-dialog .form-horizontal .btn.fachoose {
    background: #fff;
    border: 1px solid var(--line);
    color: var(--ink-2);
    box-shadow: none;
}
.btn.faupload:hover,
.btn.fachoose:hover,
.btn.faupload:focus,
.btn.fachoose:focus {
    background: #FCFDFE;
    border-color: #C9D1DD;
    color: var(--ink);
}
.btn.faupload:active,
.btn.fachoose:active { background: #F4F6F9; }
.btn.faupload .fa,
.btn.fachoose .fa { color: var(--ink-3); }

.faupload-preview {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    flex: none;
}
.faupload-preview:empty::before {
    content: "";
    width: 64px;
    height: 64px;
    display: block;
    border: 1px dashed #C9D1DD;
    border-radius: 8px;
    background: #FAFBFC url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' fill='none' stroke='%238590A2' stroke-width='1.6'%3E%3Crect x='3' y='3' width='14' height='14' rx='2'/%3E%3Ccircle cx='7.5' cy='7.5' r='1.2'/%3E%3Cpath d='M17 12l-4-4L5 17'/%3E%3C/svg%3E") center center no-repeat;
}
.faupload-preview > li {
    float: none !important;
    width: 64px !important;
    height: 64px;
    padding: 0 !important;
    margin: 0 !important;
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--line);
    background: #fff;
    list-style: none;
}
.faupload-preview > li .thumbnail {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent;
}
.faupload-preview > li .thumbnail img,
.faupload-preview > li img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
    margin: 0 !important;
}
.faupload-preview > li .btn-trash {
    position: absolute;
    right: 2px;
    top: 2px;
    height: 18px !important;
    width: 18px;
    min-width: 0;
    padding: 0 !important;
    line-height: 18px !important;
    font-size: 10px !important;
    border-radius: 4px !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity .12s;
}
.faupload-preview > li:hover .btn-trash { opacity: 1; }

/* selectpage */
.fctl .sp_container { max-width: 560px; width: 100%; }
.fctl .sp_container .sp_input {
    height: 32px;
    padding: 0 10px;
    font-size: 13px;
    color: var(--ink);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--r);
    box-shadow: none;
}
.fctl .sp_container .sp_input:focus {
    border-color: var(--pri);
    box-shadow: 0 0 0 3px var(--pri-2);
    outline: none;
}

/* bootstrap-select inside form cells */
.fctl .bootstrap-select,
.fctl .bootstrap-select.btn-group { width: 100% !important; max-width: 560px; }
.fctl .bootstrap-select > .dropdown-toggle {
    width: 100%;
    height: 32px;
    padding: 0 28px 0 10px;
    line-height: 30px;
    font-size: 13px;
    color: var(--ink);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--r);
    display: flex;
    align-items: center;
    box-shadow: none;
}
.fctl .bootstrap-select > .dropdown-toggle:focus {
    border-color: var(--pri);
    box-shadow: 0 0 0 3px var(--pri-2);
    outline: none;
}
.fctl .bootstrap-select > .dropdown-toggle .filter-option { width: 100%; text-align: left; }

/* date pickers live inside .fctl: keep dropdown anchored */
.fctl .datetimepicker,
.fctl .datetimerange { width: 100%; }

/* ==========================================================================
   3. Form validation feedback
   ========================================================================== */
.frow.has-error > .flabel,
.form-group.has-error > label.control-label { color: var(--err); }
.frow.has-error .form-control,
.form-group.has-error .form-control {
    border-color: var(--err);
    box-shadow: 0 0 0 3px var(--err-bg);
}

/* validator messages: inline block below the control instead of floating right */
.frow .msg-box,
.fctl .msg-box,
.frow .msg-box.n-right,
.fctl .msg-box.n-right,
.sp_container .msg-box,
.bootstrap-select .msg-box,
.input-group > .msg-box.n-right {
    position: static !important;
    display: block !important;
    right: auto !important;
    left: auto !important;
    top: auto !important;
    width: auto !important;
    margin: 4px 0 0 !important;
    text-align: left !important;
    line-height: 1.5;
    z-index: auto;
}
.frow .msg-box .msg-wrap,
.fctl .msg-box .msg-wrap {
    position: static !important;
    display: block;
    margin: 0 !important;
    padding: 0;
    white-space: normal;
    background: none;
    border: 0;
    box-shadow: none;
    font-size: 12px;
    line-height: 1.5;
}
.frow .msg-box .msg-wrap .n-error,
.fctl .msg-box .msg-wrap .n-error,
.frow .msg-box .msg-wrap .n-ok,
.fctl .msg-box .msg-wrap .n-ok,
.frow .msg-box .msg-wrap .n-tip,
.fctl .msg-box .msg-wrap .n-tip { padding: 0; }
.frow .msg-box .n-icon,
.fctl .msg-box .n-icon,
.frow .msg-box .n-arrow,
.fctl .msg-box .n-arrow { display: none !important; }
.frow .msg-box .n-msg,
.fctl .msg-box .n-msg { color: var(--err); }
.frow .msg-box .n-tip .n-msg,
.fctl .msg-box .n-tip .n-msg { color: var(--ink-3); }

/* ==========================================================================
   4. Sticky action bar
   ========================================================================== */
.foot {
    position: sticky;
    bottom: 0;
    z-index: 4;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    padding: 12px 24px;
    background: rgba(255, 255, 255, .92);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    border-top: 1px solid var(--line);
    border-radius: 0 0 8px 8px;
}
.foot .layer-footer { padding: 0; text-align: right; display: flex; gap: 10px; justify-content: flex-end; }
.foot .layer-footer .btn { margin: 0; }
.foot .foot-tip { margin-right: auto; font-size: 12px; color: var(--ink-3); }

/* ==========================================================================
   5. Profile page
   ========================================================================== */
.profile-grid {
    display: grid;
    grid-template-columns: minmax(0, 380px) minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}
.profile-card .card-h { padding: 14px 20px; }
.profile-body { padding: 18px 20px 4px; }

.pavatar {
    position: relative;
    width: 88px;
    height: 88px;
    margin: 2px auto 12px;
    border-radius: 50%;
}
.pavatar .profile-user-img {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
    background: #D9E3F5;
    border: 1px solid var(--line);
}
.pavatar-mask {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: rgba(20, 26, 36, .45);
    color: #fff;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity .15s;
    pointer-events: none;
}
.pavatar:hover .pavatar-mask { opacity: 1; }
.pavatar .faupload {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    opacity: 0;
    cursor: pointer;
}
.pname {
    text-align: center;
    font-size: 15px;
    font-weight: 600;
    color: var(--ink);
    margin: 0;
    line-height: 1.4;
}
.pmeta {
    text-align: center;
    font-size: 12px;
    color: var(--ink-3);
    margin: 4px 0 16px;
}
.prow { padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.prow:last-of-type { border-bottom: 0; }
.prow > label {
    display: block;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--ink);
    margin: 0 0 6px;
}
.prow .form-control { width: 100%; }
.prow.has-error > label { color: var(--err); }
.profile-card .foot { padding: 12px 20px; }

/* admin log card */
.plog { min-width: 0; }
.plog > .card-h { padding: 13px 18px 12px; border-bottom: 1px solid var(--line-2); }
.plog .card-h .toolbar { margin-left: auto; }
.plog .card-h .toolbar .btn { height: 28px; padding: 0 10px; line-height: 26px; font-size: 12.5px; }
.plog-body { min-width: 0; }
.plog-body .bootstrap-table { margin: 0; }

/* ==========================================================================
   6. Dialog forms (layer iframe pages: body.is-dialog)
   ========================================================================== */
body.is-dialog.inside-header {
    padding: 10px 22px 12px;
    background: #fff;
}

body.is-dialog .form-horizontal { margin: 0; }

body.is-dialog .form-horizontal .form-group {
    display: grid;
    grid-template-columns: 148px minmax(0, 1fr);
    column-gap: 18px;
    align-items: start;
    margin: 0;
    padding: 12px 0;
    border-bottom: 1px solid var(--line-2);
}
body.is-dialog .form-horizontal .form-group:last-child { border-bottom: 0; }
body.is-dialog .form-horizontal .form-group.hidden { display: none !important; }

/* the original footer is cloned into the layer chrome: never show it in the iframe */
body.is-dialog .form-horizontal .form-group.layer-footer { display: none !important; }

body.is-dialog .form-horizontal .form-group > label.control-label {
    grid-column: 1;
    width: auto !important;
    float: none !important;
    margin: 0;
    padding: 7px 0 0 !important;
    text-align: left;
    font-size: 13px;
    font-weight: 500;
    color: var(--ink);
    line-height: 1.5;
    word-break: break-word;
}
body.is-dialog .form-horizontal .form-group > label.control-label em,
body.is-dialog .form-horizontal .form-group > label.control-label .required { color: var(--err); font-style: normal; }
body.is-dialog .form-horizontal .form-group.has-error > label.control-label { color: var(--err); }
body.is-dialog .form-horizontal .form-group.has-success > label.control-label { color: var(--ok); }

body.is-dialog .form-horizontal .form-group > div {
    grid-column: 2;
    width: auto !important;
    float: none !important;
    padding: 0 !important;
    margin: 0;
    min-width: 0;
}
body.is-dialog .form-horizontal .form-group > *:only-child { grid-column: 1 / -1; }

/* plain text inside a row (tips / read-only notes) */
body.is-dialog .form-horizontal .form-group > div > p { margin: 7px 0 0; color: var(--ink-2); }

/* controls */
body.is-dialog .form-horizontal .form-group .form-control { width: 100%; }
body.is-dialog .form-horizontal .form-group textarea.form-control {
    height: auto;
    min-height: 84px;
    padding: 8px 10px;
    line-height: 1.6;
    resize: vertical;
}
body.is-dialog .form-horizontal .form-group select.form-control { padding-right: 28px; }
body.is-dialog .form-horizontal .form-group .help-block { margin: 4px 0 0; color: var(--ink-3); font-size: 12px; }

/* radios / checkboxes */
body.is-dialog .form-horizontal .form-group .radio,
body.is-dialog .form-horizontal .form-group .checkbox {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 18px;
    margin: 0;
    padding-top: 7px;
}
body.is-dialog .form-horizontal .form-group .radio label,
body.is-dialog .form-horizontal .form-group .checkbox label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    padding: 0;
    font-weight: 400;
    color: var(--ink-2);
    cursor: pointer;
}
body.is-dialog .form-horizontal .form-group .radio-inline,
body.is-dialog .form-horizontal .form-group .checkbox-inline { margin: 0 18px 0 0; }

/* upload group inside dialogs */
body.is-dialog .form-horizontal .form-group .input-group {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    border-collapse: separate;
}
body.is-dialog .form-horizontal .form-group .input-group > .form-control {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
}
body.is-dialog .form-horizontal .form-group .input-group > .msg-box { flex: 0 0 100%; }
body.is-dialog .form-horizontal .form-group .input-group-addon {
    flex: 0 0 auto;
    width: auto !important;
    white-space: nowrap;
}
body.is-dialog .form-horizontal .form-group .input-group-addon .btn { margin-left: 0; }
body.is-dialog .form-horizontal .form-group .input-group-addon.no-border {
    border: 0;
    background: transparent;
    padding: 0 0 0 8px;
    height: auto;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}
/* legacy info / warning banners inside dialogs */
body.is-dialog .alert {
    border-radius: var(--r);
    border: 1px solid var(--line);
    background: #FAFBFC;
    color: var(--ink-2);
    font-size: 12.5px;
    line-height: 1.6;
    padding: 10px 14px;
    margin: 0 0 2px;
}
body.is-dialog .alert-warning {
    background: var(--warn-bg);
    border-color: #F3DFB9;
    color: var(--warn);
}
body.is-dialog .alert-info {
    background: var(--pri-2);
    border-color: #D6E2FA;
    color: var(--pri-ink);
}
body.is-dialog .alert-danger {
    background: var(--err-bg);
    border-color: #EFC4C0;
    color: var(--err);
}
body.is-dialog .alert > .fa:first-child { margin-right: 6px; }
body.is-dialog .form-horizontal .input-group-addon.no-border .btn { height: 28px; line-height: 26px; font-size: 12.5px; }
body.is-dialog .form-horizontal .faupload-preview { margin-top: 10px; }

/* fieldlist inside dialogs */
body.is-dialog .fieldlist dd { margin: 0 0 8px; }
body.is-dialog .fieldlist dd ins { width: 148px; flex: 0 0 148px; }
body.is-dialog .fieldlist dd input.form-control { max-width: none; flex: 1 1 0; }

/* selectpage / selectpicker inside dialogs */
body.is-dialog .bootstrap-select { width: 100% !important; }
body.is-dialog .bootstrap-select > .dropdown-toggle {
    width: 100%;
    height: 32px;
    padding: 0 28px 0 10px;
    line-height: 30px;
    font-size: 13px;
    color: var(--ink);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--r);
    display: flex;
    align-items: center;
    box-shadow: none;
}
body.is-dialog .bootstrap-select > .dropdown-toggle:focus {
    border-color: var(--pri);
    box-shadow: 0 0 0 3px var(--pri-2);
    outline: none;
}
body.is-dialog .bootstrap-select > .dropdown-toggle .filter-option { width: 100%; text-align: left; }
body.is-dialog .sp_container { width: 100%; }
body.is-dialog .sp_container .sp_input {
    height: 32px;
    padding: 0 10px;
    font-size: 13px;
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: #fff;
}
body.is-dialog .sp_container .sp_input:focus {
    border-color: var(--pri);
    box-shadow: 0 0 0 3px var(--pri-2);
    outline: none;
}

/* validation error message in dialogs, below the field */
body.is-dialog .form-horizontal .form-group .msg-box,
body.is-dialog .form-horizontal .form-group .msg-box.n-right,
body.is-dialog .form-horizontal .input-group > .msg-box.n-right,
body.is-dialog .sp_container .msg-box,
body.is-dialog .bootstrap-select .msg-box {
    position: static !important;
    display: block !important;
    right: auto !important;
    left: auto !important;
    top: auto !important;
    width: auto !important;
    margin: 4px 0 0 !important;
    text-align: left !important;
}
body.is-dialog .msg-box .msg-wrap,
body.is-dialog .msg-box.n-right .msg-wrap {
    position: static !important;
    display: block;
    margin: 0 !important;
    padding: 0;
    white-space: normal;
    background: none;
    border: 0;
    box-shadow: none;
    font-size: 12px;
    line-height: 1.5;
}
body.is-dialog .msg-box .n-icon,
body.is-dialog .msg-box .n-arrow { display: none !important; }
body.is-dialog .msg-box .n-error .n-msg,
body.is-dialog .msg-box .n-msg { color: var(--err); }

/* ==========================================================================
   7. Layer chrome for form dialogs (parent document: title / footer)
   ========================================================================== */
.layui-layer.layui-layer-fast.layui-layer-iframe .layui-layer-title {
    background: #fff !important;
    color: var(--ink) !important;
    border-bottom: 1px solid var(--line-2) !important;
    height: 48px !important;
    line-height: 48px !important;
    padding: 0 18px !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    border-radius: 8px 8px 0 0 !important;
}
.layui-layer.layui-layer-fast.layui-layer-iframe .layui-layer-title ~ .layui-layer-setwin {
    top: 0 !important;
    height: 48px !important;
}
.layui-layer.layui-layer-fast.layui-layer-iframe .layui-layer-title ~ .layui-layer-setwin > a {
    height: 48px !important;
    line-height: 48px !important;
    color: var(--ink-3);
}
.layui-layer-fast .layui-layer-footer.layui-layer-btn {
    background: #fff !important;
    border-top: 1px solid var(--line) !important;
    padding: 12px 20px !important;
    min-height: 0 !important;
    height: auto !important;
    text-align: right !important;
    display: flex;
    flex-direction: row-reverse;
    justify-content: flex-start;
    align-items: center;
    gap: 8px;
}
/* when layer wraps the copied footer in a .row container (FastAdmin add/edit templates) */
.layui-layer-fast .layui-layer-footer.layui-layer-btn > .row {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin: 0;
    width: 100%;
}
.layui-layer-fast .layui-layer-footer.layui-layer-btn > .row > label.control-label { display: none !important; }
.layui-layer-fast .layui-layer-footer.layui-layer-btn > .row > div {
    float: none !important;
    width: 100% !important;
    padding: 0 !important;
    margin: 0;
    display: flex;
    flex-direction: row-reverse;
    justify-content: flex-start;
    align-items: center;
    gap: 8px;
}
.layui-layer-footer.layui-layer-btn .btn {
    height: 32px;
    padding: 0 14px;
    border-radius: var(--r);
    font-size: 13px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 30px;
    margin: 0;
}
.layui-layer-footer.layui-layer-btn .btn-primary {
    background: var(--pri) !important;
    border-color: var(--pri) !important;
    color: #fff !important;
}
.layui-layer-footer.layui-layer-btn .btn-primary:hover {
    background: var(--pri-ink) !important;
    border-color: var(--pri-ink) !important;
}
.layui-layer-footer.layui-layer-btn .btn-default {
    background: #fff !important;
    border: 1px solid var(--line) !important;
    color: var(--ink-2) !important;
}
.layui-layer-footer.layui-layer-btn .btn-default:hover {
    background: #FCFDFE !important;
    border-color: #C9D1DD !important;
    color: var(--ink) !important;
}
.layui-layer-footer.layui-layer-btn .btn.disabled,
.layui-layer-footer.layui-layer-btn .btn[disabled] {
    background: #FAFBFC !important;
    border-color: var(--line-2) !important;
    color: var(--ink-3) !important;
    cursor: not-allowed;
}

/* ==========================================================================
   8. Responsive
   ========================================================================== */
@media (max-width: 1024px) {
    .form-grid { grid-template-columns: 1fr; }
    .fnav {
        position: static;
        display: flex;
        align-items: center;
        overflow-x: auto;
        gap: 4px;
        padding: 8px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .fnav::-webkit-scrollbar { display: none; }
    .fnav a { padding: 8px 12px; }
    .fnav .fnav-sep { display: none; }
    .fnav a.fnav-add { flex: none; }
    .frow { grid-template-columns: 1fr; gap: 8px; padding: 14px 20px; }
    .frow > .flabel { padding-top: 0; }
    .frow > .flabel small { margin-top: 2px; }
    .frow > .btn-delcfg { opacity: 1; top: 10px; right: 8px; }
    .fctl > .form-control,
    .fctl > .input-group,
    .fctl > .fupload,
    .fctl > .fopts,
    .fctl > .fieldlist,
    .fctl > .selectpage,
    .fctl > .sp_container,
    .fctl .sp_container { max-width: none; }

    .profile-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
    .frow { padding: 12px 14px; }
    .fcard .card-h { padding: 12px 14px; }
    .fcard .card-h .meta { display: none; }
    .foot { padding: 10px 14px; }
    .foot .layer-footer .btn { flex: 1 1 auto; }
    .fnav { padding: 6px; }
    .fnav a { padding: 7px 10px; font-size: 12.5px; }
    .fctl textarea.form-control { height: 76px; }
    .fieldlist dd ins { width: 100%; flex: 1 1 100%; }
    .fieldlist dd input.form-control { max-width: none; }
    .faupload .fupload-main { flex: 1 1 100%; }

    .profile-body { padding: 16px 14px 4px; }
    .profile-card .foot { padding: 10px 14px; }

    body.is-dialog.inside-header { padding: 14px 14px 8px; }
    body.is-dialog .form-horizontal .form-group { grid-template-columns: 1fr; gap: 6px; padding: 10px 0; }
    body.is-dialog .form-horizontal .form-group > label.control-label { grid-column: 1; padding-top: 0 !important; }
    body.is-dialog .form-horizontal .form-group > div { grid-column: 1; }
    .layui-layer-fast .modal,
    body.is-dialog .table-responsive { overflow-x: auto; }
}
