/* ==========================================================================
   Enterprise Inspection System — Application theme
   Clean, light SaaS dashboard aesthetic: white surfaces, soft borders,
   blue accent, generous spacing. Fully responsive / mobile-friendly.
   ========================================================================== */

:root {
    --eai-bg: #f7f8fa;
    --eai-surface: #ffffff;
    --eai-border: #e8eaed;
    --eai-border-strong: #dcdfe4;
    --eai-text: #1a1d21;
    --eai-muted: #6b7280;
    --eai-muted-soft: #9ca3af;
    --eai-primary: #3b82f6;
    --eai-primary-600: #2563eb;
    --eai-primary-700: #1d4ed8;
    --eai-primary-soft: #eaf2ff;
    --eai-success: #22c55e;
    --eai-success-soft: #e7f8ee;
    --eai-success-text: #15803d;
    --eai-danger: #ef4444;
    --eai-danger-soft: #fdecec;
    --eai-radius: 12px;
    --eai-radius-sm: 9px;
    --eai-radius-lg: 16px;
    --eai-shadow-xs: 0 1px 2px rgba(16, 24, 40, .04);
    --eai-shadow-sm: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
    --eai-shadow-md: 0 6px 16px rgba(16, 24, 40, .08);
    --eai-sidebar-w: 264px;
    --eai-topbar-h: 64px;
}

/* --------------------------------------------------------------------------
   Base
   -------------------------------------------------------------------------- */
body.eai {
    background: var(--eai-bg);
    color: var(--eai-text);
    font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

.eai h1, .eai h2, .eai h3, .eai h4, .eai h5 {
    color: var(--eai-text);
    letter-spacing: -.015em;
}

.eai a { text-decoration: none; }

.eai-muted { color: var(--eai-muted) !important; }
.eai-page-title { font-size: 1.6rem; font-weight: 700; margin: 0; }
.eai-page-sub { color: var(--eai-muted); font-size: .85rem; margin: .15rem 0 0; }

/* --------------------------------------------------------------------------
   App shell
   -------------------------------------------------------------------------- */
.eai-shell { min-height: 100vh; }

.eai-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--eai-sidebar-w);
    background: var(--eai-surface);
    border-right: 1px solid var(--eai-border);
    display: flex;
    flex-direction: column;
    z-index: 1045;
    transition: transform .25s ease;
}

.eai-brand {
    display: flex;
    align-items: center;
    gap: .65rem;
    height: var(--eai-topbar-h);
    padding: 0 1.25rem;
    border-bottom: 1px solid var(--eai-border);
    font-weight: 700;
    font-size: 1rem;
    color: var(--eai-text);
}

.eai-brand-mark {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    background: linear-gradient(135deg, var(--eai-primary), var(--eai-primary-700));
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex: none;
}

.eai-nav {
    flex: 1;
    overflow-y: auto;
    padding: 1rem .75rem 1.5rem;
}

.eai-nav-label {
    font-size: .68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .09em;
    color: var(--eai-muted-soft);
    padding: 1.1rem .75rem .4rem;
}

.eai-nav-link {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .55rem .75rem;
    border-radius: var(--eai-radius-sm);
    color: #374151;
    font-weight: 500;
    font-size: .875rem;
    margin-bottom: .1rem;
    transition: background .15s ease, color .15s ease;
}

.eai-nav-link i { font-size: 1.05rem; color: var(--eai-muted); transition: color .15s ease; }
.eai-nav-link:hover { background: #f3f4f6; color: var(--eai-text); }
.eai-nav-link:hover i { color: var(--eai-text); }

.eai-nav-link.active {
    background: var(--eai-primary-soft);
    color: var(--eai-primary-600);
    font-weight: 600;
}
.eai-nav-link.active i { color: var(--eai-primary-600); }

.eai-nav-foot {
    padding: .75rem;
    border-top: 1px solid var(--eai-border);
}

/* Main column */
.eai-main {
    margin-left: var(--eai-sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.eai-topbar {
    height: var(--eai-topbar-h);
    background: var(--eai-surface);
    border-bottom: 1px solid var(--eai-border);
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 1030;
}

.eai-content { padding: 1.75rem 1.5rem 3rem; flex: 1; }

.eai-toggle {
    border: 0;
    background: transparent;
    color: var(--eai-muted);
    font-size: 1.35rem;
    line-height: 1;
    padding: .25rem;
    border-radius: 8px;
}
.eai-toggle:hover { background: #f3f4f6; color: var(--eai-text); }

.eai-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--eai-text);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: .8rem;
    flex: none;
}

.eai-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, .4);
    z-index: 1040;
    display: none;
}
.eai-backdrop.show { display: block; }

