/* ==========================================================================
   Design Tokens
   ========================================================================== */
:root {
  color-scheme: light;
  --bg: #f6f7fb;
  --surface: #fff;
  --line: #e7e9f0;
  --text: #555555;
  --muted: #70798b;
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --soft: #f0efff;
  --green: #13865c;
  --red: #d14343;
  --shadow: 0 8px 30px rgba(31, 41, 55, 0.055);
}

html[data-theme='dark'] {
  color-scheme: dark;
  --bg: #10131b;
  --surface: #191e29;
  --line: #303747;
  --text: #e7eaf2;
  --muted: #a0a9bc;
  --primary: #9b94ff;
  --primary-dark: #8279f5;
  --soft: #2a2947;
  --green: #71dbac;
  --red: #ff8585;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.22);
}

/* ==========================================================================
   Fonts
   ========================================================================== */
@font-face {
  font-family: IRANSansFa;
  src: url('../fonts/IRANSansFa.woff2') format('woff2');
  font-display: swap;
}

/* ==========================================================================
   Base / Reset  —  پیشفرض: LTR / انگلیسی
   ========================================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: sans-serif;
  font-size: 14px;
  line-height: 1.65;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

.svg-icon {
  display: inline-block;
  flex: none;
  vertical-align: middle;
}

/* ==========================================================================
   RTL  —  فقط برای سایت فارسی
   ========================================================================== */

html[lang='fa'] body,
html[dir='rtl'] body {
  font-family: IRANSansFa;
}

/* ==========================================================================
   Top Bar
   ========================================================================== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  height: 76px;
  padding: 0 clamp(16px, 4vw, 58px);
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 13px;
  background: var(--soft);
  color: var(--primary);
}

.brand-copy {
  display: grid;
  line-height: 1.35;
}

.brand-copy strong {
  font-size: 17px;
  font-weight: 600;
}

.brand-copy small {
  font-size: 11px;
  color: var(--muted);
}

.account-area {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.admin-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 8px;
  background: #f1efff;
  color: #5d50ce;
  font-size: 12px;
  white-space: nowrap;
}

.account-switch-form {
  display: inline-flex;
  align-items: center;
  margin: 0;
  min-width: 0;
}

.account-select {
  max-width: 220px;
  min-width: 150px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface, #fff);
  color: var(--text);
  font: inherit;
  font-size: 12px;
}

.account-email {
  max-width: 250px;
  overflow: hidden;
  font-size: 12px;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inline-form {
  display: inline-flex;
  margin: 0;
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border: 1px solid transparent;
  border-radius: 10px;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  border-color: #dfe2eb;
  background: #fff;
  color: #374151;
}

.btn-secondary:hover {
  border-color: #c8ccda;
  background: #f8f8fc;
}

.btn-quiet {
  border-color: transparent;
  background: transparent;
  color: #596174;
}

.btn-quiet:hover {
  background: #f4f5fa;
}

.btn-small {
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 12px;
}

.btn-wide {
  width: 100%;
  padding: 13px 16px;
}

/* ==========================================================================
   App Shell / Workspace
   ========================================================================== */
.app-shell {
  max-width: 1480px;
  margin: 0 auto;
  padding: 28px clamp(14px, 3vw, 36px) 20px;
}

.workspace {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

/* ==========================================================================
   Sidebar
   ========================================================================== */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-height: 520px;
  padding: 18px 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  box-shadow: var(--shadow);
}

.sidebar-title {
  padding: 4px 11px 7px;
  font-size: 11px;
  font-weight: 800;
  color: #8b92a2;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 43px;
  padding: 10px 12px;
  border-radius: 10px;
  color: #5c6476;
  font-weight: 700;
}

.nav-item:hover {
  background: #f7f7fc;
}

.nav-item.active {
  background: var(--soft);
  color: var(--primary);
}

.nav-item span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-divider {
  height: 1px;
  margin: 12px 7px;
  background: var(--line);
}

.shared-nav {
  font-size: 12px;
}

.sidebar-hint {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin-top: 12px;
  padding: 13px 10px;
  border-radius: 10px;
  background: #f8f9fc;
  color: #7b8291;
  font-size: 11px;
  line-height: 1.9;
}

.sidebar-bottom {
  display: grid;
  gap: 5px;
  margin-top: auto;
  padding: 14px 9px 3px;
  border-top: 1px solid var(--line);
  color: #70798b;
  font-size: 11px;
}

.sidebar-bottom span {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sidebar-bottom small {
  overflow-wrap: anywhere;
}

/* ==========================================================================
   File Area / Page Heading
   ========================================================================== */
.file-area {
  min-width: 0;
}

.page-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 17px;
}

.page-heading h1 {
  margin: 0;
  font-size: 25px;
  letter-spacing: -0.3px;
}

.page-heading-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.eyebrow {
  margin: 0 0 2px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1px;
  color: #8b91a2;
}

/* ==========================================================================
   Toolbar Card / Breadcrumbs / Search / Upload
   ========================================================================== */
