/*
 * Ertekaz association identity layer for Roundcube Elastic.
 * Scoped overrides only: the stock Elastic markup, IDs and JS remain intact.
 */
@font-face {
  font-family: 'Ertekaz Arabic';
  src: url('/skins/ertekaz/fonts/Iura6YBj_oCad4k1rzY.ttf') format('truetype');
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --ez-navy: #0a1e35;
  --ez-blue: #1a3a5c;
  --ez-blue-soft: #eaf2f8;
  --ez-gold: #c8a84b;
  --ez-ink: #203247;
  --ez-muted: #6b7b8e;
  --ez-line: #e3e9ef;
  --ez-surface: #ffffff;
  --ez-canvas: #f5f7fa;
  --ez-success: #2f8061;
  --ez-radius: 10px;
  --ez-shadow: 0 8px 24px rgba(10, 30, 53, .08);
}

/* Local Arabic type and calm reading rhythm without forcing message direction. */
html, body, button, input, select, textarea, .btn, .form-control {
  font-family: 'Ertekaz Arabic', 'Segoe UI', Tahoma, Arial, sans-serif;
}
body { color: var(--ez-ink); background: var(--ez-canvas); }
html[dir="rtl"] body { text-align: start; }

/* Login: retain Elastic structure, add a quiet institutional surface. */
body.task-login { background: linear-gradient(145deg, #edf3f7 0%, #f8fafc 58%, #e6eef4 100%); }
body.task-login #layout { padding: 24px; }
body.task-login #layout-content {
  border: 1px solid rgba(10, 30, 53, .08);
  border-top: 4px solid var(--ez-gold);
  border-radius: 16px;
  box-shadow: 0 22px 55px rgba(10, 30, 53, .14);
  background: var(--ez-surface);
}
body.task-login #logo img {
  max-width: 190px;
  max-height: 84px;
  object-fit: contain;
}
body.task-login #login-form .form-control,
body.task-login #login-form input[type="text"],
body.task-login #login-form input[type="password"] {
  border: 1px solid #cfd9e3;
  border-radius: 9px;
  background: #fbfcfd;
  min-height: 44px;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
body.task-login #login-form .form-control:focus,
body.task-login #login-form input:focus {
  border-color: var(--ez-blue);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(26, 58, 92, .13);
}
body.task-login #rcmloginsubmit,
body.task-login input[type="submit"] {
  min-height: 46px;
  border: 0;
  border-radius: 9px;
  background: var(--ez-navy);
  color: #fff;
  font-weight: 700;
  transition: background .18s ease, transform .18s ease, box-shadow .18s ease;
}
body.task-login #rcmloginsubmit:hover,
body.task-login #rcmloginsubmit:focus,
body.task-login input[type="submit"]:hover,
body.task-login input[type="submit"]:focus {
  background: var(--ez-blue);
  box-shadow: 0 6px 16px rgba(10, 30, 53, .18);
  transform: translateY(-1px);
}
body.task-login #messagestack { max-width: 440px; }

/* Main application canvas and navigation. */
#layout { background: var(--ez-canvas); }
#layout-menu, #layout-sidebar, #layout-list, #layout-content {
  border-color: var(--ez-line);
}
#layout-menu { background: var(--ez-navy); }
#layout-menu a, #layout-menu button { color: rgba(255,255,255,.82); }
#layout-menu a:hover, #layout-menu a:focus, #layout-menu a.selected {
  color: #fff;
  background: rgba(255,255,255,.12);
}
#layout-sidebar { background: #fbfcfd; }
#layout-sidebar .header, #layout-sidebar .footer { background: transparent; }
#layout-list, #layout-content { background: var(--ez-surface); }

