/* Tweaks on top of AdminLTE — keep the stock look, fix accessibility + mobile. */
#content { min-height: 60vh; outline: none; }

/* --- Accessibility ------------------------------------------------------- */
.skip-link { position: absolute; top: .5rem; inset-inline-start: 1rem; z-index: 2000; background: #fff; padding: .5rem 1rem;
  width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
.skip-link:focus { width: auto; height: auto; overflow: visible; clip: auto; clip-path: none; box-shadow: 0 0 0 3px #80bdff; }
/* Visible keyboard focus everywhere (Bootstrap's is faint on some elements). */
:focus-visible { outline: 3px solid #1a73e8; outline-offset: 2px; }
.btn:focus-visible, .form-control:focus-visible { box-shadow: 0 0 0 .2rem rgba(26,115,232,.45); }
.sr-only-focusable:focus { position: static; width: auto; height: auto; }
.text-muted { color: #5c6670 !important; } /* ≥ 4.5:1 on white and on #f4f6f9 */

/* Visually-hidden labels inside scrolling tables must be clipped by the table
   wrapper, not by an outer positioned ancestor (they'd widen the page on phones). */
.table-responsive { position: relative; }

/* License-gated nav items (see app.js): grayed out with a lock icon rather
   than hidden, so admins can see what their plan doesn't include. */
.nav-sidebar .feature-locked > .nav-link { opacity: .6; }

.nav-lang { width: auto; max-width: 9rem; }

/* Toasts */
.toast-host { position: fixed; top: 70px; right: 16px; z-index: 1080; display: flex; flex-direction: column; gap: .5rem; max-width: min(420px, calc(100vw - 32px)); }
.toast-host .alert { margin: 0; }

/* Notification bell */
.notif-menu { max-width: min(380px, calc(100vw - 16px)); }
.notif-item { white-space: normal; }
.notif-item.unread { font-weight: 600; border-left: 3px solid #007bff; }

/* --- Tasks kanban -------------------------------------------------------- */
.kanban { display: flex; gap: 1rem; overflow-x: auto; padding-bottom: .5rem; }
.kanban-col { flex: 1 1 0; min-width: 260px; background: #f4f6f9; border-radius: .35rem; padding: .5rem; }
.kanban-col.drag-over { outline: 2px dashed #007bff; }
.kanban-col h2 { font-weight: 700; text-transform: uppercase; font-size: .8rem; color: #454d55; margin: .25rem 0 .5rem; }
.kanban-card { background: #fff; border: 1px solid #d5d9de; border-radius: .35rem; padding: .5rem .6rem; margin-bottom: .5rem; cursor: grab; }
.kanban-card:focus-visible { outline: 3px solid #1a73e8; }
.kanban-card.priority-high { border-left: 4px solid #dc3545; }
.kanban-card.priority-normal { border-left: 4px solid #007bff; }
.kanban-card.priority-low { border-left: 4px solid #6c757d; }

/* --- Chat ---------------------------------------------------------------- */
.chat-wrap { display: flex; height: calc(100vh - 180px); min-height: 420px; border: 1px solid #dee2e6; border-radius: .35rem; overflow: hidden; background:#fff; }
.chat-channels { width: 280px; flex: 0 0 280px; border-right: 1px solid #dee2e6; overflow-y: auto; }
.chat-channels .channel { display: block; width: 100%; text-align: left; background: none; border: 0; padding: .6rem .8rem; cursor: pointer; border-bottom: 1px solid #f1f1f1; color: inherit; }
.chat-channels .channel:hover { background: #f6f8fa; }
.chat-channels .channel.active { background: #e9f2ff; }
.chat-channels .channel .preview { font-size: .8rem; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-messages { flex: 1; overflow-y: auto; padding: 1rem; background:#f8f9fb; }
.chat-msg { margin-bottom: .75rem; }
.chat-msg .meta { font-size: .75rem; color: var(--text-3); }
.chat-msg .bubble { display:inline-block; background:#fff; border:1px solid #d5d9de; border-radius:.5rem; padding:.4rem .6rem; margin-top:.15rem; white-space: pre-wrap; word-break: break-word; max-width: 100%; }
.chat-msg.mine .bubble { background:#daf1e0; border-color:#c3e6cb; }
.chat-input { border-top: 1px solid #dee2e6; padding: .5rem; display: flex; gap: .5rem; position: relative; }
/* @mention suggestions sit above the composer. */
.mention-menu { position: absolute; bottom: 100%; left: .5rem; min-width: 16rem; max-height: 16rem; overflow-y: auto; z-index: 10; box-shadow: 0 4px 12px rgba(0,0,0,.12); }
.mention-menu .list-group-item { cursor: pointer; }
.mention-menu .list-group-item.active { background: var(--accent, #007bff); border-color: var(--accent, #007bff); color: var(--accent-text, #fff); }
.mention-menu .mention-handle { opacity: .7; }
.mention { background: var(--accent-soft, #e9f2ff); color: var(--accent, #0056b3); border-radius: .25rem; padding: 0 .2rem; font-weight: 500; }
.chat-typing { min-height: 1rem; font-size: .75rem; color:var(--text-3); padding: 0 1rem; }
.chat-back { display: none; }
.unread-badge { font-size:.7rem; }

/* --- Misc components ------------------------------------------------------ */
.page-actions .btn { margin-bottom: .25rem; }
.filter-bar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: .75rem; }
.filter-bar .form-control { width: auto; min-width: 10rem; }
.stat-label { font-size: .8rem; color: var(--text-3); }
tr.row-warning { background: var(--warning-soft); }

/* --- Responsive ----------------------------------------------------------- */
/* Touch devices: comfortable tap targets for the dense xs/sm row actions. */
@media (pointer: coarse) {
  .btn-xs, .btn-sm, .btn-group-sm > .btn { min-height: 40px; min-width: 40px; padding: .4rem .6rem; font-size: .9rem; }
  .nav-sidebar .nav-link { padding-top: .75rem; padding-bottom: .75rem; }
}

@media (max-width: 767.98px) {
  .content-wrapper .content { padding-left: .25rem; padding-right: .25rem; }
  /* Tables scroll inside their .table-responsive wrapper instead of stretching the page. */
  .table-responsive { max-width: 100%; }
  .card, .card-body { min-width: 0; }
  .page-header { flex-direction: column; align-items: flex-start !important; }
  .page-header .page-actions { margin-top: .5rem; }
  .filter-bar .form-control { min-width: 0; flex: 1 1 100%; }
  .btn-group.flex-wrap-sm { flex-wrap: wrap; }
  .modal-dialog { margin: .5rem; }
  .toast-host { top: auto; bottom: 16px; right: 8px; left: 8px; max-width: none; }

  /* Chat: channel list and conversation become two screens. */
  .chat-wrap { height: calc(100vh - 150px); }
  .chat-channels { width: 100%; flex: 1 1 100%; border-right: 0; }
  .chat-main { display: none; }
  .chat-wrap.show-conversation .chat-channels { display: none; }
  .chat-wrap.show-conversation .chat-main { display: flex; }
  .chat-back { display: inline-block; }

  .kanban { flex-direction: column; }
  .kanban-col { min-width: 0; }
  .fc .fc-toolbar { flex-wrap: wrap; gap: .5rem; }
  .fc .fc-toolbar-title { font-size: 1.1rem; }
}

/* --- Right-to-left (Arabic) ----------------------------------------------- */
[dir="rtl"] body { text-align: right; }
[dir="rtl"] .main-sidebar { left: auto; right: 0; }
@media (min-width: 992px) {
  [dir="rtl"] .content-wrapper, [dir="rtl"] .main-header, [dir="rtl"] .main-footer { margin-left: 0 !important; margin-right: 250px; }
  [dir="rtl"].sidebar-collapse .content-wrapper, [dir="rtl"].sidebar-collapse .main-header, [dir="rtl"].sidebar-collapse .main-footer,
  [dir="rtl"] .sidebar-collapse .content-wrapper, [dir="rtl"] .sidebar-collapse .main-header, [dir="rtl"] .sidebar-collapse .main-footer { margin-right: 4.6rem; }
}
@media (max-width: 991.98px) {
  [dir="rtl"] .main-sidebar { transform: translateX(250px); }
  [dir="rtl"] .sidebar-open .main-sidebar { transform: translateX(0); }
}
[dir="rtl"] .nav-sidebar .nav-link > .nav-icon { margin-left: .2rem; margin-right: 0; }
[dir="rtl"] .ml-auto { margin-left: 0 !important; margin-right: auto !important; }
[dir="rtl"] .mr-1 { margin-right: 0 !important; margin-left: .25rem !important; }
[dir="rtl"] .mr-2 { margin-right: 0 !important; margin-left: .5rem !important; }
[dir="rtl"] .ml-1 { margin-left: 0 !important; margin-right: .25rem !important; }
[dir="rtl"] .ml-2 { margin-left: 0 !important; margin-right: .5rem !important; }
[dir="rtl"] .text-right { text-align: left !important; }
[dir="rtl"] .float-right { float: left !important; }
[dir="rtl"] .dropdown-menu-right { right: auto; left: 0; }
[dir="rtl"] .toast-host { right: auto; left: 16px; }
[dir="rtl"] .chat-channels { border-right: 0; border-left: 1px solid #dee2e6; }
[dir="rtl"] .chat-channels .channel { text-align: right; }
[dir="rtl"] .kanban-card.priority-high, [dir="rtl"] .kanban-card.priority-normal, [dir="rtl"] .kanban-card.priority-low { border-left-width: 1px; border-right-width: 4px; border-right-style: solid; }
[dir="rtl"] .kanban-card.priority-high { border-right-color: #dc3545; }
[dir="rtl"] .kanban-card.priority-normal { border-right-color: #007bff; }
[dir="rtl"] .kanban-card.priority-low { border-right-color: #6c757d; }
[dir="rtl"] .notif-item.unread { border-left: 0; border-right: 3px solid #007bff; }
[dir="rtl"] .input-group > .form-control:not(:last-child) { border-radius: 0 .25rem .25rem 0; }

/* Login / account pages */
.login-page .login-box { width: min(380px, calc(100vw - 32px)); }
.account-links { display: flex; justify-content: space-between; flex-wrap: wrap; gap: .5rem; }

/* Two-step sign-in (mfa.js) */
.mfa-code { font-size: 1.5rem; letter-spacing: .4em; text-align: center; font-variant-numeric: tabular-nums; }
.mfa-recovery { columns: 2; column-gap: 1rem; font-size: 1.05rem; }
.mfa-recovery li { break-inside: avoid; padding: .1rem 0; }
.mfa-qr { max-width: 100%; height: auto; }
.btn.mfa-choice, .login-card-body .btn.mfa-choice { display: flex; justify-content: flex-start; align-items: center; white-space: normal; height: auto; min-height: 0; padding: .6rem .85rem; line-height: 1.35; text-align: left; }
.btn.mfa-choice small { opacity: .85; font-weight: normal; }

/* Tab strips scroll sideways on narrow screens instead of wrapping. */
.nav-tabs { flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; }
.nav-tabs .nav-link { white-space: nowrap; }
/* Chat attachments: inline pictures/videos, download chips, files waiting to be sent. */
.chat-files { display: flex; flex-wrap: wrap; align-items: flex-start; gap: .4rem; margin-top: .25rem; }
.chat-msg.mine .chat-files { justify-content: flex-end; }
.chat-image img { display: block; max-height: 240px; max-width: min(320px, 100%); border-radius: .5rem; border: 1px solid #d5d9de; background: #fff; }
.chat-video { display: block; max-height: 280px; max-width: min(420px, 100%); border-radius: .5rem; background: #000; }
.chat-file { display: inline-flex; align-items: center; gap: .25rem; max-width: 100%; padding: .35rem .6rem; border: 1px solid #d5d9de; border-radius: .5rem; background: #fff; color: inherit; font-size: .875rem; }
.chat-file:hover { text-decoration: none; background: #f6f8fa; }
.chat-file .size, .chat-pending .size { color: var(--text-3); font-size: .75rem; white-space: nowrap; }
.chat-file.expired { color: var(--text-3); font-style: italic; }
.chat-pending { display: flex; flex-wrap: wrap; gap: .4rem; margin: 0; padding: .5rem .5rem 0; border-top: 1px solid #dee2e6; }
.chat-pending-item { position: relative; display: inline-flex; align-items: center; gap: .35rem; max-width: 16rem; padding: .25rem .5rem; border: 1px solid #d5d9de; border-radius: .5rem; background: #f8f9fb; font-size: .8rem; overflow: hidden; }
.chat-pending-item.has-error { border-color: #dc3545; }
.chat-pending-item.has-error .size { color: #dc3545; white-space: normal; }
.chat-pending-item .bar { position: absolute; left: 0; bottom: 0; height: 2px; background: var(--accent, #007bff); transition: width .2s; }
.chat-pending + .chat-input { border-top: 0; }
.chat-main.drop-target { outline: 2px dashed var(--accent, #007bff); outline-offset: -4px; }

/* Office: document list (launchers, storage meter) and the editor host. */
.office-meter { min-width: 14rem; }
.office-launchers { display: grid; grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); gap: .75rem; }
.office-launch { display: flex; align-items: center; gap: .75rem; padding: .85rem 1rem; border: 1px solid var(--border, #dee2e6); border-radius: .6rem; background: var(--surface, #fff); color: inherit; text-align: left; transition: box-shadow .15s, transform .15s, border-color .15s; }
.office-launch:hover, .office-launch:focus-visible { border-color: currentColor; box-shadow: 0 .25rem .9rem rgba(0, 0, 0, .08); transform: translateY(-1px); }
.office-launch-icon { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 2.75rem; height: 2.75rem; border-radius: .5rem; font-size: 1.35rem; color: #fff; }
.office-launch-text { display: flex; flex-direction: column; min-width: 0; }
.office-launch-text small { color: var(--text-3, #6c757d); }
.office-word .office-launch-icon { background: #2b579a; }
.office-excel .office-launch-icon { background: #217346; }
.office-upload .office-launch-icon { background: #5f6b7a; }
.office-folder .office-launch-icon { background: #c98a12; }
i.office-word { color: #2b579a; }
i.office-excel { color: #217346; }
.office-table .office-name { color: inherit; font-weight: 500; }
.office-usage summary { cursor: pointer; }
.office-editor { display: flex; flex-direction: column; height: calc(100vh - 7.5rem); min-height: 28rem; }
.office-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.office-name-group { width: auto; flex: 0 1 22rem; }
.office-frame-wrap { position: relative; flex: 1 1 auto; min-height: 0; border: 1px solid var(--border, #dee2e6); border-radius: .4rem; overflow: hidden; background: #f3f3f3; }
.office-frame { display: block; width: 100%; height: 100%; border: 0; }
.office-loading { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .25rem; background: var(--surface, #fff); text-align: center; padding: 1rem; }
@media (max-width: 767.98px) {
  .office-editor { height: calc(100vh - 6rem); }
  .office-name-group { flex-basis: 100%; order: 5; }
}
