/* ==========================================================================
   AfriDev Monitor — modern admin skin
   Loaded after style.css + custom.css. Goals: large readable type, strong
   contrast (WCAG AA+), big click targets, calm brand colours (green + gold).
   ========================================================================== */

body {
    --am-primary: #1b6b46;
    --am-primary-hover: #13553a;
    --am-primary-soft: #e6f2ec;
    --am-accent: #e3a321;
    --am-danger: #b42318;
    --am-bg: #f2f4f3;
    --am-surface: #ffffff;
    --am-surface-2: #f7f9f8;
    --am-text: #18212b;
    --am-text-muted: #4a5561;
    --am-border: #d3d9d6;
    --am-border-strong: #8a948f;
    --am-sidebar: #0f241a;
    --am-sidebar-hover: #1a3a2a;
    --am-sidebar-text: #e9f0ec;
    --am-sidebar-muted: #9fb3a8;
    --am-focus: #f5b82e;
    --am-radius: 12px;
    --am-radius-sm: 8px;
    --am-shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
    --am-header-h: 76px;
    --am-sidebar-w: 280px;
    --am-font: "Atkinson Hyperlegible", "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
}

body.am-dark {
    --am-primary: #3fae7a;
    --am-primary-hover: #56c18e;
    --am-primary-soft: #183326;
    --am-bg: #0f1512;
    --am-surface: #18211c;
    --am-surface-2: #1e2923;
    --am-text: #eef2f0;
    --am-text-muted: #b5c0ba;
    --am-border: #2d3b34;
    --am-border-strong: #5b6b63;
    --am-sidebar: #0a120e;
    --am-sidebar-hover: #183326;
}

/* ---------- Base typography ---------- */
body,
button,
input,
select,
textarea,
.btn,
.dropdown-menu,
table {
    font-family: var(--am-font);
}

body {
    font-size: 17px;
    line-height: 1.6;
    color: var(--am-text);
    background-color: var(--am-bg);
}

h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6,
.black, .bold.black {
    color: var(--am-text);
    font-weight: 700;
    letter-spacing: -0.01em;
}

p, li, td, label, small, .text-muted, .font-12, .font-13, .font-14 {
    color: inherit;
}

.font-12, .font-13, small, .small { font-size: 15px !important; }
.font-14 { font-size: 16px !important; }
.text-muted { color: var(--am-text-muted) !important; }

a { color: var(--am-primary); text-underline-offset: 3px; }
a:hover { color: var(--am-primary-hover); }

::selection { background-color: var(--am-accent); color: #111; }

/* Highly visible keyboard focus everywhere */
a:focus-visible,
button:focus-visible,
.btn:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
    outline: 3px solid var(--am-focus) !important;
    outline-offset: 2px !important;
    box-shadow: none !important;
}

/* ---------- Header ---------- */
.header {
    height: var(--am-header-h);
    background: var(--am-surface) !important;
    border-bottom: 1px solid var(--am-border);
    box-shadow: none !important;
}

.header .main-header {
    height: var(--am-header-h);
    box-shadow: none !important;
    background: var(--am-surface);
}

.header .logo { background-color: var(--am-sidebar) !important; }

@media (min-width: 1024px) {
    .header .logo { flex-basis: var(--am-sidebar-w); }
}

/* Mid widths: the user block sits in a narrow col-lg-1, so drop text that would overflow. */
@media (min-width: 1024px) and (max-width: 1279px) {
    .header .main-header-date-time,
    .header .user-info { display: none !important; }
    .header .main-header-right .nav { flex-wrap: nowrap; }
}

@media (max-width: 1023px) {
    .header .logo { flex-basis: 76px; }
    .header .logo .mobile-logo img { max-width: 60px; max-height: 48px; object-fit: contain; }
    .header .main-header-right .nav { flex-wrap: nowrap; }
    .header .main-header-right .btn.am-btn-ghost,
    .header .main-header-right .btn.am-btn-logout { min-width: 46px; padding: 8px 10px !important; }
}

.header .logo img { max-height: 54px; width: auto; }

.header .user-avatar img {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--am-border);
}

.header .user-info .user-name {
    font-size: 18px;
    color: var(--am-text);
    margin-bottom: 0;
}

.header .user-info .user-email {
    font-size: 15px;
    color: var(--am-text-muted);
    margin: 0;
}

.header .main-header-date-time .time {
    font-size: 22px;
    color: var(--am-text);
    font-family: var(--am-font);
}