@media (max-width: 991.98px) {
    .eai-sidebar { transform: translateX(-100%); box-shadow: var(--eai-shadow-md); }
    .eai-sidebar.show { transform: translateX(0); }
    .eai-main { margin-left: 0; }
    .eai-content { padding: 1.25rem 1rem 3rem; }
    .eai-topbar { padding: 0 1rem; }
}

/* --------------------------------------------------------------------------
   Cards
   -------------------------------------------------------------------------- */
.eai-card {
    background: var(--eai-surface);
    border: 1px solid var(--eai-border);
    border-radius: var(--eai-radius);
    box-shadow: var(--eai-shadow-xs);
}

.eai-card-header {
    background: var(--eai-surface);
    border-bottom: 1px solid var(--eai-border);
    padding: 1rem 1.25rem;
    font-weight: 600;
    border-radius: var(--eai-radius) var(--eai-radius) 0 0;
}

.eai-card-body { padding: 1.25rem; }
.eai-card-footer {
    background: var(--eai-surface);
    border-top: 1px solid var(--eai-border);
    padding: .9rem 1.25rem;
    border-radius: 0 0 var(--eai-radius) var(--eai-radius);
}

/* Feature / action card (reference dashboard style) */
.eai-feature {
    background: var(--eai-surface);
    border: 1px solid var(--eai-border);
    border-radius: var(--eai-radius);
    box-shadow: var(--eai-shadow-xs);
    padding: 1.35rem;
    height: 100%;
    display: flex;
    flex-direction: column;
    transition: box-shadow .18s ease, transform .18s ease;
}
.eai-feature:hover { box-shadow: var(--eai-shadow-md); transform: translateY(-1px); }

