/* =========================================
   MOEL Asset & Warehouse – Main Styles
   RTL layout, sidebar on the right
   Softer “official government” style
   Light, clean, bigger typography
========================================= */

:root {
  /* Shared layout tokens */
  --radius-lg: 18px;
  --radius-xl: 22px;
  --shadow-soft: 0 16px 40px rgba(15, 23, 42, 0.08);
  --header-height: 76px;
  --sidebar-width: 270px;

  /* LIGHT THEME – official / neutral */
  --bg-page: linear-gradient(
    135deg,
    #f3f4f6 0%,
    #e7f0ff 40%,
    #f9fafb 100%
  );
  --color-bg-elevated: #ffffff;
  --color-bg-elevated-soft: #f5f7fb;
  --color-border-subtle: rgba(148, 163, 184, 0.4);

  --color-accent: #1d4ed8;           /* main gov blue */
  --color-accent-soft: rgba(37, 99, 235, 0.12);
  --color-accent-strong: #1e40af;
  --color-text-main: #111827;
  --color-text-soft: #6b7280;
  --color-danger: #b91c1c;
  --color-success: #15803d;

  --header-bg: linear-gradient(
    90deg,
    #e5edf9 0%,
    #dde9ff 40%,
    #e5f4ff 100%
  );
  --header-text: #0f172a;

  --sidebar-bg: rgba(255, 255, 255, 0.98);
  --sidebar-text: #111827;
  --sidebar-muted: #6b7280;
  --sidebar-active-bg: rgba(37, 99, 235, 0.08);
  --sidebar-active-border: #1d4ed8;
  --sidebar-hover-bg: rgba(148, 163, 184, 0.12);

  --footer-bg: transparent;
}

/* Explicit LIGHT override (same as root) */
:root[data-theme='light'] {
  --bg-page: linear-gradient(
    135deg,
    #f3f4f6 0%,
    #e7f0ff 40%,
    #f9fafb 100%
  );
  --color-bg-elevated: #ffffff;
  --color-bg-elevated-soft: #f5f7fb;
  --color-border-subtle: rgba(148, 163, 184, 0.4);

  --color-accent: #1d4ed8;
  --color-accent-soft: rgba(37, 99, 235, 0.12);
  --color-accent-strong: #1e40af;
  --color-text-main: #111827;
  --color-text-soft: #6b7280;
  --color-danger: #b91c1c;
  --color-success: #15803d;

  --header-bg: linear-gradient(
    90deg,
    #e5edf9 0%,
    #dde9ff 40%,
    #e5f4ff 100%
  );
  --header-text: #0f172a;

  --sidebar-bg: rgba(255, 255, 255, 0.98);
  --sidebar-text: #111827;
  --sidebar-muted: #6b7280;
  --sidebar-active-bg: rgba(37, 99, 235, 0.08);
  --sidebar-active-border: #1d4ed8;
  --sidebar-hover-bg: rgba(148, 163, 184, 0.12);

  --footer-bg: transparent;
}

/* SOFT DARK THEME – calm, not flashy */
:root[data-theme='dark'] {
  --bg-page: linear-gradient(
    135deg,
    #020617 0%,
    #0b1220 40%,
    #020617 100%
  );
  --color-bg-elevated: rgba(15, 23, 42, 0.96);
  --color-bg-elevated-soft: rgba(15, 23, 42, 0.9);
  --color-border-subtle: rgba(148, 163, 184, 0.5);

  --color-accent: #60a5fa;
  --color-accent-soft: rgba(96, 165, 250, 0.18);
  --color-accent-strong: #93c5fd;
  --color-text-main: #e5e7eb;
  --color-text-soft: #9ca3af;
  --color-danger: #fca5a5;
  --color-success: #4ade80;

  --header-bg: linear-gradient(
    90deg,
    #0b1120 0%,
    #111827 40%,
    #1d283a 100%
  );
  --header-text: #f9fafb;

  --sidebar-bg: rgba(15, 23, 42, 0.97);
  --sidebar-text: #e5e7eb;
  --sidebar-muted: #9ca3af;
  --sidebar-active-bg: rgba(96, 165, 250, 0.22);
  --sidebar-active-border: #bfdbfe;
  --sidebar-hover-bg: rgba(30, 64, 175, 0.35);

  --footer-bg: rgba(15, 23, 42, 0.94);
}