/* Brand accents where Elastic already exposes actions and headings. */
.header, .footer { border-color: var(--ez-line); }
.header a.button, .footer a.button, .toolbar a.button, .toolbar button,
.btn, button {
  border-radius: 8px;
  transition: background .16s ease, border-color .16s ease, color .16s ease, box-shadow .16s ease;
}
.btn-primary, .button.mainaction, .toolbar a.button.mainaction {
  background: var(--ez-navy);
  border-color: var(--ez-navy);
}
.btn-primary:hover, .btn-primary:focus, .button.mainaction:hover, .button.mainaction:focus {
  background: var(--ez-blue);
  border-color: var(--ez-blue);
}

/* Folder list: quieter hierarchy and clear unread state. */
.folderlist li a, .listing li a { border-radius: 7px; margin-block: 1px; }
.folderlist li a:hover, .folderlist li a:focus, .listing li a:hover, .listing li a:focus {
  background: var(--ez-blue-soft);
}
.folderlist li.selected > a, .folderlist li.selected > div > a,
.listing li.selected > a, .listing li.selected > div > a {
  background: var(--ez-blue-soft);
  color: var(--ez-navy);
  font-weight: 700;
}
.folderlist .unreadcount { background: var(--ez-gold); color: var(--ez-navy); }

/* Message list: readable scan order, gentle selected/unread emphasis. */
.messagelist { color: var(--ez-ink); }
.messagelist tr { border-color: var(--ez-line); }
.messagelist tr:hover td { background: #f7fafc; }
.messagelist tr.selected td { background: var(--ez-blue-soft); }
.messagelist tr.unread td, .messagelist tr.unread .subject a { font-weight: 700; }
.messagelist td.subject a { color: var(--ez-ink); }
.messagelist td.subject span.fromto, .messagelist td.subject span.date,
.messagelist td.subject span.size { color: var(--ez-muted); }
.messagelist td { overflow-wrap: anywhere; }

/* Reading area, attachments and headers. */
#message-header { background: #fbfcfd; border-color: var(--ez-line); }
#message-header .header-title { color: var(--ez-navy); font-weight: 700; }
.message-partheaders, .attachmentslist { border-color: var(--ez-line); border-radius: 8px; }
.attachmentslist { background: #fbfcfd; }
.attachmentslist li:hover { background: var(--ez-blue-soft); }
.message-htmlpart { box-shadow: none; }

/* Compose, contacts, settings and dialogs share the same field language. */
.form-control, .custom-select, select, textarea, input[type="text"], input[type="email"], input[type="url"] {
  border-radius: 8px;
  border-color: #cfd9e3;
  min-height: 40px;
}
.form-control:focus, .custom-select:focus, select:focus, textarea:focus, input:focus {
  border-color: var(--ez-blue);
  box-shadow: 0 0 0 3px rgba(26, 58, 92, .12);
}
.recipient-input, .file-upload, .html-editor, .tox.tox-tinymce { border-radius: 8px; }
.ui-dialog, .popover, .popup { border-radius: 10px; box-shadow: var(--ez-shadow); }
.ui-dialog .ui-dialog-titlebar { border-radius: 10px 10px 0 0; }
.nav-tabs .nav-link.active { color: var(--ez-navy); border-bottom-color: var(--ez-gold); }

/* Keyboard and touch affordances. */
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible,
a:focus-visible, .btn:focus-visible { outline: 3px solid rgba(26, 58, 92, .3); outline-offset: 2px; }
button, input[type="button"], input[type="submit"], a.button, .btn { min-height: 40px; }

/* Mixed Arabic/Latin data remains LTR; received message HTML keeps its own direction. */
html[dir="rtl"] a[href^="mailto:"], html[dir="rtl"] a[href^="http:"],
html[dir="rtl"] a[href^="https:"], html[dir="rtl"] .email,
html[dir="rtl"] .recipient, html[dir="rtl"] .fromto,
html[dir="rtl"] input[type="email"], html[dir="rtl"] input[type="url"] {
  direction: ltr;
  text-align: left;
  unicode-bidi: plaintext;
}
.message-htmlpart, .message-part, #messagepartframe, .message-htmlpart iframe { unicode-bidi: normal; }

/* Responsive: use Elastic's mobile layout; only prevent accidental clipping. */
#layout, #layout > div, #layout-sidebar, #layout-list, #layout-content,
.listbox, .table-widget, .boxcontent { min-width: 0; max-width: 100%; }
#messagelist, .listingbox, .table-widget { overflow-x: auto; }
@media screen and (max-width: 767px) {
  body { font-size: 14px; }
  body.task-login #layout { padding: 12px; }
  body.task-login #layout-content { border-radius: 12px; }
  body.task-login #logo img { max-width: 160px; max-height: 68px; }
  .toolbar { gap: 4px; flex-wrap: wrap; }
  .toolbar a.button, .toolbar button, .btn { min-height: 42px; }
  #message-header .header-headers { line-height: 1.65; }
  .popup, .popover, .ui-dialog { max-width: calc(100vw - 16px); }
}
@media screen and (max-width: 390px) {
  body.task-login #layout { padding: 8px; }
  body.task-login #layout-content { width: 100%; }
  #messagelist table { min-width: 500px; }
}

/* Elastic login groups: keep the icon and field aligned at every width. */
body.task-login #login-form td.input {
  display: flex;
  align-items: stretch;
  width: 100%;
  min-width: 0;
}
body.task-login #login-form td.input .input-group-prepend {
  flex: 0 0 auto;
  display: flex;
  align-items: stretch;
}
body.task-login #login-form td.input .form-control,
body.task-login #login-form td.input input {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
}

