/*
 * DCManage Platform — interface styles.
 *
 * Written by hand and served from this origin. The platform runs on networks
 * that reach nothing but their own site, so there is no font service, no
 * icon service, no stylesheet host and no build step between this file and
 * the browser. Icons are inline SVG for the same reason.
 *
 * Direction is handled with logical properties (inline-start / inline-end)
 * so the Persian and English interfaces are one stylesheet with a different
 * `dir` attribute, rather than two that drift apart.
 *
 * Author: MAJID ISALOO
 */

:root {
  --bg: #eef1f6;
  --surface: #ffffff;
  --surface-sunken: #f7f9fc;
  --surface-hover: #f2f5fa;
  --border: #dfe4ec;
  --border-strong: #c3cbd9;

  --text: #10151c;
  --text-muted: #5a6675;
  --text-faint: #8a94a3;

  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --brand-soft: #e8f0ff;
  --brand-gradient: linear-gradient(135deg, #2563eb 0%, #4f46e5 100%);

  --danger: #d64545;
  --danger-soft: #fdeded;
  --success: #15803d;
  --success-soft: #e7f6ed;
  --warning: #b45309;
  --warning-soft: #fff5e3;
  --info: #0e7490;
  --info-soft: #e3f5f8;

  --radius-lg: 14px;
  --radius: 10px;
  --radius-sm: 7px;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 8px 24px -12px rgba(15, 23, 42, .12);
  --shadow-lg: 0 4px 12px rgba(15, 23, 42, .08), 0 24px 48px -24px rgba(15, 23, 42, .25);

  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-fa: "Vazirmatn", system-ui, Tahoma, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, monospace;

  --sidebar-width: 250px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

body[dir="rtl"] { font-family: var(--font-fa); }

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-dark); }

svg.icon { width: 17px; height: 17px; flex: 0 0 auto; stroke-width: 1.9; }

/* ═══════════ Layout ═══════════ */

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-width);
  flex: 0 0 var(--sidebar-width);
  background: var(--surface);
  border-inline-end: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.brand__mark {
  width: 36px; height: 36px;
  border-radius: 9px;
  background: var(--brand-gradient);
  display: grid; place-items: center;
  box-shadow: 0 4px 12px -3px rgba(37, 99, 235, .5);
  flex: 0 0 auto;
}

.brand__mark svg { width: 21px; height: 21px; color: #fff; }
.brand__text { line-height: 1.2; min-width: 0; }
.brand__name { font-weight: 750; font-size: 15.5px; letter-spacing: -.2px; }
.brand__name span { color: var(--brand); }
.brand__sub { font-size: 11px; color: var(--text-faint); }

.sidebar__nav { padding: 10px 12px 16px; flex: 1; overflow-y: auto; }

.sidebar__section {
  padding: 16px 8px 6px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--text-faint);
}

.sidebar__link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  margin-bottom: 2px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 500;
  transition: background .12s, color .12s;
}

.sidebar__link:hover { background: var(--surface-hover); color: var(--text); }

.sidebar__link.is-active {
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-weight: 650;
}

.sidebar__link.is-active svg { color: var(--brand); }

.sidebar__footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--text-faint);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 60px;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 26px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar__title { font-weight: 650; font-size: 15px; }
.topbar__actions { display: flex; align-items: center; gap: 10px; }

.user-chip {
  display: flex; align-items: center; gap: 9px;
  padding: 5px 12px 5px 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}

body[dir="rtl"] .user-chip { padding: 5px 6px 5px 12px; }

.avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--brand-gradient);
  color: #fff; font-size: 11px; font-weight: 700;
  display: grid; place-items: center; flex: 0 0 auto;
}

.content { padding: 26px; flex: 1; max-width: 1500px; width: 100%; }

.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 22px; flex-wrap: wrap;
}

.page-header h1 { margin: 0 0 5px; font-size: 22px; font-weight: 700; letter-spacing: -.3px; }
.page-header p { margin: 0; color: var(--text-muted); max-width: 76ch; }

/* ═══════════ Cards ═══════════ */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  overflow: hidden;
}

.card__header {
  padding: 15px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 650;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  background: linear-gradient(180deg, #fff 0%, var(--surface-sunken) 100%);
}

.card__body { padding: 20px; }
.card__body--flush { padding: 0; }

/* Statistic tiles */

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}

.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 17px 18px;
  display: flex; gap: 14px; align-items: flex-start;
  transition: box-shadow .15s, transform .15s;
}

