/* ===========================================================
   Admin Portal shell — restyled to match the HRD Mitti & Mantra
   storefront theme (charcoal + terracotta orange + white).
   Relies on the CSS variables defined in home.css's :root
   (--orange-700, --ink, --grey-100, --radius-lg, --shadow-soft…),
   which is always linked before this file.
   =========================================================== */

.mm-admin-body {
    background: var(--grey-100);
    margin: 0;
}

.mm-admin-shell {
    display: flex;
    min-height: 100vh;
}

/* ---------- Sidebar (same charcoal as the site footer) ---------- */
.mm-admin-sidebar {
    width: 250px;
    flex-shrink: 0;
    background: var(--ink);
    color: #fff;
    display: flex;
    flex-direction: column;
    padding: 22px 16px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.mm-admin-sidebar__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    text-decoration: none;
    font-weight: 800;
    font-size: 1.05rem;
    padding: 4px 6px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, .1);
    margin-bottom: 16px;
}

.mm-admin-sidebar__brand .mm-brand__mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--orange-500), var(--orange-700));
    color: #fff;
    font-size: .78rem;
    letter-spacing: .04em;
}

.mm-admin-sidebar__nav {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1;
}

.mm-admin-sidebar__link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 12px;
    border-radius: 12px;
    color: rgba(255, 255, 255, .72);
    text-decoration: none;
    font-size: .92rem;
    font-weight: 600;
    transition: background .15s ease, color .15s ease;
}

.mm-admin-sidebar__link:hover {
    background: rgba(255, 255, 255, .08);
    color: #fff;
}

.mm-admin-sidebar__link.is-active {
    background: linear-gradient(135deg, var(--orange-500), var(--orange-700));
    color: #fff;
}

.mm-admin-sidebar__footer {
    border-top: 1px solid rgba(255, 255, 255, .1);
    padding-top: 16px;
    margin-top: 16px;
}

.mm-admin-sidebar__user {
    display: flex;
    flex-direction: column;
    margin-bottom: 12px;
    padding: 0 4px;
}

.mm-admin-sidebar__user strong {
    color: #fff;
    font-size: .92rem;
}

.mm-admin-sidebar__user span {
    color: var(--orange-300);
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
}

.mm-admin-sidebar__footer .mm-btn--outline {
    color: #fff;
    border-color: rgba(255, 255, 255, .3);
    background: transparent;
}

.mm-admin-sidebar__footer .mm-btn--outline:hover {
    background: rgba(255, 255, 255, .1);
    border-color: rgba(255, 255, 255, .5);
}

/* ---------- Main content ---------- */
.mm-admin-main {
    flex: 1;
    padding: 32px 36px 60px;
    min-width: 0;
}

.mm-admin-page-title {
    font-size: 1.6rem;
    font-weight: 800;
    margin-bottom: 4px;
    color: var(--ink);
}

.mm-admin-page-sub {
    color: var(--muted);
    margin-bottom: 26px;
}

/* ---------- Stat cards ---------- */
.mm-admin-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 16px;
    margin-bottom: 30px;
}

.mm-admin-stat {
    background: #fff;
    border-radius: var(--radius-md);
    padding: 20px 22px;
    box-shadow: var(--shadow-soft);
    border: 1px solid rgba(35, 39, 43, .06);
}

.mm-admin-stat__label {
    font-size: .76rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--muted);
    margin-bottom: 8px;
    font-weight: 700;
}

.mm-admin-stat__value {
    font-size: 1.7rem;
    font-weight: 800;
    color: var(--ink);
}

.mm-admin-stat--warn .mm-admin-stat__value {
    color: var(--orange-700);
}

/* ---------- Cards / panels ---------- */
.mm-admin-card {
    background: #fff;
    border-radius: var(--radius-lg);
    padding: 26px 28px;
    box-shadow: var(--shadow-soft);
    border: 1px solid rgba(35, 39, 43, .06);
    margin-bottom: 24px;
}

.mm-admin-card__title {
    font-size: 1.1rem;
    font-weight: 800;
    margin-bottom: 16px;
    color: var(--ink);
}

/* ---------- Tables ---------- */
.mm-admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .9rem;
}

