/* =============================================================================
   Asmaani Jodey — Frontend Portal CSS  (v1.1 — Mobile-First)
   Dark sidebar: #10101E | Gold: #C8962A | Clean professional UI
   Mobile-first: base styles are for mobile, desktop layered on top.
============================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;600&display=swap');

/* ── Variables ──────────────────────────────────────────────────────────── */
.ajm-portal,
.ajm-portal-login-wrap {
    --ajm-gold:       #C8962A;
    --ajm-gold-dk:    #a47520;
    --ajm-gold-light: rgba(200,150,42,.12);
    --ajm-dark:       #10101E;
    --ajm-dark2:      #1a1a2e;
    --ajm-sidebar:    #10101E;
    --ajm-surface:    #F4F4F8;
    --ajm-white:      #ffffff;
    --ajm-border:     #e0e0e8;
    --ajm-text:       #1a1a2e;
    --ajm-muted:      #888;
    --ajm-green:      #2e7d32;
    --ajm-red:        #c62828;
    --ajm-blue:       #1565c0;
    --ajm-blue-light: #1976d2;
    --ajm-amber:      #e65100;
    --ajm-radius:     10px;
    --ajm-shadow:     0 2px 16px rgba(0,0,0,.10);
    --ajm-touch:      48px;   /* minimum touch target height */
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

/* ── Reset ──────────────────────────────────────────────────────────────── */
.ajm-portal *,
.ajm-portal-login-wrap * {
    box-sizing: border-box;
}

/* ── Portal Layout (mobile-first: stacked) ──────────────────────────────── */
.ajm-portal {
    display: flex;
    flex-direction: column;      /* stack on mobile */
    min-height: 100vh;
    background: var(--ajm-surface);
    position: relative;
}

/* ── Mobile Top Bar / Sidebar ───────────────────────────────────────────── */
.ajm-sidebar {
    width: 100%;
    background: var(--ajm-sidebar);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    z-index: 200;
    box-shadow: 0 2px 12px rgba(0,0,0,.3);
}

/* Top strip: brand + user initial */
.ajm-sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px 12px;
    border-bottom: 1px solid rgba(255,255,255,.06);
}
.ajm-sidebar-icon  { font-size: 22px; flex-shrink: 0; }
.ajm-sidebar-title { color: var(--ajm-gold); font-size: 14px; font-weight: 700; line-height: 1.2; }
.ajm-sidebar-sub   { color: rgba(255,255,255,.4); font-size: 10px; }

/* User section hidden on mobile (compact) */
.ajm-sidebar-user  { display: none; }
.ajm-user-avatar   {
    width: 36px; height: 36px;
    background: var(--ajm-gold);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 15px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.ajm-user-name { color: #fff; font-size: 13px; font-weight: 600; }
.ajm-user-role { color: rgba(255,255,255,.45); font-size: 11px; }

/* Bottom nav strip (mobile): horizontal icon tabs */
.ajm-nav {
    list-style: none;
    margin: 0; padding: 0;
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    border-top: 1px solid rgba(255,255,255,.06);
}
.ajm-nav::-webkit-scrollbar { display: none; }
.ajm-nav-item { flex-shrink: 0; }
.ajm-nav-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 14px;
    min-height: var(--ajm-touch);
    color: rgba(255,255,255,.65);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    border-bottom: 3px solid transparent;
    transition: all .15s;
    white-space: nowrap;
}
.ajm-nav-link:hover,
.ajm-nav-item.ajm-nav-active .ajm-nav-link {
    color: var(--ajm-gold);
    background: var(--ajm-gold-light);
    border-bottom-color: var(--ajm-gold);
}
.ajm-nav-icon      { font-size: 16px; }
.ajm-nav-divider   { display: none; }
.ajm-nav-label     { display: none; }

/* Logout button in footer */
.ajm-sidebar-footer {
    padding: 10px 16px;
    border-top: 1px solid rgba(255,255,255,.06);
    display: flex;
    justify-content: flex-end;
}

/* ── Main Content ───────────────────────────────────────────────────────── */
.ajm-main {
    flex: 1;
    padding: 0 0 48px;
    min-width: 0;
    overflow-x: hidden;
}
.ajm-main-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border-bottom: 1px solid var(--ajm-border);
    background: var(--ajm-white);
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.ajm-main-header h1 { font-size: 18px; font-weight: 700; color: var(--ajm-dark); margin: 0; }
.ajm-date { margin-left: auto; font-size: 12px; color: var(--ajm-muted); }

/* ── Cards ──────────────────────────────────────────────────────────────── */
.ajm-card {
    background: var(--ajm-white);
    border: 1px solid var(--ajm-border);
    border-radius: var(--ajm-radius);
    box-shadow: var(--ajm-shadow);
    overflow: hidden;
    margin: 0 12px 16px;
}
.ajm-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--ajm-border);
    background: var(--ajm-surface);
    flex-wrap: wrap;
    gap: 8px;
}
.ajm-card-header h2 { margin: 0; font-size: 14px; font-weight: 600; color: var(--ajm-dark); }
.ajm-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-top: 1px solid var(--ajm-border);
    background: var(--ajm-surface);
    flex-wrap: wrap;
    gap: 8px;
}