a.tile:hover { box-shadow: var(--shadow); transform: translateY(-1px); }

.tile__icon {
  width: 40px; height: 40px; border-radius: 11px;
  display: grid; place-items: center; flex: 0 0 auto;
  background: var(--brand-soft); color: var(--brand);
}

.tile__icon svg { width: 20px; height: 20px; }
.tile__icon--success { background: var(--success-soft); color: var(--success); }
.tile__icon--warning { background: var(--warning-soft); color: var(--warning); }
.tile__icon--danger  { background: var(--danger-soft);  color: var(--danger); }
.tile__icon--info    { background: var(--info-soft);    color: var(--info); }

.tile__label {
  font-size: 11.5px; font-weight: 650; letter-spacing: .4px;
  text-transform: uppercase; color: var(--text-faint);
}

.tile__value { font-size: 25px; font-weight: 750; line-height: 1.15; margin-top: 3px; letter-spacing: -.5px; }
.tile__hint { font-size: 12px; color: var(--text-muted); }

/* ═══════════ Tables ═══════════ */

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; }

table.data th {
  text-align: start;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
  color: var(--text-faint);
  padding: 11px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-sunken);
  white-space: nowrap;
}

table.data td { padding: 13px 20px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr { transition: background .1s; }
table.data tbody tr:hover { background: var(--surface-hover); }

.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.mono { font-family: var(--font-mono); font-size: 12.5px; }
.nowrap { white-space: nowrap; }

/* ═══════════ Badges ═══════════ */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 650; line-height: 1.5;
}

.badge--neutral { background: var(--surface-sunken); color: var(--text-muted); border: 1px solid var(--border); }
.badge--accent  { background: var(--brand-soft);   color: var(--brand-dark); }
.badge--success { background: var(--success-soft); color: var(--success); }
.badge--danger  { background: var(--danger-soft);  color: var(--danger); }
.badge--warning { background: var(--warning-soft); color: var(--warning); }
.badge--info    { background: var(--info-soft);    color: var(--info); }

.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: 0 0 auto; }

/* ═══════════ Forms ═══════════ */

.field { margin-bottom: 17px; }
.field label { display: block; font-weight: 650; margin-bottom: 6px; font-size: 13px; }
.field .hint { color: var(--text-muted); font-size: 12.5px; margin-top: 5px; }

input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], select, textarea {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font: inherit; color: var(--text); background: var(--surface);
  transition: border-color .12s, box-shadow .12s;
}

input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.check {
  display: flex; gap: 9px; align-items: flex-start;
  font-weight: 500; cursor: pointer;
}

.check input { width: auto; margin-top: 3px; flex: 0 0 auto; }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 15px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text);
  font: inherit; font-weight: 650; cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s, box-shadow .12s;
}