.toolbar-card,
.files-card {
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.toolbar-card {
  padding: 15px 17px;
  margin-bottom: 17px;
}

.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px;
  padding: 0 1px 12px;
  border-bottom: 1px solid #f0f1f5;
  font-size: 12px;
  color: #686f81;
}

.breadcrumbs a {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 5px;
  border-radius: 6px;
}

.breadcrumbs a:hover {
  background: #f6f6fc;
  color: var(--primary);
}

.breadcrumbs strong {
  font-weight: 800;
  color: #303746;
}

.crumb-separator {
  display: inline-flex;
  color: #a6aab7;
}

.toolbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 13px;
  padding-top: 13px;
}

.search-form {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 8px;
  max-width: 400px;
  height: 42px;
  padding: 0 10px;
  border: 1px solid #e5e7ef;
  border-radius: 10px;
  background: #fafbfe;
  color: #858b9a;
}

.search-form input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.search-form input::placeholder {
  color: #a0a5b2;
}

.search-submit,
.clear-search {
  display: grid;
  place-items: center;
  padding: 3px;
  border: 0;
  background: transparent;
  color: #777e8f;
  cursor: pointer;
}

.search-submit:hover,
.clear-search:hover {
  color: var(--primary);
}

.upload-form {
  display: flex;
  align-items: center;
  gap: 8px;
}

.upload-form input[type='file'] {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.upload-pick {
  max-width: 230px;
  overflow: hidden;
}

.upload-pick span {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
}


.upload-progress {
  margin: 14px 0 2px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface, #fff);
}

.upload-progress[hidden] { display: none !important; }

.upload-progress-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  color: var(--text);
  font-size: 12px;
}

.upload-progress-heading strong {
  min-width: 3.5em;
  text-align: end;
  font-variant-numeric: tabular-nums;
}

.upload-progress-track {
  width: 100%;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--line, #e5e7eb);
}

.upload-progress-track > span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
  transition: width 0.16s ease;
}

.upload-progress.is-error { border-color: #d88b8b; }
.upload-progress.is-error .upload-progress-track > span { background: #b64a4a; }
html[data-theme='dark'] .upload-progress { background: var(--surface, #202633); }

/* ==========================================================================
   Files Card / Table
   ========================================================================== */
.files-card {
  overflow: hidden;
}

.files-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.files-heading h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
}

.files-heading p {
  margin: 3px 0 0;
  font-size: 11px;
  color: var(--muted);
}

.connection-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  border: 1px solid #d3f4e4;
  border-radius: 20px;
  background: #ebfbf4;
  color: #13865c;
  font-size: 11px;
}

.connection-status i {
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #18a66d;
}

.table-wrap {
  width: 100%;
  overflow: auto;
}

.file-table {
  width: 100%;
  min-width: 690px;
  border-collapse: collapse;
  text-align: left;
}

.file-table th {
  padding: 12px 16px;
  background: #fafbfe;
  color: #8a90a0;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  text-align: center;
}

.file-table td {
  padding: 12px 16px;
  border-top: 1px solid #f0f1f5;
  font-size: 12px;
  color: #657084;
  white-space: nowrap;
  text-align: center;
}

.file-table tbody tr {
  transition: background 0.12s, box-shadow 0.12s;
}

.file-table tbody tr:hover {
  background: #fcfcff;
}

.file-table tbody tr[draggable='true'] {
  cursor: grab;
}

.file-table tbody tr.is-dragging {
  opacity: 0.42;
}

.file-table tbody tr.drop-over {
  background: #f0efff;
  box-shadow: inset 0 0 0 2px #a7a2f9;
}

.file-name-cell {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 250px;
}

.file-icon {
  display: grid;
  flex: none;
  place-items: center;
  width: 39px;
  height: 39px;
  border-radius: 11px;
}

.folder-icon {
  background: #fff5d9;
  color: #c58c16;
}

.image-icon {
  background: #e9f6ff;
  color: #1988c9;
}

.doc-icon {
  background: #f0efff;
  color: #655ce4;
}

.file-title {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.file-name {
  display: block;
  max-width: 360px;
  overflow: hidden;
  font-size: 13px;
  font-weight: 800;
  color: #313847;
  text-overflow: ellipsis;
}

.file-title a:hover {
  color: var(--primary);
}

.file-title small {
  max-width: 360px;
  overflow: hidden;
  font-size: 10px;
  color: #9aa0ae;
  text-overflow: ellipsis;
}

.row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #7d8494;
  cursor: pointer;
}

.icon-button:hover {
  border-color: #e9e7ff;
  background: #f2f2ff;
  color: var(--primary);
}

.icon-button.share-ready {
  background: #eefbf5;
  color: #148358;
}

.icon-button.danger-button:hover {
  border-color: #ffe0e0;
  background: #fff0f0;
  color: var(--red);
}

/* ==========================================================================
   Empty State
   ========================================================================== */
.empty-state {
  padding: 55px 20px 60px;
  color: var(--muted);
  text-align: center;
}

.empty-icon {
  display: grid;
  place-items: center;
  width: 68px;
  height: 68px;
  margin: 0 auto 12px;
  border-radius: 20px;
  background: #f3f2ff;
  color: #6b63de;
}

.empty-state h3 {
  margin: 0 0 4px;
  font-size: 16px;
  color: #3c4352;
}

.empty-state p {
  margin: 0;
  font-size: 12px;
}

/* ==========================================================================
   Table Footer / Pagination
   ========================================================================== */
.table-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  background: #fcfcfe;
  color: #8a90a0;
  font-size: 11px;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  direction: ltr;
}

.pagination-numbers {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
}

.pagination-page,
.pagination-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  background: var(--surface, #fff);
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-decoration: none;
  box-sizing: border-box;
  transition: border-color .15s ease, background .15s ease, color .15s ease;
}

.pagination-arrow {
  min-width: 36px;
  padding: 0;
}

.pagination-page:hover,
.pagination-arrow:not(.is-disabled):hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--surface-secondary, #f6f6fc);
}