.header .main-header-date-time .date {
    font-size: 15px;
    color: var(--am-text-muted);
}

.header .main-header-right .nav {
    align-items: center;
    gap: 4px;
}

.header .main-header-right .nav > li { align-items: center; }

.header .dropdown-menu a {
    display: block;
    padding: 12px 18px;
    font-size: 17px;
    color: var(--am-text);
}

.header .dropdown-menu a:hover { background: var(--am-primary-soft); }

/* Header text buttons */
.btn.am-btn-ghost,
.btn.am-btn-logout {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--am-surface) !important;
    color: var(--am-text) !important;
    border: 2px solid var(--am-border) !important;
    min-height: 46px;
    padding: 8px 16px !important;
    font-size: 16px !important;
}

.btn.am-btn-ghost:hover {
    border-color: var(--am-primary) !important;
    color: var(--am-primary) !important;
}

.btn.am-btn-logout {
    color: var(--am-danger) !important;
}

.btn.am-btn-logout:hover {
    background: #fdecea !important;
    border-color: var(--am-danger) !important;
}

.am-dark .btn.am-btn-logout:hover { background: #3a1714 !important; }

.btn.am-btn-ghost i,
.btn.am-btn-logout i { font-size: 20px; }

/* ---------- Sidebar ---------- */
.sidebar {
    background-color: var(--am-sidebar) !important;
    inset-block-start: var(--am-header-h);
    height: calc(100% - var(--am-header-h));
}

body.sidebar-open .sidebar {
    inset-block-start: var(--am-header-h);
    height: calc(100% - var(--am-header-h));
}

@media (min-width: 1024px) {
    body:not(.sidebar-folded) .sidebar,
    body.sidebar-folded.open-sidebar-folded .sidebar {
        width: var(--am-sidebar-w);
    }
}

@media (max-width: 1023px) {
    .sidebar { width: var(--am-sidebar-w); }
}

/* Pin/fold toggle removed: the menu always stays open on large screens */
.sidebar .sidebar-header { display: none !important; }

.sidebar .sidebar-body { padding: 16px 14px 120px; }

.sidebar .sidebar-body li {
    padding-left: 0;
    margin-bottom: 2px;
}

.sidebar .sidebar-body li.nav-category {
    margin: 22px 10px 8px;
    font-size: 13px !important;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--am-sidebar-muted);
}

.sidebar .sidebar-body li a {
    display: flex;
    align-items: center;
    gap: 14px;
    height: auto;
    min-height: 48px;
    padding: 10px 40px 10px 14px;
    border-radius: 10px;
    font-size: 17px;
    line-height: 1.3;
    color: var(--am-sidebar-text) !important;
    overflow: visible;
    white-space: normal;
    transition: background-color .15s ease;
}

.sidebar .sidebar-body li i {
    position: static;
    flex: 0 0 24px;
    text-align: center;
    font-size: 20px;
    color: var(--am-sidebar-muted);
}

.sidebar .sidebar-body li > a:hover {
    background-color: var(--am-sidebar-hover);
    color: #fff !important;
}

.sidebar .sidebar-body li:hover > a i,
.sidebar .sidebar-body li.active > a i { color: var(--am-accent); }

/* Current page: gold bar + highlighted row */
.sidebar .sidebar-body > ul > li.active > a {
    background-color: var(--am-sidebar-hover);
    color: #fff !important;
    font-weight: 700;
    box-shadow: inset 4px 0 0 var(--am-accent);
}

/* Submenu */
.sidebar .sidebar-body ul ul,
.sidebar .sidebar-body ul.sub-menu {
    padding-left: 0;
    margin: 4px 0 8px 25px;
    border-left: 2px solid rgba(255, 255, 255, .14);
}

.sidebar .sidebar-body ul.sub-menu li { padding-left: 0; }
.sidebar .sidebar-body ul.sub-menu li:before { display: none; }

.sidebar .sidebar-body ul.sub-menu li a {
    min-height: 44px;
    margin-left: 8px;
    padding: 8px 36px 8px 14px;
    font-size: 16px;
    color: #d3ded8 !important;
}

.sidebar .sidebar-body ul.sub-menu li.active > a {
    color: #fff !important;
    font-weight: 700;
    background-color: rgba(227, 163, 33, .16);
}