/* ========== Reset & Base ========== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

/* base settings for both app and login pages */
body.app-body,
body.login-body {
  min-height: 100vh;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px; /* bigger base font */
  line-height: 1.6;
  background: var(--bg-page);
  color: var(--color-text-main);
  scroll-behavior: smooth;
}

/* Scrollbar (slim) */
body.app-body::-webkit-scrollbar,
body.login-body::-webkit-scrollbar {
  width: 8px;
}
body.app-body::-webkit-scrollbar-track,
body.login-body::-webkit-scrollbar-track {
  background: transparent;
}
body.app-body::-webkit-scrollbar-thumb,
body.login-body::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.6);
  border-radius: 999px;
}

/* ========== Layout Shell ========== */

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */

.app-header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-inline: 1.75rem;
  background: var(--header-bg);
  color: var(--header-text);
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.14);
  position: sticky;
  top: 0;
  z-index: 40;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.header-logo {
  width: 50px;
  height: 50px;
  border-radius: 999px;
  background:
    radial-gradient(circle at 30% 0%, rgba(255, 255, 255, 0.95), transparent),
    rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.28);
}

.header-logo-img {
  max-width: 34px;
  max-height: 34px;
}

.header-titles {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.header-title {
  font-size: 1.25rem;
  font-weight: 700;
}

.header-subtitle {
  font-size: 0.9rem;
  opacity: 0.9;
}

/* Header actions */

.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.header-icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  border: none;
  background: rgba(15, 23, 42, 0.05);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: background 0.18s ease, transform 0.12s ease, box-shadow 0.18s ease;
}

.header-icon-btn:hover {
  background: rgba(15, 23, 42, 0.12);
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.16);
}

.header-icon-btn:active {
  transform: translateY(0);
  box-shadow: none;
}

/* burger icon */
#sidebar-toggle {
  display: none; /* desktop hidden */
  flex-direction: column;
  gap: 3px;
}
#sidebar-toggle .bar {
  width: 18px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
}

.header-user {
  text-align: right;
  display: flex;
  flex-direction: column;
  gap: 0.08rem;
}

.header-user-name {
  font-size: 0.95rem;
  font-weight: 600;
}

.header-user-role {
  font-size: 0.78rem;
  opacity: 0.9;
}

.header-logout {
  font-size: 0.8rem;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  text-decoration: none;
  color: var(--header-text);
  border: 1px solid rgba(255, 255, 255, 0.6);
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(12px);
  transition: background 0.2s ease, transform 0.12s ease, box-shadow 0.18s ease;
}
.header-logout:hover {
  background: rgba(255, 255, 255, 0.22);
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.18);
}

/* Theme icon text size */
.theme-icon {
  font-size: 1.1rem;
}

/* ===== Language switcher in header (generic) ===== */

