/* ── FwaGrid – reusable data-grid component ────────────────────────── */

/* Wrapper */
.fwg-wrap{font-size:.9rem}

/* ── Toolbar (actions row above the grid) ── */
.fwg-toolbar{display:flex;gap:.4rem;flex-wrap:wrap;align-items:center;padding:.45rem .5rem;background:var(--surface,#f8f9fa);border:1px solid var(--border,#dee2e6);border-bottom:none;border-radius:6px 6px 0 0}
.fwg-toolbar .fwg-tb-btn{padding:.3rem .7rem;font-size:.8rem;font-weight:600;border-radius:5px;border:1px solid var(--border,#dee2e6);background:#fff;color:#1b2a4a;cursor:pointer;transition:background .15s,color .15s,border-color .15s,opacity .15s;white-space:nowrap;line-height:1.4}
.fwg-toolbar .fwg-tb-btn:hover:not(:disabled){background:#1b2a4a;color:#fff;border-color:#1b2a4a}
.fwg-toolbar .fwg-tb-btn:disabled{opacity:.4;cursor:not-allowed}
.fwg-toolbar .fwg-tb-btn.fwg-btn-danger:hover:not(:disabled){background:#991b1b;border-color:#991b1b;color:#fff}
.fwg-toolbar .fwg-tb-btn.fwg-btn-primary{background:#1b2a4a;color:#fff;border-color:#1b2a4a}
.fwg-toolbar .fwg-tb-btn.fwg-btn-primary:hover:not(:disabled){background:#c8a84e;border-color:#c8a84e;color:#1b2a4a}
.fwg-toolbar .fwg-tb-spacer{flex:1}

/* ── Column picker ── */
.fwg-col-picker{position:relative;display:inline-block}
.fwg-col-picker-btn{font-size:.78rem!important}
.fwg-col-dropdown{position:absolute;right:0;top:calc(100% + 4px);background:#fff;border:1px solid var(--border,#dee2e6);border-radius:8px;box-shadow:0 4px 16px rgba(0,0,0,.12);z-index:500;min-width:220px;max-height:min(420px,calc(100vh - 8rem));overflow-y:auto;padding:.35rem 0}
.fwg-col-dropdown.fwg-col-dropdown-up{top:auto;bottom:calc(100% + 4px)}
.fwg-col-dropdown-item{display:flex;align-items:center;gap:.45rem;padding:.3rem .75rem;cursor:pointer;font-size:.82rem;white-space:nowrap;user-select:none}
.fwg-col-dropdown-item:hover{background:var(--surface,#f8f9fa)}
.fwg-col-dropdown-item input[type=checkbox]{accent-color:#1b2a4a;width:15px;height:15px;cursor:pointer}
.fwg-col-dropdown-reset{display:block;width:calc(100% - 1rem);margin:.35rem .5rem .15rem;padding:.3rem .5rem;font-size:.78rem;font-weight:600;border:1px solid var(--border,#dee2e6);border-radius:5px;background:var(--surface,#f8f9fa);color:#1b2a4a;cursor:pointer;text-align:center}
.fwg-col-dropdown-reset:hover{background:#1b2a4a;color:#fff}

/* ── Table ── */
.fwg-table-wrap{overflow-x:auto;border:1px solid var(--border,#dee2e6);border-radius:0 0 6px 6px}
.fwg-toolbar+.fwg-table-wrap{border-top:none}
.fwg-table{width:100%;border-collapse:collapse;table-layout:fixed}
.fwg-table th,.fwg-table td{padding:.5rem .65rem;text-align:left;border-bottom:1px solid var(--border,#dee2e6);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;box-sizing:border-box}
.fwg-table thead th{font-weight:600;background:var(--surface,#f8f9fa);position:sticky;top:0;z-index:1;user-select:none}
.fwg-table tbody tr:last-child td{border-bottom:none}

/* Radio select column */
.fwg-col-sel{width:36px!important;min-width:36px!important;max-width:36px!important;text-align:center!important;padding-left:4px!important;padding-right:4px!important}
.fwg-radio{cursor:pointer;width:16px;height:16px;accent-color:#1b2a4a}

/* Selected row */
.fwg-table tbody tr.fwg-selected{background:rgba(251,191,36,.12)}
.fwg-table tbody tr.fwg-selected td{font-weight:500}

/* Hover */
.fwg-table tbody tr:hover{background:var(--surface,#f8f9fa)}
.fwg-table tbody tr.fwg-selected:hover{background:rgba(251,191,36,.18)}

/* ── Sortable header ── */
.fwg-sortable{cursor:pointer;position:relative;padding-right:1.2rem!important}
.fwg-sortable:hover{color:#1b2a4a}
.fwg-sort-icon{position:absolute;right:.3rem;top:50%;transform:translateY(-50%);font-size:.65rem;color:var(--muted,#6b7280);pointer-events:none}
.fwg-sort-asc .fwg-sort-icon::after{content:'▲'}
.fwg-sort-desc .fwg-sort-icon::after{content:'▼'}
.fwg-sort-none .fwg-sort-icon::after{content:'⇅';font-size:.7rem;opacity:.4}

/* ── Column resize handle ── */
.fwg-th-inner{position:relative;display:block}
.fwg-resize{position:absolute;right:-2px;top:0;bottom:0;width:5px;cursor:col-resize;z-index:2}
.fwg-resize:hover,.fwg-resizing .fwg-resize{background:rgba(27,42,74,.22)}

/* ── Pager (below the grid) ── */
.fwg-pager{display:flex;gap:.5rem;align-items:center;justify-content:flex-end;padding:.5rem .5rem .25rem;font-size:.82rem;color:var(--muted,#6b7280);flex-wrap:wrap}
.fwg-pager select{padding:.2rem .35rem;border:1px solid var(--border,#dee2e6);border-radius:4px;font-size:.82rem;background:#fff}
.fwg-pager button{padding:.2rem .5rem;border:1px solid var(--border,#dee2e6);border-radius:4px;background:#fff;cursor:pointer;font-size:.82rem}
.fwg-pager button:hover:not(:disabled){background:var(--surface,#f8f9fa)}
.fwg-pager button:disabled{opacity:.35;cursor:not-allowed}
.fwg-pager .fwg-page-info{min-width:90px;text-align:center}

/* ── Empty state ── */
.fwg-empty{padding:1.5rem;text-align:center;color:var(--muted,#6b7280);font-size:.9rem;border:1px solid var(--border,#dee2e6);border-radius:6px}

/* ── Truncate helper ── */
.fwg-truncate{max-width:250px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;display:inline-block;vertical-align:middle}

/* ── Edit modal (shared) ── */
.fwg-modal-overlay{display:none;position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,.45);z-index:1000;justify-content:center;align-items:flex-start;padding:2rem 1rem;overflow-y:auto}
.fwg-modal-overlay.active{display:flex}
.fwg-modal{background:#fff;border-radius:10px;max-width:600px;width:100%;padding:1.5rem;box-shadow:0 4px 24px rgba(0,0,0,.15);max-height:calc(100vh - 4rem);overflow-y:auto}
.fwg-modal h3{margin:0 0 .75rem;font-size:1.15rem}
.fwg-modal label{display:block;font-weight:600;margin:.65rem 0 .25rem;font-size:.85rem}
.fwg-modal input[type=text],.fwg-modal input[type=email],.fwg-modal input[type=tel],.fwg-modal input[type=url],.fwg-modal input[type=number],.fwg-modal input[type=date],.fwg-modal input[type=month],.fwg-modal input[type=datetime-local],.fwg-modal textarea,.fwg-modal select{width:100%;padding:.45rem .6rem;border:1px solid var(--border,#dee2e6);border-radius:6px;font-size:.88rem;box-sizing:border-box;font-family:inherit;background:#fff;color:#0f172a}
.fwg-modal textarea{resize:vertical;min-height:5rem}
@media(min-width:768px){.fwg-modal{resize:both;min-width:400px;min-height:250px}}
.fwg-modal-close{background:none;border:none;font-size:1.4rem;cursor:pointer;color:var(--muted,#6b7280);padding:.25rem}
.fwg-modal-actions{display:flex;gap:.5rem;margin-top:1rem;justify-content:flex-end}
.fwg-modal-actions .btn{min-width:90px}
.fwg-modal .fwg-field-row{display:grid;grid-template-columns:1fr 1fr;gap:0 .75rem}
.fwg-modal .fwg-field-row label,.fwg-modal .fwg-field-row input,.fwg-modal .fwg-field-row select{grid-column:auto}
.fwg-modal .fwg-check-row{display:flex;gap:.5rem;align-items:center;margin:.65rem 0 .25rem}
.fwg-modal .fwg-check-row label{margin:0;font-weight:normal;font-size:.88rem}

/* Shared field control style used by admin pages */
.form-select,
input.form-select,
select.form-select,
textarea.form-select{
	padding:.45rem .65rem;
	border:1px solid var(--border,#cbd5e1);
	border-radius:8px;
	font-size:.88rem;
	line-height:1.35;
	background:#fff;
	color:#0f172a;
	transition:border-color .15s ease, box-shadow .15s ease;
	box-sizing:border-box;
}

.form-select:focus,
input.form-select:focus,
select.form-select:focus,
textarea.form-select:focus,
.fwg-modal input:focus,
.fwg-modal select:focus,
.fwg-modal textarea:focus{
	outline:none;
	border-color:#2563eb;
	box-shadow:0 0 0 3px rgba(37,99,235,.15);
}

/* Unified admin controls: applied by JS on /admin/* pages */
.admin-unified-control{
	padding:.45rem .65rem !important;
	border:1px solid var(--border,#cbd5e1) !important;
	border-radius:8px !important;
	font-size:.88rem !important;
	line-height:1.35 !important;
	background:#fff !important;
	color:#0f172a !important;
	box-sizing:border-box !important;
	font-family:inherit !important;
}

.admin-unified-control:focus{
	outline:none !important;
	border-color:#2563eb !important;
	box-shadow:0 0 0 3px rgba(37,99,235,.15) !important;
}

/* Admin control utility classes to avoid inline control styles */
.admin-w-100{width:100% !important}
.admin-flex-1{flex:1 1 auto}
.admin-minw-120{min-width:120px !important}
.admin-minw-160{min-width:160px !important}
.admin-minw-170{min-width:170px !important}
.admin-minw-180{min-width:180px !important}
.admin-minw-200{min-width:200px !important}
.admin-minw-220{min-width:220px !important}
.admin-minw-240{min-width:240px !important}
.admin-minw-280{min-width:280px !important}
.admin-maxw-120{max-width:120px !important}
.admin-maxw-200{max-width:200px !important}
.admin-mb-025{margin-bottom:.25rem !important}
.admin-mb-035{margin-bottom:.35rem !important}
.admin-mb-04{margin-bottom:.4rem !important}
.admin-textarea-readonly{
	min-height:160px;
	line-height:1.45;
	background:#f8fafc;
	color:#1f2937;
	resize:vertical;
}