.btn:hover { background: var(--surface-hover); color: var(--text); }
.btn--primary { background: var(--brand-gradient); border-color: transparent; color: #fff; box-shadow: 0 2px 8px -2px rgba(37, 99, 235, .5); }
.btn--primary:hover { filter: brightness(1.06); color: #fff; }
.btn--danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn--danger:hover { filter: brightness(.94); color: #fff; }
.btn--sm { padding: 6px 11px; font-size: 12.5px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.form-actions { display: flex; gap: 10px; align-items: center; padding-top: 4px; }

/* ═══════════ Alerts ═══════════ */

.alert {
  padding: 13px 16px; border-radius: var(--radius);
  margin-bottom: 20px; border: 1px solid transparent;
  display: flex; gap: 11px; align-items: flex-start;
}

.alert svg { flex: 0 0 auto; margin-top: 2px; }
.alert--success { background: var(--success-soft); border-color: #b9e3ca; color: #14622f; }
.alert--danger  { background: var(--danger-soft);  border-color: #f2c4c4; color: #a13232; }
.alert--warning { background: var(--warning-soft); border-color: #f0dcae; color: #8a4b09; }
.alert--info    { background: var(--info-soft);    border-color: #b6dfe8; color: #0b5c74; }
.alert ul { margin: 6px 0 0; padding-inline-start: 18px; }

/* ═══════════ Permission editor ═══════════ */

.perm-group { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 14px; overflow: hidden; }

.perm-group__header {
  padding: 12px 16px; background: var(--surface-sunken);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
}

.perm-group__title { font-weight: 700; }
.perm-group__desc { color: var(--text-muted); font-size: 12.5px; margin-top: 2px; max-width: 84ch; }

.perm-row {
  display: flex; gap: 12px; padding: 10px 16px;
  border-bottom: 1px solid var(--border); align-items: flex-start;
}

.perm-row:last-child { border-bottom: none; }
.perm-row:hover { background: var(--surface-hover); }
.perm-row input[type="checkbox"] { margin-top: 3px; flex: 0 0 auto; }
.perm-row__key { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-faint); margin-inline-start: 6px; }
.perm-row__label { display: block; }

/* ═══════════ Progress ═══════════ */

.meter { background: var(--surface-sunken); border-radius: 999px; height: 6px; overflow: hidden; margin-top: 5px; border: 1px solid var(--border); }
.meter__fill { height: 100%; border-radius: 999px; background: var(--success); transition: width .3s; }
.meter__fill--warning { background: #d97706; }
.meter__fill--danger { background: var(--danger); }

/* ═══════════ Rack elevation ═══════════ */

.rack {
  border: 2px solid var(--border-strong);
  border-radius: var(--radius);
  overflow: hidden;
  background: #2c3442;
  max-width: 560px;
  box-shadow: var(--shadow-lg);
}

.rack__unit {
  display: flex; align-items: stretch;
  border-bottom: 1px solid #3c4557;
  min-height: 26px;
}

.rack__unit:last-child { border-bottom: none; }

.rack__number {
  flex: 0 0 40px;
  display: grid; place-items: center;
  font-family: var(--font-mono); font-size: 10.5px;
  color: #94a3b8; background: #232a36;
  border-inline-end: 1px solid #3c4557;
}

.rack__slot { flex: 1; display: flex; align-items: center; padding: 3px 12px; min-width: 0; }
.rack__slot--free { color: #55607a; font-size: 11px; }

.rack__device {
  flex: 1; display: flex; align-items: center; justify-content: space-between;
  gap: 10px; min-width: 0;
  background: linear-gradient(180deg, #3d4759 0%, #333c4c 100%);
  border: 1px solid #4b5468; border-radius: 5px;
  padding: 4px 11px; color: #e7ecf5; font-size: 12.5px; font-weight: 600;
}

.rack__device a { color: #fff; }
.rack__device a:hover { color: #bfdbfe; }
.rack__device small { color: #9fb0c9; font-weight: 400; font-family: var(--font-mono); font-size: 11px; }

/* ═══════════ Sign-in and public ═══════════ */

.signin {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1000px 500px at 50% -10%, rgba(37, 99, 235, .18), transparent 70%),
    linear-gradient(180deg, #eef2f8 0%, #dfe6f0 100%);
}

.signin__card {
  width: 100%; max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 32px;
}

.signin__brand { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 6px; }
.signin__brand .brand__mark { width: 46px; height: 46px; border-radius: 12px; }
.signin__brand .brand__mark svg { width: 26px; height: 26px; }
.signin__title { font-size: 19px; font-weight: 750; letter-spacing: -.3px; }
.signin__title span { color: var(--brand); }
.signin__sub { text-align: center; color: var(--text-muted); margin-bottom: 24px; font-size: 13px; }

.hero { text-align: center; max-width: 660px; width: 100%; }
.hero__mark { width: 62px; height: 62px; border-radius: 17px; margin: 0 auto 18px; }
.hero__mark svg { width: 34px; height: 34px; }
.hero h1 { font-size: 34px; font-weight: 800; letter-spacing: -1px; margin: 0 0 8px; }
.hero h1 span { color: var(--brand); }
.hero p { color: var(--text-muted); font-size: 15px; margin: 0 auto 26px; max-width: 52ch; }

.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-top: 28px; text-align: start; }

.feature {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 15px; box-shadow: var(--shadow-sm);
}

.feature__icon { width: 32px; height: 32px; border-radius: 9px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; margin-bottom: 9px; }
.feature h3 { margin: 0 0 3px; font-size: 13.5px; font-weight: 700; }
.feature p { margin: 0; font-size: 12.5px; color: var(--text-muted); }

/* ═══════════ Small screens ═══════════ */

@media (max-width: 900px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; border-inline-end: none; border-bottom: 1px solid var(--border); }
  .sidebar__nav { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px; }
  .sidebar__section { display: none; }
  .sidebar__link { margin-bottom: 0; }
  .sidebar__footer { display: none; }
  .content { padding: 16px; }
  .topbar { padding: 0 16px; height: 54px; }
  .topbar__title { display: none; }
  .hero h1 { font-size: 26px; }
}
