/* AIAP admin portal theme (green). Built on Bootstrap 5. */
:root {
    --aiap-green: #1e7b4f;
    --aiap-green-dark: #155c3a;
    --aiap-green-light: #e8f4ee;
    --aiap-sidebar-width: 240px;
    --bs-link-color: var(--aiap-green);
    --bs-link-hover-color: var(--aiap-green-dark);
    --bs-link-color-rgb: 30, 123, 79;
    --bs-link-hover-color-rgb: 21, 92, 58;
}

.text-aiap { color: var(--aiap-green) !important; }

.btn-aiap {
    --bs-btn-color: #fff;
    --bs-btn-bg: var(--aiap-green);
    --bs-btn-border-color: var(--aiap-green);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--aiap-green-dark);
    --bs-btn-hover-border-color: var(--aiap-green-dark);
    --bs-btn-active-bg: var(--aiap-green-dark);
    --bs-btn-active-border-color: var(--aiap-green-dark);
    --bs-btn-focus-shadow-rgb: 30, 123, 79;
}

/* Required field marker: <span class="aiap-req" title="Required">*</span> after the label text */
.aiap-req { color: #dc3545; font-weight: 600; margin-left: .15rem; }

.form-control:focus, .form-select:focus {
    border-color: #7cbf9d;
    box-shadow: 0 0 0 .2rem rgba(30, 123, 79, .2);
}

/* ---- Logged-in layout ---- */
.app-body { background: #f4f6f5; }

.app-topbar {
    background: var(--aiap-green);
    min-height: 56px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .15);
}
.app-brand-sub { font-weight: 400; opacity: .8; font-size: .9rem; }

.app-shell { display: flex; min-height: calc(100vh - 56px); }

.app-sidebar { background: #fff; border-right: 1px solid #e3e7e5; }
@media (min-width: 992px) {
    .app-sidebar {
        width: var(--aiap-sidebar-width);
        flex: 0 0 var(--aiap-sidebar-width);
        position: sticky;
        top: 56px;
        height: calc(100vh - 56px);
        overflow-y: auto;
    }
}
.app-sidebar .nav-link {
    color: #34423b;
    padding: .55rem 1.25rem;
    border-left: 3px solid transparent;
}
.app-sidebar .nav-link:hover { background: var(--aiap-green-light); color: var(--aiap-green-dark); }
.app-sidebar .nav-link.active {
    background: var(--aiap-green-light);
    color: var(--aiap-green-dark);
    border-left-color: var(--aiap-green);
    font-weight: 600;
}
/* Estate sub-menu (shown on the pages of one estate) */
.app-sidebar .nav-estate-title {
    padding: .35rem 1.25rem .2rem 2.6rem;
    font-size: .78rem;
    font-weight: 600;
    color: var(--aiap-green-dark);
}
.app-sidebar .nav-estate .nav-link { padding: .35rem 1.25rem .35rem 2.6rem; font-size: .92rem; }
.app-sidebar .nav-section {
    padding: 1rem 1.25rem .35rem;
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #8a958f;
}

.app-main { flex: 1 1 auto; min-width: 0; padding: 1.5rem; }
@media (max-width: 575.98px) { .app-main { padding: 1rem; } }

.card { border-color: #e3e7e5; }

/* ---- Audit Trail ---- */
.audit-details { max-width: 28rem; }
.audit-details summary { cursor: pointer; }

/* ---- Permissions card ---- */
.grant-companies { max-height: 14rem; overflow-y: auto; background: #fafcfb; }

/* ---- Password rules checklist ---- */
.password-rules li { color: #6c757d; margin-bottom: .15rem; }
.password-rules li i { margin-right: .35rem; }
.password-rules li.ok { color: var(--aiap-green); }

/* ---- Two-factor ---- */
.otp-input { letter-spacing: .35em; font-variant-numeric: tabular-nums; }
.otp-boxes { display: flex; justify-content: center; align-items: center; gap: .5rem; max-width: 100%; }
.otp-box {
    flex: 0 1 3rem; min-width: 1.9rem; height: 3.5rem; padding: 0;   /* shrink to fit narrow columns */
    text-align: center; font-size: 1.6rem; font-weight: 600; font-variant-numeric: tabular-nums;
    caret-color: var(--aiap-green);
}
.otp-box:focus { border-color: var(--aiap-green); box-shadow: 0 0 0 .2rem rgba(30, 123, 79, .25); }
.setup-steps .otp-boxes { gap: .35rem; }
@media (max-width: 400px) {
    .otp-boxes { gap: .3rem; }
    .otp-box { height: 3rem; font-size: 1.35rem; }
}
.auth-wrapper.auth-wrapper-wide { max-width: 720px; }   /* beats .auth-wrapper below */
.setup-steps .setup-code, .setup-steps .setup-qr { max-width: 420px; margin-left: auto; margin-right: auto; }
.setup-steps { padding-left: 1.2rem; }
.setup-steps > li { margin-bottom: 1.25rem; }
.setup-steps > li::marker { font-weight: 600; color: var(--aiap-green); }
.qr-box { width: 200px; max-width: 100%; border: 1px solid #e3e7e5; border-radius: .5rem; padding: .5rem; background: #fff; }
.qr-box svg { display: block; width: 100%; height: auto; }
.manual-key {
    font-family: SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 1rem; letter-spacing: .05em; word-break: break-all;
    background: #f4f6f5; border-radius: .375rem; padding: .5rem .75rem;
}
.recovery-codes {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem;
    background: #f4f6f5; border-radius: .5rem; padding: 1rem;
}
.recovery-codes code { font-size: 1.05rem; color: #1f2a24; text-align: center; letter-spacing: .05em; }
/* A checkbox in a bordered box (e.g. roles on the user form): the same gap left of the box as on the right */
.form-check-card { padding: .6rem .75rem .6rem 2.4rem; min-height: 0; }
.form-check-card .form-check-input { margin-left: -1.65rem; margin-top: .2rem; }

@media print {
    .app-topbar, .app-sidebar, .btn, .form-check, hr, .alert { display: none !important; }
    .app-main { padding: 0; }
}

/* ---- Login / error pages ---- */
.auth-body {
    min-height: 100vh;
    background: linear-gradient(160deg, var(--aiap-green-dark) 0%, var(--aiap-green) 45%, #6fae6a 100%);
}
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 1rem;
    max-width: 440px;
    margin: 0 auto;
}
.auth-card { border: 0; border-radius: .75rem; }
.auth-wrapper > p { color: rgba(255, 255, 255, .8) !important; }

/* ---- Maps (Leaflet) ---- */
.aiap-map { height: 380px; border-radius: .5rem; border: 1px solid #dfe5e2; z-index: 0; }
.aiap-map-sm { height: 260px; }
.leaflet-container { font: inherit; }

/* Upper-case code fields: keep the example text (placeholder) in normal case. */
.text-uppercase::placeholder { text-transform: none; }

/* ---- Boundary editor ---- */
.aiap-map-lg { height: 560px; }
@media (max-width: 767.98px) { .aiap-map-lg { height: 420px; } }
.aiap-map-drawing { cursor: crosshair; }
.aiap-map-drawing .leaflet-interactive { cursor: crosshair; }
.aiap-vertex { background: #fff; border: 3px solid #ffcc00; border-radius: 50%; box-shadow: 0 0 3px rgba(0, 0, 0, .6); }
.aiap-vertex-first { background: #ffcc00; border-color: #fff; }
.aiap-vertex-mid { background: rgba(255, 255, 255, .7); border: 2px solid #ffcc00; border-radius: 50%; }
/* a plot being drawn is cyan, so it stands apart from the yellow estate outline */
.aiap-vertex.aiap-vertex-plot, .aiap-vertex-mid.aiap-vertex-plot { border-color: #00e5ff; }
.aiap-vertex-first.aiap-vertex-plot { background: #00e5ff; border-color: #fff; }
.aiap-legend-swatch { display: inline-block; width: .9rem; height: .9rem; border-radius: .2rem; vertical-align: -.1rem; margin-right: .25rem; }
.leaflet-tooltip.aiap-plot-label { background: transparent; border: 0; box-shadow: none; color: #fff; font-weight: 600; text-shadow: 0 0 3px #000, 0 0 2px #000; padding: 0; }
.leaflet-tooltip.aiap-plot-label::before { display: none; }