.mm-admin-table th {
    text-align: left;
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    font-weight: 700;
    color: var(--muted);
    border-bottom: 2px solid var(--grey-100);
    padding: 10px 12px;
}

.mm-admin-table td {
    padding: 13px 12px;
    border-bottom: 1px solid var(--grey-100);
    vertical-align: middle;
    color: var(--ink);
}

.mm-admin-table tr:hover td {
    background: #fffaf5;
}

.mm-admin-table tr:last-child td {
    border-bottom: none;
}

.mm-admin-table a {
    color: var(--orange-700);
    font-weight: 700;
    text-decoration: none;
}

.mm-admin-table a:hover {
    text-decoration: underline;
}

.mm-admin-badge {
    display: inline-block;
    padding: 3px 11px;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 700;
}

.mm-admin-badge--ok { background: #dcfce7; color: #15803d; }
.mm-admin-badge--warn { background: #fef3c7; color: #b45309; }
.mm-admin-badge--danger { background: #fee2e2; color: #b91c1c; }
.mm-admin-badge--muted { background: var(--grey-100); color: var(--grey-600); }

/* Small button variant for inline row actions */
.mm-btn--sm {
    padding: 7px 14px;
    font-size: .8rem;
    border-radius: 10px;
}

/* ---------- Forms ---------- */
.mm-admin-form label {
    display: block;
    margin-bottom: 16px;
    font-size: .85rem;
    font-weight: 700;
    color: var(--ink);
}

.mm-admin-form input[type="text"],
.mm-admin-form input[type="email"],
.mm-admin-form input[type="password"],
.mm-admin-form input[type="tel"],
.mm-admin-form input[type="number"],
.mm-admin-form input[type="date"],
.mm-admin-form select,
.mm-admin-form textarea {
    width: 100%;
    margin-top: 7px;
    padding: 11px 13px;
    border: 1.5px solid #e4e6ea;
    border-radius: 10px;
    font-size: .9rem;
    background: #fbfbfc;
    font-weight: 400;
    color: var(--ink);
    transition: border-color .15s ease;
}

.mm-admin-form input:focus,
.mm-admin-form select:focus,
.mm-admin-form textarea:focus {
    outline: none;
    border-color: var(--orange-500);
    background: #fff;
}

.mm-admin-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0 20px;
}

/* ---------- Permission grid (Admins page) ---------- */
.mm-perm-grid {
    width: 100%;
    border-collapse: collapse;
}

.mm-perm-grid th, .mm-perm-grid td {
    padding: 9px 10px;
    border-bottom: 1px solid var(--grey-100);
    text-align: center;
    font-size: .85rem;
    color: var(--ink);
}

.mm-perm-grid th {
    color: var(--muted);
    font-weight: 700;
    text-transform: uppercase;
    font-size: .7rem;
    letter-spacing: .05em;
}

.mm-perm-grid th:first-child, .mm-perm-grid td:first-child {
    text-align: left;
}

.mm-perm-grid input[type="checkbox"] {
    width: 17px;
    height: 17px;
    accent-color: var(--orange-500);
}

/* ---------- Auth screens (login / access denied) ---------- */
.mm-admin-body--auth {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background:
        radial-gradient(circle at 15% 15%, rgba(249, 115, 22, .12), transparent 55%),
        radial-gradient(circle at 85% 85%, rgba(194, 65, 12, .10), transparent 55%),
        var(--grey-100);
}

.mm-admin-auth {
    width: 100%;
    max-width: 440px;
    padding: 20px;
}

.mm-admin-auth__card {
    background: #fff;
    border-radius: var(--radius-lg);
    padding: 40px 36px 36px;
    box-shadow: var(--shadow-lift);
    position: relative;
    overflow: hidden;
}

.mm-admin-auth__card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 6px;
    background: linear-gradient(90deg, var(--orange-300), var(--orange-500), var(--orange-700));
}

.mm-admin-auth__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--ink);
    font-weight: 800;
    margin-bottom: 22px;
    font-size: 1.05rem;
}