.pagination-page.is-current {
  border-color: var(--primary);
  color: #fff;
  background: var(--primary);
  cursor: default;
}

.pagination-arrow.is-disabled {
  color: #a7abb4;
  background: #fff;
  cursor: default;
  opacity: .7;
}

.pagination-ellipsis {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 36px;
  padding: 0 2px;
  color: var(--muted, #8a90a0);
  user-select: none;
}

html[data-theme='dark'] .pagination-page,
html[data-theme='dark'] .pagination-arrow {
  color: var(--text);
  background: #202633;
}

html[data-theme='dark'] .pagination-page.is-current {
  color: #fff;
  background: var(--primary);
}

html[data-theme='dark'] .pagination-arrow.is-disabled {
  color: #737b88;
  background: #202633;
}

/* ==========================================================================
   Page Footer
   ========================================================================== */
.page-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  padding: 20px 4px 0;
  color: #9ba1af;
  font-size: 11px;
}

.text-button {
  padding: 3px;
  border: 0;
  background: none;
  color: #9ba1af;
  cursor: pointer;
}

.text-button:hover {
  color: var(--red);
}

/* ==========================================================================
   Notices / Public Link Box
   ========================================================================== */
.notice {
  display: grid;
  gap: 9px;
  margin: 0 0 16px;
  padding: 13px 15px;
  border: 1px solid #e0e5f0;
  border-radius: 12px;
  background: #fff;
  font-size: 12px;
}

.notice p {
  margin: 4px 0 0;
}

.notice.success {
  border-color: #d0f1df;
  background: #f0fbf5;
  color: #20674b;
}

.notice.error {
  border-color: #f6d9d6;
  background: #fff6f5;
  color: #963b35;
}

.notice.info {
  border-color: #dee6ff;
  background: #f4f7ff;
  color: #425991;
}

.public-link-box {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
}

.public-link-box input {
  flex: 1;
  min-width: 220px;
  padding: 8px 10px;
  border: 1px solid #dce5de;
  border-radius: 8px;
  background: #fff;
  color: #425b50;
  font-size: 11px;
}

/* ==========================================================================
   Login
   ========================================================================== */
.login-shell {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 76px);
  padding: 38px 18px;
}

.login-card {
  width: min(100%, 490px);
  padding: 40px 38px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: #fff;
  box-shadow: var(--shadow);
  text-align: center;
}

.login-illustration {
  display: grid;
  place-items: center;
  width: 95px;
  height: 95px;
  margin: 0 auto 20px;
  border-radius: 26px;
  background: var(--soft);
  color: var(--primary);
}

.login-card .eyebrow {
  text-align: center;
}

.login-card h1 {
  margin: 8px 0;
  font-size: 26px;
}

.login-card p {
  margin: 0 0 23px;
  color: #7a8191;
  font-size: 13px;
  line-height: 2;
}

.login-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin-top: 18px;
  font-size: 11px;
  color: #8b91a0;
}

.login-note svg {
  color: #8880e8;
}

/* ==========================================================================
   Dialog
   ========================================================================== */
.app-dialog {
  width: min(92vw, 460px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  color: var(--text);
  box-shadow: 0 25px 80px rgba(20, 25, 45, 0.22);
}

.app-dialog::backdrop {
  background: rgba(25, 31, 52, 0.38);
  backdrop-filter: blur(3px);
}

.dialog-form {
  padding: 23px;
}

.dialog-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 15px;
  margin-bottom: 22px;
}

.dialog-heading h2 {
  margin: 0;
  font-size: 17px;
}