/* Chevron instead of +/- */
.sidebar .sidebar-body li.has-sub-item:after,
.sidebar .sidebar-body li.has-sub-item.sub-menu-opened:after {
    background-image: none;
    width: 9px;
    height: 9px;
    top: 19px;
    right: 18px;
    z-index: 1;
    pointer-events: none;
    border-right: 2px solid var(--am-sidebar-muted);
    border-bottom: 2px solid var(--am-sidebar-muted);
    transform: rotate(-45deg);
    transition: transform .15s ease;
}

.sidebar .sidebar-body li.has-sub-item.sub-menu-opened:after {
    transform: rotate(45deg);
    top: 17px;
}

.sidebar .badge { font-size: 12px; padding: 4px 7px; }

/* ---------- Main content ---------- */
.main-content { margin-top: calc(var(--am-header-h) + 28px); }
body.sidebar-open .main-content { margin-top: calc(var(--am-header-h) + 28px); }

@media (min-width: 1024px) {
    body:not(.sidebar-folded) .main-content { margin-left: calc(var(--am-sidebar-w) + 12px); }
    body:not(.sidebar-folded) .main-content > .container-fluid { padding: 0 28px; }
    body:not(.sidebar-folded) .footer { padding-left: calc(var(--am-sidebar-w) + 40px); }
}

.footer {
    background-color: transparent;
    color: var(--am-text-muted);
    font-size: 15px;
}

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

.card .card-header {
    background: transparent;
    border-bottom: 1px solid var(--am-border);
    padding: 20px 24px;
}

.card .card-header h3,
.card .card-header h4,
.card .card-header .font-24,
.card .card-header .font-20 {
    font-size: 24px !important;
    margin: 0;
    color: var(--am-text);
}

.card .card-body { padding: 24px; }

.mb-30 { margin-bottom: 28px !important; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px;
    padding: 10px 22px;
    font-size: 17px;
    font-weight: 700;
    line-height: 1.2;
    border-radius: var(--am-radius-sm);
    border: 2px solid transparent;
    text-transform: none;
    letter-spacing: 0;
    box-shadow: none !important;
}

.btn:not([class*="btn-"]):not(.am-btn-ghost):not(.am-btn-logout),
.btn.btn-primary {
    background-color: var(--am-primary);
    color: #fff;
}

.btn:not([class*="btn-"]):not(.am-btn-ghost):not(.am-btn-logout):hover,
.btn.btn-primary:hover {
    background-color: var(--am-primary-hover);
    color: #fff;
}

.btn.sm,
.btn-sm {
    min-height: 40px;
    padding: 6px 14px;
    font-size: 15px;
}

.btn.long { padding-left: 28px; padding-right: 28px; }