.mm-admin-auth__brand .mm-brand__mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 11px;
    background: linear-gradient(135deg, var(--orange-500), var(--orange-700));
    color: #fff;
    font-size: .8rem;
    letter-spacing: .04em;
}

.mm-admin-auth__card h1 {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--ink);
    margin-bottom: 6px;
}

.mm-admin-auth__sub {
    color: var(--muted);
    margin-bottom: 24px;
    font-size: .92rem;
}

.mm-admin__login label {
    display: block;
    margin-bottom: 16px;
    font-size: .85rem;
    font-weight: 700;
    color: var(--ink);
}

.mm-admin__login input[type="text"],
.mm-admin__login input[type="email"],
.mm-admin__login input[type="password"] {
    width: 100%;
    margin-top: 7px;
    padding: 12px 14px;
    border: 1.5px solid #e4e6ea;
    border-radius: 12px;
    font-size: .95rem;
    background: #fbfbfc;
    color: var(--ink);
    transition: border-color .15s ease;
}

.mm-admin__login input:focus {
    outline: none;
    border-color: var(--orange-500);
    background: #fff;
}

.mm-admin__hint {
    font-size: .8rem;
    color: var(--muted);
    margin-top: 6px;
}

.mm-admin__checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 400 !important;
}

.mm-admin__checkbox input {
    width: auto;
    margin: 0;
    accent-color: var(--orange-500);
}

/* ---------- Confirmation toast (fires after every admin operation) ---------- */
#mmAdminToast {
    position: fixed;
    top: 22px;
    right: 22px;
    z-index: 2000;
    max-width: 360px;
    padding: 14px 20px;
    border-radius: 12px;
    font-size: .9rem;
    font-weight: 600;
    color: #fff;
    box-shadow: var(--shadow-lift);
    opacity: 0;
    transform: translateY(-12px);
    pointer-events: none;
    transition: opacity .2s ease, transform .2s ease;
}

#mmAdminToast.is-visible {
    opacity: 1;
    transform: translateY(0);
}

#mmAdminToast.is-success {
    background: linear-gradient(135deg, #16a34a, #15803d);
}

#mmAdminToast.is-error {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
}

@media (max-width: 480px) {
    #mmAdminToast {
        left: 16px;
        right: 16px;
        top: 16px;
        max-width: none;
    }
}

/* ---------- Responsive ---------- */
@media (max-width: 880px) {
    .mm-admin-shell {
        flex-direction: column;
    }

    .mm-admin-sidebar {
        width: 100%;
        height: auto;
        position: static;
        flex-direction: row;
        align-items: center;
        overflow-x: auto;
    }

    .mm-admin-sidebar__nav {
        flex-direction: row;
        overflow-x: auto;
    }

    .mm-admin-sidebar__footer {
        display: none;
    }

    .mm-admin-main {
        padding: 20px 16px 40px;
    }
}

/* ============================================================
   Confirmation dialog + toast
   ============================================================ */
.mm-dialog {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: grid;
    place-items: center;
    padding: 20px;
}

.mm-dialog[hidden] {
    display: none;
}

.mm-dialog__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(24, 21, 18, .5);
    backdrop-filter: blur(3px);
}

.mm-dialog__panel {
    position: relative;
    width: min(92vw, 420px);
    background: #fff;
    border-radius: 18px;
    padding: 30px 28px 24px;
    text-align: center;
    box-shadow: 0 24px 60px rgba(0, 0, 0, .25);
    animation: mm-dialog-pop .18s ease-out both;
}

@keyframes mm-dialog-pop {
    from { opacity: 0; transform: translateY(10px) scale(.97); }
    to   { opacity: 1; transform: none; }
}

.mm-dialog__icon {
    width: 58px;
    height: 58px;
    margin: 0 auto 16px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 1.7rem;
    font-weight: 700;
    background: #dcfce7;
    color: #15803d;
}

.mm-dialog.is-error .mm-dialog__icon {
    background: #fee2e2;
    color: #b91c1c;
}

.mm-dialog__title {
    margin: 0 0 8px;
    font-size: 1.2rem;
    font-weight: 700;
    color: #1f2937;
}

.mm-dialog.is-error .mm-dialog__title {
    color: #b91c1c;
}

