/* =========================================================
   Maham V5.3 — Product UX / Theme / RTL-LTR Design System
   ========================================================= */

:root{
  --primary:#A64D68;--primary-strong:#8B3F59;--primary-soft:#F8EAF0;
  --secondary:#465F73;--secondary-strong:#354C60;--secondary-soft:#EAF4F8;
  --accent:#465F73;--accent-strong:#354C60;
  --danger:#C34C4C;--success:#2F7D5C;--warning:#A86D1F;--info:#465F73;
  --radius-xs:8px;--radius-sm:12px;--radius-md:16px;--radius-lg:22px;--radius-xl:28px;
  --space-1:4px;--space-2:8px;--space-3:12px;--space-4:16px;--space-5:20px;--space-6:24px;--space-8:32px;
  --focus:0 0 0 3px rgba(166,77,104,.20);
}

html[data-theme="light"]{
  --bg-primary:#F7F9FA;--bg-secondary:#F1F4F6;--surface:#FFFFFF;--surface-secondary:#FBFCFD;
  --surface-elevated:#FFFFFF;--text-primary:#20282E;--text-secondary:#55636C;--text-muted:#74818A;
  --border:#E1E7EA;--border-strong:#D1D9DD;--hover:#F8F1F4;--active:#F8EAF0;--disabled:#EDF1F3;
  --overlay:rgba(37,40,50,.24);--shadow-xs:0 2px 10px rgba(32,40,46,.04);--shadow-md:0 12px 36px rgba(32,40,46,.07);
}
html[data-theme="dark"]{
  --bg-primary:#1D2027;--bg-secondary:#181B22;--surface:#252832;--surface-secondary:#2E3440;
  --surface-elevated:#333947;--text-primary:#F1F4F5;--text-secondary:#C1C8CC;--text-muted:#9AA5AC;
  --border:#373D47;--border-strong:#454C58;--hover:#352D34;--active:#3D2C35;--disabled:#303741;
  --primary:#B85B76;--primary-strong:#CC748D;--primary-soft:#442F3A;
  --secondary:#5F7D91;--secondary-strong:#7E9BAE;--secondary-soft:#2D3945;
  --accent:#5F7D91;--accent-strong:#7E9BAE;
  --danger:#D86A6A;--success:#67B58C;--warning:#D7A45B;--info:#7E9BAE;
  --overlay:rgba(8,10,14,.52);--shadow-xs:0 2px 12px rgba(0,0,0,.16);--shadow-md:0 18px 42px rgba(0,0,0,.24);
}
html,body{background:var(--bg-primary)!important;color:var(--text-primary)!important}
body{line-height:1.65;text-align:start}
body,button,input,select,textarea{font-family:"Almarai",Tahoma,Arial,sans-serif}
::selection{background:rgba(166,77,104,.24);color:var(--text-primary)}
:focus-visible{outline:0;box-shadow:var(--focus)!important}
.skip-link{position:fixed;inset-inline-start:14px;top:10px;z-index:1000;transform:translateY(-160%);background:var(--surface);color:var(--text-primary);border:1px solid var(--border);border-radius:10px;padding:10px 14px;box-shadow:var(--shadow-md)}
.skip-link:focus{transform:none}

/* Workspace */
.main-content{background:var(--bg-primary)!important;border-color:var(--border)!important;color:var(--text-primary)!important;box-shadow:none!important}
.page-head,.card,.kpi-card,.idea-card,.saved-note,.notification-item,.table-wrap,.detail-item,.note-box,.quick-action,.action-panel,.achievement-card,.mini-stat{background:var(--surface)!important;border-color:var(--border)!important;color:var(--text-primary)!important;box-shadow:var(--shadow-xs)!important}
.page-head h1,.section-head h2,.card h2,.card h3,.task-title,.profile-main h2{color:var(--text-primary)!important}
.page-head p,.section-head p,.muted,.hint,.kpi-label,.kpi-sub,.employee-cell small,.profile-main p,.detail-item small,.achievement-meta,.app-footer{color:var(--text-secondary)!important}
.eyebrow{background:var(--primary-soft)!important;color:var(--primary-strong)!important;border-color:var(--border)!important}
.today,.toolbar,.detail-item,.note-box,.quick-action,.action-panel{background:var(--surface-secondary)!important;border-color:var(--border)!important;color:var(--text-secondary)!important}

