/* ============================================================================
   formtypes.css
   Styles for the eight FormType renderers in Components/FormTypes/.
   Loaded from _Host.cshtml alongside site.css + dynamic-ui.css.
   ============================================================================ */

/* ── Shared: empty / loading states ─────────────────────────────────────── */
.ft-empty,
.ft-loading {
    padding: 40px 20px;
    text-align: center;
    color: #64748b;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
}
.ft-empty > .las,
.ft-loading > .las {
    font-size: 3rem;
    display: block;
    margin-bottom: 12px;
    color: #94a3b8;
}
.ft-empty p, .ft-loading p { margin: 0; font-size: 14px; }

/* ── Toast (per-view local notification) ────────────────────────────────── */
.ft-toast {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 13px;
    margin-bottom: 10px;
    border: 1px solid;
}
.ft-toast--info    { background:#eff6ff; color:#1d4ed8; border-color:#bfdbfe; }
.ft-toast--success { background:#dcfce7; color:#166534; border-color:#bbf7d0; }
.ft-toast--error   { background:#fee2e2; color:#991b1b; border-color:#fecaca; }

/* ═════════════════════════════════════════════════════════════════════════
   FormToolbar
   ═════════════════════════════════════════════════════════════════════════ */
.form-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 10px 14px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,.04);
    margin-bottom: 12px;
}
.form-toolbar__start,
.form-toolbar__end {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.form-toolbar__title {
    font-weight: 700; font-size: 14px; color: #0f172a;
}
.form-toolbar .btn {
    padding: 7px 14px;
    border-radius: 8px;
    border: 1px solid transparent;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex; align-items: center; gap: 6px;
    transition: background .15s, border-color .15s, color .15s;
    background: #f1f5f9;
    color: #334155;
}
.form-toolbar .btn:hover { background: #e2e8f0; }
.form-toolbar .btn-new    { background:#3b82f6; color:#fff; }
.form-toolbar .btn-new:hover { background:#2563eb; }
.form-toolbar .btn-save   { background:#16a34a; color:#fff; }
.form-toolbar .btn-save:hover { background:#15803d; }
.form-toolbar .btn-sec    { background:#fff; border-color:#e2e8f0; color:#475569; }
.form-toolbar .btn-sec:hover { border-color:#3b82f6; color:#3b82f6; }
.form-toolbar .btn-attach { background:#f5f3ff; color:#7c3aed; border-color:#e9d5ff; }
.form-toolbar .btn-attach:hover { background:#ede9fe; }
.form-toolbar .btn-danger { background:#fef2f2; color:#dc2626; border-color:#fecaca; }
.form-toolbar .btn-danger:hover { background:#fee2e2; border-color:#fca5a5; }
.form-toolbar .btn:disabled { opacity:.6; cursor:not-allowed; }

/* Dropdown */
.entry-dropdown { position: relative; }
.entry-dropdown__menu {
    display: none;
    position: absolute; top: calc(100% + 4px); inset-inline-end: 0;
    background: #fff; border: 1px solid #e2e8f0; border-radius: 10px;
    min-width: 180px; padding: 6px; z-index: 40;
    box-shadow: 0 8px 20px rgba(0,0,0,.08);
}
.entry-dropdown.open .entry-dropdown__menu { display: block; }
.entry-dropdown__item {
    width: 100%;
    display: flex; align-items: center; gap: 8px;
    padding: 7px 10px;
    background: transparent; border: none; border-radius: 6px;
    text-align: start;
    font-size: 13px; color: #334155; cursor: pointer;
}
.entry-dropdown__item:hover { background: #f1f5f9; }
.entry-dropdown__item--danger:hover { background: #fee2e2; color: #991b1b; }
.entry-dropdown__divider { height:1px; background:#e2e8f0; margin:4px 0; }

/* ═════════════════════════════════════════════════════════════════════════
   Grid toolbar (used inside FormToolbar EndFragment)
   ═════════════════════════════════════════════════════════════════════════ */
.grid-toolbar__limit {
    display: flex; align-items: center; gap: 8px;
    padding: 4px 8px;
    background: #f8fafc;
    border-radius: 8px;
    font-size: 12px;
    color: #475569;
}
.grid-toolbar__limit label {
    display: inline-flex; align-items: center; gap: 4px; cursor: pointer;
}
.grid-toolbar__limit input[type="radio"] {
    accent-color: #3b82f6;
    margin: 0;
}
.grid-toolbar__search {
    display: flex; align-items: center; gap: 6px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 6px 10px;
    min-width: 200px;
}
.grid-toolbar__search input {
    flex: 1;
    background: transparent; border: none; outline: none;
    font-size: 13px; color: #1e293b;
}
.grid-toolbar__search .las { color: #94a3b8; }

/* ═════════════════════════════════════════════════════════════════════════
   Data grid table
   ═════════════════════════════════════════════════════════════════════════ */
.data-grid-view .grid-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
}
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.data-table thead { background: #f8fafc; }
.data-table th {
    text-align: start;
    padding: 10px 12px;
    font-size: 12px; font-weight: 700; color: #475569;
    border-bottom: 1px solid #e2e8f0;
}
.data-table td {
    padding: 8px 12px;
    border-bottom: 1px solid #f1f5f9;
    color: #334155;
    vertical-align: middle;
}
.data-table tbody tr:hover td { background: #fafbfd; }
.data-table__idx     { width: 40px; text-align: center; color: #94a3b8; }
.data-table__actions { width: 90px; text-align: center; }
.data-table__empty   { text-align: center; padding: 24px 0; color: #94a3b8; }
.data-table__empty .las { display: block; margin-bottom: 8px; font-size: 2rem; }
.data-table .pk-cell { font-family: monospace; color: #1d4ed8; font-weight: 600; }
.action-btn {
    width: 30px; height: 30px;
    border-radius: 6px; border: none;
    background: #f1f5f9; color: #475569;
    cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    transition: background .15s, color .15s;
}
.action-btn:hover        { background: #3b82f6; color: #fff; }
.action-edit:hover       { background: #16a34a; }
.action-view:hover       { background: #3b82f6; }

.grid-footer {
    display: flex; justify-content: flex-end; padding: 8px 14px;
    background: #f8fafc; border-top: 1px solid #e2e8f0; font-size: 12px;
    color: #64748b;
}
.stat-pill {
    background: #eff6ff; color: #1d4ed8;
    padding: 3px 10px; border-radius: 9999px;
    font-weight: 600;
}

/* Loading overlay */
.grid-loading-overlay {
    position: absolute; inset: 0;
    background: rgba(255,255,255,.85);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    z-index: 5;
}
.grid-loading-spinner {
    width: 40px; height: 40px;
    border: 3px solid #e2e8f0;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Inline form panel */
.inline-form-panel {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    margin-bottom: 12px;
    overflow: hidden;
}
.inline-form-panel__header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 14px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}
.inline-form-panel__header h3 {
    margin: 0; font-size: 14px; display: flex; align-items: center; gap: 8px; color:#1e293b;
}
.inline-form-panel__header-actions {
    display: flex; align-items: center; gap: 8px;
}
.inline-form-panel__close {
    background: transparent; border: none; cursor: pointer;
    width: 28px; height: 28px; border-radius: 6px;
    color: #64748b; display: flex; align-items: center; justify-content: center;
}
.inline-form-panel__close:hover { background: #fee2e2; color: #991b1b; }
.inline-form-panel__body { padding: 14px; }

/* ═════════════════════════════════════════════════════════════════════════
   Modals + fields-modal
   ═════════════════════════════════════════════════════════════════════════ */
.modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.45);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000;
}
.modal-content {
    background: #fff; border-radius: 12px;
    width: 90%; max-width: 500px; max-height: 90vh;
    display: flex; flex-direction: column;
    box-shadow: 0 20px 40px rgba(0,0,0,.15);
}
.modal-header {
    padding: 12px 16px; border-bottom: 1px solid #e2e8f0;
    display: flex; justify-content: space-between; align-items: center;
}
.modal-header h3 {
    margin: 0; font-size: 15px; display: flex; align-items: center; gap: 8px; color:#0f172a;
}
.modal-close {
    background: transparent; border: none; cursor: pointer;
    width: 28px; height: 28px; border-radius: 6px;
    color: #64748b; display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: #fee2e2; color: #991b1b; }
.modal-body { padding: 16px; overflow-y: auto; }
.modal-footer {
    padding: 12px 16px; border-top: 1px solid #e2e8f0;
    display: flex; justify-content: flex-end; gap: 8px;
}

.fields-modal .modal-body { max-height: 60vh; }
.fields-modal__item {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    color: #334155;
}
.fields-modal__item:hover { background: #f1f5f9; }
.fields-modal__item input[type="checkbox"] { accent-color: #3b82f6; }
.fields-modal__item small {
    font-family: monospace; color: #94a3b8; font-size: 11px;
}
.pk-badge {
    background: #fef3c7; color: #92400e;
    padding: 2px 6px; border-radius: 4px;
    font-size: 10px; font-weight: 700;
    margin-inline-start: auto;
}

/* ═════════════════════════════════════════════════════════════════════════
   Report skeleton
   ═════════════════════════════════════════════════════════════════════════ */
.report-view .report-shell {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 16px;
}
.report-shell__header {
    display: flex; justify-content: space-between; align-items: flex-start;
    margin-bottom: 16px;
}
.report-shell__header h2 { margin: 0 0 4px; font-size: 18px; color: #0f172a; }
.report-shell__header .hint { color: #64748b; font-size: 13px; margin: 0; max-width: 720px; }
.report-shell__icon { font-size: 3rem; color: #cbd5e1; }
.report-shell__body { display: grid; grid-template-columns: 1fr 240px; gap: 20px; }
@media (max-width: 700px) {
    .report-shell__body { grid-template-columns: 1fr; }
}
.report-skeleton {
    background: #f8fafc; border-radius: 10px; padding: 20px;
    display: flex; flex-direction: column; gap: 10px;
    min-height: 240px;
}
.report-skeleton__row {
    height: 12px; border-radius: 4px;
    background: linear-gradient(90deg, #e2e8f0 0%, #f1f5f9 50%, #e2e8f0 100%);
    background-size: 200% 100%;
    animation: shimmer 1.6s infinite linear;
}
.report-skeleton__row--title { height: 24px; width: 60%; }
.report-skeleton__row--short { width: 45%; }
@keyframes shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
.report-meta {
    background: #f8fafc; border-radius: 10px; padding: 14px;
    display: flex; flex-direction: column; gap: 10px;
}
.report-meta__item { display: flex; flex-direction: column; }
.report-meta__label { font-size: 11px; color: #94a3b8; text-transform: uppercase; letter-spacing: .05em; }
.report-meta__value { font-size: 14px; font-weight: 700; color: #1e293b; }

/* ═════════════════════════════════════════════════════════════════════════
   Dashboard (KPI cards + panels)
   ═════════════════════════════════════════════════════════════════════════ */
.dashboard-banner {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff; border-radius: 12px;
    padding: 20px 24px; margin-bottom: 14px;
}
.dashboard-banner h2 { margin: 0 0 6px; font-size: 18px; }
.dashboard-banner p  { margin: 0; opacity: .85; font-size: 13px; }

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 14px;
    margin-bottom: 14px;
}
.kpi-card {
    position: relative; overflow: hidden;
    background: linear-gradient(135deg, var(--kpi-c1, #3b82f6), var(--kpi-c2, #1d4ed8));
    color: #fff; border-radius: 12px;
    padding: 16px; min-height: 110px;
}
.kpi-card__label { font-size: 12px; opacity: .85; margin-bottom: 4px; }
.kpi-card__value { font-size: 24px; font-weight: 700; }
.kpi-card__change {
    display: inline-flex; align-items: center; gap: 3px;
    padding: 2px 8px; border-radius: 9999px;
    background: rgba(255,255,255,.2);
    font-size: 11px; font-weight: 600; margin-top: 8px;
}
.kpi-card__icon {
    position: absolute; bottom: -10px; inset-inline-end: 10px;
    font-size: 4.5rem; opacity: .15;
}

.dashboard-row {
    display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
}
@media (max-width: 700px) { .dashboard-row { grid-template-columns: 1fr; } }
.dashboard-panel {
    background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; padding: 14px;
}
.dashboard-panel h4 {
    margin: 0 0 12px; font-size: 14px; color: #0f172a;
    display: flex; align-items: center; gap: 8px;
}
.dashboard-panel__placeholder {
    background: #f8fafc; border-radius: 10px; min-height: 180px;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    color: #94a3b8;
}
.dashboard-panel__placeholder .las { font-size: 3rem; margin-bottom: 6px; }

/* ═════════════════════════════════════════════════════════════════════════
   Chart picker
   ═════════════════════════════════════════════════════════════════════════ */
.chart-type-picker { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chart-type-picker__btn {
    padding: 6px 12px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 12px; font-weight: 600; color: #475569; cursor: pointer;
    display: inline-flex; align-items: center; gap: 6px;
}
.chart-type-picker__btn:hover { border-color: #3b82f6; color: #3b82f6; }
.chart-type-picker__btn.active { background: #3b82f6; color: #fff; border-color: #3b82f6; }

.chart-card {
    background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; padding: 14px;
}
.chart-card__head {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px;
}
.chart-card__head h4 {
    margin: 0; font-size: 14px; color: #0f172a; display: flex; align-items: center; gap: 8px;
}
.chart-range {
    padding: 5px 10px; border: 1px solid #e2e8f0; border-radius: 6px;
    font-size: 12px; color: #475569; background: #fff;
}
.chart-card__body {
    min-height: 260px;
    background: #f8fafc; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
}
.chart-card__placeholder {
    text-align: center; color: #94a3b8;
}
.chart-card__placeholder .las { font-size: 3rem; display: block; margin-bottom: 6px; }
.chart-card__placeholder p    { margin: 0; font-size: 14px; }
.chart-card__placeholder small{ display:block; margin-top: 4px; font-size: 11px; }

/* ═════════════════════════════════════════════════════════════════════════
   Custom View
   ═════════════════════════════════════════════════════════════════════════ */
.custom-view__body {
    background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; padding: 20px;
    min-height: 240px;
}
.custom-view__placeholder {
    text-align: center; color: #64748b; padding: 24px;
}
.custom-view__placeholder .las { font-size: 3rem; color: #94a3b8; display:block; margin-bottom: 10px; }
.custom-view__placeholder h3   { margin: 0 0 8px; color: #0f172a; }
.custom-view__hint {
    display: block; text-align: start;
    background: #0f172a; color: #f1f5f9;
    padding: 12px 14px; border-radius: 8px;
    font-family: 'Fira Code', monospace; font-size: 12px;
    margin: 12px auto 0; max-width: 480px; overflow-x: auto;
    direction: ltr;
}

/* ═════════════════════════════════════════════════════════════════════════
   Card row & column views
   ═════════════════════════════════════════════════════════════════════════ */
.card-row-list {
    display: flex; flex-direction: column; gap: 10px;
}
.card-row {
    display: flex; align-items: stretch;
    background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; overflow: hidden;
    transition: transform .15s, box-shadow .15s;
}
.card-row:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0,0,0,.06);
    border-color: #cbd5e1;
}
.card-row__icon {
    width: 90px; min-height: 90px;
    display: flex; align-items: center; justify-content: center;
    color: #fff;
}
.card-row__icon .las { font-size: 2.4rem; }
.card-row__content { flex: 1; padding: 12px 16px; }
.card-row__title   { margin: 0 0 8px; font-size: 15px; color: #0f172a; }
.card-row__meta    { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: #475569; }
.card-row__meta-item small { color: #94a3b8; margin-inline-end: 4px; }
.card-row__meta-item strong { color: #1e293b; font-weight: 600; }
.card-row__actions {
    display: flex; align-items: center; padding: 0 14px; gap: 4px;
    border-inline-start: 1px solid #f1f5f9;
}

.card-column-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 14px;
}
.card-column {
    background: #fff; border: 1px solid #e2e8f0; border-radius: 12px;
    overflow: hidden; display: flex; flex-direction: column;
    transition: transform .15s, box-shadow .15s;
}
.card-column:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 24px rgba(0,0,0,.08);
    border-color: #cbd5e1;
}
.card-column__cover {
    height: 120px;
    display: flex; align-items: center; justify-content: center;
    color: #fff;
}
.card-column__cover .las { font-size: 3rem; opacity: .9; }
.card-column__body { flex: 1; padding: 12px 14px; }
.card-column__title { margin: 0 0 10px; font-size: 15px; color: #0f172a; }
.card-column__fields {
    list-style: none; margin: 0; padding: 0;
    display: flex; flex-direction: column; gap: 6px;
}
.card-column__fields li {
    display: flex; justify-content: space-between; align-items: center;
    font-size: 12px; color: #475569;
}
.card-column__fields li strong { color: #1e293b; font-weight: 600; }
.card-column__footer {
    padding: 8px 14px;
    border-top: 1px solid #f1f5f9;
    display: flex; justify-content: flex-end;
}

/* ── Print helpers ──────────────────────────────────────────────────────── */
@media print {
    .form-toolbar, .grid-toolbar__search, .grid-toolbar__limit,
    .modal-backdrop, .inline-form-panel__header {
        display: none !important;
    }
}

/* =============================================================================
   MINDEXIA OVERRIDES — reskins the ported FormType views with tokens
   ============================================================================= */

.mfv-container,
.mfv-toolbar,
.mfv-header,
.mfv-body {
    background: var(--mx-surface);
    color: var(--mx-text);
    border-color: var(--mx-border);
}

.mfv-title, .mfv-header h1, .mfv-header h2 { color: var(--mx-text-strong); }
.mfv-subtitle, .mfv-desc { color: var(--mx-text-muted); }

.mfv-toolbar {
    border: 1px solid var(--mx-border);
    border-radius: var(--mx-radius-md);
    padding: var(--mx-space-3) var(--mx-space-4);
}

.mfv-toolbar button {
    background: var(--mx-brand);
    color: var(--mx-text-inverse);
    border: none;
    padding: 0 var(--mx-space-4);
    height: var(--mx-control-h);
    border-radius: var(--mx-radius);
    font-family: inherit;
    font-weight: 500;
    transition: background var(--mx-t-fast);
}
.mfv-toolbar button:hover { background: var(--mx-brand-hover); }
.mfv-toolbar button.mfv-btn-outline,
.mfv-toolbar button.secondary {
    background: var(--mx-surface);
    color: var(--mx-brand);
    border: 1px solid var(--mx-border-strong);
}
.mfv-toolbar button.mfv-btn-outline:hover,
.mfv-toolbar button.secondary:hover {
    background: var(--mx-brand-soft);
    border-color: var(--mx-brand);
}

/* DataGridView table */
.mfv-datagrid table,
.datagrid-view table {
    width: 100%;
    border-collapse: collapse;
    background: var(--mx-surface);
    border: 1px solid var(--mx-border);
    border-radius: var(--mx-radius-md);
    overflow: hidden;
}
.mfv-datagrid th,
.datagrid-view th {
    background: var(--mx-brand);
    color: var(--mx-text-inverse);
    text-align: right;
    padding: var(--mx-space-3) var(--mx-space-4);
    font-weight: 600;
    font-size: var(--mx-fs-sm);
}
.mfv-datagrid td,
.datagrid-view td {
    padding: var(--mx-space-3) var(--mx-space-4);
    border-bottom: 1px solid var(--mx-border);
    color: var(--mx-text);
}
.mfv-datagrid tbody tr:nth-child(even) td,
.datagrid-view tbody tr:nth-child(even) td {
    background: var(--mx-surface-alt);
}
.mfv-datagrid tbody tr:hover td,
.datagrid-view tbody tr:hover td {
    background: var(--mx-surface-hover);
}

/* Cards / dashboard tiles */
.mfv-cards .mfv-card,
.mfv-dashboard .mfv-tile,
.dashboard-tile {
    background: var(--mx-surface);
    border: 1px solid var(--mx-border);
    border-radius: var(--mx-radius-lg);
    box-shadow: var(--mx-shadow-xs);
    padding: var(--mx-space-5);
    color: var(--mx-text);
}
.mfv-dashboard .mfv-tile:hover,
.dashboard-tile:hover {
    box-shadow: var(--mx-shadow-md);
    border-color: var(--mx-brand);
}