.header-lang-switcher,
.lang-switch,
.lang-switcher {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.header-lang-btn,
.lang-btn,
.lang-pill {
  border-radius: 999px;
  padding: 0.28rem 0.7rem;
  font-size: 0.8rem;
  border: 1px solid rgba(255, 255, 255, 0.6);
  background: rgba(255, 255, 255, 0.16);
  color: var(--header-text);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.18s ease, transform 0.12s ease, box-shadow 0.15s ease;
}

.header-lang-btn:hover,
.lang-btn:hover,
.lang-pill:hover {
  background: rgba(255, 255, 255, 0.26);
  transform: translateY(-1px);
}

.header-lang-btn.is-active,
.lang-btn.is-active,
.lang-pill.is-active {
  background: rgba(255, 255, 255, 0.34);
}

/* ========== Main container (sidebar right) ========== */

.app-main {
  flex: 1 1 auto;
  min-height: calc(100vh - var(--header-height));
  display: flex;
  background: transparent;
}

/* keep this class for semantics */
.app-main-rtl {
  flex-direction: row;
}

/* Sidebar */

.app-sidebar {
  order: 1; /* first in row -> in RTL it's on the RIGHT side */
  flex: 0 0 var(--sidebar-width);
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  border-left: 1px solid var(--color-border-subtle); /* divider with content */
  box-shadow: -10px 0 26px rgba(15, 23, 42, 0.15);
  position: relative;
  z-index: 30;
}

.sidebar-inner {
  height: 100%;
  padding: 1.2rem 1rem 1.7rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  overflow-y: auto;
}

.sidebar-inner::-webkit-scrollbar {
  width: 6px;
}
.sidebar-inner::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.55);
  border-radius: 999px;
}

/* Sidebar groups */

.sidebar-section-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--sidebar-muted);
  margin-bottom: 0.25rem;
  padding-inline: 0.5rem;
}

.sidebar-group {
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
  padding: 0.35rem 0.3rem 0.4rem;
  border-radius: var(--radius-lg);
}

.sidebar-group + .sidebar-group {
  margin-top: 0.5rem;
}

/* Sidebar links */

.sidebar-link {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;  /* push text + icon to the right edge */
  direction: rtl;             /* RTL text */
  gap: 0.5rem;
  padding: 0.55rem 0.75rem;
  border-radius: 999px;
  text-decoration: none;
  color: var(--sidebar-text);
  font-size: 0.9rem;
  line-height: 1.4;
  transition: background 0.15s ease, color 0.15s ease, transform 0.12s ease,
              box-shadow 0.15s ease;
  text-align: right;
}

.sidebar-link-icon {
  font-size: 1.05rem;
  opacity: 0.9;
}

.sidebar-link-label {
  flex: 1 1 auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* active / hover */
.sidebar-link:hover {
  background: var(--sidebar-hover-bg);
  transform: translateY(-1px);
}

.sidebar-link.is-active {
  background: var(--sidebar-active-bg);
  box-shadow: 0 0 0 1px var(--sidebar-active-border);
  color: var(--sidebar-active-border);
}

/* Sidebar footer (version / logo text) */
.sidebar-footer {
  margin-top: auto;
  padding-top: 0.7rem;
  font-size: 0.72rem;
  color: var(--sidebar-muted);
  text-align: center;
}

/* Content area */

.app-content {
  order: 2;  /* content after sidebar -> appears on LEFT in RTL */
  flex: 1 1 auto;
  padding: 1.6rem 2rem 2.4rem;
  display: flex;
  flex-direction: column;
  gap: 1.6rem;
  max-width: 1200px;
  width: 100%;
  margin-inline: auto;
}

.app-content h1 {
  margin: 0;
  font-size: 2.4rem;
  font-weight: 700;
  text-align: right;
  letter-spacing: 0.01em;
}

/* Cards */

.card {
  background: var(--color-bg-elevated);
  border-radius: var(--radius-xl);
  border: 1px solid var(--color-border-subtle);
  padding: 1.3rem 1.4rem 1.5rem;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(10px);
}

.card-form {
  background: var(--color-bg-elevated-soft);
}

.card h2,
.card h3 {
  margin-top: 0;
  margin-bottom: 0.9rem;
  font-size: 1.15rem;
  text-align: right;
}

/* Dashboard cards grid */

.cards-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.1rem;
}

.cards-grid .card {
  text-align: right;
}

/* Forms */

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  text-align: right;
}