.dialog-heading p {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.field-label {
  display: block;
  margin: 0 0 7px;
  font-size: 12px;
  font-weight: 800;
  color: #51596b;
}

.field {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid #dfe2eb;
  border-radius: 10px;
  outline: none;
  background: #fff;
  color: var(--text);
}

.field:focus {
  border-color: #8d87f3;
  box-shadow: 0 0 0 3px rgba(103, 95, 226, 0.12);
}

.dialog-actions {
  display: flex;
  gap: 8px;
  margin-top: 20px;
}

/* ==========================================================================
   Drag & Drop
   ========================================================================== */
.drop-toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  z-index: 20;
  max-width: min(90vw, 600px);
  padding: 11px 17px;
  border-radius: 10px;
  background: #252a3a;
  color: #fff;
  font-size: 12px;
  box-shadow: 0 12px 30px #0002;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 20px);
  transition: 0.18s;
}

.drop-toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.drop-toast.error {
  background: #923d3d;
}

.drop-target-active {
  outline: 2px dashed #8179f3;
  outline-offset: -3px;
  background: #f4f2ff !important;
}

/* ==========================================================================
   Setup
   ========================================================================== */
.setup-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 30px 16px;
}

.setup-shell {
  width: min(100%, 510px);
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 23px;
  background: #fff;
  box-shadow: var(--shadow);
}

.setup-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--primary);
  font-size: 16px;
  font-weight: 900;
}

.setup-brand svg {
  width: 32px;
  height: 32px;
}

.setup-shell h1 {
  margin: 19px 0 6px;
  font-size: 24px;
}

.subheading {
  margin: 0 0 22px;
  font-size: 12px;
  line-height: 2;
  color: var(--muted);
}

.setup-form {
  display: grid;
  gap: 0;
}

.setup-form .field {
  margin-bottom: 15px;
}

.steps-box {
  margin-top: 23px;
  padding: 14px 17px;
  border: 1px solid #eceef5;
  border-radius: 12px;
  background: #f8f9fc;
  font-size: 12px;
}

.steps-box ol {
  margin: 7px 0 0;
  padding-left: 20px;
  color: #747c8c;
  line-height: 2;
}

.copy-row {
  display: flex;
  gap: 7px;
  margin-bottom: 15px;
}

.copy-row input {
  flex: 1;
  min-width: 0;
  padding: 10px;
  border: 1px solid #dfe2eb;
  border-radius: 9px;
}

.setup-shell > .btn {
  margin-top: 5px;
}

.hint {
  font-size: 11px;
  color: var(--muted);
}

/* ==========================================================================
   Locale Switch
   ========================================================================== */
.locale-switch {
  display: flex;
  flex: none;
  align-items: center;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 9px;
}

.locale-switch a {
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 11px;
    color: #687083;
}

.locale-switch a:hover {
  background: var(--soft);
  color: var(--primary);
}

/* ==========================================================================
   View Switch / Grid View
   ========================================================================== */
.files-heading-tools {
  display: flex;
  align-items: center;
  gap: 10px;
}

.view-switch {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fbfbfe;
}

.view-switch button {
  display: grid;
  place-items: center;
  width: 31px;
  height: 29px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #737b8d;
  cursor: pointer;
}

.view-switch button[aria-pressed='true'] {
  background: var(--soft);
  color: var(--primary);
  box-shadow: 0 1px 3px #29235d12;
}

.view-switch button:disabled {
  opacity: 0.5;
  cursor: wait;
}

.grid-wrap {
  display: none;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 245px), 1fr));
  gap: 12px;
  padding: 16px;
}

.app-shell[data-view-mode='grid'] .table-wrap {
  display: none;
}

.app-shell[data-view-mode='grid'] .grid-wrap {
  display: grid;
}

.grid-file-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fff;
  transition: border-color 0.14s, box-shadow 0.14s, background 0.14s;
}

.grid-file-card[draggable='true'] {
  cursor: grab;
}

.grid-file-card:hover {
  border-color: #d8d5ff;
  box-shadow: 0 5px 18px rgba(57, 48, 135, 0.06);
}

.grid-file-card.is-dragging {
  opacity: 0.42;
}

.grid-file-card.drop-over {
  border-color: #a7a2f9;
  background: #f0efff;
  box-shadow: inset 0 0 0 2px #a7a2f9;
}

.grid-file-main {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.grid-file-main .file-title {
  flex: 1;
}

.grid-file-main .file-name {
  max-width: 100%;
  white-space: nowrap;
}

.grid-file-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px solid #f0f1f5;
  font-size: 11px;
  color: var(--muted);
}

.grid-file-meta span:last-child {
  overflow-wrap: anywhere;
  text-align: right;
}

.grid-file-meta.modified {
  padding-top: 0;
  border-top: 0;
}

.grid-actions {
  flex-wrap: wrap;
  margin-top: auto;
  padding-top: 11px;
  border-top: 1px solid #f0f1f5;
}

.grid-file-card .row-actions {
    justify-content: center;
}

/* ==========================================================================
   Theme Toggle (opt-in dark mode via localStorage)
   ========================================================================== */
.theme-toggle {
    display: grid;
    place-items: center;
    width: 30px;
    height: 26px;
    padding: 0;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--text);
    cursor: pointer;
}

.theme-toggle:hover {
  background: var(--soft);
  color: var(--primary);
}

