/*
 * Acorduri GDPR — editorul „Tipuri de acord” + setările firmei (public/js/gdprFormsEditor.js).
 * Namespace: clase `gfe-*`, tokeni `--gfe-*` (derivați din `--ml-*`, cu rezervă).
 * Stil: „Direcția A — clar și aerisit” (docs/design/STIL-DIRECTIA-A.md): margini vizibile, umbră discretă,
 * un singur buton principal pe ecran. Capcane light-theme.css: NICIO clasă nu conține card/panel/section/close;
 * bordurile care trebuie să se vadă se scriu cu !important + specificitate.
 */
.gfe-root {
    --gfe-font: var(--ml-font, 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
    --gfe-text: var(--ml-text, #0f172a);
    --gfe-text-2: var(--ml-text-2, #334155);
    --gfe-muted: var(--ml-text-muted, #64748b);
    --gfe-border: var(--ml-border, #d3dbe5);
    --gfe-sep: var(--ml-sep, #e3e8ef);
    --gfe-primary: var(--ml-primary, #2563eb);
    --gfe-primary-hover: var(--ml-primary-hover, #1d4ed8);
    --gfe-primary-soft: #eff6ff;
    --gfe-danger: var(--ml-danger, #dc2626);
    --gfe-warning: var(--ml-warning, #b45309);
    --gfe-success: var(--ml-success, #16a34a);
    --gfe-radius: var(--ml-radius-lg, 12px);
    --gfe-radius-sm: var(--ml-radius-md, 8px);
    --gfe-shadow: var(--ml-shadow-card, 0 1px 2px rgba(15,23,42,.06), 0 2px 8px -2px rgba(15,23,42,.06));
    --gfe-focus: var(--ml-focus, 0 0 0 3px rgba(37,99,235,.25));
    font-family: var(--gfe-font);
    color: var(--gfe-text);
    font-size: 14px;
    line-height: 1.45;
}
.gfe-root *, .gfe-fs * { box-sizing: border-box; }

/* ---------- blocuri (carduri) ---------- */
.gfe-root .gfe-box, .gfe-fs .gfe-box {
    background: #fff;
    border: 1px solid var(--gfe-border) !important;
    border-radius: var(--gfe-radius);
    box-shadow: var(--gfe-shadow);
    padding: 16px 18px;
    margin-bottom: 16px;
}
.gfe-box-head {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    margin: -2px 0 12px;
}
.gfe-box-title { font-size: 16px; font-weight: 700; margin: 0; color: var(--gfe-text); }
.gfe-box-sub { font-size: 13px; color: var(--gfe-muted); margin: 2px 0 0; }
.gfe-grow { flex: 1 1 auto; min-width: 0; }
.gfe-muted { color: var(--gfe-muted) !important; font-size: 13px; }
.gfe-mono { font-family: ui-monospace, SFMono-Regular, Consolas, 'Liberation Mono', monospace; font-size: 12.5px; }

/* ---------- butoane (scara comună) ---------- */
.gfe-root .gfe-btn, .gfe-fs .gfe-btn, .gfe-in-modal .gfe-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 36px; padding: 0 14px; border-radius: var(--gfe-radius-sm);
    font: 600 13.5px/1 var(--gfe-font); cursor: pointer; white-space: nowrap;
    background: #fff; color: var(--gfe-text); border: 1px solid var(--gfe-border) !important;
    box-shadow: none; text-decoration: none;
}
.gfe-root .gfe-btn:hover, .gfe-fs .gfe-btn:hover, .gfe-in-modal .gfe-btn:hover { background: #f8fafc; border-color: #94a3b8 !important; }
.gfe-root .gfe-btn:focus-visible, .gfe-fs .gfe-btn:focus-visible, .gfe-in-modal .gfe-btn:focus-visible { outline: none; box-shadow: var(--gfe-focus); }
.gfe-root .gfe-btn.gfe-btn-primary, .gfe-fs .gfe-btn.gfe-btn-primary, .gfe-in-modal .gfe-btn.gfe-btn-primary {
    background: var(--gfe-primary); color: #fff; border-color: var(--gfe-primary) !important;
    box-shadow: 0 1px 2px rgba(15,23,42,.08);
}
.gfe-root .gfe-btn.gfe-btn-primary:hover, .gfe-fs .gfe-btn.gfe-btn-primary:hover, .gfe-in-modal .gfe-btn.gfe-btn-primary:hover { background: var(--gfe-primary-hover); }
.gfe-root .gfe-btn.gfe-btn-ghost, .gfe-fs .gfe-btn.gfe-btn-ghost, .gfe-in-modal .gfe-btn.gfe-btn-ghost { background: transparent; border-color: transparent !important; color: #475569; }
.gfe-root .gfe-btn.gfe-btn-ghost:hover, .gfe-fs .gfe-btn.gfe-btn-ghost:hover, .gfe-in-modal .gfe-btn.gfe-btn-ghost:hover { background: #f1f5f9; }
.gfe-root .gfe-btn.gfe-btn-del, .gfe-fs .gfe-btn.gfe-btn-del, .gfe-in-modal .gfe-btn.gfe-btn-del { color: var(--gfe-danger); }
.gfe-root .gfe-btn.gfe-btn-sm, .gfe-fs .gfe-btn.gfe-btn-sm, .gfe-in-modal .gfe-btn.gfe-btn-sm { height: 32px; padding: 0 10px; font-size: 12.5px; }
.gfe-root .gfe-btn.gfe-btn-icon, .gfe-fs .gfe-btn.gfe-btn-icon, .gfe-in-modal .gfe-btn.gfe-btn-icon { width: 32px; padding: 0; font-size: 15px; }
.gfe-root .gfe-btn[disabled], .gfe-fs .gfe-btn[disabled], .gfe-in-modal .gfe-btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------- pastile ---------- */
.gfe-pill {
    display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 9px; border-radius: 999px;
    font-size: 12px; font-weight: 700; white-space: nowrap;
}
.gfe-root .gfe-pill-ok, .gfe-fs .gfe-pill-ok { background: #f0fdf4; color: #15803d !important; }
.gfe-root .gfe-pill-off, .gfe-fs .gfe-pill-off { background: #f1f5f9; color: #475569 !important; }
.gfe-root .gfe-pill-def, .gfe-fs .gfe-pill-def { background: #fffbeb; color: #b45309 !important; }
.gfe-root .gfe-pill-info, .gfe-fs .gfe-pill-info { background: var(--gfe-primary-soft); color: #1d4ed8 !important; }

/* ---------- lista tipurilor de acord ---------- */
.gfe-list { display: flex; flex-direction: column; gap: 10px; }
.gfe-row {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center;
    border: 1px solid var(--gfe-border) !important; border-radius: var(--gfe-radius-sm);
    padding: 12px 14px; background: #fff;
}
.gfe-row.is-off { background: #f8fafc; }
.gfe-row-title { font-weight: 700; font-size: 14.5px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.gfe-row-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 6px; }
.gfe-link {
    display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
    border: 1px solid var(--gfe-sep) !important; border-radius: 6px; padding: 3px 4px 3px 8px; background: #f8fafc;
}
.gfe-link-url { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; color: var(--gfe-text-2) !important; }
.gfe-row-acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.gfe-star { color: #d97706 !important; }
.gfe-empty { padding: 22px; text-align: center; color: var(--gfe-muted); border: 1px dashed var(--gfe-border) !important; border-radius: var(--gfe-radius-sm); }
.gfe-err { color: var(--gfe-danger) !important; font-size: 13px; }
.gfe-skel { height: 58px; border-radius: var(--gfe-radius-sm); background: linear-gradient(90deg, #f1f5f9, #e2e8f0, #f1f5f9); background-size: 200% 100%; animation: gfe-skel 1.2s linear infinite; }
@keyframes gfe-skel { to { background-position: -200% 0; } }

/* ---------- formulare ---------- */
.gfe-field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; min-width: 0; }
.gfe-field > label, .gfe-lbl { font-size: 13px; font-weight: 600; color: var(--gfe-text-2) !important; }
.gfe-hint { font-size: 12px; color: var(--gfe-muted) !important; }
.gfe-root input[type=text], .gfe-root input[type=url], .gfe-root textarea, .gfe-root select,
.gfe-fs input[type=text], .gfe-fs textarea, .gfe-fs select {
    font: 400 14px/1.4 var(--gfe-font); color: var(--gfe-text);
    border: 1px solid var(--gfe-border) !important; border-radius: var(--gfe-radius-sm);
    padding: 8px 10px; background: #fff; width: 100%; min-height: 36px;
}
.gfe-root textarea, .gfe-fs textarea { resize: vertical; min-height: 120px; }
.gfe-fs textarea.gfe-mono { font-size: 12.5px; line-height: 1.5; }
.gfe-root input:focus, .gfe-root textarea:focus, .gfe-root select:focus,
.gfe-fs input:focus, .gfe-fs textarea:focus, .gfe-fs select:focus { outline: none; border-color: var(--gfe-primary) !important; box-shadow: var(--gfe-focus); }
.gfe-fs input[readonly] { background: #f8fafc; color: var(--gfe-muted); }
.gfe-grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.gfe-check { display: inline-flex; align-items: center; gap: 7px; font-size: 13.5px; cursor: pointer; color: var(--gfe-text-2) !important; }
.gfe-check input { width: 16px; height: 16px; accent-color: var(--gfe-primary); }
.gfe-color { display: flex; align-items: center; gap: 8px; }
.gfe-root .gfe-color input[type=color], .gfe-fs .gfe-color input[type=color] {
    width: 44px !important; height: 36px !important; min-height: 0 !important; padding: 3px !important;
    border: 1px solid var(--gfe-border) !important; border-radius: 6px; background: #fff; cursor: pointer; flex: 0 0 auto;
}
.gfe-color input[type=text] { width: 110px; font-family: ui-monospace, Consolas, monospace; }

/* ---------- setările firmei ---------- */
.gfe-brand { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 18px; align-items: start; }
.gfe-logo-box {
    border: 1px dashed var(--gfe-border) !important; border-radius: var(--gfe-radius-sm); background: #fff;
    min-height: 100px; display: flex; align-items: center; justify-content: center; padding: 10px;
}
.gfe-logo-box img { max-width: 100%; max-height: 110px; object-fit: contain; }

/* ---------- avertismente ---------- */
.gfe-note {
    border-radius: var(--gfe-radius-sm); padding: 10px 12px; font-size: 13px; margin-bottom: 12px;
    border: 1px solid #fde68a !important; background: #fffbeb; color: #92400e;
}
.gfe-note.gfe-note-info { border-color: #bfdbfe !important; background: #eff6ff; color: #1e3a8a; }
.gfe-note.gfe-note-err { border-color: #fecaca !important; background: #fef2f2; color: #991b1b; }
.gfe-note p, .gfe-note li, .gfe-note strong { color: inherit !important; }
.gfe-note ul { margin: 6px 0 0 18px; padding: 0; }

/* ---------- fereastra pe tot ecranul (editorul) ---------- */
.gfe-fs {
    position: fixed; inset: 0; z-index: 10000; display: flex; flex-direction: column;
    background: var(--app-bg-gradient, linear-gradient(135deg, #eef3fd, #f1f1fd 50%, #f5f0fc));
    font-family: var(--gfe-font, 'Inter', sans-serif); color: #0f172a; font-size: 14px; line-height: 1.45;
    --gfe-font: var(--ml-font, 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
    --gfe-text: var(--ml-text, #0f172a); --gfe-text-2: var(--ml-text-2, #334155); --gfe-muted: var(--ml-text-muted, #64748b);
    --gfe-border: var(--ml-border, #d3dbe5); --gfe-sep: var(--ml-sep, #e3e8ef);
    --gfe-primary: var(--ml-primary, #2563eb); --gfe-primary-hover: var(--ml-primary-hover, #1d4ed8); --gfe-primary-soft: #eff6ff;
    --gfe-danger: var(--ml-danger, #dc2626); --gfe-radius: 12px; --gfe-radius-sm: 8px;
    --gfe-shadow: 0 1px 2px rgba(15,23,42,.06), 0 2px 8px -2px rgba(15,23,42,.06);
    --gfe-focus: 0 0 0 3px rgba(37,99,235,.25);
}
.gfe-fs-head {
    display: flex; align-items: center; gap: 10px; padding: 10px 18px; background: #fff;
    border-bottom: 1px solid var(--gfe-border) !important; flex: 0 0 auto;
    padding-top: max(10px, env(safe-area-inset-top));
}
.gfe-fs-title { font-size: 17px; font-weight: 700; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.gfe-dirty { font-size: 12px; color: var(--gfe-warning, #b45309) !important; font-weight: 600; white-space: nowrap; }
.gfe-fs-body { flex: 1 1 auto; overflow: auto; padding: 18px; }
.gfe-fs-inner { max-width: 1180px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(300px, 1fr); gap: 16px; align-items: start; }
.gfe-fs-foot {
    flex: 0 0 auto; display: flex; gap: 8px; align-items: center; justify-content: flex-end; flex-wrap: wrap;
    padding: 10px 18px; background: #fff; border-top: 1px solid var(--gfe-border) !important;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
}
.gfe-fs-foot .gfe-foot-note { margin-right: auto; }

/* taburile textului */
.gfe-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--gfe-sep) !important; margin-bottom: 12px; flex-wrap: wrap; }
.gfe-fs .gfe-tab {
    height: 36px; padding: 0 12px; border: 0 !important; border-bottom: 2px solid transparent !important; background: transparent;
    font: 600 13.5px/1 var(--gfe-font); color: #475569; cursor: pointer; margin-bottom: -1px; border-radius: 6px 6px 0 0;
}
.gfe-fs .gfe-tab:hover { background: #f8fafc; }
.gfe-fs .gfe-tab[aria-selected="true"] { color: var(--gfe-primary); border-bottom-color: var(--gfe-primary) !important; }
.gfe-fs .gfe-tab:focus-visible { outline: none; box-shadow: var(--gfe-focus); }
.gfe-split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.gfe-frame {
    width: 100%; border: 1px solid var(--gfe-border) !important; border-radius: var(--gfe-radius-sm); background: #fff;
    min-height: 320px; display: block;
}
.gfe-frame-tall { height: 70vh; }

/* lista acordurilor DA/NU */
.gfe-consents { display: flex; flex-direction: column; gap: 8px; }
.gfe-crow {
    border: 1px solid var(--gfe-border) !important; border-radius: var(--gfe-radius-sm); background: #fff; padding: 10px;
    display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 8px; align-items: start;
}
.gfe-crow.is-drag { opacity: .45; }
.gfe-crow.is-over { border-color: var(--gfe-primary) !important; box-shadow: var(--gfe-focus); }
.gfe-grip { cursor: grab; color: #94a3b8; font-size: 16px; line-height: 36px; text-align: center; user-select: none; }
.gfe-crow-main { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.gfe-crow-opts { display: flex; gap: 14px; flex-wrap: wrap; }
.gfe-crow-key { font-size: 11.5px; color: #94a3b8 !important; }
.gfe-crow-acts { display: flex; gap: 2px; }
.gfe-sugg { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }

/* câmpurile pacientului */
.gfe-fields { display: flex; flex-direction: column; }
.gfe-frow { display: grid; grid-template-columns: minmax(0, 1fr) 160px; gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--gfe-sep) !important; }
.gfe-frow:last-child { border-bottom: 0 !important; }

/* QR */
.gfe-qr { text-align: center; }
.gfe-qr img { width: 260px; max-width: 100%; image-rendering: pixelated; border: 1px solid var(--gfe-sep) !important; border-radius: 8px; }

/* fereastra de rezervă (fără ErpUi) */
.gfe-pop-back { position: fixed; inset: 0; z-index: 10050; background: rgba(15,23,42,.45); display: flex; align-items: center; justify-content: center; padding: 16px; }
.gfe-pop { background: #fff; border-radius: 12px; max-width: 560px; width: 100%; max-height: 90vh; overflow: auto; padding: 18px; box-shadow: 0 20px 50px -10px rgba(15,23,42,.35); font-family: 'Inter', sans-serif; }
.gfe-pop-foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
.gfe-toast-host { position: fixed; right: 16px; bottom: 16px; z-index: 10060; display: flex; flex-direction: column; gap: 8px; }
.gfe-toast { background: #0f172a; color: #fff; padding: 10px 14px; border-radius: 8px; font: 500 13.5px/1.4 'Inter', sans-serif; max-width: 380px; }
.gfe-toast[data-kind="error"] { background: #991b1b; }
.gfe-toast[data-kind="success"] { background: #166534; }

/* ---------- tabletă / telefon ---------- */
@media (max-width: 1024px) {
    .gfe-fs-inner { grid-template-columns: minmax(0, 1fr); }
    .gfe-split { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 768px) {
    .gfe-root .gfe-box, .gfe-fs .gfe-box { padding: 12px; }
    .gfe-row { grid-template-columns: minmax(0, 1fr); }
    .gfe-row-acts { justify-content: flex-start; }
    .gfe-brand { grid-template-columns: minmax(0, 1fr); }
    .gfe-grid2 { grid-template-columns: minmax(0, 1fr); }
    .gfe-fs-body { padding: 10px; }
    .gfe-fs-head { padding-left: 10px; padding-right: 10px; }
    .gfe-fs-foot { padding-left: 10px; padding-right: 10px; }
    .gfe-fs-foot .gfe-foot-note { display: none; }
    .gfe-root .gfe-btn, .gfe-fs .gfe-btn, .gfe-in-modal .gfe-btn { height: 44px; }
    .gfe-root .gfe-btn.gfe-btn-sm, .gfe-fs .gfe-btn.gfe-btn-sm, .gfe-in-modal .gfe-btn.gfe-btn-sm { height: 40px; }
    .gfe-root .gfe-btn.gfe-btn-icon, .gfe-fs .gfe-btn.gfe-btn-icon, .gfe-in-modal .gfe-btn.gfe-btn-icon { width: 40px; }
    .gfe-frow { grid-template-columns: minmax(0, 1fr) 140px; }
    .gfe-fs input[type=text], .gfe-fs textarea, .gfe-fs select { font-size: 16px; }
    .gfe-hide-m { display: none !important; }
}

/* derularea paginii de dedesubt e oprită cât e deschis editorul */
html.gfe-noscroll, html.gfe-noscroll body { overflow: hidden !important; }

/* conținutul pus în ferestrele ErpUi.modal (QR, previzualizare, „Tip de acord nou”) */
.gfe-in-modal { font-family: var(--ml-font, 'Inter', sans-serif); color: #0f172a;
    --gfe-border: var(--ml-border, #d3dbe5); --gfe-sep: var(--ml-sep, #e3e8ef); --gfe-primary: var(--ml-primary, #2563eb);
    --gfe-primary-hover: var(--ml-primary-hover, #1d4ed8); --gfe-text: #0f172a; --gfe-muted: #64748b; --gfe-radius-sm: 8px;
    --gfe-font: var(--ml-font, 'Inter', sans-serif); --gfe-focus: 0 0 0 3px rgba(37,99,235,.25); }
.gfe-in-modal .gfe-frame { width: 100%; border: 1px solid var(--gfe-border) !important; border-radius: 8px; background: #fff; display: block; }
.gfe-in-modal .gfe-frame-tall { height: 68vh; }
.gfe-in-modal .gfe-hint, .gfe-in-modal .gfe-muted { font-size: 12.5px; color: #64748b !important; }
.gfe-in-modal .gfe-mono { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; }
.gfe-in-modal .gfe-qr { text-align: center; }
.gfe-in-modal .gfe-qr img { width: 260px; max-width: 100%; image-rendering: pixelated; border: 1px solid var(--gfe-sep) !important; border-radius: 8px; }
@media (max-width: 768px) { .gfe-in-modal .gfe-btn { height: 44px; } }

/* câmpuri v2 (listă ordonată) */
.gfe-frow.gfe-frow-v2 { grid-template-columns: minmax(0, 1fr) auto; align-items: flex-start; padding: 10px 0; }
.gfe-frow-v2 input[type="text"], .gfe-frow-v2 select, .gfe-frow-v2 textarea { max-width: 100%; }
@media (max-width: 760px) { .gfe-frow.gfe-frow-v2 { grid-template-columns: minmax(0, 1fr); } }
