/* ==========================================================================
   Dashboards Platform - ANC (Afaq Alnama Co.) Theme
   Same design tokens as the Sales Dashboard / Trip-to-Cash modules, so the
   platform shell, login, and every module read as one brand.
   ========================================================================== */

:root {
  --bg-deep: #f6f2ec;
  --bg-gradient: radial-gradient(circle at 15% 0%, rgba(163, 38, 56, 0.05) 0%, transparent 45%),
                 radial-gradient(circle at 85% 15%, rgba(242, 183, 5, 0.09) 0%, transparent 40%),
                 linear-gradient(160deg, #faf7f2 0%, #f5efe6 45%, #efe3d3 100%);

  --surface: rgba(255, 255, 255, 0.9);
  --glass-bg: rgba(255, 255, 255, 0.72);
  --glass-border: rgba(60, 40, 28, 0.1);
  --glass-blur: 18px;

  --text: #2b211d;
  --text-muted: #6e5a52;

  --accent: #a32638;
  --accent-strong: #7a1d2a;
  --accent-soft: rgba(163, 38, 56, 0.12);
  --gold: #d69e00;

  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;

  --tile-shadow: 0 10px 24px rgba(60, 40, 28, 0.08);
  --tile-shadow-hover: 0 24px 48px rgba(60, 40, 28, 0.16);
  --focus-ring: rgba(163, 38, 56, 0.25);
}

/* Deliberately no @media (prefers-color-scheme: dark) override - the ANC
   brand (and the Sales Dashboard/Trip-to-Cash modules themselves) is a
   fixed off-white/cream theme regardless of the visitor's OS setting, so
   the platform shell matches them exactly instead of going dark. */

* {
  box-sizing: border-box;
}

/* .modal-overlay (and anything else) that sets its own `display` for
   layout otherwise wins over the browser's default [hidden] rule, since
   author styles beat the UA stylesheet regardless of specificity - a
   modal would stay in flow and clickable/visible even with hidden="true"
   set in HTML/JS. This override guarantees hidden always actually hides. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: "Tajawal", "Inter", "Segoe UI", Tahoma, Arial, sans-serif;
  background: var(--bg-gradient), var(--bg-deep);
  background-attachment: fixed;
  color: var(--text);
}

/* ---------------- Shared background orbs ---------------- */
.bg-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.16;
  z-index: 0;
  pointer-events: none;
}

.orb-1 {
  width: 420px;
  height: 420px;
  top: -120px;
  left: -100px;
  background: var(--accent-strong);
}

.orb-2 {
  width: 380px;
  height: 380px;
  bottom: -140px;
  right: -80px;
  background: var(--gold);
}

/* ---------------- Launcher topbar ---------------- */
.topbar {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 32px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
}

.brand-logo {
  font-size: 24px;
}

.brand-mark {
  height: 40px;
  width: auto;
  background: #fff;
  border-radius: 8px;
  padding: 4px 8px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

.search-wrap {
  position: relative;
  min-width: 220px;
  flex: 0 1 320px;
}

.search-icon {
  position: absolute;
  top: 50%;
  right: 14px;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search-wrap input {
  width: 100%;
  padding: 10px 40px 10px 16px;
  border-radius: 999px;
  border: 1px solid var(--glass-border);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.search-wrap input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

main {
  position: relative;
  z-index: 1;
  flex: 1;
  padding: 24px 32px 8px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 28px 20px;
  max-width: 900px;
  margin: 24px auto;
}

.tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  padding: 8px;
  border-radius: 16px;
  transition: transform 0.15s ease, background 0.15s ease;
}

.tile:hover,
.tile:focus-visible {
  transform: translateY(-3px);
  background: rgba(255, 255, 255, 0.35);
}

.tile:focus-visible {
  outline: 2px solid var(--focus-ring);
}

.tile-icon {
  width: 108px;
  height: 108px;
  border-radius: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  box-shadow: var(--tile-shadow);
  transition: box-shadow 0.15s ease;
}

.tile:hover .tile-icon {
  box-shadow: var(--tile-shadow-hover);
}

.tile-label {
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  line-height: 1.3;
  max-width: 150px;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  margin-top: 40px;
}

.credit {
  position: relative;
  z-index: 1;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  padding: 0 16px 24px;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--text-muted);
}

.topbar-user button {
  border: none;
  background: var(--glass-border);
  color: var(--text);
  padding: 6px 14px;
  border-radius: 999px;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
}

/* ---------------- Login page ---------------- */
.login-page {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow: hidden;
}

/* Structure and every spacing value below is copied 1:1 from
   sales-dashboard's own .login-view/.brand/.login-form (frontend/style.css)
   - .login-card is a plain block holding two stacked pieces (.login-brand,
   then .login-form), not one flat flex list, so the generous gap after the
   logo/title block and the per-field spacing match exactly instead of
   being squeezed into one uniform small gap. */

/* .login-page is a row-direction flex container (align-items/justify-
   content: center), so its direct child's own width is shrink-to-fit, not
   the container's full width. sales-dashboard has no such wrapper - its
   .login-card is that direct flex child, so its own `width: 100%` resolves
   cleanly against .login-view's full width before max-width clamps it to
   400px. Here .login-credit needs to sit under the card as a second
   stacked line, so this wrapper exists - giving IT the same max-width
   makes .login-card's 100% resolve the same way instead of shrinking to
   whatever width its content would otherwise pack into (~330px). */
.login-shell {
  width: 100%;
  max-width: 400px;
}

.login-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 400px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 24px rgba(60, 40, 28, 0.08);
  padding: 40px 36px;
  animation: fadeUp 0.5s ease;
}