/* Bio-parse card special style */
.ajm-bioparse-card { border-left: 4px solid var(--ajm-gold); }
.ajm-bioparse-card .ajm-card-header { background: #fff8eb; }
.ajm-hint-tag {
    font-size: 10px;
    background: var(--ajm-gold);
    color: #fff;
    padding: 2px 8px;
    border-radius: 20px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
}

/* ── Stats Grid ─────────────────────────────────────────────────────────── */
.ajm-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 0 12px;
    margin-bottom: 16px;
}
.ajm-stat-card {
    background: var(--ajm-white);
    border: 1px solid var(--ajm-border);
    border-left: 4px solid var(--ajm-gold);
    border-radius: var(--ajm-radius);
    padding: 14px 16px;
    box-shadow: var(--ajm-shadow);
}
.ajm-stat-card.ajm-stat-blue       { border-left-color: var(--ajm-blue); }
.ajm-stat-card.ajm-stat-blue-light { border-left-color: var(--ajm-blue-light); }
.ajm-stat-card.ajm-stat-gold       { border-left-color: var(--ajm-gold); }
.ajm-stat-card.ajm-stat-green      { border-left-color: var(--ajm-green); }
.ajm-stat-card.ajm-stat-amber      { border-left-color: var(--ajm-amber); }
.ajm-stat-card.ajm-stat-red        { border-left-color: var(--ajm-red); }
.ajm-stat-num   { font-size: 26px; font-weight: 700; color: var(--ajm-dark); line-height: 1; margin-bottom: 4px; }
.ajm-stat-label { font-size: 11px; color: var(--ajm-muted); font-weight: 500; }