.eai-feature-icon {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    background: var(--eai-primary-soft);
    color: var(--eai-primary-600);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    margin-bottom: 1rem;
}
.eai-feature-icon.is-green { background: var(--eai-success-soft); color: var(--eai-success-text); }
.eai-feature-icon.is-purple { background: #f0ecff; color: #7c3aed; }
.eai-feature-icon.is-amber { background: #fff5e6; color: #c2740a; }

.eai-feature-title { font-size: 1rem; font-weight: 700; margin: 0 0 .35rem; }
.eai-feature-text { color: var(--eai-muted); font-size: .85rem; line-height: 1.55; margin: 0 0 1rem; flex: 1; }

/* Stat card */
.eai-stat {
    background: var(--eai-surface);
    border: 1px solid var(--eai-border);
    border-radius: var(--eai-radius);
    padding: 1.15rem 1.25rem;
    box-shadow: var(--eai-shadow-xs);
    height: 100%;
}
.eai-stat-label { color: var(--eai-muted); font-size: .78rem; font-weight: 500; margin-bottom: .35rem; }
.eai-stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1.1; }
.eai-stat-icon {
    width: 40px; height: 40px; border-radius: 10px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 1.1rem; flex: none;
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn { border-radius: 9px; font-weight: 500; font-size: .875rem; padding: .5rem .95rem; }
.btn-sm { padding: .32rem .65rem; font-size: .8rem; border-radius: 8px; }
.btn-lg { padding: .7rem 1.25rem; font-size: .95rem; }

.btn-primary {
    background: var(--eai-primary);
    border-color: var(--eai-primary);
    box-shadow: 0 1px 2px rgba(37, 99, 235, .25);
}
.btn-primary:hover, .btn-primary:focus,
.btn-primary:not(:disabled):not(.disabled):active {
    background: var(--eai-primary-600);
    border-color: var(--eai-primary-600);
}

.btn-outline-primary { color: var(--eai-primary-600); border-color: #c7dbff; background: #fff; }
.btn-outline-primary:hover { background: var(--eai-primary-soft); color: var(--eai-primary-700); border-color: #aecbff; }

.btn-success { background: var(--eai-success); border-color: var(--eai-success); }
.btn-success:hover { background: #16a34a; border-color: #16a34a; }

.btn-outline-secondary { color: #4b5563; border-color: var(--eai-border-strong); background: #fff; }
.btn-outline-secondary:hover { background: #f3f4f6; color: var(--eai-text); border-color: var(--eai-border-strong); }

.btn-outline-danger { color: var(--eai-danger); border-color: #f6c9c9; background: #fff; }
.btn-outline-danger:hover { background: var(--eai-danger-soft); color: #b91c1c; border-color: #f0b4b4; }

/* Status pill button (reference "Done" button) */
.eai-pill {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    background: var(--eai-success-soft);
    color: var(--eai-success-text);
    border: 1px solid #cdeed9;
    border-radius: 999px;
    padding: .32rem .8rem;
    font-size: .8rem;
    font-weight: 600;
}

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */
.form-label { font-weight: 500; font-size: .82rem; color: #374151; margin-bottom: .35rem; }
.form-text { font-size: .78rem; color: var(--eai-muted); }
.form-control, .form-select {
    border-radius: var(--eai-radius-sm);
    border-color: var(--eai-border-strong);
    font-size: .875rem;
    padding: .5rem .75rem;
    color: var(--eai-text);
}
.form-control::placeholder { color: #9aa1ab; }
.form-control:focus, .form-select:focus {
    border-color: #a9c7ff;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, .14);
}
.form-control-sm, .form-select-sm { font-size: .8rem; padding: .35rem .6rem; border-radius: 8px; }
.input-group-text { background: #f9fafb; border-color: var(--eai-border-strong); color: var(--eai-muted); border-radius: var(--eai-radius-sm); }
.form-check-input:checked { background-color: var(--eai-primary); border-color: var(--eai-primary); }
.form-check-input:focus { border-color: #a9c7ff; box-shadow: 0 0 0 3px rgba(59, 130, 246, .14); }

/* --------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */
.table { font-size: .85rem; margin-bottom: 0; color: var(--eai-text); }
.table > thead th {
    background: #fbfcfd;
    color: var(--eai-muted);
    font-weight: 600;
    font-size: .74rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    border-bottom: 1px solid var(--eai-border);
    white-space: nowrap;
    padding: .7rem .85rem;
}
.table > tbody td { padding: .8rem .85rem; border-color: #f1f3f5; vertical-align: middle; }
.table-hover > tbody > tr:hover > * { background: #fafbfc; }
.table-striped > tbody > tr:nth-of-type(odd) > * { background: #fcfcfd; }
.table thead a { color: var(--eai-muted); font-weight: 600; }
.table thead a:hover { color: var(--eai-primary-600); }

.eai-table-wrap { border-radius: 0 0 var(--eai-radius) var(--eai-radius); overflow: hidden; }

/* --------------------------------------------------------------------------
   Badges
   -------------------------------------------------------------------------- */
.badge { font-weight: 600; border-radius: 999px; padding: .32em .6em; font-size: .7rem; }
.text-bg-light { background: #f3f4f6 !important; color: #4b5563 !important; }
.text-bg-success { background: var(--eai-success-soft) !important; color: var(--eai-success-text) !important; }
.text-bg-secondary { background: #f0f1f3 !important; color: #6b7280 !important; }
.text-bg-primary { background: var(--eai-primary-soft) !important; color: var(--eai-primary-600) !important; }
.text-bg-danger { background: var(--eai-danger-soft) !important; color: #b91c1c !important; }
.text-bg-info { background: #e6f4ff !important; color: #0b6bcb !important; }
.border { border-color: var(--eai-border) !important; }

/* --------------------------------------------------------------------------
   Pagination
   -------------------------------------------------------------------------- */
.pagination { gap: .2rem; }
.page-link {
    border: 1px solid var(--eai-border);
    border-radius: 8px;
    color: #4b5563;
    font-size: .82rem;
    padding: .38rem .68rem;
    min-width: 34px;
    text-align: center;
}
.page-link:hover { background: #f3f4f6; color: var(--eai-text); border-color: var(--eai-border); }
.page-item.active .page-link { background: var(--eai-primary); border-color: var(--eai-primary); color: #fff; }
.page-item.disabled .page-link { color: #c1c5cb; background: #fbfbfc; }

/* --------------------------------------------------------------------------
   Alerts
   -------------------------------------------------------------------------- */
.alert { border-radius: var(--eai-radius-sm); border: 1px solid transparent; font-size: .85rem; }
.alert-danger { background: var(--eai-danger-soft); border-color: #f7d4d4; color: #b91c1c; }
.alert-success { background: var(--eai-success-soft); border-color: #cdeed9; color: var(--eai-success-text); }
.alert-warning { background: #fff8ec; border-color: #f6e3c2; color: #a1620a; }
.alert-info { background: #eef5ff; border-color: #d6e6ff; color: #1d4ed8; }

/* --------------------------------------------------------------------------
   Modals
   -------------------------------------------------------------------------- */
.modal-content { border: 0; border-radius: var(--eai-radius-lg); box-shadow: 0 22px 48px rgba(16,24,40,.18); }
.modal-header { border-bottom: 1px solid var(--eai-border); padding: 1.15rem 1.35rem; }
.modal-title { font-weight: 700; font-size: 1.02rem; }
.modal-body { padding: 1.35rem; }
.modal-footer { border-top: 1px solid var(--eai-border); padding: .9rem 1.35rem; }

/* --------------------------------------------------------------------------
   Login screen
   -------------------------------------------------------------------------- */
.eai-auth-bg {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background:
        radial-gradient(1200px 600px at 100% 0%, #eef4ff 0%, transparent 55%),
        radial-gradient(900px 500px at 0% 100%, #f5f0ff 0%, transparent 55%),
        var(--eai-bg);
}
.eai-auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--eai-surface);
    border: 1px solid var(--eai-border);
    border-radius: var(--eai-radius-lg);
    box-shadow: var(--eai-shadow-md);
    padding: 2.25rem;
}
@media (max-width: 575.98px) { .eai-auth-card { padding: 1.6rem; } }

/* --------------------------------------------------------------------------
   Bootstrap compatibility (legacy markup)
   -------------------------------------------------------------------------- */
.eai .card {
    background: var(--eai-surface);
    border: 1px solid var(--eai-border);
    border-radius: var(--eai-radius);
    box-shadow: var(--eai-shadow-xs);
}
.eai .card-header {
    background: var(--eai-surface);
    border-bottom: 1px solid var(--eai-border);
    padding: 1rem 1.25rem;
    font-weight: 600;
    color: var(--eai-text);
}
.eai .card-footer { background: var(--eai-surface); border-top: 1px solid var(--eai-border); }
.eai .text-muted { color: var(--eai-muted) !important; }
.eai .bg-white { background: var(--eai-surface) !important; }
.eai h2.h4, .eai h2 { font-weight: 700; }
.eai code { color: #374151; }

/* Empty state */
.eai-empty { text-align: center; color: var(--eai-muted); padding: 2.5rem 1rem; }

/* --------------------------------------------------------------------------
   Checklist (touch-friendly toggle chips) — capture form
   -------------------------------------------------------------------------- */
.eai-checklist {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
}
.eai-check-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;              /* comfortable touch target */
    padding: .5rem 1rem;
    border: 1px solid var(--eai-border-strong);
    border-radius: 999px;
    background: #fff;
    color: #374151;
    font-size: .875rem;
    font-weight: 500;
    cursor: pointer;
    user-select: none;
    transition: background .15s ease, border-color .15s ease, color .15s ease;
    margin: 0;
}
.eai-check-chip:hover { border-color: #aecbff; background: #f7faff; }
.btn-check:checked + .eai-check-chip {
    background: var(--eai-primary-soft);
    border-color: var(--eai-primary);
    color: var(--eai-primary-700);
    font-weight: 600;
}
.btn-check:focus-visible + .eai-check-chip {
    outline: 0;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, .2);
}
.btn-check:disabled + .eai-check-chip { opacity: .55; cursor: not-allowed; }

/* --------------------------------------------------------------------------
   Dynamic field builder (uniform grid)
   -------------------------------------------------------------------------- */
.field-row .field-col .form-label {
    font-size: .78rem;
    font-weight: 500;
    margin-bottom: .35rem;
    min-height: 1.1rem;
}
.field-row .form-control-sm,
.field-row .form-select-sm {
    height: 34px;
    line-height: 1.2;
}
.field-row .form-check-input {
    margin-top: 0;
    width: 2.2em;
    height: 1.15em;
}
/* Align the required switch with the input boxes in the row above. */
.field-row .form-check.form-switch {
    min-height: 34px;
    padding-left: 2.6em;
}
.field-row .remove-field { font-size: .8rem; }
.field-row .field-handle:hover { color: var(--eai-primary) !important; }
.field-row .field-footer { border-color: var(--eai-border) !important; }
.field-row.dragging { opacity: .5; }

/* --------------------------------------------------------------------------
   Utilities
   -------------------------------------------------------------------------- */
.eai-empty { text-align: center; color: var(--eai-muted); padding: 2.5rem 1rem; }
.eai-divider { height: 1px; background: var(--eai-border); border: 0; margin: 1rem 0; opacity: 1; }
.eai-code {
    background: #f3f4f6;
    color: #374151;
    border-radius: 6px;
    padding: .12rem .4rem;
    font-size: .78rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* Sidebar section separation (reference style) */
.eai-nav-group { margin-bottom: .35rem; }

@media print {
    .eai-sidebar, .eai-topbar, .btn, .pagination { display: none !important; }
    .eai-main { margin-left: 0; }
}