.theme-icon-dark {
  display: none;
}

html[data-theme='dark'] .theme-icon-light {
  display: none;
}

html[data-theme='dark'] .theme-icon-dark {
  display: inline-flex;
}

/* ==========================================================================
   Dark Theme
   ========================================================================== */

html[data-theme='dark'] body {
  background: var(--bg);
  color: var(--text);
}

html[data-theme='dark'] .topbar,
html[data-theme='dark'] .sidebar,
html[data-theme='dark'] .login-card,
html[data-theme='dark'] .setup-shell,
html[data-theme='dark'] .app-dialog {
  border-color: var(--line);
  background: var(--surface);
  color: var(--text);
}

html[data-theme='dark'] .btn-secondary {
  border-color: #3b4354;
  background: #242a37;
  color: var(--text);
}

html[data-theme='dark'] .btn-primary {
    color: #d7d3ff;
    background: #302e55;
    border-color: #514f76;
}
html[data-theme='dark'] .btn-primary:hover {
  background: #232141;
}

html[data-theme='dark'] .btn-secondary:hover,
html[data-theme='dark'] .btn-quiet:hover,
html[data-theme='dark'] .nav-item:hover {
  border-color: #454e61;
  background: #292f3d;
}

html[data-theme='dark'] .btn-quiet {
  color: #c2c9d8;
}

html[data-theme='dark'] .admin-tag {
  background: #302e50;
  color: #c6c0ff;
}

html[data-theme='dark'] .sidebar-title,
html[data-theme='dark'] .eyebrow,
html[data-theme='dark'] .breadcrumbs,
html[data-theme='dark'] .file-table td,
html[data-theme='dark'] .account-email,
html[data-theme='dark'] .sidebar-bottom,
html[data-theme='dark'] .sidebar-hint,
html[data-theme='dark'] .file-title small,
html[data-theme='dark'] .login-card p,
html[data-theme='dark'] .login-note,
html[data-theme='dark'] .field-label,
html[data-theme='dark'] .steps-box ol {
  color: #aeb7c9;
}

html[data-theme='dark'] .nav-item {
  color: #c1c9d9;
}

html[data-theme='dark'] .sidebar-hint,
html[data-theme='dark'] .steps-box,
html[data-theme='dark'] .search-form,
html[data-theme='dark'] .view-switch,
html[data-theme='dark'] .file-table th,
html[data-theme='dark'] .table-footer {
  border-color: var(--line);
  background: #202633;
  color: #aeb7c9;
}

html[data-theme='dark'] .breadcrumbs,
html[data-theme='dark'] .file-table td,
html[data-theme='dark'] .files-heading,
html[data-theme='dark'] .table-footer,
html[data-theme='dark'] .grid-file-meta,
html[data-theme='dark'] .grid-actions {
  border-color: var(--line);
}

html[data-theme='dark'] .breadcrumbs strong,
html[data-theme='dark'] .file-name,
html[data-theme='dark'] .empty-state h3,
html[data-theme='dark'] .dialog-heading h2,
html[data-theme='dark'] .setup-shell h1 {
  color: var(--text);
}

html[data-theme='dark'] .breadcrumbs a:hover,
html[data-theme='dark'] .file-table tbody tr:hover,
html[data-theme='dark'] .grid-file-card:hover {
  background: #222837;
}

html[data-theme='dark'] .file-table tbody tr.drop-over,
html[data-theme='dark'] .grid-file-card.drop-over,
html[data-theme='dark'] .drop-target-active {
  background: #2b2a49 !important;
}

html[data-theme='dark'] .grid-file-card {
  border-color: var(--line);
  background: #191e29;
}

html[data-theme='dark'] .folder-icon {
  background: #393122;
  color: #e7bd62;
}

html[data-theme='dark'] .image-icon {
  background: #1e3445;
  color: #77caff;
}

html[data-theme='dark'] .doc-icon,
html[data-theme='dark'] .empty-icon {
  background: #302e50;
  color: #b6b0ff;
}

html[data-theme='dark'] .icon-button {
  color: #aab3c5;
}

html[data-theme='dark'] .icon-button:hover {
  border-color: #45406e;
  background: #302e50;
  color: #c6c0ff;
}

html[data-theme='dark'] .icon-button.share-ready {
  background: #1c3a31;
  color: #83dfb5;
}

html[data-theme='dark'] .icon-button.danger-button:hover {
  border-color: #66343d;
  background: #40272d;
  color: #ff9a9a;
}

html[data-theme='dark'] .notice {
  border-color: #343d50;
  background: #202633;
  color: var(--text);
}

html[data-theme='dark'] .notice.success {
  border-color: #285342;
  background: #1c352d;
  color: #a2e8c6;
}

html[data-theme='dark'] .notice.error {
  border-color: #63353d;
  background: #3a252a;
  color: #ffb5b5;
}

html[data-theme='dark'] .notice.info {
  border-color: #35476a;
  background: #232d43;
  color: #c1d1ff;
}

