/* ========== BASE ========== */
* {
  box-sizing: border-box;
}

html, body {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  padding: 0;
  background: #000;
  color: #0f0;
  font-family: Tahoma, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden; /* جلوگیری از اسکرول افقی */
}

/* Matrix canvas – covers entire background */
#q, #matrix-canvas {
  position: fixed;
  inset: 0;
  z-index: -1;
}

/* ========== SCROLLBARS ========== */
.file-list::-webkit-scrollbar,
.result-list::-webkit-scrollbar {
  width: 10px;
}
.file-list::-webkit-scrollbar-track,
.result-list::-webkit-scrollbar-track {
  background: #000;
  border-radius: 8px;
}
.file-list::-webkit-scrollbar-thumb,
.result-list::-webkit-scrollbar-thumb {
  background: #0f0;
  border-radius: 8px;
}
.file-list::-webkit-scrollbar-thumb:hover,
.result-list::-webkit-scrollbar-thumb:hover {
  background: #0a0;
}
.file-list, .result-list {
  scrollbar-width: thin;
  scrollbar-color: #0f0 #000;
}

/* ========== TOAST NOTIFICATION ========== */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  background: #0f0;
  color: #000;
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: bold;
  opacity: 0;
  transition: opacity 0.3s ease-in-out;
  z-index: 1000;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: calc(100vw - 40px);
  box-sizing: border-box;
}
.toast.show {
  opacity: 1;
}

/* ========== FILE LIST PAGES (configs, servers, software) ========== */
.file-box {
  background: rgba(0,0,0,0.85);
  padding: 25px;
  border-radius: 15px;
  box-shadow: 0 0 20px #0f0;
  width: 90%;
  max-width: 420px;
  margin: 20px auto; /* مرکز‌چین */
}
.file-box h3 {
  text-align: center;
  margin-bottom: 15px;
}
.file-list {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid #0f0;
  border-radius: 8px;
  text-align: center;
}
.file-list li {
  padding: 10px;
  border-bottom: 1px solid #0f0;
  cursor: pointer;
  transition: 0.2s;
  user-select: none;
}
.file-list li:last-child {
  border-bottom: none;
}
.file-list li:hover {
  background: #0f0;
  color: #000;
}

/* ========== UPLOAD PAGE ========== */
.upload-form {
  background: rgba(0,0,0,0.85);
  padding: 30px;
  border-radius: 15px;
  box-shadow: 0 0 20px #0f0;
  width: 90%;
  max-width: 420px;
  margin: 20px auto;
  text-align: center;
}
.upload-form input {
  width: 100%;
  height: 44px;
  box-sizing: border-box;
  padding: 10px;
  margin: 8px 0;
  background: #000;
  border: 1px solid #0f0;
  color: #0f0;
  border-radius: 8px;
  font-family: Tahoma, sans-serif;
}
.upload-form input[type=file]::file-selector-button {
  background: #000;
  color: #0f0;
  border: 2px solid #0f0;
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  font-family: Tahoma, sans-serif;
  transition: 0.3s;
}
.upload-form input[type=file]::file-selector-button:hover {
  background: #0f0;
  color: #000;
}
.upload-form input[type=button],
.upload-form input[type=submit] {
  font-weight: bold;
  cursor: pointer;
  border: 2px solid #0f0;
  transition: 0.3s;
}
.upload-form input[type=button]:hover,
.upload-form input[type=submit]:hover {
  background: #0f0;
  color: #000;
}
.progress-container {
  width: 100%;
  height: 18px;
  border: 1px solid #0f0;
  border-radius: 6px;
  margin-top: 10px;
}
.progress-bar {
  height: 100%;
  width: 0%;
  background: #0f0;
  color: #000;
  font-weight: bold;
  font-size: 12px;
  border-radius: 6px;
  text-align: center;
  line-height: 18px;
}
.copy-link {
  cursor: pointer;
  text-decoration: underline;
  color: #0f0;
}
.copy-link:hover {
  color: #fff;
}
#blockTimer {
  color: red;
  font-weight: bold;
  display: none;
}