label {
  font-size: 0.8rem;
  color: var(--color-text-soft);
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
select,
textarea {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border-radius: 16px;
  border: 1px solid var(--color-border-subtle);
  background: rgba(255, 255, 255, 0.9);
  color: var(--color-text-main);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease,
              transform 0.08s ease;
}

textarea {
  border-radius: 16px;
  min-height: 70px;
  resize: vertical;
}

:root[data-theme='dark'] input[type="text"],
:root[data-theme='dark'] input[type="password"],
:root[data-theme='dark'] input[type="number"],
:root[data-theme='dark'] input[type="date"],
:root[data-theme='dark'] select,
:root[data-theme='dark'] textarea {
  background: rgba(15, 23, 42, 0.9);
  color: var(--color-text-main);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 2px var(--color-accent-soft);
  transform: translateY(-1px);
}

/* Checkbox / radio inline text */
input[type="checkbox"],
input[type="radio"] {
  width: auto;
  margin-left: 0.35rem;
}

/* Form grids */

.form-grid-2,
.form-grid-3,
.form-grid-4 {
  display: grid;
  gap: 1rem 1.1rem;
}

.form-grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.form-grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.form-grid-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

/* Buttons */

.btn-primary {
  border: none;
  border-radius: 999px;
  padding: 0.55rem 1.6rem;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--color-accent);
  color: #ffffff;
  box-shadow: 0 14px 24px rgba(37, 99, 235, 0.28);
  transition: background 0.18s ease, transform 0.12s ease,
              box-shadow 0.18s ease;
}

.btn-primary:hover {
  background: var(--color-accent-strong);
  transform: translateY(-1px);
  box-shadow: 0 18px 28px rgba(30, 64, 175, 0.32);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 8px 18px rgba(30, 64, 175, 0.25);
}

/* Base small pill button */
.btn-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid var(--color-border-subtle);
  padding: 0.25rem 0.75rem;
  font-size: 0.8rem;
  background: rgba(255, 255, 255, 0.96);
  text-decoration: none;
  color: var(--color-text-main);
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease,
              box-shadow 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn-sm:hover {
  background: var(--color-accent-soft);
  transform: translateY(-1px);
}

/* Light blue EDIT pill */
.btn-sm-edit {
  border-color: rgba(37, 99, 235, 0.4);
  background: rgba(37, 99, 235, 0.06);
  color: var(--color-accent);
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.16);
}

.btn-sm-edit:hover {
  background: rgba(37, 99, 235, 0.14);
  border-color: rgba(37, 99, 235, 0.55);
  color: var(--color-accent-strong);
  box-shadow: 0 12px 22px rgba(30, 64, 175, 0.22);
}

.btn-sm-edit:active {
  transform: translateY(0);
  box-shadow: 0 5px 14px rgba(30, 64, 175, 0.2);
}

/* Light red DELETE pill */
.btn-sm-delete {
  border-color: rgba(248, 113, 113, 0.6);
  background: rgba(248, 113, 113, 0.08);
  color: var(--color-danger);
  box-shadow: 0 8px 18px rgba(248, 113, 113, 0.16);
}

.btn-sm-delete:hover {
  background: rgba(248, 113, 113, 0.16);
  border-color: rgba(248, 113, 113, 0.8);
  color: #7f1d1d;
  box-shadow: 0 12px 22px rgba(220, 38, 38, 0.22);
}

.btn-sm-delete:active {
  transform: translateY(0);
  box-shadow: 0 5px 14px rgba(220, 38, 38, 0.2);
}

/* Alerts */

.alert {
  border-radius: 999px;
  padding: 0.5rem 0.9rem;
  font-size: 0.83rem;
}

.alert-success {
  background: rgba(34, 197, 94, 0.08);
  border: 1px solid rgba(34, 197, 94, 0.3);
  color: var(--color-success);
}

.alert-error {
  background: rgba(248, 113, 113, 0.08);
  border: 1px solid rgba(248, 113, 113, 0.45);
  color: var(--color-danger);
}

/* Tables */

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  direction: rtl;
}

.table thead {
  background: #e5edf9;
}

.table th,
.table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.3);
  text-align: right;
}

.table th {
  font-weight: 600;
  color: var(--color-text-soft);
}

.table tr:last-child td {
  border-bottom: none;
}

/* Footer */