html[data-theme='dark'] .public-link-box input,
html[data-theme='dark'] .copy-row input,
html[data-theme='dark'] .field {
  border-color: #3b4354;
  background: #111620;
  color: var(--text);
}

html[data-theme='dark'] .public-link-box input {
  border-color: #375548;
  color: #b1e8cd;
}

html[data-theme='dark'] .field::placeholder,
html[data-theme='dark'] .search-form input::placeholder {
  color: #7f8ba2;
}

html[data-theme='dark'] .connection-status {
  border-color: #285342;
  background: #1c352d;
  color: #86e0b4;
}

html[data-theme='dark'] .view-switch button {
  color: #adb6c8;
}

html[data-theme='dark'] .view-switch button[aria-pressed='true'] {
  background: #302e50;
  color: #c4beff;
}

html[data-theme='dark'] .locale-switch a {
  color: #c0c8d8;
}

html[data-theme='dark'] .locale-switch a:hover {
  background: #302e50;
  color: #c6c0ff;
}

html[data-theme='dark'] .search-submit,
html[data-theme='dark'] .clear-search {
  color: #aeb7c9;
}

html[data-theme='dark'] .page-footer,
html[data-theme='dark'] .text-button {
  color: #929db2;
}

html[data-theme='dark'] .app-dialog::backdrop {
  background: rgba(0, 0, 0, 0.62);
}

html[data-theme='dark'] .setup-brand {
  color: #b1abff;
}

/* ==========================================================================
   Responsive – 1000px
   ========================================================================== */
@media (max-width: 1000px) {
  .workspace {
    grid-template-columns: 190px minmax(0, 1fr);
    gap: 14px;
  }

  .sidebar {
    padding: 14px 8px;
  }

  .account-email {
    max-width: 160px;
  }

  .file-table td,
  .file-table th {
    padding: 11px 12px;
  }

  .file-name-cell {
    min-width: 220px;
  }
}

/* ==========================================================================
   Responsive – 760px
   ========================================================================== */
@media (max-width: 760px) {
  .topbar {
    min-height: 68px;
    height: auto;
    padding: 12px 15px;
  }

  .account-area {
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .account-select {
    max-width: 135px;
    min-width: 110px;
    padding: 7px 6px;
  }

  .account-email,
  .admin-tag,
  .account-area .btn span {
    display: none;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    min-height: auto;
    align-items: start;
  }

  .sidebar-title,
  .sidebar-divider,
  .sidebar-hint,
  .sidebar-bottom {
    grid-column: 1 / -1;
  }

  .sidebar-bottom {
    margin-top: 8px;
  }

  .page-heading h1 {
    font-size: 22px;
  }

  .toolbar-row {
    flex-direction: column;
    align-items: stretch;
  }

  .search-form {
    flex: none;
    max-width: none;
  }

  .upload-form {
    justify-content: flex-start;
  }

  .upload-pick {
    flex: 1;
    max-width: none;
  }

  .app-shell {
    padding-top: 16px;
  }

  .files-heading {
    padding: 14px;
  }

  .page-footer {
    padding-top: 15px;
  }

  .public-link-box input {
    flex-basis: 100%;
  }

  .files-heading-tools {
    gap: 6px;
  }

  .files-heading-tools .connection-status {
    padding: 7px;
    font-size: 0;
  }

  .files-heading-tools .connection-status i {
    width: 7px;
    height: 7px;
  }

  .grid-wrap {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr));
    gap: 9px;
    padding: 10px;
  }

  .grid-file-card {
    padding: 12px;
  }

  .locale-switch {
    gap: 1px;
  }
}

/* ==========================================================================
   Responsive – 480px
   ========================================================================== */
@media (max-width: 480px) {
  .brand-copy small {
    display: none;
  }

  .page-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .page-heading-actions {
    width: 100%;
    justify-content: space-between;
  }

.page-heading .btn {
    padding: 9px 10px;
    font-size: 11px;
  }

  .page-heading .btn .svg-icon {
    width: 16px;
  }

  .toolbar-card {
    padding: 12px;
  }

  .files-heading {
    align-items: flex-start;
  }

  .connection-status {
    padding: 4px 7px;
    font-size: 10px;
  }

  .table-footer {
    flex-direction: column;
    align-items: flex-start;
  }

  .pagination {
    justify-content: center;
    width: 100%;
  }

  .login-card {
    padding: 30px 20px;
  }

  .login-card h1 {
    font-size: 22px;
  }

  .setup-shell {
    padding: 24px 19px;
  }

  .account-area .btn {
    padding: 7px;
  }

  .dialog-form {
    padding: 19px;
  }

  .dialog-actions {
    flex-wrap: wrap;
  }
}

/* ========================================================================== 
   Persian Documentation Page
   ========================================================================== */