/* ========== REGISTRATION & CHANGE PASSWORD PAGES ========== */
.form-box {
  background: rgba(0,0,0,0.85);
  padding: 30px;
  border-radius: 15px;
  box-shadow: 0 0 20px #0f0;
  width: 90%;
  max-width: 420px;
  margin: 20px auto;
  text-align: center;
}
.form-box h2, .form-box h3 {
  margin-bottom: 20px;
}
input[type=text], input[type=password] {
  width: 100%;
  padding: 12px;
  margin: 8px 0;
  background: #000;
  border: 1px solid #0f0;
  color: #0f0;
  border-radius: 8px;
  font-size: 16px;
  box-sizing: border-box;
  text-align: left;
}
.password-container {
  position: relative;
  width: 100%;
}
.password-container input {
  width: 100%;
  padding-left: 40px;
  height: 44px;
  line-height: 44px;
}
.password-container .toggle-password {
  position: absolute;
  top: 50%;
  left: 10px;
  transform: translateY(-50%);
  cursor: pointer;
  color: #0f0;
  font-size: 20px;
  user-select: none;
}
button, input[type=submit], input[type=button] {
  width: 100%;
  padding: 12px;
  margin: 4px 0;
  border: 2px solid #0f0;
  background: #000;
  color: #0f0;
  border-radius: 8px;
  font-weight: bold;
  cursor: pointer;
  transition: 0.3s;
}
button:hover, input[type=submit]:hover, input[type=button]:hover {
  background: #0f0;
  color: #000;
}
input:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.timer {
  font-weight: bold;
  color: red;
  margin-bottom: 8px;
}
.error {
  color: red;
  font-weight: bold;
}
.success {
  color: lime;
  font-weight: bold;
}
.success-details {
  margin-top: 20px;
  text-align: right;
  direction: rtl;
  font-size: 16px;
  background: rgba(0,255,0,0.1);
  padding: 15px;
  border-radius: 10px;
  border: 1px solid #0f0;
}
.success-details p {
  margin: 10px 0;
}
.success-details a {
  color: #0f0;
  text-decoration: underline;
}
p.message {
  font-weight: bold;
  margin-bottom: 10px;
}

/* ========== LIVE STREAM PAGE ========== */
#streamWrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}
#chatBox {
  width: 90%;
  max-width: 1440px;
  background: rgba(0,0,0,0.8);
  border: 2px solid #0f0;
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 30px #0f0;
  margin: 20px auto;
}
#videoWrapper {
  position: relative;
  width: 100%;
  margin-bottom: 10px;
}
#video {
  width: 100%;
  height: auto;
  border: none;
  border-radius: 8px;
  box-shadow: none;
}
#offlineMsg {
  position: absolute;
  inset: 0;
  display: none;
  justify-content: center;
  align-items: center;
  color: #0f0;
  background: rgba(0,0,0,0.6);
  font-size: 2rem;
  border-radius: 8px;
  text-align: center;
}
#chatMessages {
  height: 180px;
  overflow-y: auto;
  font-size: 14px;
  margin-bottom: 8px;
}
#chatMessages div {
  margin-bottom: 6px;
}
#chatInput {
  width: 100%;
  box-sizing: border-box;
  padding: 8px;
  background: #000;
  color: #0f0;
  border: 1px solid #0f0;
  outline: none;
}

