/* ==========================================================================
   styles.css — Ministry of Investment / Invest UAE corporate theme
   Palette sampled from the official MOI · Invest UAE logo:
     Navy  #243447  (Invest UAE mark — primary)
     Gold  #B49450  (Ministry of Investment wordmark — accent)
   Auto light/dark via prefers-color-scheme. No frameworks; CSS variables.
   ========================================================================== */

:root {
  color-scheme: light;         /* keep form controls/scrollbars light in OS dark mode */
  --bg: #ffffff;               /* clean white canvas */
  --surface: #ffffff;
  --surface-2: #f6f4ee;        /* warm off-white for fields */
  --border: #e7e2d6;           /* warm hairline */
  --text: #20242b;             /* charcoal */
  --text-muted: #6f6a5f;       /* warm grey */
  --primary: #9c7826;          /* Ministry of Investment gold (actions) */
  --primary-hover: #836325;    /* deepened gold */
  --on-primary: #ffffff;
  --accent: #b08c46;           /* lighter gold for strips / hairlines */
  --accent-soft: #ddcc9c;
  --focus-ring: rgba(176, 140, 70, 0.30);
  --success-bg: #e6f6ec; --success-fg: #1f7a44; --success-bd: #b6e2c6;
  --error-bg: #fdecec;   --error-fg: #b3261e;   --error-bd: #f3c4c1;
  --warning-bg: #fff6e5; --warning-fg: #8a5a00;  --warning-bd: #f1d9a6;
  --shadow: 0 8px 30px rgba(60, 48, 20, 0.10);
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Light theme only — a clean white interface regardless of OS dark mode. */

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body.centered {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

/* --- Cards --------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  position: relative;
  overflow: hidden;
}
/* Gold accent strip — mirrors the gold bar atop invest.gov.ae */
.auth-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 4px;
  background: linear-gradient(90deg, var(--accent), var(--accent-soft));
}

/* --- Brand -------------------------------------------------------------- */
.brand { text-align: center; margin-bottom: 24px; }

/* Official MOI · Invest UAE logo — a high-res PNG rendered at fixed display
   sizes (native ratio ~2.25:1) so it stays crisp and never overscales. */
.brand-logo {
  display: block;
  width: 240px;
  height: 107px;
  object-fit: contain;
  margin: 0 auto 18px;
}
.brand-logo.sm {
  width: 104px;
  height: 46px;
  margin: 0;
}
.brand-title { font-size: 20px; margin: 0 0 4px; font-weight: 650; }
.brand-sub { margin: 0; color: var(--text-muted); font-size: 13px; }

/* --- Form fields -------------------------------------------------------- */
.field { display: block; margin-bottom: 16px; }
.field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}
.field-hint { margin: 2px 0 10px; font-size: 12.5px; color: var(--text-muted); }
.field-hint code, code {
  background: var(--surface-2);
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 12px;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="datetime-local"],
select {
  width: 100%;
  padding: 11px 13px;
  font-size: 15px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
input[type="datetime-local"]:focus,
select:focus,
.file-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.file-input {
  width: 100%;
  padding: 14px;
  font-size: 14px;
  color: var(--text-muted);
  background: var(--surface-2);
  border: 1.5px dashed var(--border);
  border-radius: 10px;
  cursor: pointer;
}
.file-input::file-selector-button {
  margin-right: 12px;
  padding: 8px 14px;
  border: none;
  border-radius: 8px;
  background: var(--primary);
  color: var(--on-primary);
  font-weight: 600;
  cursor: pointer;
}
.file-input::file-selector-button:hover { background: var(--primary-hover); }

/* --- Buttons ------------------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  font-size: 14.5px;
  font-weight: 600;
  font-family: inherit;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-block { width: 100%; margin-top: 6px; }
.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--surface-2); }

/* --- Alerts ------------------------------------------------------------- */
.alert {
  border: 1px solid;
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 18px;
  font-size: 14px;
}
.alert ul { margin: 4px 0 0; padding-left: 20px; }
.alert li { margin: 2px 0; }
.alert-error   { background: var(--error-bg);   color: var(--error-fg);   border-color: var(--error-bd); }
.alert-success { background: var(--success-bg); color: var(--success-fg); border-color: var(--success-bd); }
.alert-warning { background: var(--warning-bg); color: var(--warning-fg); border-color: var(--warning-bd); }

/* --- Card footer -------------------------------------------------------- */
.card-footer {
  margin-top: 22px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}

/* --- Top bar ------------------------------------------------------------ */
.topbar {
  background: var(--surface);            /* white, like the body... */
  border-bottom: 1px solid var(--border);
  border-top: 4px solid var(--accent);   /* gold brand strip */
  box-shadow: 0 2px 10px rgba(60, 48, 20, 0.06);  /* ...but lifted, so it stays distinct */
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-inner {
  max-width: 820px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand-row { display: flex; align-items: center; gap: 12px; }
.topbar-title { font-weight: 650; font-size: 15.5px; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.user-chip {
  font-size: 13px;
  color: var(--text-muted);
  background: var(--surface-2);
  padding: 6px 12px;
  border-radius: 999px;
}
.inline { display: inline; margin: 0; }

/* --- Page layout -------------------------------------------------------- */
.container {
  max-width: 820px;
  margin: 0 auto;
  padding: 36px 24px 60px;
}
.page-title { font-size: 24px; margin: 0 0 6px; font-weight: 680; }
.page-sub { color: var(--text-muted); margin: 0 0 24px; font-size: 14.5px; }

.upload-card { padding: 28px; }
.upload-field {
  padding: 18px 0;
  border-bottom: 1px solid var(--border);
}
.upload-field:first-of-type { padding-top: 0; }
.actions { margin-top: 22px; }

.page-footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 12.5px;
  padding: 24px;
}

/* --- Responsive --------------------------------------------------------- */
@media (max-width: 520px) {
  .card { padding: 22px; }
  .topbar-inner { padding: 12px 16px; }
  .container { padding: 24px 16px 40px; }
  .user-chip { display: none; }
}

/* --- File-sharing portal additions ------------------------------------- */
.check {
  display: flex; align-items: center; gap: 8px;
  margin: 14px 0 4px; font-size: 14px; color: var(--text); cursor: pointer;
}
.check input { width: 16px; height: 16px; accent-color: var(--primary); }
.conditional {
  margin: 6px 0 10px; padding: 14px 16px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
}
.warn {
  font-size: 13px; color: var(--warning-fg);
  background: var(--warning-bg); border: 1px solid var(--warning-bd);
  border-radius: 8px; padding: 8px 10px; margin: 8px 0 0;
}

.btn-danger { background: var(--error-bg); color: var(--error-fg); border-color: var(--error-bd); }
.btn-danger:hover { background: var(--error-fg); color: #fff; }
.btn-xs { padding: 4px 10px; font-size: 12.5px; }

.muted { color: var(--text-muted); }

.badge {
  display: inline-block; font-size: 11.5px; font-weight: 600; line-height: 1;
  padding: 4px 8px; border-radius: 999px; border: 1px solid var(--border);
}
.badge-lock { background: var(--warning-bg); color: var(--warning-fg); border-color: var(--warning-bd); }
.badge-time { background: var(--surface-2); color: var(--text-muted); }
.badge-expired { background: var(--error-bg); color: var(--error-fg); border-color: var(--error-bd); }
.badge-ok { background: var(--success-bg); color: var(--success-fg); border-color: var(--success-bd); }

.table-wrap { overflow-x: auto; }
.links-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.links-table th, .links-table td {
  text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.links-table th { color: var(--text-muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
.links-table .short { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.links-table .inline { display: inline; }

.short-box { display: flex; gap: 8px; margin: 16px 0; }
.short-url {
  flex: 1; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-2); color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px;
}
.success-card { text-align: left; }

/* --- Inline set-password form in the users table ----------------------- */
.pw-form { display: inline-flex; gap: 6px; align-items: center; margin-right: 8px; }
.pw-mini {
  width: 130px; padding: 5px 8px; font-size: 12.5px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-2); color: var(--text);
}

/* --- Logo link + narrow (centered) container --------------------------- */
.brand-link { text-decoration: none; color: inherit; cursor: pointer; }
.container-narrow { max-width: 520px; }

/* --- Avatar + dropdown menu -------------------------------------------- */
.usermenu { position: relative; }
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--surface-2); color: var(--primary);
  border: 1px solid var(--border); cursor: pointer; padding: 0;
}
.avatar:hover { background: var(--accent-soft); }
.usermenu-pop {
  position: absolute; right: 0; top: calc(100% + 8px);
  min-width: 220px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow); overflow: hidden; z-index: 20;
}
.usermenu-head { padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.usermenu-name { font-weight: 650; font-size: 14px; }
.usermenu-sub { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; word-break: break-all; }
.usermenu-item {
  display: block; width: 100%; text-align: left;
  padding: 11px 16px; font-size: 14px; color: var(--text);
  background: transparent; border: none; cursor: pointer; text-decoration: none;
  font-family: inherit;
}
.usermenu-item:hover { background: var(--surface-2); }
.usermenu-logout { color: var(--error-fg); border-top: 1px solid var(--border); }

/* --- Slug counter ------------------------------------------------------ */
.slug-counter { font-variant-numeric: tabular-nums; color: var(--text-muted); }
.slug-counter.over { color: var(--error-fg); font-weight: 600; }

/* --- Microsoft sign-in button + break-glass divider -------------------- */
.btn-ms {
  background: #ffffff; color: #1b1b1b; border: 1px solid #c8c8c8; gap: 10px;
}
.btn-ms:hover { background: #f3f3f3; }
.bg-divider {
  display: flex; align-items: center; text-align: center;
  color: var(--text-muted); font-size: 12px; margin: 20px 0 14px;
}
.bg-divider::before, .bg-divider::after {
  content: ""; flex: 1; height: 1px; background: var(--border);
}
.bg-divider span { padding: 0 10px; text-transform: uppercase; letter-spacing: .05em; }

/* --- Radio set (access mode) ------------------------------------------- */
.radio-set { border: none; padding: 0; margin: 6px 0 0; display: grid; gap: 8px; }
.radio { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.radio input { width: 16px; height: 16px; accent-color: var(--primary); }
.conditional.sub { margin-top: 12px; background: #fff; }

/* --- Recipient grid ----------------------------------------------------- */
.recip-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.recip-row input { flex: 1; }
.recip-remove { flex: 0 0 auto; }
.recip-add { margin-top: 8px; }
.resend { margin-top: 10px; }

/* --- Read-only account profile ----------------------------------------- */
.profile { display: grid; grid-template-columns: auto 1fr; gap: 8px 18px; margin: 8px 0 0; }
.profile dt { color: var(--text-muted); font-size: 13px; font-weight: 600; }
.profile dd { margin: 0; font-size: 14px; word-break: break-all; }

.badge-selected { background: var(--warning-bg); color: var(--warning-fg); border-color: var(--warning-bd); }

/* --- Links list (dashboard) -------------------------------------------- */
.list-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; flex-wrap: wrap; margin-bottom: 14px;
}
.list-head .page-title { margin: 0; display: inline-flex; align-items: center; gap: 10px; }
.count {
  font-size: 12.5px; font-weight: 600; color: var(--text-muted);
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 2px 9px; line-height: 1.5;
}
.list-search {
  width: 260px; max-width: 100%; padding: 9px 12px; font-size: 14px;
}

.link-list { display: flex; flex-direction: column; }
.link-item {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 8px; border-top: 1px solid var(--border);
}
.link-item:first-child { border-top: none; }
.link-item:hover { background: var(--surface-2); border-radius: 10px; }
/* Search filter hides items via [hidden]; override the flex display. */
.link-item[hidden] { display: none; }

/* Leading access marker before the title */
.li-access {
  flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 6px; border: 1px solid var(--border);
}
.li-access.acc-public   { background: var(--surface-2); color: var(--text-muted); }
.li-access.acc-anyone   { background: var(--warning-bg); color: var(--warning-fg); border-color: var(--warning-bd); }
.li-access.acc-selected { background: #e8f1fd; color: #1e5fb3; border-color: #c1d6f3; }
.li-access svg { display: block; }

/* Creator line (superuser view) */
.li-creator {
  display: flex; align-items: center; gap: 5px;
  font-size: 12.5px; color: var(--text-muted); margin-top: 4px;
}
.li-creator svg { opacity: .75; }

/* Icon-only buttons */
.btn-icon { padding: 7px; line-height: 0; }
.btn-icon svg { display: block; }

/* File-type icon chip */
.li-icon {
  flex: 0 0 auto; width: 44px; height: 44px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; letter-spacing: .02em;
  border: 1px solid var(--border); color: var(--text-muted); background: var(--surface-2);
}
.li-icon.ft-pdf  { background: #fdecec; color: #b3261e; border-color: #f3c4c1; }
.li-icon.ft-ppt  { background: #fff1e6; color: #b3551e; border-color: #f3d6c1; }
.li-icon.ft-html { background: #e8f1fd; color: #1e5fb3; border-color: #c1d6f3; }
.li-icon.ft-xls  { background: #e6f6ec; color: #1f7a44; border-color: #b6e2c6; }

.li-body { flex: 1 1 auto; min-width: 0; }
.li-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.li-name { font-weight: 650; font-size: 15px; }
.li-badges { display: inline-flex; gap: 5px; }
.li-meta {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 12.5px; color: var(--text-muted); margin-top: 3px;
}
.li-file { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 280px; }
.li-owner { font-weight: 600; }
.li-dot { opacity: .5; }
.li-short { display: flex; align-items: center; gap: 8px; margin-top: 7px; min-width: 0; }
.li-url {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px;
  color: var(--primary); text-decoration: none;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 320px;
}
.li-url:hover { text-decoration: underline; }
.li-actions { flex: 0 0 auto; display: flex; align-items: center; gap: 6px; }

.empty-state {
  text-align: center; color: var(--text-muted); font-size: 14px;
  padding: 28px 12px;
}

/* Stack each link into a card on narrow screens. */
@media (max-width: 640px) {
  .link-item { flex-wrap: wrap; }
  .li-body { flex-basis: calc(100% - 58px); }
  .li-actions { flex-basis: 100%; padding-left: 58px; flex-wrap: wrap; }
  .li-file { max-width: 200px; }
  .li-url { max-width: 200px; }
  .list-search { width: 100%; }
}