/* Final login proportions: a focused card on desktop, full-width on mobile. */
body.task-login #layout-content {
  width: calc(100% - 32px);
  max-width: 520px;
  min-width: 0;
  height: auto;
  min-height: 0;
}
body.task-login #login-form td.input .input-group-prepend {
  width: auto;
  min-width: 0;
  flex: 0 0 auto;
}
body.task-login #login-form td.input .input-group-text {
  width: auto;
  min-width: 44px;
}
@media screen and (max-width: 767px) {
  body.task-login #layout-content { width: calc(100% - 16px); max-width: 520px; }
}

/* Elastic mobile table override: only the login control row needs this. */
body.task-login #login-form td.input { display: flex !important; }
body.task-login #login-form td.input .input-group-prepend { width: auto !important; }
body.task-login #login-form td.input .form-control,
body.task-login #login-form td.input input { width: auto !important; }

/* Keep each login icon beside its field, including Elastic mobile mode. */
body.task-login #login-form td.input { flex-direction: row !important; }

/* Stable login icon placement for Elastic's mobile table layout. */
body.task-login #login-form td.input {
  display: block !important;
  position: relative;
  width: 100%;
  height: 44px;
  min-height: 44px;
}
body.task-login #login-form td.input .input-group-prepend {
  position: absolute;
  inset-inline-start: 0;
  inset-block-start: 0;
  z-index: 2;
  width: auto !important;
  height: 44px;
}
body.task-login #login-form td.input .input-group-text {
  min-width: 48px;
  height: 44px;
  border-radius: 8px;
}
body.task-login #login-form td.input .form-control,
body.task-login #login-form td.input input {
  display: block;
  width: 100% !important;
  height: 44px;
  padding-inline-start: 58px;
}

/* Simplified branded login: remove the logo when it interferes with alignment. */
body.task-login #logo { display: none !important; }
body.task-login #layout-content { padding-top: 28px; }
body.task-login #login-form { margin-top: 0; }
body.task-login #login-form td.input { margin-bottom: 12px; }

/* Final centered login card after removing the logo. */
body.task-login #layout-content {
  display: flex !important;
  flex-direction: column;
  justify-content: center;
  align-items: stretch;
  box-sizing: border-box;
  min-height: 300px !important;
  height: auto !important;
  padding: 34px 20px 26px !important;
  overflow: visible;
}
body.task-login #login-form {
  position: relative;
  top: auto !important;
  inset-block-start: auto !important;
  margin: 0 !important;
  width: 100%;
}
@media screen and (max-width: 480px) {
  body.task-login #layout-content {
    min-height: 330px !important;
    padding: 38px 18px 28px !important;
  }
}