/* ========== SEARCH PAGE ========== */
.main-box {
  background: rgba(0,0,0,0.85);
  padding: 30px;
  border-radius: 15px;
  box-shadow: 0 0 20px #0f0;
  width: 95%;
  max-width: 1300px;
  margin: 20px auto;
  border: 1px solid #0f0;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}
.main-box h1 {
  font-size: 2rem;
  margin: 0 0 20px;
  border-bottom: 1px dashed #0f0;
  padding-bottom: 10px;
  text-align: center;
  color: #0f0;
}
.stats-box {
  text-align: right;
  margin: 0 -30px 20px -30px;
  padding: 8px 30px;
  background: rgba(0,20,0,0.6);
  font-size: 1rem;
  border: none;
  border-bottom: 1px solid #0f0;
  border-top: 1px solid #0f0;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 15px;
}
.stats-item {
  color: #0f0;
}
.stats-item strong {
  color: #0f0;
  font-size: 1.2rem;
  margin-left: 5px;
}
.search-box {
  margin-bottom: 25px;
}
.search-form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}
.search-input {
  height: 48px;
  box-sizing: border-box;
  padding: 10px 15px;
  background: #000;
  border: 1px solid #0f0;
  color: #0f0;
  border-radius: 8px;
  font-family: Tahoma, sans-serif;
  font-size: 1rem;
  flex: 3 1 300px;
  min-width: 250px;
}
.search-input:focus {
  outline: none;
  box-shadow: 0 0 8px #0f0;
}
.search-btn, .reset-btn {
  height: 48px;
  border: 2px solid #0f0;
  font-weight: bold;
  cursor: pointer;
  transition: 0.3s;
  background: #0f0;
  color: #000;
  border-radius: 8px;
  padding: 0 25px;
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-family: Tahoma, sans-serif;
  white-space: nowrap;
}
.search-btn:hover, .reset-btn:hover {
  background: #000;
  color: #0f0;
}
.reset-btn {
  background: transparent;
  color: #0f0;
}
.result-count {
  text-align: right;
  margin: 15px -30px 20px -30px;
  padding: 8px 30px;
  background: rgba(0,20,0,0.6);
  font-size: 1rem;
  border: none;
  border-bottom: 1px solid #0f0;
  border-top: 1px solid #0f0;
}
.result-count strong {
  color: #0f0;
}
.result-list {
  list-style: none;
  padding: 0;
  margin: 0 -30px;
  background: rgba(0,0,0,0.5);
}
.result-list li {
  padding: 18px 30px;
  border-bottom: 1px solid #0f0;
  transition: 0.2s;
}
.result-list li:last-child {
  border-bottom: none;
}
.result-list li:hover {
  background: rgba(0, 30, 0, 0.7);
}
.result-title {
  font-size: 1.2rem;
  color: #0f0;
  text-decoration: none;
  display: inline-block;
  margin-bottom: 6px;
  font-weight: bold;
  text-align: right;
  width: 100%;
  cursor: pointer;
}
.result-title:hover {
  text-decoration: underline;
}
.result-url {
  color: #0f0;
  font-size: 0.8rem;
  direction: ltr;
  text-align: left;
  margin: 5px 0;
  opacity: 0.9;
  word-break: break-all;
  font-family: 'Courier New', monospace;
}
.result-description {
  color: #0a0;
  font-size: 0.9rem;
  line-height: 1.5;
  opacity: 0.9;
  text-align: right;
}
.pagination {
  margin: 20px 0 10px;
  text-align: center;
  direction: ltr;
}
.pagination a, .pagination span {
  display: inline-block;
  padding: 8px 14px;
  margin: 0 4px 8px;
  border: 2px solid #0f0;
  border-radius: 8px;
  text-decoration: none;
  color: #0f0;
  background: transparent;
  font-weight: bold;
  transition: 0.2s;
}
.pagination span.current {
  background: #0f0;
  color: #000;
  border-color: #0f0;
}
.pagination a:hover {
  background: #0f0;
  color: #000;
  box-shadow: 0 0 8px #0f0;
}
.empty-message, .error-box {
  text-align: center;
  padding: 40px 20px;
  border: 1px dashed #0f0;
  border-radius: 8px;
  margin: 20px 0;
  background: rgba(0,0,0,0.3);
  color: #0f0;
}
.error-box {
  border-color: #f00;
  color: #f66;
}

/* ========== RESPONSIVE MEDIA QUERIES ========== */
@media (max-width: 700px) {
  .main-box { padding: 20px; }
  .stats-box, .result-count, .result-list {
    margin-left: -20px;
    margin-right: -20px;
    padding-left: 20px;
    padding-right: 20px;
  }
  .result-list { margin-left: -20px; margin-right: -20px; }
  .result-list li { padding: 15px 20px; }
  .result-title { font-size: 1rem; }
  .result-url { font-size: 0.7rem; }
  .result-description { font-size: 0.8rem; }
  .pagination a, .pagination span { padding: 6px 10px; font-size: 0.9rem; }
}

@media (max-width: 600px) {
  body {
    padding: 0;
  }
  .file-box, .upload-form, .form-box, .main-box {
    padding: 20px;
    width: 95%;
  }
  #chatBox {
    width: 95%;
    padding: 10px;
  }

  /* در صفحه جستجو، حاشیه‌های منفی را حذف می‌کنیم تا سرریز نشود */
  .stats-box, .result-count, .result-list {
    margin-left: 0;
    margin-right: 0;
    padding-left: 0;
    padding-right: 0;
    width: 100%;
  }
  .stats-box {
    padding: 8px 0;
  }
  .result-count {
    padding: 8px 0;
  }
  .result-list li {
    padding: 15px 0;
  }
}

@media (max-width: 500px) {
  .file-box, .upload-form, .form-box {
    padding: 18px;
  }
  .main-box {
    padding: 15px;
  }
  .main-box h1 {
    font-size: 1.5rem;
  }
}

@media (max-width: 400px) {
  .file-box, .upload-form, .form-box, .main-box {
    padding: 12px;
  }
  .search-input, .search-btn, .reset-btn {
    height: 44px;
    font-size: 0.95rem;
    width: 100% !important; /* تمام عرض */
  }
  .pagination a, .pagination span {
    padding: 5px 8px;
    margin: 0 2px 5px;
    font-size: 0.8rem;
  }
  .empty-message, .error-box {
    padding: 20px 15px;
    font-size: 0.9rem;
  }
}

@media (min-width: 900px) {
  .file-box { width: 840px; padding: 50px; }
  .file-list { max-height: 600px; }
}

* {
  -webkit-tap-highlight-color: transparent;
}
/* Centered pages (like change password, upload, etc.) */
body.centered {
  justify-content: center;
  min-height: 100vh; /* fallback برای مرورگرهای قدیمی */
  min-height: 100dvh;
}