.docs-page {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}
.docs-topbar {
  position: sticky;
  top: 0;
  z-index: 10;
}
.docs-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.docs-header-actions .btn { gap: 7px; }
.docs-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 28px clamp(14px, 3vw, 38px) 36px;
}
.docs-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(220px, .8fr);
  align-items: center;
  gap: 28px;
  min-height: 290px;
  padding: clamp(24px, 5vw, 56px);
  border: 1px solid var(--line);
  border-radius: 24px;
  background: linear-gradient(135deg, var(--surface) 18%, var(--soft) 100%);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.docs-hero-copy { max-width: 800px; }
.docs-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 11px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
}
.docs-hero h1 {
  margin: 17px 0 12px;
  color: var(--text);
  font-size: clamp(26px, 4vw, 42px);
  line-height: 1.5;
  letter-spacing: -.6px;
}
.docs-hero p {
  max-width: 760px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 2.15;
}
.docs-hero-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 22px; }
.docs-hero-art {
  position: relative;
  min-height: 210px;
  display: grid;
  place-items: center;
  color: var(--primary);
}
.docs-art-cloud {
  display: grid;
  place-items: center;
  width: 122px;
  height: 122px;
  border: 1px solid var(--line);
  border-radius: 35px;
  background: var(--surface);
  box-shadow: 0 20px 45px rgba(64, 55, 160, .12);
}
.docs-art-file, .docs-art-folder {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.docs-art-file span { font-size: 9px; font-weight: 900; letter-spacing: .6px; }
.docs-art-file-one { top: 8px; right: 7%; transform: rotate(7deg); }
.docs-art-file-two { bottom: 10px; left: 2%; transform: rotate(-7deg); }
.docs-art-folder { right: 7%; bottom: 17px; padding: 13px; }
.docs-facts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 16px 0 24px;
}
.docs-facts article {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}
.docs-fact-icon {
  display: grid;
  place-items: center;
  flex: 0 0 39px;
  width: 39px;
  height: 39px;
  border-radius: 12px;
  background: var(--soft);
  color: var(--primary);
}
.docs-facts strong { display: block; color: var(--text); font-size: 13px; }
.docs-facts small { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; line-height: 1.7; }
.docs-layout { display: grid; grid-template-columns: 245px minmax(0, 1fr); align-items: start; gap: 20px; }
.docs-sidebar {
  position: sticky;
  top: 94px;
  display: grid;
  gap: 4px;
  padding: 17px 13px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.docs-sidebar h2 { margin: 0 10px 8px; font-size: 14px; }
.docs-sidebar a {
  padding: 9px 10px;
  border-radius: 9px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.7;
  text-decoration: none;
  transition: background .15s ease, color .15s ease;
}
.docs-sidebar a:hover { background: var(--soft); color: var(--primary); }
.docs-content { min-width: 0; display: grid; gap: 16px; }
.docs-section {
  min-width: 0;
  padding: clamp(20px, 3vw, 32px);
  border: 1px solid var(--line);
  border-radius: 17px;
  background: var(--surface);
  box-shadow: var(--shadow);
  scroll-margin-top: 88px;
  line-height: 2.05;
  font-size: 13px;
}
.docs-section p { margin: 11px 0; }
.docs-section h3 { font-size: 14px; }
.docs-section ul, .docs-section ol { padding-right: 22px; margin: 12px 0; }
.docs-section li { padding-right: 2px; margin: 5px 0; }
.docs-section code, .docs-callout code {
  direction: ltr;
  unicode-bidi: plaintext;
  display: inline-block;
  max-width: 100%;
  overflow-wrap: anywhere;
  padding: 0 5px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--bg);
  font-size: .9em;
}
.docs-section-heading { display: flex; align-items: center; gap: 13px; margin-bottom: 17px; }
.docs-number {
  display: grid;
  place-items: center;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--soft);
  color: var(--primary);
  font-weight: 900;
  font-size: 13px;
}
.docs-section-heading p { margin: 0 0 2px; color: var(--primary); font-size: 10px; font-weight: 800; }
.docs-section-heading h2 { margin: 0; color: var(--text); font-size: clamp(17px, 2.5vw, 22px); line-height: 1.6; }
.docs-two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.docs-mini-card { padding: 16px; border: 1px solid var(--line); border-radius: 13px; background: var(--bg); }
.docs-mini-card h3 { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--text); }
.docs-mini-card h3 svg { color: var(--primary); }
.docs-mini-card ul { margin-bottom: 0; }
.docs-callout { margin: 16px 0; padding: 15px 17px; border: 1px solid var(--line); border-right: 4px solid var(--primary); border-radius: 12px; background: var(--bg); }
.docs-callout > strong { display: block; color: var(--text); margin-bottom: 4px; }
.docs-callout p:last-child { margin-bottom: 0; }
.docs-callout ul { margin-bottom: 0; }
.docs-callout-info { border-right-color: var(--primary); }
.docs-callout-warning { border-right-color: #d59627; }
.docs-callout-danger { border-right-color: var(--red); }
.docs-steps { counter-reset: docs-step; list-style: none; padding: 0 !important; }
.docs-steps > li { position: relative; counter-increment: docs-step; padding: 0 47px 18px 0; margin: 0 0 16px; border-bottom: 1px solid var(--line); }
.docs-steps > li:last-child { padding-bottom: 0; margin-bottom: 0; border-bottom: 0; }
.docs-steps > li::before {
  content: counter(docs-step);
  position: absolute;
  top: 0;
  right: 0;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--soft);
  color: var(--primary);
  font-weight: 900;
}
.docs-steps > li strong { display: block; color: var(--text); }
.docs-steps > li p { margin: 4px 0 0; color: var(--muted); }
.docs-inline-link { color: var(--primary); font-weight: 800; text-decoration: none; }
.docs-inline-link:hover { text-decoration: underline; }
.docs-checklist { list-style: none; padding: 0 !important; }
.docs-checklist li { position: relative; padding-right: 28px; margin: 10px 0; }
.docs-checklist li::before { content: '✓'; position: absolute; right: 0; top: 0; color: var(--green); font-weight: 900; }
.docs-operation-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.docs-operation-grid article { min-width: 0; padding: 15px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); }
.docs-operation-grid article > span { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--soft); color: var(--primary); }
.docs-operation-grid h3 { margin: 9px 0 4px; }
.docs-operation-grid p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.9; }
.docs-table-wrap { max-width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
.docs-table { width: 100%; border-collapse: collapse; font-size: 12px; line-height: 1.8; }
.docs-table th, .docs-table td { padding: 12px 13px; text-align: right; vertical-align: top; border-bottom: 1px solid var(--line); }
.docs-table th { background: var(--bg); color: var(--text); font-weight: 800; white-space: nowrap; }
.docs-table tr:last-child td { border-bottom: 0; }
.docs-table td:first-child { width: 34%; font-weight: 700; }
.docs-code { direction: ltr; text-align: left; overflow-x: auto; padding: 17px; border: 1px solid var(--line); border-radius: 12px; background: #171b26; color: #ecedf6; line-height: 1.8; font-size: 12px; }
.docs-code code { display: block; padding: 0; border: 0; background: transparent; color: inherit; direction: ltr; unicode-bidi: plaintext; }
.docs-muted { color: var(--muted); }
.docs-faq { display: grid; gap: 8px; }
.docs-faq details { border: 1px solid var(--line); border-radius: 11px; background: var(--bg); }
.docs-faq summary { position: relative; padding: 13px 16px; color: var(--text); cursor: pointer; font-weight: 800; }
.docs-faq details[open] summary { color: var(--primary); }
.docs-faq details p { padding: 0 16px 14px; margin: 0; color: var(--muted); }
.docs-last-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 20px; }
.docs-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px;
  margin-top: 20px;
  padding: 18px 4px 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
}
.docs-footer span { margin-left: auto; }
.docs-footer a, .docs-footer-link { display: inline-flex; align-items: center; gap: 6px; color: var(--primary); text-decoration: none; font-weight: 700; }
.docs-footer a:hover, .docs-footer-link:hover { text-decoration: underline; }
.login-page-footer { width: min(780px, calc(100% - 32px)); margin: -16px auto 28px; padding-top: 15px; flex-wrap: wrap; }
.page-footer .docs-footer-link { color: var(--primary); font-size: 11px; }
html[data-theme='dark'] .docs-hero { background: linear-gradient(135deg, var(--surface) 18%, #24223e 100%); }
html[data-theme='dark'] .docs-art-cloud, html[data-theme='dark'] .docs-art-file, html[data-theme='dark'] .docs-art-folder { border-color: var(--line); background: var(--surface); }
html[data-theme='dark'] .docs-callout-warning { border-right-color: #d9a84c; }
@media (max-width: 1040px) {
  .docs-layout { grid-template-columns: 205px minmax(0, 1fr); gap: 13px; }
  .docs-operation-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .docs-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .docs-shell { padding-top: 16px; }
  .docs-hero { grid-template-columns: minmax(0, 1fr); min-height: 0; gap: 5px; padding: 24px; }
  .docs-hero-art { min-height: 135px; transform: scale(.78); transform-origin: center top; margin-bottom: -18px; }
  .docs-layout { grid-template-columns: minmax(0, 1fr); }
  .docs-sidebar { position: static; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .docs-sidebar h2 { grid-column: 1 / -1; }
  .docs-two-col { grid-template-columns: minmax(0, 1fr); }
  .docs-facts { gap: 8px; }
  .docs-facts article { padding: 11px; }
  .docs-operation-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .docs-header-actions .btn span { display: none; }
  .docs-footer span { width: 100%; margin: 0; }
  .login-page-footer { justify-content: center; }
}
@media (max-width: 430px) {
  .docs-operation-grid { grid-template-columns: minmax(0, 1fr); }
  .docs-facts { grid-template-columns: minmax(0, 1fr); }
  .docs-sidebar { grid-template-columns: minmax(0, 1fr); }
  .docs-hero h1 { font-size: 25px; }
}
