:root {
  --bg: #0f1115;
  --bg-elevated: #171a21;
  --bg-hover: #1f232c;
  --border: #262b35;
  --text: #e8eaed;
  --text-dim: #9aa0ac;
  --accent: #6c8cff;
  --accent-hover: #8aa3ff;
  --danger: #ff6b6b;
  --success: #4ade80;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Vazirmatn', Tahoma, 'Segoe UI', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  direction: rtl;
  min-height: 100vh;
}

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

/* متن‌های انگلیسی/عددی داخل این المان‌ها بر اساس محتوا خودکار جهت می‌گیرند */
input[type=text], input[type=search], textarea,
.item-name a, table.file-table td, .breadcrumb a {
  unicode-bidi: plaintext;
}

.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.auth-card h1 { font-size: 22px; margin-bottom: 4px; }
.auth-card p.subtitle { color: var(--text-dim); margin-top: 0; margin-bottom: 24px; font-size: 14px; }

input, select, textarea, button {
  font-family: inherit;
  font-size: 14px;
}

input[type=text], input[type=password], input[type=search], select {
  width: 100%;
  padding: 11px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  margin-bottom: 14px;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
  padding: 10px 18px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #0b0d12;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.btn:hover { background: var(--accent-hover); }
.btn.secondary { background: var(--bg-hover); color: var(--text); border: 1px solid var(--border); }
.btn.secondary:hover { background: var(--border); }
.btn.danger { background: var(--danger); color: #1a0000; }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.error-box { background: rgba(255,107,107,.12); color: var(--danger); padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 13px; }

/* App shell */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-wrap: wrap;
  gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; }
.brand .logo { font-size: 22px; }
.header-right { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.badge {
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.badge.admin { color: #ffb84d; border-color: #ffb84d55; }
.badge.editor { color: #6c8cff; border-color: #6c8cff55; }
.badge.viewer { color: #9aa0ac; }

.search-box { position: relative; }
.search-box input { margin-bottom: 0; width: 220px; }

.container { max-width: 1100px; margin: 0 auto; padding: 24px; }

.storage-bar {
  display: flex; gap: 24px; color: var(--text-dim); font-size: 13px; margin-bottom: 18px; flex-wrap: wrap;
}

.breadcrumb { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; font-size: 14px; color: var(--text-dim); }
.breadcrumb a { color: var(--text-dim); }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb .sep { color: var(--border); }

.toolbar { display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }

.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 18px;
  text-align: center;
  color: var(--text-dim);
  margin-bottom: 20px;
  transition: border-color .15s, background .15s;
  font-size: 13px;
}
.dropzone.dragover { border-color: var(--accent); background: rgba(108,140,255,.06); color: var(--accent); }

table.file-table { width: 100%; border-collapse: collapse; }
table.file-table th {
  text-align: right; font-size: 12px; color: var(--text-dim); font-weight: 500;
  padding: 8px 10px; border-bottom: 1px solid var(--border);
}
table.file-table td { padding: 10px; border-bottom: 1px solid var(--border); font-size: 14px; vertical-align: middle; }
table.file-table tr:hover td { background: var(--bg-hover); }
.item-name { display: flex; align-items: center; gap: 10px; }
.item-name .icon { font-size: 18px; }
.item-name a { color: var(--text); font-weight: 500; }
.item-name a:hover { color: var(--accent); }
.item-actions { display: flex; gap: 6px; justify-content: flex-end; }
.icon-btn {
  background: none; border: none; cursor: pointer; color: var(--text-dim);
  font-size: 15px; padding: 4px 6px; border-radius: 6px;
}
.icon-btn:hover { background: var(--border); color: var(--text); }

.empty-state { text-align: center; padding: 60px 20px; color: var(--text-dim); }
.empty-state .big-icon { font-size: 48px; margin-bottom: 10px; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.55);
  display: none; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 26px; width: 100%; max-width: 420px;
}
.modal h3 { margin-top: 0; }
.modal .modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--bg-elevated); border: 1px solid var(--border); padding: 12px 20px;
  border-radius: 8px; z-index: 200; font-size: 14px; display: none; max-width: 90vw;
}
.toast.show { display: block; }
.toast.success { border-color: var(--success); color: var(--success); }
.toast.error { border-color: var(--danger); color: var(--danger); }

/* Editor page */
.editor-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; flex-wrap: wrap; gap: 10px; }
textarea.text-editor {
  width: 100%; min-height: 65vh; background: var(--bg-elevated); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 18px;
  font-family: 'Cascadia Code', 'Consolas', monospace; font-size: 14px; line-height: 1.7; resize: vertical;
}

/* Share page */
.share-preview { text-align: center; margin: 24px 0; }
.share-preview img { max-width: 100%; border-radius: var(--radius); }
.share-preview video, .share-preview audio { width: 100%; max-width: 600px; }

/* Users admin */
.card { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; margin-bottom: 24px; }
.card h2 { margin-top: 0; font-size: 17px; }
.role-select { width: auto; padding: 6px 10px; margin-bottom: 0; }
.activity-list { list-style: none; padding: 0; margin: 0; max-height: 340px; overflow-y: auto; }
.activity-list li { padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; color: var(--text-dim); display: flex; justify-content: space-between; gap: 10px; }
.activity-list li b { color: var(--text); }

@media (max-width: 640px) {
  .app-header { padding: 12px 14px; }
  .search-box input { width: 140px; }
  table.file-table th:nth-child(3), table.file-table td:nth-child(3) { display: none; }
}