/* Darker variants so white text passes contrast */
.btn.btn-dark { background-color: #26313b !important; border-color: #26313b !important; color: #fff !important; }
.btn.btn-success { background-color: #1b7a4a !important; border-color: #1b7a4a !important; color: #fff !important; }
.btn.btn-info { background-color: #0b6aa2 !important; border-color: #0b6aa2 !important; color: #fff !important; }
.btn.btn-warning { background-color: #f1b52d !important; border-color: #f1b52d !important; color: #1c1c1c !important; }
.btn.btn-danger { background-color: var(--am-danger) !important; border-color: var(--am-danger) !important; color: #fff !important; }
.btn.btn-dark:hover, .btn.btn-success:hover, .btn.btn-info:hover,
.btn.btn-warning:hover, .btn.btn-danger:hover { filter: brightness(.9); }

.btn-outline-primary { color: var(--am-primary); border-color: var(--am-primary); }
.btn-outline-primary:hover { background: var(--am-primary); color: #fff; }

/* Outline variant from style.css (.btn.btn-{colour}.btn-border). Same specificity as the
   solid !important rules above but later in the file, so it wins. Text colours meet AA on white. */
.btn.btn-border { --am-outline: var(--am-primary); background-color: transparent !important; border-color: var(--am-outline) !important; color: var(--am-outline) !important; }
.btn.btn-border.btn-secondary { --am-outline: var(--am-text-muted); }
.btn.btn-border.btn-dark { --am-outline: #26313b; }
.btn.btn-border.btn-success { --am-outline: #1b7a4a; }
.btn.btn-border.btn-info { --am-outline: #0b6aa2; }
.btn.btn-border.btn-warning { --am-outline: #8a5a00; }
.btn.btn-border.btn-danger { --am-outline: var(--am-danger); }
.btn.btn-border:hover, .btn.btn-border:focus-visible { background-color: var(--am-outline) !important; color: #fff !important; filter: none; }

/* Round icon buttons in tables stay compact but tappable */
.btn-circle,
.details-btn {
    min-width: 40px;
    min-height: 40px;
}

/* ---------- Forms ---------- */
label,
.form-group label,
.font-14.bold.black {
    font-size: 16px !important;
    font-weight: 700;
    color: var(--am-text);
    margin-bottom: 6px;
}

.theme-input-style,
.form-control,
select.theme-input-style,
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
    min-height: 48px;
    height: auto;
    padding: 10px 14px;
    font-size: 17px;
    color: var(--am-text);
    background-color: var(--am-surface);
    border: 2px solid var(--am-border-strong) !important;
    border-radius: var(--am-radius-sm);
}

textarea.theme-input-style,
textarea.form-control { min-height: 120px; }

.theme-input-style.border-0,
.form-control.border-0 { border: 0 !important; }

.theme-input-style::placeholder,
.form-control::placeholder { color: #6b7570; opacity: 1; }

.theme-input-style:focus,
.form-control:focus {
    border-color: var(--am-primary) !important;
    box-shadow: 0 0 0 3px rgba(27, 107, 70, .2);
    background-color: var(--am-surface);
    color: var(--am-text);
}

input[type="checkbox"],
input[type="radio"] {
    width: 20px;
    height: 20px;
    accent-color: var(--am-primary);
    vertical-align: middle;
}

.text-danger,
.invalid-feedback,
.am-field-error {
    color: var(--am-danger) !important;
    font-size: 16px;
    font-weight: 700;
}

.select2-container .select2-selection--single,
.select2-container .select2-selection--multiple {
    min-height: 48px !important;
    border: 2px solid var(--am-border-strong) !important;
    border-radius: var(--am-radius-sm) !important;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 44px !important;
    font-size: 17px;
}

/* ---------- Tables ---------- */
table,
.table {
    color: var(--am-text);
    font-size: 16px;
}

table th,
.table th,
table.dataTable thead th {
    background-color: var(--am-surface-2);
    color: var(--am-text) !important;
    font-size: 15px;
    font-weight: 700;
    text-transform: none;
    padding: 14px 16px !important;
    border-bottom: 2px solid var(--am-border) !important;
}

/* DataTables' hidden sizing header (scrollX) must stay collapsed */
.dataTables_scrollBody thead th,
table.dataTable thead tr[style*="height: 0"] th {
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    border: 0 !important;
}

table td,
.table td,
table.dataTable tbody td {
    padding: 14px 16px !important;
    vertical-align: middle;
    border-color: var(--am-border) !important;
}

table.hoverable tbody tr:hover,
.table-hover tbody tr:hover,
table.dataTable tbody tr:hover {
    background-color: var(--am-primary-soft) !important;
}

table img { border-radius: 6px; }

.table-responsive { border-radius: var(--am-radius-sm); }

/* ---------- Pagination ---------- */
.page-item .page-link {
    min-width: 44px;
    width: auto;
    height: 44px;
    padding: 0 12px !important;
    font-size: 16px;
    border-radius: var(--am-radius-sm) !important;
    color: var(--am-text);
    border: 1px solid var(--am-border);
}

.page-item.active .page-link,
.page-item .page-link:hover {
    background-color: var(--am-primary) !important;
    border-color: var(--am-primary) !important;
    color: #fff !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    min-width: 44px;
    min-height: 44px;
    font-size: 16px;
    border-radius: var(--am-radius-sm) !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover,
.dataTables_wrapper .dataTables_paginate .paginate_button:not(.disabled):hover {
    background: var(--am-primary) !important;
    border-color: var(--am-primary) !important;
    color: #fff !important;
}

/* Replace the old purple brand colour */
.c1 { color: var(--am-primary) !important; }
.c1-bg { background-color: var(--am-primary) !important; }

/* ---------- Badges, alerts, dropdowns ---------- */
.badge { font-size: 14px; font-weight: 700; padding: 6px 10px; border-radius: 999px; }
.alert { font-size: 17px; border-radius: var(--am-radius-sm); }

.dropdown-menu {
    border: 1px solid var(--am-border);
    border-radius: var(--am-radius-sm);
    box-shadow: 0 10px 30px rgba(16, 24, 40, .12);
    font-size: 17px;
}

.dropdown-menu .dropdown-item,
.dropdown-menu > a {
    padding: 10px 18px;
    font-size: 17px;
}

/* Toast messages readable */
#toast-container > div {
    font-size: 17px;
    width: 380px;
    padding: 18px 18px 18px 56px;
    opacity: 1;
    box-shadow: 0 10px 30px rgba(16, 24, 40, .2);
}

.toast-success { background-color: #1b6b46 !important; }

/* Modals */
.modal-content { border-radius: var(--am-radius); border: none; }
.modal-title { font-size: 22px; color: var(--am-text); }

/* ---------- Dashboard welcome + quick actions ---------- */
.am-welcome {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 28px;
    background: linear-gradient(120deg, var(--am-surface) 55%, var(--am-primary-soft));
}

.am-welcome h1 { font-size: 30px; margin: 0 0 4px; }
.am-welcome p { font-size: 19px; color: var(--am-text-muted); margin: 0; }

.am-quick-actions { display: flex; flex-wrap: wrap; gap: 12px; }

.am-quick {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 56px;
    padding: 12px 20px;
    font-size: 18px;
    font-weight: 700;
    color: var(--am-text);
    background: var(--am-surface);
    border: 2px solid var(--am-border);
    border-radius: var(--am-radius);
    text-decoration: none;
}

.am-quick i { font-size: 22px; color: var(--am-primary); }

.am-quick:hover {
    border-color: var(--am-primary);
    color: var(--am-primary);
    text-decoration: none;
}

/* ---------- Dashboard stat tiles ---------- */
.main-content .card .state-content h2,
.main-content .card .state-content h3 { color: var(--am-text); }

/* ---------- Login / auth pages ---------- */
body.am-auth {
    min-height: 100vh;
    background: var(--am-bg);
}

body.am-auth:before { display: none; }

.am-auth-shell {
    display: grid;
    grid-template-columns: minmax(320px, 44%) 1fr;
    min-height: 100vh;
}

.am-auth-brand {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    padding: 64px;
    background:
        radial-gradient(1200px 600px at -10% 110%, rgba(227, 163, 33, .22), transparent 60%),
        linear-gradient(160deg, #123826 0%, #0b1d15 100%);
    color: #fff;
}

.am-auth-logo { width: min(360px, 100%); height: auto; }

.btn.am-btn-block:hover { background-color: var(--am-primary-hover); color: #fff; }
.am-auth-name { font-size: 40px; font-weight: 700; }

.am-auth-tagline {
    margin-top: 24px;
    font-size: 22px;
    color: #dfe9e3;
    border-left: 4px solid var(--am-accent);
    padding-left: 16px;
}

.am-auth-panel {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 48px 24px 24px;
}

.am-auth-card,
.am-auth-panel > .row > .card,
.am-auth-panel .card {
    width: 100%;
    max-width: 480px;
    margin: auto 0;
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
}

.am-auth-title { font-size: 36px; margin-bottom: 8px; }
.am-auth-sub { font-size: 19px; color: var(--am-text-muted); margin-bottom: 32px; }

.am-auth-card .form-group { margin-bottom: 24px; }

.am-auth-card label {
    display: block;
    font-size: 18px !important;
    margin-bottom: 8px;
}

.am-auth-card .theme-input-style {
    width: 100%;
    min-height: 56px;
    font-size: 19px;
}

.am-password { position: relative; }
.am-password .theme-input-style { padding-right: 96px; }

.am-password-toggle {
    position: absolute;
    top: 6px;
    right: 6px;
    bottom: 6px;
    min-width: 76px;
    border: none;
    border-radius: 6px;
    background: var(--am-primary-soft);
    color: var(--am-primary);
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
}

.btn.am-btn-block {
    background-color: var(--am-primary);
    color: #fff;
    width: 100%;
    min-height: 58px;
    font-size: 20px;
    margin-top: 8px;
}

.am-auth-help {
    margin-top: 24px;
    text-align: center;
    font-size: 18px;
}

.am-auth-help a { text-decoration: underline; }

.am-auth-footer {
    margin-top: auto;
    padding-top: 32px;
    color: var(--am-text-muted);
    font-size: 15px;
    text-align: center;
}

@media (max-width: 900px) {
    .am-auth-shell { grid-template-columns: 1fr; }
    .am-auth-brand { padding: 28px 24px; align-items: center; }
    .am-auth-logo { max-width: 220px; }
    .am-auth-tagline { display: none; }
}

/* Respect users who ask for less motion */
@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}
