/* رنگ‌ها و تنظیمات اصلی */
:root {
  --navy: #14263d;
  --navy-light: #28415e;
  --gold: #c59445;
  --background: #f5f7f9;
  --surface: #ffffff;
  --border: #e2e7ec;
  --text: #243447;
  --muted: #718093;
  --shadow: 0 6px 20px rgba(20, 38, 61, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--background);
  color: var(--text);
  font-family: "B Nazanin", "BNazanin", Tahoma, Arial, sans-serif;
  line-height: 1.8;
}

button, a { font: inherit; }
a { color: inherit; text-decoration: none; }
.container { width: min(1120px, calc(100% - 40px)); margin: 0 auto; }

.site-header { background: var(--surface); border-bottom: 1px solid var(--border); }
.header-content { min-height: 96px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.brand { display: flex; align-items: center; gap: 16px; color: var(--navy); font-weight: bold; min-width: 0; }
.brand-logo { width: 82px; max-width: 100%; height: auto; display: block; object-fit: contain; }
.brand-name { font-size: 1.35rem; white-space: nowrap; }

.page-section { padding: 42px 0 52px; }
.hero { max-width: 720px; margin-bottom: 22px; }
.eyebrow { color: var(--gold); font-size: 0.85rem; font-weight: bold; margin: 0 0 8px; }
h1, h2, h3, p { margin-top: 0; }
h1 { color: var(--navy); font-size: clamp(2rem, 4vw, 2.7rem); font-weight: 700; line-height: 1.5; margin-bottom: 4px; }
h2 { color: var(--navy); font-size: 1.75rem; font-weight: 700; margin-bottom: 8px; }
h3 { color: var(--navy); font-size: 1.2rem; font-weight: 700; margin-bottom: 4px; }
.section-heading { margin-bottom: 14px; }
.section-heading-actions { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.section-heading-actions h2 { margin-bottom: 0; }
.section-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.project-heading { align-items: flex-end; }

.project-grid, .folder-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.card, .folder-card, .file-panel { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); }
.project-card { padding: 18px 20px; display: flex; flex-direction: column; min-height: 178px; cursor: pointer; transition: 0.2s ease; }
.project-card:hover { border-color: #c9d3dd; box-shadow: 0 8px 22px rgba(20, 38, 61, 0.09); }
.project-card:focus-visible { outline: 3px solid rgba(197, 148, 69, 0.35); outline-offset: 2px; }
.project-description { max-width: 100%; margin: 4px 0 10px; overflow: hidden; color: var(--muted); font-size: 0.88rem; line-height: 1.45; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; }
.card-top-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.card-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: auto; margin-bottom: 18px; color: var(--muted); font-size: 0.82rem; }
.status { color: #657b3c; background: #f0f5e9; border-radius: 30px; padding: 2px 10px; }

.button { display: inline-flex; align-items: center; justify-content: center; border: 1px solid transparent; border-radius: 6px; padding: 8px 16px; cursor: pointer; transition: 0.2s ease; }
.button-primary { background: var(--navy); color: white; }
.button-primary:hover { background: var(--navy-light); }
.button-secondary { background: transparent; border-color: var(--border); color: var(--navy); }
.button-secondary:hover { border-color: var(--navy); background: #f7f9fb; }
.button-small { padding: 5px 11px; font-size: 0.82rem; }
.button-danger { background: #9d3e3e; color: #fff; }
.button-danger:hover { background: #833030; }
.button:disabled { opacity: 0.58; cursor: wait; }

.breadcrumb { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; color: var(--muted); font-size: 0.86rem; margin-bottom: 14px; }
.breadcrumb-link { padding: 0; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.breadcrumb-link:hover { color: var(--navy); text-decoration: underline; }
.breadcrumb-current { color: var(--navy); }
.back-button { margin-bottom: 14px; }
.folder-grid { grid-template-columns: repeat(3, 1fr); }
.folder-section { margin-bottom: 14px; }
.folder-card { padding: 16px 18px; min-height: 108px; display: flex; flex-direction: column; justify-content: space-between; cursor: pointer; transition: 0.2s ease; }
.folder-card:hover { border-color: #c9d3dd; box-shadow: 0 8px 22px rgba(20, 38, 61, 0.09); }
.folder-card:focus-visible { outline: 3px solid rgba(197, 148, 69, 0.35); outline-offset: 2px; }

.context-menu-wrapper { position: relative; flex: 0 0 auto; }
.menu-trigger, .modal-close { border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.menu-trigger { width: 32px; height: 32px; border-radius: 6px; font-size: 1.35rem; line-height: 1; }
.menu-trigger:hover { background: #f1f4f7; color: var(--navy); }
.context-menu { position: absolute; top: 38px; left: 0; z-index: 5; min-width: 158px; padding: 6px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); box-shadow: 0 10px 24px rgba(20, 38, 61, 0.12); }
.context-menu button { display: block; width: 100%; padding: 8px 10px; border: 0; border-radius: 5px; background: transparent; color: var(--text); cursor: pointer; text-align: right; font-size: 0.86rem; white-space: nowrap; }
.context-menu button:hover { background: #f4f6f8; }
.context-menu .menu-danger { color: #9d3e3e; }
.empty-state { padding: 36px 24px; border: 1px dashed #cbd4dd; border-radius: 10px; background: rgba(255, 255, 255, 0.65); color: var(--muted); text-align: center; }
.empty-state p { margin-bottom: 16px; }

.file-panel { overflow: hidden; }
.panel-header { padding: 20px 22px; display: flex; justify-content: space-between; align-items: center; gap: 15px; border-bottom: 1px solid var(--border); }
.panel-header h3 { margin: 0; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 650px; }
th, td { padding: 14px 20px; text-align: right; border-bottom: 1px solid var(--border); font-size: 0.88rem; }
th { color: var(--muted); background: #fafbfc; font-weight: normal; }
tr:last-child td { border-bottom: 0; }
.file-name { color: var(--navy); font-weight: bold; }
.muted { color: var(--muted); }
.file-actions { display: flex; align-items: center; gap: 7px; }
.table-state { min-height: 90px; display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--muted); text-align: center; }
.table-state-error { color: #9d3e3e; flex-wrap: wrap; }
.spinner { width: 20px; height: 20px; border: 2px solid #d5dce3; border-top-color: var(--navy); border-radius: 50%; animation: spin 0.8s linear infinite; }

.site-footer { border-top: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: 0.8rem; }
.site-footer p { margin: 0; padding: 12px 0; }
.site-footer span { color: var(--gold); padding: 0 4px; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 10; max-width: calc(100% - 40px); padding: 12px 18px; border-radius: 7px; background: var(--navy); color: white; box-shadow: var(--shadow); opacity: 0; transform: translateY(12px); pointer-events: none; transition: 0.25s ease; }
.toast.show { opacity: 1; transform: translateY(0); }

.modal-backdrop { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 20px; background: rgba(20, 38, 61, 0.42); }
.modal { width: min(100%, 440px); padding: 24px; border-radius: 12px; background: var(--surface); box-shadow: 0 20px 55px rgba(20, 38, 61, 0.2); }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.modal-header h2 { margin: 0; }
.modal-close { width: 32px; height: 32px; border-radius: 6px; font-size: 1.7rem; line-height: 1; }
.modal-close:hover { background: #f1f4f7; color: var(--navy); }
.form-field { display: block; margin-bottom: 16px; color: var(--navy); font-weight: bold; }
.form-field input, .form-field select, .form-field textarea { display: block; width: 100%; margin-top: 6px; padding: 9px 11px; border: 1px solid #cbd4dd; border-radius: 6px; background: #fff; color: var(--text); font: inherit; font-weight: normal; outline: none; }
.form-field textarea { resize: vertical; min-height: 80px; }
.form-field input:focus, .form-field select:focus, .form-field textarea:focus { border-color: var(--navy-light); box-shadow: 0 0 0 3px rgba(40, 65, 94, 0.1); }
.form-error { min-height: 24px; margin-bottom: 0; color: #a43d3d; font-size: 0.86rem; }
.modal-text { color: var(--muted); }
.modal-actions { display: flex; justify-content: flex-start; gap: 10px; margin-top: 20px; }
.upload-progress { height: 8px; overflow: hidden; margin: 8px 0; border-radius: 20px; background: #e7ebef; }
.upload-progress-bar { width: 0; height: 100%; background: var(--gold); transition: width 0.2s ease; }
.upload-status { min-height: 25px; margin-bottom: 0; color: var(--muted); font-size: 0.85rem; }

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 760px) {
  .container { width: min(100% - 28px, 600px); }
  .page-section { padding: 28px 0 40px; }
  .project-grid, .folder-grid { grid-template-columns: 1fr; }
  .section-heading-actions, .project-heading { align-items: stretch; flex-direction: column; }
  .section-actions { width: 100%; }
  .section-actions .button, .project-heading > .button { flex: 1; }
  .header-content { min-height: 82px; }
  .brand { gap: 12px; }
  .brand-logo { width: 68px; }
  .brand-name { font-size: 1.1rem; white-space: normal; line-height: 1.4; }
  .panel-header { align-items: flex-start; flex-direction: column; }
  .modal { padding: 20px; }
  .modal-actions .button { flex: 1; }
  .file-actions { align-items: stretch; flex-direction: column; }
}

/* Final navigation and hierarchy polish. */
.brand { cursor: pointer; transition: opacity 0.2s ease, transform 0.2s ease; }
.brand:hover { opacity: 0.84; transform: translateY(-1px); }
.home-section .hero { margin-bottom: 18px; }
.project-card { min-height: 168px; }
.project-card .card-meta { margin-bottom: 0; }
.status { display: inline-flex; align-items: center; border-radius: 30px; padding: 3px 10px; font-size: 0.8rem; font-weight: bold; }
.status-active { color: #5f793b; background: #eef5e6; }
.status-in_progress { color: #35658c; background: #eaf2f9; }
.status-on_hold { color: #80652d; background: #fbf3df; }
.status-completed { color: #65717d; background: #eef0f2; }
.archive-label { color: #8a5b55; font-size: 0.78rem; }
.folder-section { margin-bottom: 14px; }
.loading-state { min-height: 120px; display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--muted); }
.inline-state { padding: 22px; color: var(--muted); }
.inline-state p { margin-bottom: 12px; }
.route-state-section, .route-loading-section { min-height: 360px; }
.route-state { max-width: 560px; margin: 0 auto; padding: 72px 20px; text-align: center; }
.route-state h1 { font-size: clamp(1.6rem, 3vw, 2.2rem); margin-bottom: 22px; }
.subfolder-section { margin-top: 6px; }
.subfolder-list, .file-list { overflow: hidden; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow); }
.subfolder-row, .file-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 14px; min-height: 56px; padding: 10px 18px; border-bottom: 1px solid var(--border); transition: background 0.2s ease; cursor: pointer; }
.subfolder-row:last-child, .file-row:last-child { border-bottom: 0; }
.subfolder-row:hover, .file-row:hover { background: #fafbfd; }
.subfolder-row:focus-visible, .file-row:focus-visible { outline: 3px solid rgba(197, 148, 69, 0.35); outline-offset: -3px; }
.row-main { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.row-main strong { overflow: hidden; color: var(--navy); text-overflow: ellipsis; white-space: nowrap; }
.file-section { margin-top: 30px; }
.file-section .section-heading { margin-bottom: 12px; }
.file-panel { min-height: 68px; }
.file-actions { justify-content: flex-end; }
.context-menu-wrapper { z-index: 2; }
.context-menu-portal { position: fixed; z-index: 1000; top: 0; left: 0; }
.button:focus-visible, .breadcrumb-link:focus-visible, .brand:focus-visible, .menu-trigger:focus-visible { outline: 3px solid rgba(197, 148, 69, 0.35); outline-offset: 2px; }
.folder-action-bar { gap: 8px; }
.folder-content-list { display: flex; flex-direction: column; gap: 0; }
.folder-content-list .subfolder-list, .folder-content-list .file-panel { margin: 0; }
.folder-content-list .file-panel { border-radius: 10px; }
.content-divider { height: 1px; margin: 10px 0; background: var(--border); opacity: 0.72; }

@media (max-width: 760px) {
  .home-section .hero { margin-bottom: 16px; }
  .subfolder-row, .file-row { gap: 10px; padding: 10px 12px; }
  .file-row { grid-template-columns: minmax(0, 1fr); }
  .file-row .file-actions { flex-direction: row; align-items: center; }
  .row-main strong { white-space: normal; }
  .route-state { padding: 48px 12px; }
  .folder-action-bar { width: 100%; }
  .folder-action-bar .button { flex: 1; }
}

/* View modes: the same content can be browsed as cards, rows, or compact rows. */
.view-switcher { display: inline-flex; align-items: center; gap: 2px; padding: 2px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); }
.view-switcher-button { width: 30px; height: 28px; padding: 0; border: 0; border-radius: 5px; background: transparent; color: var(--muted); cursor: pointer; line-height: 1; transition: background 0.2s ease, color 0.2s ease; }
.view-switcher-button:hover, .view-switcher-button.is-active { background: #eef2f6; color: var(--navy); }
.view-switcher-button:focus-visible { outline: 3px solid rgba(197, 148, 69, 0.35); outline-offset: 1px; }

.item-main { min-width: 0; display: flex; align-items: center; gap: 11px; }
.item-main h3 { min-width: 0; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-icon { display: inline-grid; place-items: center; width: 34px; height: 34px; flex: 0 0 auto; border-radius: 8px; }
.project-icon { color: var(--navy); background: #eef2f6; }
.project-icon svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.folder-icon { color: var(--gold); background: #fbf5e9; font-size: 1.4rem; }
.file-icon { color: var(--navy-light); background: #eef2f6; font-size: 0.66rem; font-weight: bold; letter-spacing: 0.02em; }

.project-card, .folder-card { position: relative; }
.project-card .card-top-row, .folder-card .card-top-row { position: absolute; top: 12px; left: 12px; }
.project-card .item-main, .folder-card .item-main { padding-left: 28px; }
.folder-card .item-main { padding-left: 0; }

.project-grid.view-list, .folder-grid.view-list,
.project-grid.view-compact, .folder-grid.view-compact { display: flex; flex-direction: column; gap: 0; overflow: hidden; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow); }
.view-list .project-card, .view-list .folder-card,
.view-compact .project-card, .view-compact .folder-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; border: 0; border-bottom: 1px solid var(--border); border-radius: 0; box-shadow: none; }
.view-list .project-card:last-child, .view-list .folder-card:last-child,
.view-compact .project-card:last-child, .view-compact .folder-card:last-child { border-bottom: 0; }
.view-list .project-card { min-height: 64px; padding: 10px 16px; }
.view-list .folder-card { min-height: 58px; padding: 10px 16px; }
.view-list .project-card .card-top-row, .view-list .folder-card .card-top-row,
.view-compact .project-card .card-top-row, .view-compact .folder-card .card-top-row { position: static; grid-column: 2; grid-row: 1 / span 2; align-self: center; }
.view-list .project-card .card-meta { grid-column: 1; margin: 0; justify-content: flex-start; }
.view-list .project-card .project-description { grid-column: 1; grid-row: 2; margin: 0; font-size: 0.82rem; -webkit-line-clamp: 1; }
.view-list .project-card .card-meta { grid-row: 3; }
.view-list .project-card .card-top-row { grid-row: 1 / span 3; }
.view-list .project-card .item-main, .view-list .folder-card .item-main,
.view-compact .project-card .item-main, .view-compact .folder-card .item-main { padding-left: 0; }

.view-compact .project-card, .view-compact .folder-card { min-height: 42px; padding: 5px 10px; gap: 8px; }
.view-compact .item-main { gap: 8px; }
.view-compact .item-icon { width: 26px; height: 26px; font-size: 0.95rem; border-radius: 6px; }
.view-compact .project-card { min-height: 58px; }
.view-compact .project-card .project-description { grid-column: 1; grid-row: 2; margin: 0; font-size: 0.76rem; line-height: 1.25; -webkit-line-clamp: 1; }
.view-compact .project-card .card-meta { display: flex; grid-column: 1; grid-row: 3; margin: 0; justify-content: flex-start; font-size: 0.7rem; }
.view-compact .project-card .card-top-row { grid-row: 1 / span 3; }
.view-compact .project-card .card-top-row, .view-compact .folder-card .card-top-row { top: 5px; left: 10px; }

.subfolder-list.view-gallery { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; overflow: visible; border: 0; background: transparent; box-shadow: none; }
.view-gallery .subfolder-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto auto; min-height: 106px; padding: 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow); }
.view-gallery .subfolder-row .item-icon { grid-column: 1; grid-row: 1; }
.view-gallery .subfolder-row .row-main { grid-column: 1; grid-row: 2; align-self: end; }
.view-gallery .subfolder-row .context-menu-wrapper { grid-column: 2; grid-row: 1; }
.subfolder-list.view-compact .subfolder-row { min-height: 40px; padding: 5px 10px; gap: 8px; }
.subfolder-list.view-compact .item-icon { width: 26px; height: 26px; font-size: 0.95rem; border-radius: 6px; }

.file-list.view-gallery { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; overflow: visible; border: 0; background: transparent; box-shadow: none; }
.view-gallery .file-row { display: flex; min-height: 142px; flex-direction: column; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 16px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow); }
.view-gallery .file-row .row-main { width: 100%; }
.view-gallery .file-row .file-actions { width: 100%; justify-content: flex-start; }
.file-list.view-compact .file-row { min-height: 40px; padding: 5px 10px; gap: 8px; }
.file-list.view-compact .item-icon { width: 26px; height: 26px; font-size: 0.58rem; border-radius: 6px; }
.file-list.view-compact .file-actions .button { padding: 3px 8px; font-size: 0.76rem; }

.view-list .file-row { transition: background 0.2s ease, transform 0.2s ease; }
.view-gallery .file-row, .view-gallery .subfolder-row, .view-list .project-card, .view-list .folder-card, .view-compact .project-card, .view-compact .folder-card { transition: background 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease; }

@media (max-width: 760px) {
  .view-switcher-button { width: 28px; }
  .subfolder-list.view-gallery, .file-list.view-gallery { grid-template-columns: 1fr; }
  .view-gallery .subfolder-row, .view-gallery .file-row { min-height: 88px; }
  .subfolder-row, .file-row { grid-template-columns: auto minmax(0, 1fr) auto; }
  .file-row { grid-template-columns: auto minmax(0, 1fr); }
  .file-row .file-actions { grid-column: 2; justify-self: start; }
  .view-list .project-card, .view-list .folder-card { padding-inline: 12px; }
}

/* Shared operational control style. */
.section-actions { gap: 8px; }
.section-actions > .button,
.folder-action-bar > .button {
  height: 40px;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid var(--navy);
  border-radius: 6px;
  background: var(--navy);
  color: #fff;
  line-height: 1.4;
}
.section-actions > .button:hover,
.folder-action-bar > .button:hover {
  border-color: var(--navy-light);
  background: var(--navy-light);
  color: #fff;
}
.view-switcher {
  display: inline-flex;
  align-items: center;
  height: 40px;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--navy);
  border-radius: 6px;
  background: var(--navy);
}
.view-switcher-button {
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: rgba(255, 255, 255, 0.78);
  cursor: pointer;
  line-height: 1;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.view-switcher-button:hover,
.view-switcher-button.is-active {
  border-color: rgba(255, 255, 255, 0.42);
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}

/* File management actions and public share view. */
.file-actions { flex-wrap: wrap; }
.file-actions .context-menu-wrapper { display: inline-flex; }
.file-actions .menu-trigger { width: 32px; height: 32px; }
.file-info-list { display: grid; gap: 10px; margin: 0; }
.file-info-list > div { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.file-info-list > div:last-child { border-bottom: 0; }
.file-info-list dt { color: var(--muted); }
.file-info-list dd { margin: 0; color: var(--navy); overflow-wrap: anywhere; }
.share-list { display: grid; gap: 10px; max-height: 290px; overflow-y: auto; margin-top: 18px; }
.share-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px; border: 1px solid var(--border); border-radius: 8px; background: #fbfcfd; }
.share-row-main { min-width: 0; display: grid; gap: 2px; }
.share-row-main a { overflow: hidden; color: var(--navy); text-overflow: ellipsis; white-space: nowrap; direction: ltr; text-align: right; }
.share-row-actions { display: flex; flex-wrap: wrap; gap: 6px; flex: 0 0 auto; }
.share-page-section { display: grid; min-height: 62vh; place-items: center; }
.share-page .site-footer { display: none; }
.share-card { width: min(100%, 480px); padding: 34px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); text-align: center; }
.share-card .file-icon { width: 52px; height: 52px; margin: 0 auto 18px; }
.share-card h1 { margin-bottom: 8px; font-size: clamp(1.5rem, 4vw, 2.2rem); overflow-wrap: anywhere; }
.share-file-meta { margin-bottom: 24px; color: var(--muted); }

@media (max-width: 760px) {
  .share-row { align-items: stretch; flex-direction: column; }
  .share-row-actions { justify-content: flex-start; }
  .share-card { padding: 26px 20px; }
}