.mm-dialog__message {
    margin: 0 0 22px;
    color: #4b5563;
    font-size: .93rem;
    line-height: 1.55;
}

.mm-dialog__ok {
    min-width: 130px;
}

/* The inline status paragraph is replaced by the dialog above — keep it in
   the DOM (the script reads its text) but out of the layout. */
p[data-admin-status] {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.mm-admin-toast {
    position: fixed;
    left: 50%;
    bottom: 26px;
    transform: translate(-50%, 20px);
    z-index: 1100;
    max-width: min(90vw, 460px);
    padding: 13px 20px;
    border-radius: 12px;
    font-size: .9rem;
    font-weight: 600;
    color: #fff;
    background: #15803d;
    box-shadow: 0 12px 30px rgba(0, 0, 0, .22);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease, transform .2s ease;
}

.mm-admin-toast.is-error {
    background: #b91c1c;
}

.mm-admin-toast.is-visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* ============================================================
   Users page
   ============================================================ */
.mm-admin-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-bottom: 18px;
}

.mm-admin-toolbar form {
    display: flex;
    gap: 8px;
    flex: 1 1 320px;
}

.mm-admin-toolbar input[type="search"],
.mm-admin-toolbar select {
    flex: 1;
    padding: 10px 13px;
    border: 1.5px solid #e4e6ea;
    border-radius: 10px;
    font-size: .9rem;
    background: #fff;
}

.mm-admin-stat-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.mm-admin-stat {
    background: #fff;
    border: 1px solid #eceff3;
    border-radius: 14px;
    padding: 16px 18px;
}

.mm-admin-stat__value {
    font-size: 1.6rem;
    font-weight: 700;
    color: #1f2937;
    line-height: 1.1;
}

.mm-admin-stat__label {
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #8b95a1;
    margin-top: 4px;
}

.mm-admin-empty {
    padding: 26px;
    text-align: center;
    color: #8b95a1;
    font-size: .92rem;
}

/* ============================================================
   Detailed permissions page
   ============================================================ */
.mm-perm-admin {
    border: 1px solid #eceff3;
    border-radius: 16px;
    padding: 0;
    margin-bottom: 18px;
    overflow: hidden;
    background: #fff;
}

.mm-perm-admin__head {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: #fafbfc;
    border-bottom: 1px solid #eceff3;
}

.mm-perm-admin__who strong {
    display: block;
    font-size: 1rem;
    color: #1f2937;
}

.mm-perm-admin__who span {
    font-size: .82rem;
    color: #8b95a1;
}

.mm-perm-admin__body {
    padding: 6px 20px 20px;
}

.mm-perm-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 14px 0 4px;
}

.mm-perm-group {
    margin-top: 16px;
}

.mm-perm-group__title {
    font-size: .74rem;
    font-weight: 700;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: #c2410c;
    margin-bottom: 8px;
}

.mm-perm-table {
    width: 100%;
    border-collapse: collapse;
}

.mm-perm-table th {
    text-align: left;
    font-size: .74rem;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: #8b95a1;
    padding: 8px 10px;
    border-bottom: 1px solid #eceff3;
}

.mm-perm-table th.is-check,
.mm-perm-table td.is-check {
    width: 82px;
    text-align: center;
}

.mm-perm-table td {
    padding: 11px 10px;
    border-bottom: 1px solid #f3f5f7;
    vertical-align: top;
}

.mm-perm-table tr:last-child td {
    border-bottom: 0;
}

.mm-perm-table__name {
    font-weight: 600;
    color: #1f2937;
    font-size: .92rem;
}

.mm-perm-table__desc {
    display: block;
    font-weight: 400;
    font-size: .8rem;
    color: #8b95a1;
    margin-top: 3px;
    line-height: 1.45;
}

.mm-perm-table input[type="checkbox"] {
    width: 17px;
    height: 17px;
    accent-color: #c2410c;
    cursor: pointer;
}

.mm-perm-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid #eceff3;
}

@media (max-width: 640px) {
    .mm-perm-table__desc {
        display: none;
    }

    .mm-perm-table th.is-check,
    .mm-perm-table td.is-check {
        width: 58px;
    }
}