/* Controls */
.btn{min-height:40px;border-radius:var(--radius-sm);transition:background .16s ease,border-color .16s ease,color .16s ease,transform .16s ease;box-shadow:none}
.btn-primary{background:var(--primary)!important;color:#fff!important}.btn-primary:hover{background:var(--primary-strong)!important}.btn-danger{background:color-mix(in srgb,var(--danger) 11%,var(--surface))!important;color:var(--danger)!important}.btn-light,.btn-soft{background:var(--surface-secondary)!important;color:var(--text-primary)!important;border:1px solid var(--border)!important}.btn-dark{background:#20282D!important;color:#fff!important}
.input,.select,.textarea,.chat-search-input,.chat-user-search input{background:var(--surface)!important;color:var(--text-primary)!important;border-color:var(--border)!important;min-height:44px}
.input::placeholder,.textarea::placeholder,.chat-search-input::placeholder,.chat-user-search input::placeholder{color:var(--text-muted)!important}
.input:focus,.select:focus,.textarea:focus,.chat-search-input:focus,.chat-user-search input:focus{border-color:var(--primary)!important;box-shadow:var(--focus)!important}
.form-group label{color:var(--text-primary)!important}.form-group .hint{color:var(--text-secondary)!important}
select{color-scheme:light dark}

/* Tables */
.table-wrap{overflow:auto}.table{color:var(--text-primary)}.table th{background:var(--surface-secondary)!important;color:var(--text-secondary)!important;border-color:var(--border)!important;text-align:start}.table td{border-color:var(--border)!important;text-align:start}.table tbody tr:hover td{background:var(--hover)!important}
.progress{background:var(--disabled)!important}.progress span{background:var(--primary)!important}

/* Alerts / badges */
.alert-success{background:color-mix(in srgb,var(--success) 11%,var(--surface))!important;color:var(--success)!important;border-color:color-mix(in srgb,var(--success) 30%,var(--border))!important}.alert-error{background:color-mix(in srgb,var(--danger) 10%,var(--surface))!important;color:var(--danger)!important;border-color:color-mix(in srgb,var(--danger) 28%,var(--border))!important}.alert-info{background:color-mix(in srgb,var(--info) 10%,var(--surface))!important;color:var(--info)!important;border-color:color-mix(in srgb,var(--info) 28%,var(--border))!important}.alert-warning{background:color-mix(in srgb,var(--warning) 11%,var(--surface))!important;color:var(--warning)!important;border-color:color-mix(in srgb,var(--warning) 28%,var(--border))!important}
.badge-gray,.badge-dark{background:var(--surface-secondary)!important;color:var(--text-secondary)!important}.badge-blue{background:color-mix(in srgb,var(--info) 12%,var(--surface))!important;color:var(--info)!important}.badge-green{background:color-mix(in srgb,var(--success) 12%,var(--surface))!important;color:var(--success)!important}.badge-red{background:color-mix(in srgb,var(--danger) 11%,var(--surface))!important;color:var(--danger)!important}.badge-orange{background:color-mix(in srgb,var(--warning) 12%,var(--surface))!important;color:var(--warning)!important}

/* Sidebar: calm navigation in both themes */
.sidebar{background:#151B1F!important;color:#EEF3F4!important;border-inline-start:1px solid rgba(255,255,255,.06)!important;border-left:0!important}.sidebar nav{overflow-y:auto;overscroll-behavior:contain;scrollbar-width:thin}.sidebar nav a{color:#B7C2C7!important}.sidebar nav a:hover{background:rgba(255,255,255,.055)!important;color:#fff!important}.sidebar nav a.active{background:rgba(166,77,104,.24)!important;color:#fff!important;border:0!important;box-shadow:inset 3px 0 0 #A64D68}.sidebar-footer{background:transparent!important}.preference-panel{display:grid;grid-template-columns:1fr 1fr;gap:7px;margin-bottom:10px}.preference-control{min-width:0;min-height:38px;padding:7px 9px;border-radius:11px;background:rgba(255,255,255,.055);border:1px solid rgba(255,255,255,.07);color:#D3DCE0;display:flex;align-items:center;gap:7px;font-size:10px}.preference-control b{font-size:9px}.preference-control select{width:100%;min-width:0;border:0;background:transparent;color:#D3DCE0;font:inherit;outline:0}.preference-control option{color:#1f2b30;background:#fff}.user-mini{border-color:rgba(255,255,255,.06)!important}.notify-enable{background:#fff!important;color:#26343A!important}.logout-side{color:#D5DEE2!important}

/* Public pages preferences */
.public-preferences{position:fixed;z-index:500;top:83px;inset-inline-end:16px;display:flex;gap:8px}.public-pref{min-height:40px;min-width:42px;border-radius:12px;background:var(--surface);color:var(--text-primary);border:1px solid var(--border);box-shadow:var(--shadow-xs);display:flex;align-items:center;justify-content:center;gap:6px;padding:7px 10px;font-size:10px;font-weight:700}.public-theme select{border:0;background:transparent;color:inherit;outline:0;font:inherit}
.login-page,.login-side,.register-body,.auth-page,.landing-body,.installer{background:var(--bg-primary)!important;color:var(--text-primary)!important}.login-box,.register-box,.install-box,.landing-nav,.landing-features article{background:var(--surface)!important;border-color:var(--border)!important;color:var(--text-primary)!important}.login-box>p,.login-note,.register-form-head p,.landing-section-head p,.landing-copy p{color:var(--text-secondary)!important}

/* Modal & overlays: remove the heavy gray wall from V5.2 */
.chat-modal,.sidebar-overlay.show,.install-sheet,.image-viewer{background:var(--overlay)!important}.chat-modal{backdrop-filter:blur(2px)!important}.chat-modal-card,.install-sheet-card{background:var(--surface)!important;color:var(--text-primary)!important;border:1px solid var(--border)!important;box-shadow:var(--shadow-md)!important}.chat-modal-card header button,.install-sheet-close{background:var(--surface-secondary)!important;color:var(--text-primary)!important}.chat-user-result:hover{background:var(--hover)!important}.chat-search-empty{color:var(--text-secondary)!important}

/* Chat */
body.page-chat,.page-chat .main-content{background:var(--bg-primary)!important;color:var(--text-primary)!important}.chat-v5{background:transparent!important}.chat-list-pane,.chat-conversation-pane{background:var(--surface)!important;border-color:var(--border)!important;box-shadow:var(--shadow-xs)!important}.chat-list-header,.chat-header-v5,.composer-stack{background:var(--surface)!important;border-color:var(--border)!important}.chat-list-search,.message-stream,.chat-welcome{background:var(--surface-secondary)!important}.conversation{color:var(--text-primary)!important;border-color:transparent!important}.conversation:hover{background:var(--hover)!important}.conversation.active{background:var(--active)!important}.conversation-copy small,.conversation-line time,.chat-peer-copy p{color:var(--text-secondary)!important}.bubble:not(.mine){background:var(--surface)!important;border-color:var(--border)!important;color:var(--text-primary)!important}.bubble.mine{background:var(--primary)!important;color:#fff!important}.message-text{unicode-bidi:plaintext;direction:auto;text-align:start}.quoted-message{background:color-mix(in srgb,var(--surface-secondary) 88%,transparent)!important;border-color:var(--border)!important;color:inherit!important}.chat-composer{background:var(--surface)!important;border-color:var(--border)!important}.chat-composer textarea{background:transparent!important;color:var(--text-primary)!important}.typing-row,.chat-day-separator span,.unread-separator span{background:var(--surface)!important;color:var(--text-secondary)!important;border-color:var(--border)!important}.file-card{background:var(--surface-secondary)!important;color:var(--text-primary)!important;border-color:var(--border)!important}

/* Bidirectional support */
[dir="ltr"] .sidebar{right:auto!important;left:0!important;border-inline-start:0!important;border-inline-end:1px solid rgba(255,255,255,.06)!important}
[dir="ltr"] .main-content{margin-right:14px!important;margin-left:260px!important}
[dir="ltr"] .sidebar nav a.active{box-shadow:inset -3px 0 0 #A64D68}
[dir="ltr"] .sidebar-collapse,.directional-icon{transform:scaleX(-1)}
[dir="ltr"] .table th,[dir="ltr"] .table td{text-align:left}
[dir="ltr"] .timeline{padding-right:0;padding-left:19px}[dir="ltr"] .timeline:before{right:auto;left:5px}[dir="ltr"] .timeline-item{padding-right:0;padding-left:10px}[dir="ltr"] .timeline-item:before{right:auto;left:-18px}
[dir="ltr"] .callout{border-right:0;border-left:4px solid var(--primary)}[dir="ltr"] .callout.red{border-left-color:var(--danger)}
[dir="ltr"] .chat-user-search span{right:auto;left:31px}[dir="ltr"] .chat-user-search input{padding-left:40px;padding-right:12px}
[dir="ltr"] .conversation,[dir="ltr"] .employee-cell,[dir="ltr"] .profile-main{text-align:left}

/* Accessible touch targets and responsive behavior */
button,a.btn,.icon-btn,.chat-icon-action,.chat-new-btn,.message-quick-action{touch-action:manipulation}
@media(max-width:760px){
  .main-content{background:var(--bg-primary)!important;border-color:var(--border)!important}
  .mobile-topbar{background:var(--surface)!important;color:var(--text-primary)!important;border-color:var(--border)!important}
  .pref-icon{min-width:38px;height:38px;border:1px solid var(--border);border-radius:10px;background:var(--surface-secondary);color:var(--text-primary);display:grid;place-items:center;font-size:10px;font-weight:800}
  [dir="ltr"] .main-content{margin-left:7px!important;margin-right:7px!important}
  [dir="ltr"] .sidebar{left:0!important;right:auto!important;transform:translateX(-105%)}[dir="ltr"] .sidebar.open{transform:translateX(0)}
  .public-preferences{top:10px;inset-inline-end:10px}.public-pref{min-height:38px}
  .chat-modal{background:var(--overlay)!important}.chat-modal-card{border-radius:22px 22px 0 0!important}
}
@media(max-width:420px){.preference-panel{grid-template-columns:1fr}.public-theme select{max-width:86px}}
.nav-section-label{display:block;padding:13px 12px 5px;color:#728087;font-size:8px;font-weight:800;letter-spacing:.04em;text-transform:uppercase;pointer-events:none}.sidebar-collapsed .nav-section-label{font-size:0;height:8px;padding:4px;border-top:1px solid rgba(255,255,255,.06);margin-top:6px}




/* V5.7 — compact utility controls inherit the active theme without text clutter. */
.mobile-pref-icon .ui-icon,.mobile-notify .ui-icon{width:20px;height:20px}
.mobile-notify .ui-icon{color:var(--primary)}
.mobile-notify span:not(.ui-icon){background:var(--accent)!important;color:#fff!important;border:2px solid var(--surface)!important;box-shadow:0 3px 10px rgba(166,77,104,.22)!important}
[data-theme="dark"] .mobile-notify span:not(.ui-icon){border-color:var(--surface)!important}

/* =========================================================
   V5.10 — complete dark-mode contrast pass
   ========================================================= */
html[data-theme="dark"] body{background:var(--bg-primary)!important;color:var(--text-primary)!important}
html[data-theme="dark"] .page-head,
html[data-theme="dark"] .card,
html[data-theme="dark"] .kpi-card,
html[data-theme="dark"] .table-wrap,
html[data-theme="dark"] .toolbar,
html[data-theme="dark"] .quick-action,
html[data-theme="dark"] .idea-card,
html[data-theme="dark"] .saved-note,
html[data-theme="dark"] .notification-item,
html[data-theme="dark"] .detail-item,
html[data-theme="dark"] .note-box,
html[data-theme="dark"] .action-panel{background:var(--surface)!important;border-color:var(--border)!important;color:var(--text-primary)!important}
html[data-theme="dark"] .toolbar,
html[data-theme="dark"] .detail-item,
html[data-theme="dark"] .note-box,
html[data-theme="dark"] .quick-action{background:var(--surface-secondary)!important}
html[data-theme="dark"] .idea-card p,
html[data-theme="dark"] .saved-note p,
html[data-theme="dark"] .notification-copy p,
html[data-theme="dark"] .quick-action small,
html[data-theme="dark"] .detail-item small,
html[data-theme="dark"] .note-box p{color:var(--text-secondary)!important}
html[data-theme="dark"] .page-back-btn{background:var(--surface-secondary);border-color:var(--border);color:var(--text-primary)}
html[data-theme="dark"] .page-back-btn:hover{background:var(--active);color:var(--primary-strong)}

/* Chat text had light-mode hardcoded colors; force every readable layer onto theme tokens. */
html[data-theme="dark"] .chat-list-header h2,
html[data-theme="dark"] .conversation-line b,
html[data-theme="dark"] .chat-peer-copy h3,
html[data-theme="dark"] .chat-welcome h2,
html[data-theme="dark"] .chat-user-result b,
html[data-theme="dark"] .message-text,
html[data-theme="dark"] .message-sender,
html[data-theme="dark"] .chat-modal-card header h3{color:var(--text-primary)!important}
html[data-theme="dark"] .chat-kicker,
html[data-theme="dark"] .conversation-line time,
html[data-theme="dark"] .conversation-line.preview small,
html[data-theme="dark"] .chat-peer-copy p,
html[data-theme="dark"] .chat-welcome p,
html[data-theme="dark"] .chat-user-result small,
html[data-theme="dark"] .message-time,
html[data-theme="dark"] .composer-hint,
html[data-theme="dark"] .reply-preview small,
html[data-theme="dark"] .reply-preview span,
html[data-theme="dark"] .upload-item small{color:var(--text-secondary)!important}
html[data-theme="dark"] .chat-list-search input,
html[data-theme="dark"] .chat-user-search input,
html[data-theme="dark"] .chat-composer,
html[data-theme="dark"] .reply-preview,
html[data-theme="dark"] .upload-item,
html[data-theme="dark"] .quoted-message,
html[data-theme="dark"] .file-card{background:var(--surface-secondary)!important;border-color:var(--border)!important;color:var(--text-primary)!important}
html[data-theme="dark"] .attach-button,
html[data-theme="dark"] .chat-icon-action,
html[data-theme="dark"] .chat-mobile-back,
html[data-theme="dark"] .chat-modal-back,
html[data-theme="dark"] .chat-modal-close,
html[data-theme="dark"] .chat-system-back{background:var(--surface-secondary)!important;border-color:var(--border)!important;color:var(--text-primary)!important}
html[data-theme="dark"] .bubble:not(.mine){background:var(--surface-elevated)!important;border-color:var(--border)!important;color:var(--text-primary)!important}
html[data-theme="dark"] .bubble:not(.mine) .message-text{color:var(--text-primary)!important}
html[data-theme="dark"] .bubble:not(.mine) .message-quick-action{color:var(--text-secondary)!important}
html[data-theme="dark"] .bubble:not(.mine) .message-quick-action:hover{color:var(--primary-strong)!important}
html[data-theme="dark"] .chat-day-separator span,
html[data-theme="dark"] .unread-separator span,
html[data-theme="dark"] .load-older{background:var(--surface-elevated)!important;border-color:var(--border)!important;color:var(--text-secondary)!important}
html[data-theme="dark"] .chat-user-skeleton{background:linear-gradient(90deg,var(--surface-secondary) 25%,var(--surface-elevated) 50%,var(--surface-secondary) 75%);background-size:200% 100%}
html[data-theme="dark"] .media-image{background:var(--surface-secondary)!important}
html[data-theme="dark"] .media-image img{background:var(--surface-secondary)!important}
html[data-theme="dark"] .chat-modal-card{background:var(--surface)!important}
html[data-theme="dark"] .chat-modal-card header{border-color:var(--border)!important}
html[data-theme="dark"] .chat-modal{background:transparent!important}
html[data-theme="dark"] .image-viewer{background:rgba(3,6,8,.96)!important}

/* Sidebar remains deliberately darker but keeps readable controls. */
html[data-theme="dark"] .sidebar{background:#0f1518!important}
html[data-theme="dark"] .sidebar-utility-btn{background:#252832!important;border-color:#2b373c!important;color:#d4dde0!important}
html[data-theme="dark"] .user-mini{background:#252832!important;border-color:#2b373c!important}
[dir="ltr"] body.sidebar-collapsed .main-content{margin-left:86px!important;margin-right:14px!important}
html[data-theme="dark"] .live-notification{background:var(--surface)!important;border-color:var(--border)!important;color:var(--text-primary)!important;box-shadow:0 18px 48px rgba(0,0,0,.34)}
html[data-theme="dark"] .live-notification-icon{background:var(--surface-secondary)!important;color:var(--primary-strong)!important}
