/* ==========================================================================
   FAI UMI — Admin Panel (wp-admin)
   ========================================================================== */
:root {
    --green:        #0b5d3b;
    --green-dark:   #0a5236;
    --green-darker: #063d29;
    --gold:         #c9a34e;
    --gold-dark:    #a5822f;
    --ink:          #17241d;
    --muted:        #6b7a72;
    --line:         #e4ebe7;
    --bg:           #eaf1ec;
    --card:         #ffffff;
    --danger:       #c0392b;
    --danger-dark:  #97271b;
    --ok:           #1e874b;
    --radius:       12px;
    --radius-lg:    16px;
    --shadow-sm:    0 1px 2px rgba(10, 40, 25, .05);
    --shadow:       0 2px 4px rgba(10, 40, 25, .04), 0 8px 24px -8px rgba(10, 40, 25, .12);
    --shadow-lg:    0 20px 48px -16px rgba(10, 40, 25, .22);
    --sidebar-w:    248px;
    --font:         'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-head:    'Plus Jakarta Sans', var(--font);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body.admin { background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 14px; line-height: 1.5; }
a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; }

/* ---------- Auth (login / forgot) ---------- */
.auth-body {
    min-height: 100vh; margin: 0; display: grid; place-items: center; padding: 2rem;
    font-family: var(--font);
    background: linear-gradient(135deg, var(--green-darker), #127a4e);
}
.auth-card {
    width: 100%; max-width: 400px; background: #fff; border-radius: 16px; padding: 2.5rem 2rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .3); text-align: center;
}
.auth-logo { margin-bottom: 1rem; }
.auth-card h1 { font-size: 1.4rem; margin: 0 0 .25rem; color: var(--green-dark); }
.auth-sub { color: var(--muted); margin: 0 0 1.5rem; font-size: .95rem; }
.auth-form { text-align: left; }
.auth-form label { display: block; margin-bottom: 1rem; }
.auth-form label span { display: block; font-weight: 600; margin-bottom: .35rem; font-size: .85rem; }
.auth-form input { width: 100%; }
.auth-link { display: inline-block; margin-top: 1.25rem; color: var(--muted); font-size: .9rem; }

/* ---------- Shell ---------- */
.admin-shell { display: flex; min-height: 100vh; }
.admin-sidebar {
    width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
    background: linear-gradient(180deg, var(--green-darker) 0%, var(--green-dark) 60%, #0c4a31 100%);
    color: #cfe6da;
    position: fixed; top: 0; left: 0; bottom: 0; overflow-y: auto; z-index: 40;
    display: flex; flex-direction: column; box-shadow: 4px 0 24px -12px rgba(0,0,0,.4);
}
.admin-sidebar .brand { padding: 1.15rem 1.25rem; border-bottom: 1px solid rgba(255, 255, 255, .1); margin-bottom: .35rem; }
.admin-sidebar .brand a { display: flex; align-items: center; gap: .6rem; color: #fff; font-weight: 800; font-size: 1rem; font-family: var(--font-head); }
.admin-sidebar .brand a:hover { text-decoration: none; }
.admin-sidebar .brand span { line-height: 1.15; }
.admin-nav { padding: .5rem .75rem 2rem; }
.nav-group {
    text-transform: uppercase; font-size: .66rem; letter-spacing: .09em; color: rgba(201, 163, 78, .8);
    padding: 1.1rem .75rem .4rem; font-weight: 800;
}
.nav-link {
    display: flex; align-items: center; gap: .7rem; padding: .62rem .8rem; color: #cfe6da;
    font-weight: 500; border-radius: 9px; margin-bottom: 2px; transition: background .15s, color .15s, transform .15s;
}
.nav-link:hover { background: rgba(255, 255, 255, .08); color: #fff; text-decoration: none; }
.nav-link.active { background: linear-gradient(90deg, rgba(201, 163, 78, .28), rgba(201, 163, 78, .1)); color: #fff; box-shadow: inset 3px 0 0 var(--gold); }
.nav-link .ic { width: 1.4rem; height: 1.4rem; display: grid; place-items: center; text-align: center; color: var(--gold); font-size: 1rem; }

/* ---------- Main ---------- */
.admin-main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }
.admin-topbar {
    height: 64px; background: rgba(255,255,255,.85); backdrop-filter: saturate(180%) blur(10px);
    border-bottom: 1px solid var(--line);
    display: flex; align-items: center; gap: 1rem; padding: 0 1.75rem; position: sticky; top: 0; z-index: 30;
    box-shadow: 0 1px 12px -6px rgba(10,40,25,.12);
}
.sidebar-toggle { display: none; background: none; border: none; font-size: 1.4rem; cursor: pointer; color: var(--green-dark); }
.view-site { color: var(--muted); font-weight: 600; font-size: .9rem; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: .75rem; }
.user-chip { display: flex; align-items: center; gap: .5rem; color: var(--ink); }
.user-chip:hover { text-decoration: none; }
.avatar-dot {
    width: 30px; height: 30px; border-radius: 50%; background: var(--green); color: #fff;
    display: grid; place-items: center; font-weight: 700; font-size: .85rem;
}
.user-name { font-weight: 600; }
.user-role { font-size: .7rem; text-transform: uppercase; color: var(--gold-dark); background: #f6efdd; padding: .1rem .4rem; border-radius: 4px; letter-spacing: .04em; }
.admin-content { padding: 1.75rem 2rem 3rem; width: 100%; max-width: none; }

/* ---------- Page header ---------- */
.page-head { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.4rem; flex-wrap: wrap; }
.page-head h1 { font-size: 1.6rem; margin: 0; color: var(--green-dark); font-family: var(--font-head); font-weight: 800; letter-spacing: -.01em; position: relative; padding-bottom: .4rem; }
.page-head h1::after { content: ""; position: absolute; left: 0; bottom: 0; width: 44px; height: 3px; border-radius: 3px; background: linear-gradient(90deg, var(--gold), var(--green)); }
.page-head .actions { margin-left: auto; display: flex; gap: .5rem; }

/* ---------- Flash ---------- */
.flash { padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-weight: 500; }
.flash-success { background: #e4f5eb; color: #12633a; border: 1px solid #b8e2c9; }
.flash-error { background: #fbe9e7; color: #97271b; border: 1px solid #f2c4bd; }
.flash ul { margin: 0; padding-left: 1.2rem; }

/* ---------- Cards ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); overflow: hidden; }
.card + .card { margin-top: 1.25rem; }
.card-head { padding: 1.1rem 1.4rem; border-bottom: 1px solid var(--line); font-weight: 700; color: var(--green-dark); font-family: var(--font-head); }
.card-body { padding: 1.4rem; }

/* ---------- Stats grid ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1.1rem; margin-bottom: 1.6rem; }
.stat {
    position: relative; background: #fff; border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 1.3rem 1.4rem;
    box-shadow: var(--shadow); overflow: hidden; transition: transform .18s, box-shadow .18s;
}
.stat::before { content: ""; position: absolute; top: 0; left: 0; width: 100%; height: 4px; background: linear-gradient(90deg, var(--green), var(--gold)); }
.stat:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.stat .num { font-size: 2.1rem; font-weight: 800; color: var(--green-dark); line-height: 1; font-family: var(--font-head); }
.stat .lbl { color: var(--muted); font-size: .82rem; margin-top: .4rem; font-weight: 600; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; background: #fff; }
table.data th, table.data td { padding: .85rem 1.1rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data th { background: #eef5f0; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: #5c7168; font-weight: 700; }
table.data tbody tr { transition: background .12s; }
table.data tbody tr:hover { background: #f3f9f5; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data td.actions { white-space: nowrap; text-align: right; }
table.data .thumb { width: 46px; height: 46px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .72rem; font-weight: 700; letter-spacing: .02em; }
.badge-published { background: #e4f5eb; color: #12633a; }
.badge-draft { background: #eef1ef; color: #647065; }
.badge-scheduled { background: #fff3d6; color: #8a6412; }
.badge-auto { background: #eaf0fb; color: #3559a8; }
.badge-muted { background: #eef1ef; color: #647065; }
.badge-gold { background: #f6efdd; color: var(--gold-dark); }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; gap: .4rem; justify-content: center;
    padding: .55rem 1rem; border-radius: 8px; border: 1px solid transparent; font-weight: 600;
    font-size: .88rem; cursor: pointer; font-family: var(--font); line-height: 1.2; transition: .15s; white-space: nowrap;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); box-shadow: 0 6px 16px -6px rgba(10,40,25,.35); }
.btn-primary { background: linear-gradient(135deg, var(--green), #0e7146); color: #fff; }
.btn-primary:hover { background: linear-gradient(135deg, var(--green-dark), var(--green)); color: #fff; }
.btn-gold { background: var(--gold); color: #3a2c07; }
.btn-gold:hover { background: var(--gold-dark); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-dark); color: #fff; }
.btn-ghost { background: transparent; color: var(--green-dark); border-color: var(--line); }
.btn-ghost:hover { background: #eef3f0; color: var(--green-dark); }
.btn-sm { padding: .35rem .7rem; font-size: .8rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.inline-form { display: inline; }

/* ---------- Forms ---------- */
input[type=text], input[type=email], input[type=password], input[type=url], input[type=number],
input[type=search], input[type=date], input[type=datetime-local], select, textarea {
    width: 100%; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 8px;
    font-family: var(--font); font-size: .9rem; color: var(--ink); background: #fff;
}
textarea { resize: vertical; min-height: 90px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(11, 93, 59, .12); }
.field { margin-bottom: 1.1rem; }
.field > label, .field-label { display: block; font-weight: 600; margin-bottom: .35rem; font-size: .85rem; }
.field .hint { color: var(--muted); font-size: .8rem; margin-top: .3rem; }
.field .err { color: var(--danger); font-size: .8rem; margin-top: .3rem; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.25rem; }
.form-grid .full { grid-column: 1 / -1; }
.checkbox-row { display: flex; align-items: center; gap: .5rem; }
.checkbox-row input { width: auto; }
.form-actions { display: flex; gap: .6rem; margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.layout-cols { display: grid; grid-template-columns: 1fr 300px; gap: 1.25rem; align-items: start; }
.mono { font-family: ui-monospace, 'Cascadia Code', Consolas, monospace; }

/* ---------- Rich text editor ---------- */
.rte { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.rte-toolbar { display: flex; flex-wrap: wrap; gap: .15rem; padding: .35rem; background: #f7faf8; border-bottom: 1px solid var(--line); }
.rte-toolbar button {
    background: #fff; border: 1px solid var(--line); border-radius: 5px; min-width: 30px; height: 28px; padding: 0 .4rem;
    cursor: pointer; font-size: .85rem; color: var(--ink); font-family: var(--font);
}
.rte-toolbar button:hover { background: #eef3f0; }
.rte-area { min-height: 260px; padding: .8rem 1rem; outline: none; overflow-y: auto; }
.rte-area:empty::before { content: attr(data-placeholder); color: var(--muted); }

/* ---------- Tabs (translations) ---------- */
.tabs { border-bottom: 1px solid var(--line); display: flex; gap: .25rem; margin-bottom: 1rem; }
.tab-btn {
    background: none; border: none; border-bottom: 3px solid transparent; padding: .55rem .9rem;
    cursor: pointer; font-weight: 600; color: var(--muted); font-family: var(--font); font-size: .9rem;
}
.tab-btn.active { color: var(--green-dark); border-bottom-color: var(--gold); }
.tab-btn .flag { margin-right: .3rem; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ---------- Media gallery ---------- */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 1rem; }
.media-item { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.media-item .thumb { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: #eef1ef; }
.media-item .meta { padding: .5rem .6rem; }
.media-item .meta .name { font-size: .78rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dropzone {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .55rem;
    width: 100%; min-height: 160px;
    border: 2px dashed #c3d5cb; border-radius: var(--radius-lg); padding: 2rem 1.5rem; text-align: center;
    color: var(--muted); background: #fff; cursor: pointer; margin-bottom: 1rem; transition: .18s;
}
.dropzone:hover { border-color: var(--green); background: #f5faf7; }
.dropzone.drag { border-color: var(--green); background: #eef8f2; color: var(--green-dark); }
.dropzone #fileInput { display: none; }
.dz-icon { width: 60px; height: 60px; display: grid; place-items: center; border-radius: 50%; background: #eef5f0; color: var(--green); }
.dz-text { font-weight: 700; color: var(--ink); font-size: 1rem; }
.dz-hint { font-size: .8rem; color: var(--muted); }

/* ---------- Image picker preview ---------- */
.img-preview { margin-top: .5rem; }
.img-preview img { max-height: 140px; border-radius: 8px; border: 1px solid var(--line); }

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

/* ---------- Pagination ---------- */
.pager { display: flex; gap: .35rem; margin-top: 1.25rem; flex-wrap: wrap; }
.pager a, .pager span {
    padding: .4rem .7rem; border: 1px solid var(--line); border-radius: 7px; background: #fff; color: var(--ink); font-size: .85rem;
}
.pager .active { background: var(--green); color: #fff; border-color: var(--green); }

/* ---------- Sidebar backdrop (mobile) ---------- */
.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 35; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .form-grid, .layout-cols { grid-template-columns: 1fr; }
}
@media (max-width: 782px) {
    .admin-sidebar { transform: translateX(-100%); transition: transform .2s ease; }
    body.sidebar-open .admin-sidebar { transform: translateX(0); }
    body.sidebar-open .sidebar-backdrop { display: block; }
    .admin-main { margin-left: 0; }
    .sidebar-toggle { display: block; }
    .user-name { display: none; }
    .admin-content { padding: 1rem; }
}

/* CAPTCHA on login */
.captcha-row{display:flex;align-items:center;gap:.5rem;margin-bottom:.5rem}
.captcha-img{border:1px solid var(--admin-border,#d9e2dc);border-radius:8px;display:block;background:#f6f9f7}
.captcha-reload{width:40px;height:40px;border:1px solid var(--admin-border,#d9e2dc);border-radius:8px;background:#fff;
  cursor:pointer;font-size:1.1rem;line-height:1;color:#0b5d3b;transition:.2s}
.captcha-reload:hover{background:#0b5d3b;color:#fff}

/* Sidebar unread badge */
.nav-badge{display:inline-block;min-width:18px;height:18px;line-height:18px;text-align:center;padding:0 5px;
  border-radius:9px;background:#c9a34e;color:#3a2c07;font-size:.7rem;font-weight:800;margin-inline-start:auto}
.admin-nav .nav-link{display:flex;align-items:center}

/* Admin list filter bar */
.filter-bar{display:flex;flex-wrap:wrap;align-items:flex-end;gap:.75rem;margin-bottom:1rem;
  background:#fff;border:1px solid var(--admin-border,#dbe7e0);border-radius:12px;padding:.85rem 1rem}
.filter-field{display:flex;flex-direction:column;gap:.3rem}
.filter-field>span{font-size:.72rem;font-weight:700;text-transform:uppercase;letter-spacing:.04em;color:var(--admin-muted,#6b7c74)}
.filter-field select,.filter-field input{padding:.5rem .7rem;border:1px solid var(--admin-border,#dbe7e0);
  border-radius:8px;background:#fff;color:#12211b;font-size:.9rem;min-width:170px}
.filter-field select:focus,.filter-field input:focus{outline:none;border-color:#0b5d3b;box-shadow:0 0 0 3px #e6f4ee}
.filter-search{flex:1;min-width:180px}
.filter-search input{width:100%;min-width:0}
.filter-actions{display:flex;gap:.5rem;align-items:center;padding-bottom:1px}
@media (max-width:640px){.filter-field,.filter-search{width:100%}.filter-field select,.filter-field input{width:100%}}

/* ---------- Slug field (below title, with URL prefix) ---------- */
.slug-field { margin-top: -.3rem; }
.slug-input { display: flex; align-items: stretch; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.slug-input:focus-within { border-color: var(--green); box-shadow: 0 0 0 3px rgba(11,93,59,.12); }
.slug-prefix { display: flex; align-items: center; padding: 0 .6rem; background: #eef5f0; color: var(--muted); font-size: .8rem;
    font-family: ui-monospace, Consolas, monospace; border-right: 1px solid var(--line); white-space: nowrap; max-width: 45%; overflow: hidden; text-overflow: ellipsis; }
.slug-input input { border: 0 !important; border-radius: 0 !important; box-shadow: none !important; flex: 1; }

/* ---------- Enhanced rich-text editor ---------- */
.rte { box-shadow: var(--shadow-sm); }
.rte-toolbar { gap: .3rem; padding: .45rem .5rem; align-items: center; position: sticky; top: 0; z-index: 2; }
.rte-group { display: inline-flex; gap: .15rem; padding-right: .3rem; margin-right: .1rem; border-right: 1px solid var(--line); }
.rte-group:last-child { border-right: 0; }
.rte-toolbar button { min-width: 32px; height: 30px; transition: .12s; }
.rte-toolbar button:hover { background: var(--green); color: #fff; border-color: var(--green); }
.rte-toolbar button.is-active { background: var(--green); color: #fff; border-color: var(--green); }
.rte-block { height: 30px; padding: 0 .5rem; border: 1px solid var(--line); border-radius: 5px; background: #fff;
    font-size: .82rem; color: var(--ink); cursor: pointer; width: auto; min-width: 120px; }
.rte-area { min-height: 320px; }
.rte-area.prose { font-size: .95rem; line-height: 1.75; color: var(--ink); }
.rte-area.prose h2 { font-size: 1.35rem; margin: 1rem 0 .5rem; }
.rte-area.prose h3 { font-size: 1.15rem; margin: 1rem 0 .5rem; }
.rte-area.prose h4 { font-size: 1.02rem; margin: .9rem 0 .4rem; }
.rte-area.prose p { margin: 0 0 .8rem; }
.rte-area.prose ul, .rte-area.prose ol { margin: 0 0 .8rem; padding-left: 1.4rem; }
.rte-area.prose blockquote { border-left: 3px solid var(--gold); background: #f7faf8; margin: .8rem 0; padding: .5rem 1rem; color: var(--muted); border-radius: 0 6px 6px 0; }
.rte-area.prose a { color: var(--green); text-decoration: underline; }
.rte-area.prose img { max-width: 100%; height: auto; border-radius: 6px; margin: .5rem 0; }
.rte-area:empty::before { content: attr(data-placeholder); color: var(--muted); font-style: italic; }

/* Admin sidebar logo (UMI crest on a white badge for contrast on dark green) */
.admin-sidebar .brand-logo { height: 40px; width: auto; background: #fff; padding: 4px 6px; border-radius: 9px; flex-shrink: 0; box-shadow: 0 2px 8px rgba(0,0,0,.25); }
