/* ============================================================================
   יומן הפעילות. משתמש בטוקנים הקיימים ב-base.css בלבד ואינו מוסיף פלטה.
   כל המרווחים לוגיים (inline/block) ולא left/right, כי המסך RTL והדף כולו
   עבר לזה מזמן.

   העיקרון שמארגן את הקובץ: **שורה ביומן היא שורת סריקה, לא כרטיס.**
   מי שפותח את המסך מחפש דבר אחד בתוך מאה, ולכן הצפיפות גבוהה, העמודות
   מיושרות, והפרטים מוסתרים עד שמבקשים אותם. פתיחה היא <details> מקורי:
   הוא נגיש מהמקלדת בלי שורת JS, ונשאר פתוח בהדפסה.
   ============================================================================ */

/* ── מסננים ─────────────────────────────────────────────── */
.audit-filters {
    display: grid;
    /* auto-fit ולא ארבע עמודות קשיחות: במסך צר זה מתקפל לשתיים ואז לאחת,
       ולא נדחס לשדות שאי אפשר להקליד בהם. */
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 12px;
    padding: 14px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    margin-block-end: 14px;
}
.audit-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.audit-field > span {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-muted, #64748b);
}
.audit-field .form-input,
.audit-field .form-select { width: 100%; }
.audit-field-actions {
    flex-direction: row;
    align-items: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

/* ── שורת מצב ───────────────────────────────────────────── */
.audit-status {
    font-size: 12.5px;
    color: var(--color-muted, #64748b);
    margin-block-end: 8px;
    min-height: 18px;
}

/* ── הרשימה ─────────────────────────────────────────────── */
.audit-list {
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
}

.audit-empty {
    padding: 28px 16px;
    text-align: center;
    color: var(--color-muted, #64748b);
    font-size: 14px;
}
.audit-empty-error { color: #991b1b; background: #fef2f2; }

/* ── שורה ───────────────────────────────────────────────── */
.audit-row { border-block-end: 1px solid #f1f5f9; }
.audit-row:last-child { border-block-end: none; }

.audit-row > summary {
    display: grid;
    /* תאריך צר וקבוע, פעולה גמישה, מבצע צר. במסך צר העמודות נערמות. */
    grid-template-columns: 84px 1fr minmax(120px, auto);
    gap: 12px;
    align-items: center;
    padding: 10px 14px;
    cursor: pointer;
    list-style: none;
    /* פס הגוון יושב על הקצה הפנימי. הוא **תוספת** לטקסט ולא במקומו:
       שם הפעולה הוא מה שאומר מה קרה, והפס רק מאפשר לסרוק מהר. */
    border-inline-start: 3px solid transparent;
}
.audit-row > summary::-webkit-details-marker { display: none; }
.audit-row > summary:hover { background: #f8fafc; }
.audit-row > summary:focus-visible {
    outline: 2px solid var(--color-primary, #2f4f7f);
    outline-offset: -2px;
}

.audit-tone-destructive > summary { border-inline-start-color: var(--color-danger, #ef4444); }
.audit-tone-failed      > summary { border-inline-start-color: var(--color-warning, #f59e0b); }
.audit-tone-approval    > summary { border-inline-start-color: var(--color-success, #10b981); }
.audit-tone-neutral     > summary { border-inline-start-color: #cbd5e1; }

/* התאריך. bdi כי ספרות בהקשר עברי קופצות בלעדיו. */
.audit-when {
    display: flex;
    flex-direction: column;
    line-height: 1.35;
    font-variant-numeric: tabular-nums;
    unicode-bidi: isolate;
}
.audit-when b { font-size: 12.5px; font-weight: 600; color: #334155; }
.audit-when i { font-size: 11px; font-style: normal; color: var(--color-muted, #64748b); }

.audit-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.audit-action { font-size: 14px; font-weight: 600; color: #1e293b; }
.audit-summary {
    font-size: 12.5px;
    color: var(--color-muted, #64748b);
    /* סיכום ארוך נחתך ולא שובר את הרשת. הפרטים המלאים בפתיחה ממילא. */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    unicode-bidi: isolate;
}

.audit-actor {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 12.5px;
    color: #334155;
    text-align: end;
}
.audit-actor i { font-size: 11px; font-style: normal; color: var(--color-muted, #64748b); }

/* התחזות היא העובדה החשובה בשורה שיש בה כזו, ולכן היא טקסט ולא רק צבע. */
.audit-imp {
    align-self: flex-end;
    font-size: 10.5px;
    font-weight: 700;
    color: #7c2d12;
    background: #ffedd5;
    border: 1px solid #fed7aa;
    border-radius: 999px;
    padding: 1px 7px;
}

/* ── גוף פתוח ───────────────────────────────────────────── */
.audit-body {
    padding: 4px 30px 14px;
    background: #f8fafc;
    border-block-start: 1px solid #f1f5f9;
}
.audit-details {
    margin: 10px 0 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 8px 18px;
}
.audit-details > div {
    display: grid;
    grid-template-columns: 92px 1fr;
    gap: 8px;
    align-items: baseline;
    min-width: 0;
}
.audit-details dt {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--color-muted, #64748b);
}
.audit-details dd {
    margin: 0;
    font-size: 13px;
    color: #1e293b;
    /* נימוק הוא טקסט חופשי ויכול להיות ארוך. נשבר, לא גולש. */
    overflow-wrap: anywhere;
    unicode-bidi: isolate;
    /* רשימת מזהים של אישור מרוכז יכולה למנות עשרות. **הגבלת גובה ולא חיתוך
       ערכים:** המזהים הם כל התועלת של השורה ביומן ביקורת, אז כולם נשארים
       ב-DOM, ניתנים לסימון, להעתקה ולחיפוש בדף, והתא נגלל במקום להציף את
       שאר הפרטים. `lh` נתמך רחב, ויש נפילה לפיקסלים למקרה שלא. */
    max-height: 140px;
    max-height: 9lh;
    overflow: auto;
    overscroll-behavior: contain;
}
.audit-nodetails {
    margin: 10px 0 0;
    font-size: 12.5px;
    color: var(--color-muted, #64748b);
}
.audit-stamp {
    margin: 12px 0 0;
    font-size: 11px;
    color: #94a3b8;
    font-variant-numeric: tabular-nums;
    unicode-bidi: isolate;
}

.audit-more-wrap { display: flex; justify-content: center; margin-block-start: 14px; }

/* ── צר ─────────────────────────────────────────────────── */
@media (max-width: 640px) {
    .audit-row > summary {
        grid-template-columns: 1fr;
        gap: 4px;
        padding: 12px 14px;
    }
    .audit-when { flex-direction: row; gap: 8px; align-items: baseline; }
    .audit-actor { text-align: start; flex-direction: row; gap: 8px; align-items: baseline; }
    .audit-imp { align-self: baseline; }
    .audit-summary { white-space: normal; }
    .audit-body { padding-inline: 14px; }
    /* מטרת מגע: שורה שנפתחת בלחיצה במובייל צריכה גובה אמיתי. */
    .audit-row > summary { min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
    .audit-row > summary { transition: none; }
}