.app-footer {
  padding: 0.6rem 1.6rem 0.9rem;
  background: var(--footer-bg);
  color: var(--color-text-soft);
  font-size: 0.78rem;
}

.footer-inner {
  max-width: 1200px;
  margin-inline: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ========== Login Page ========== */

body.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-wrapper {
  width: 100%;
  max-width: 960px;
  padding: 2.5rem 1.5rem;
  display: flex;
  justify-content: center;
}

.login-card {
  width: 100%;
  max-width: 480px;
  background: var(--color-bg-elevated);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-soft);
  border: 1px solid var(--color-border-subtle);
  padding: 2.1rem 2.2rem 1.9rem;
  backdrop-filter: blur(10px);
}

.login-card-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.4rem;
}

.login-logo-circle {
  width: 64px;
  height: 64px;
  border-radius: 999px;
  background:
    radial-gradient(circle at 30% 0%, rgba(255, 255, 255, 0.95), transparent),
    rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.16);
}

.login-logo-img {
  max-width: 44px;
  max-height: 44px;
}

.login-titles {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  text-align: right;
}

.login-ministry {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--color-text-main);
}

.login-system {
  font-size: 0.88rem;
  color: var(--color-text-soft);
}

.login-card-body {
  margin-top: 0.3rem;
}

.login-heading {
  margin: 0 0 0.4rem;
  font-size: 1.35rem;
  font-weight: 700;
  text-align: right;
}

.login-subtext {
  margin: 0 0 1.1rem;
  font-size: 0.9rem;
  color: var(--color-text-soft);
  text-align: right;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.login-form .form-group label {
  font-size: 0.85rem;
}

.login-form .form-group input[type="text"],
.login-form .form-group input[type="password"] {
  font-size: 0.92rem;
}

.login-form-footer {
  margin-top: 0.4rem;
  display: flex;
  justify-content: flex-end;
}

.login-submit {
  min-width: 140px;
}

.login-footer {
  margin-top: 1.4rem;
  border-top: 1px solid rgba(148, 163, 184, 0.25);
  padding-top: 0.7rem;
  text-align: center;
}

.login-footer-text {
  font-size: 0.8rem;
  color: var(--color-text-soft);
}

/* RTL / LTR tweaks */

body.login-body.rtl .login-card,
body.login-body.rtl .login-titles,
body.login-body.rtl .login-heading,
body.login-body.rtl .login-subtext {
  text-align: right;
}

body.login-body.ltr .login-card,
body.login-body.ltr .login-titles,
body.login-body.ltr .login-heading,
body.login-body.ltr .login-subtext {
  text-align: left;
}

body.login-body.ltr .login-form-footer {
  justify-content: flex-start;
}

/* ========== Responsive ========== */

@media (max-width: 960px) {
  #sidebar-toggle {
    display: inline-flex;
  }

  .app-main {
    position: relative;
    display: block; /* stack content, sidebar becomes overlay */
  }

  .app-sidebar {
    position: fixed;
    top: var(--header-height);
    bottom: 0;
    right: 0;
    transform: translateX(100%);
    transition: transform 0.22s ease-out;
    border-left: none;
    box-shadow: -12px 0 26px rgba(15, 23, 42, 0.35);
  }

  body.sidebar-open .app-sidebar {
    transform: translateX(0);
  }

  .app-content {
    padding: 1.2rem 1.2rem 2rem;
  }

  .cards-grid {
    grid-template-columns: 1fr;
  }

  .form-grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .login-card {
    padding: 1.8rem 1.5rem 1.6rem;
  }

  .login-logo-circle {
    width: 56px;
    height: 56px;
  }

  .login-logo-img {
    max-width: 38px;
    max-height: 38px;
  }
}

@media (max-width: 640px) {
  .form-grid-2,
  .form-grid-3,
  .form-grid-4 {
    grid-template-columns: 1fr;
  }

  .footer-inner {
    flex-direction: column;
    gap: 0.4rem;
  }

  .login-wrapper {
    padding: 2rem 1rem;
  }
}