.login-brand {
  text-align: center;
  margin-bottom: 28px;
}

.login-brand img {
  display: block;
  width: 168px;
  height: auto;
  object-fit: contain;
  background: #fff;
  border-radius: 12px;
  padding: 10px 14px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.25);
  margin: 0 auto 16px;
}

.login-brand h1 {
  font-size: 1.4rem;
  margin: 0 0 6px;
  color: var(--text);
}

.login-brand p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.login-form label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 12px;
}

.login-form input {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.6);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.login-form input:focus {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.95);
}

.password-field {
  position: relative;
}

.login-form .password-field input {
  width: 100%;
  padding-inline-end: 42px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  inset-inline-end: 4px;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
}

.password-toggle:hover {
  color: var(--accent);
  background: rgba(163, 38, 56, 0.08);
}

.password-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.password-toggle svg {
  display: block;
  pointer-events: none;
}

.login-error {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(220, 38, 38, 0.1);
  color: #dc2626;
  font-size: 0.85rem;
  text-align: center;
}

.login-submit {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin-top: 22px;
  padding: 10px 18px;
  border: none;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff;
  box-shadow: 0 12px 24px rgba(163, 38, 56, 0.4);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: box-shadow 0.15s ease, opacity 0.15s ease;
}

.login-submit:hover {
  box-shadow: 0 14px 30px rgba(163, 38, 56, 0.55);
}

.login-submit:active {
  transform: scale(0.97);
}

.login-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
}

.login-credit {
  position: relative;
  z-index: 1;
  margin-top: 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
}

/* ---------------- Admin panel (Manage Accounts / Change Password) ---------------- */
.topbar-user button.btn-secondary {
  border: 1px solid var(--glass-border);
  background: var(--surface);
  color: var(--text);
  padding: 7px 14px;
  border-radius: 999px;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(43, 33, 29, 0.45);
}

.modal-card {
  position: relative;
  width: 100%;
  max-width: 420px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 48px rgba(60, 40, 28, 0.14);
  padding: 28px 26px;
}

.modal-card-wide {
  max-width: 720px;
}

.modal-card h2 {
  margin: 0 0 16px;
  font-size: 1.1rem;
}

.modal-card h3 {
  margin: 24px 0 4px;
  font-size: 0.95rem;
  color: var(--text-muted);
}

.modal-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.modal-card-header h2 {
  margin: 0;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 12px;
}

.form input,
.form select {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.6);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
}

.form input:focus,
.form select:focus {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.95);
}

.checkbox-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin-top: 6px;
}

.checkbox-inline {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text);
}

.checkbox-inline input {
  width: auto;
}

.access-badges {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
}

.badge-red {
  background: rgba(220, 38, 38, 0.1);
  color: #dc2626;
}

.badge-green {
  background: rgba(22, 163, 74, 0.12);
  color: #16a34a;
}

.field-hint {
  margin: 4px 0 0;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.field-hint.field-hint-error {
  color: #dc2626;
}

.form-error {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(220, 38, 38, 0.1);
  color: #dc2626;
  font-size: 0.85rem;
  text-align: center;
}

.form-success {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(22, 163, 74, 0.12);
  color: #16a34a;
  font-size: 0.85rem;
  text-align: center;
}

.btn-primary,
.btn-ghost {
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff;
  box-shadow: 0 12px 24px rgba(163, 38, 56, 0.35);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.5);
  color: var(--text);
  border: 1px solid var(--glass-border);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.78rem;
}

.table-scroll {
  overflow-x: auto;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  color: var(--text);
  font-size: 0.85rem;
}

table.data-table thead th {
  padding: 10px 12px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.68rem;
  border-bottom: 1px solid var(--glass-border);
}

table.data-table tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--glass-border);
  vertical-align: top;
}

.account-you-tag {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.account-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.account-actions .action-view {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.reset-pw-form {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.reset-pw-input {
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
  font-family: inherit;
  font-size: 0.8rem;
}

@media (max-width: 480px) {
  .topbar {
    padding: 16px;
  }

  main {
    padding: 16px;
  }

  .grid {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 20px 12px;
  }

  .tile-icon {
    width: 84px;
    height: 84px;
    font-size: 36px;
  }
}