/* ── Quick Actions ──────────────────────────────────────────────────────── */
.ajm-quick-actions {
    display: flex;
    gap: 10px;
    padding: 0 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.ajm-quick-actions .ajm-btn { flex: 1; justify-content: center; min-height: var(--ajm-touch); }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.ajm-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0 18px;
    height: var(--ajm-touch);         /* 48px touch target */
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    border: 2px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: all .15s;
    line-height: 1;
    font-family: inherit;
    -webkit-appearance: none;
    touch-action: manipulation;       /* prevents double-tap zoom */
}
.ajm-btn-sm {
    height: 36px;
    padding: 0 12px;
    font-size: 12px;
    border-radius: 6px;
}
.ajm-btn-gold    { background: var(--ajm-gold);  color: #fff; border-color: var(--ajm-gold); }
.ajm-btn-gold:hover { background: var(--ajm-gold-dk); border-color: var(--ajm-gold-dk); color: #fff; }
.ajm-btn-outline { background: transparent; color: var(--ajm-dark); border-color: var(--ajm-border); }
.ajm-btn-outline:hover { border-color: var(--ajm-gold); color: var(--ajm-gold); }
.ajm-btn-primary { background: var(--ajm-blue); color: #fff; border-color: var(--ajm-blue); }
.ajm-btn-primary:hover { background: #0d47a1; color: #fff; }
.ajm-btn-danger  { background: #ffebee; color: var(--ajm-red); border-color: #ef9a9a; }
.ajm-btn-danger:hover { background: var(--ajm-red); color: #fff; border-color: var(--ajm-red); }

/* ── Tables — horizontally scrollable on mobile ─────────────────────────── */
.ajm-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.ajm-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    min-width: 540px;
}
.ajm-table th {
    background: var(--ajm-surface);
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    color: #555;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .05em;
    border-bottom: 1px solid var(--ajm-border);
    white-space: nowrap;
}
.ajm-table td {
    padding: 11px 14px;
    border-bottom: 1px solid #f0f0f4;
    vertical-align: middle;
}
.ajm-table tbody tr:hover { background: #fafafe; }
.ajm-table tbody tr:last-child td { border-bottom: none; }

/* ── Codes ──────────────────────────────────────────────────────────────── */
.ajm-code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    background: #f0f0f8;
    color: var(--ajm-dark);
    padding: 2px 7px;
    border-radius: 4px;
    font-weight: 600;
}
.ajm-code-lg { font-size: 17px; padding: 4px 12px; }

/* ── Badges ─────────────────────────────────────────────────────────────── */
.ajm-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
}
.ajm-badge-active  { background: #e8f5e9; color: #2e7d32; }
.ajm-badge-deleted { background: #ffebee; color: #c62828; }
.ajm-badge-pending { background: #fff8e1; color: #e65100; }

/* ── Form Elements ──────────────────────────────────────────────────────── */
.ajm-form-grid {
    display: grid;
    grid-template-columns: 1fr;          /* single column on mobile */
    gap: 14px;
    padding: 16px;
}
.ajm-form-full    { grid-column: 1 / -1; }
.ajm-form-group   { display: flex; flex-direction: column; gap: 6px; }
.ajm-form-group > label { font-size: 14px; font-weight: 600; color: #444; }
.ajm-form-section {
    grid-column: 1 / -1;
    font-size: 11px;
    font-weight: 700;
    color: var(--ajm-gold);
    text-transform: uppercase;
    letter-spacing: .07em;
    padding: 10px 0 6px;
    border-bottom: 2px solid var(--ajm-border);
    margin-top: 6px;
}
.ajm-required { color: var(--ajm-red); }
.ajm-hint { font-size: 12px; color: var(--ajm-muted); line-height: 1.4; }

/* Inputs — 48px min height for comfortable mobile tap */
.ajm-input {
    padding: 12px 14px;
    border: 1.5px solid var(--ajm-border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 15px;
    background: var(--ajm-white);
    color: var(--ajm-text);
    transition: border-color .15s, box-shadow .15s;
    width: 100%;
    min-height: var(--ajm-touch);          /* 48px touch target */
    -webkit-appearance: none;
}
select.ajm-input {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23888' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}
.ajm-input:focus {
    border-color: var(--ajm-gold);
    outline: none;
    box-shadow: 0 0 0 3px rgba(200,150,42,.15);
}
.ajm-textarea {
    min-height: 96px;
    resize: vertical;
    line-height: 1.6;
}

.ajm-form-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px;
    border-top: 1px solid var(--ajm-border);
    background: var(--ajm-surface);
}
.ajm-form-actions .ajm-btn { width: 100%; }

/* ── Code Preview Box ───────────────────────────────────────────────────── */
.ajm-code-preview-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--ajm-dark);
    color: #fff;
    padding: 14px 16px;
    border-radius: 8px;
    margin: 12px 16px;
    gap: 12px;
    flex-wrap: wrap;
}
.ajm-code-preview-label { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: #aaa; margin-bottom: 4px; }
.ajm-code-preview-value { font-family: 'JetBrains Mono', monospace; font-size: 18px; font-weight: 700; color: var(--ajm-gold); }

/* ── Duplicate Warning ──────────────────────────────────────────────────── */
.ajm-duplicate-warning {
    background: #ffebee;
    border: 2px solid var(--ajm-red);
    border-radius: 8px;
    padding: 14px 16px;
    margin: 0 12px 14px;
    color: #b71c1c;
    font-size: 14px;
    line-height: 1.6;
}

/* ── Alerts ─────────────────────────────────────────────────────────────── */
.ajm-alert { border-radius: 8px; padding: 14px 16px; font-size: 14px; line-height: 1.5; }
.ajm-alert-success { background: #e8f5e9; color: #1b5e20; border: 1px solid #a5d6a7; }
.ajm-alert-error   { background: #ffebee; color: #b71c1c; border: 1px solid #ef9a9a; }

/* ── Profile Detail Grid ────────────────────────────────────────────────── */
.ajm-profile-grid { display: grid; grid-template-columns: 1fr; gap: 1px; background: var(--ajm-border); }
.ajm-pf { display: flex; flex-direction: column; gap: 4px; background: var(--ajm-white); padding: 12px 16px; }
.ajm-pf-full { grid-column: 1 / -1; }
.ajm-pf-private { background: #fff8e1; }
.ajm-pfl { font-size: 11px; font-weight: 700; color: var(--ajm-muted); text-transform: uppercase; letter-spacing: .04em; }

/* ── Pagination ─────────────────────────────────────────────────────────── */
.ajm-pagination { display: flex; gap: 6px; align-items: center; padding: 12px 16px; flex-wrap: wrap; }

/* ── WhatsApp Preview Box ───────────────────────────────────────────────── */
.ajm-wa-preview {
    background: #e5ddd5;
    border-radius: 8px;
    padding: 16px;
    font-family: 'Segoe UI', sans-serif;
    font-size: 14px;
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 420px;
    overflow-y: auto;
}

/* ── Login Page ─────────────────────────────────────────────────────────── */
.ajm-portal-login-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 16px;
    background: linear-gradient(135deg, #10101E 0%, #1a1a2e 60%, #10101E 100%);
}
.ajm-login-card {
    background: var(--ajm-white);
    border-radius: 16px;
    padding: 32px 24px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 8px 40px rgba(0,0,0,.3);
}
.ajm-login-logo      { text-align: center; margin-bottom: 24px; }
.ajm-login-icon      { font-size: 40px; margin-bottom: 8px; }
.ajm-login-title     { font-size: 22px; font-weight: 700; color: var(--ajm-dark); margin: 0 0 4px; }
.ajm-login-subtitle  { color: var(--ajm-muted); font-size: 14px; margin: 0; }
.ajm-login-form .ajm-label { font-size: 13px; font-weight: 600; color: #444; }
.ajm-portal-error    { padding: 20px; color: var(--ajm-red); text-align: center; }

/* ── Tablet (≥ 600px) ───────────────────────────────────────────────────── */
@media (min-width: 600px) {
    .ajm-card       { margin: 0 20px 18px; }
    .ajm-stats-grid { padding: 0 20px; gap: 12px; grid-template-columns: repeat(3, 1fr); }
    .ajm-quick-actions { padding: 0 20px; }
    .ajm-quick-actions .ajm-btn { flex: 0 1 auto; width: auto; }
    .ajm-form-grid  { grid-template-columns: 1fr 1fr; padding: 20px; gap: 16px; }
    .ajm-form-actions { flex-direction: row; }
    .ajm-form-actions .ajm-btn { width: auto; }
    .ajm-code-preview-box { margin: 14px 20px; }
    .ajm-duplicate-warning { margin: 0 20px 16px; }
    .ajm-main-header { padding: 20px; }
    .ajm-profile-grid { grid-template-columns: 1fr 1fr; }
    .ajm-pf-full { grid-column: 1 / -1; }
}

/* ── Desktop (≥ 900px): sidebar goes back to left column ───────────────── */
@media (min-width: 900px) {
    .ajm-portal { flex-direction: row; }

    .ajm-sidebar {
        width: 240px;
        min-width: 240px;
        flex-direction: column;
        position: sticky;
        top: 0;
        height: 100vh;
        overflow-y: auto;
        box-shadow: none;
        border-right: 1px solid rgba(255,255,255,.06);
    }

    .ajm-sidebar-brand { padding: 22px 20px 16px; border-bottom: 1px solid rgba(255,255,255,.08); }

    /* Show user section on desktop */
    .ajm-sidebar-user {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 14px 20px;
        border-bottom: 1px solid rgba(255,255,255,.06);
    }

    /* Vertical nav on desktop */
    .ajm-nav {
        flex-direction: column;
        overflow: visible;
        margin: 12px 0;
        flex: 1;
        border-top: none;
    }
    .ajm-nav-link {
        padding: 10px 20px;
        border-bottom: none;
        border-left: 3px solid transparent;
        white-space: normal;
        min-height: auto;
    }
    .ajm-nav-link:hover,
    .ajm-nav-item.ajm-nav-active .ajm-nav-link {
        border-bottom: none;
        border-left-color: var(--ajm-gold);
    }
    .ajm-nav-divider { display: block; border-top: 1px solid rgba(255,255,255,.06); margin: 8px 0; }
    .ajm-nav-label   { display: block; padding: 8px 20px; font-size: 10px; text-transform: uppercase; letter-spacing: .1em; color: rgba(255,255,255,.3); }

    .ajm-sidebar-footer { margin-top: auto; }

    .ajm-main { overflow-x: auto; }
    .ajm-main-header { padding: 24px 28px 16px; }
    .ajm-card { margin: 0 28px 20px; }
    .ajm-stats-grid { padding: 0 28px; gap: 14px; }
    .ajm-quick-actions { padding: 0 28px; }
    .ajm-code-preview-box { margin: 16px 24px; }
    .ajm-duplicate-warning { margin: 0 28px 16px; }
    .ajm-stat-num { font-size: 28px; }
}

/* ── Activity List ──────────────────────────────────────────────────────── */
.ajm-activity-list { padding: 8px 0; }
.ajm-activity-item {
    padding: 12px 16px;
    border-bottom: 1px solid #f0f0f4;
    display: grid;
    gap: 2px;
}
.ajm-activity-item:last-child { border-bottom: none; }
.ajm-activity-action { font-weight: 600; font-size: 13px; color: var(--ajm-dark); }
.ajm-activity-who    { font-size: 12px; color: var(--ajm-muted); }
.ajm-activity-time   { font-size: 11px; color: #aaa; }
