/* ═══════════════════════════════════════════════════════════
   Kavoshgar Apps — shared styles
   شامل: دکمه apps در header، grid پاپ‌آپ، دیالوگ launcher،
          صفحه All Apps
   ═══════════════════════════════════════════════════════════ */

/* ── دکمه Apps در header ─────────────────────────────────── */
.kv-apps-btn {
  width: 40px; height: 40px;
  border: none; background: transparent;
  border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary, #70757a);
  font-size: 20px;
  transition: background .15s;
  flex-shrink: 0;
}
.kv-apps-btn:hover  { background: #e8eaed; }
.kv-apps-btn:focus-visible {
  outline: 2px solid var(--primary, #4285f4);
  outline-offset: 2px;
}

/* ── Grid پاپ‌آپ ─────────────────────────────────────────── */
.kv-grid-panel {
  position: absolute;
  width: 280px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,.18), 0 2px 8px rgba(0,0,0,.1);
  z-index: 900;
  direction: rtl;
  opacity: 0;
  transform: scale(.95) translateY(-8px);
  transform-origin: top right;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
  overflow: hidden;
}
.kv-grid-panel.kv-grid-visible {
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: auto;
}
.kv-grid-inner { padding: 16px 12px 8px; }

/* شبکه اپ‌ها */
.kv-grid-apps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}
.kv-grid-item {
  display: flex; flex-direction: column;
  align-items: center; gap: 6px;
  padding: 12px 8px;
  background: none; border: none;
  border-radius: 12px; cursor: pointer;
  transition: background .15s;
}
.kv-grid-item:hover { background: #f1f3f4; }
.kv-grid-item:focus-visible {
  outline: 2px solid var(--primary, #4285f4);
  outline-offset: 1px;
}
.kv-grid-item-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  transition: transform .15s;
}
.kv-grid-item:hover .kv-grid-item-icon { transform: scale(1.08); }
.kv-grid-item-name {
  font-size: 11px;
  color: #3c4043;
  font-family: 'Vazirmatn', sans-serif;
  text-align: center;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 72px;
}

/* فوتر گرید */
.kv-grid-footer {
  border-top: 1px solid #e8eaed;
  margin-top: 8px;
  padding-top: 8px;
  text-align: center;
}
.kv-grid-all-link {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px;
  color: var(--primary, #4285f4);
  text-decoration: none;
  padding: 8px 16px;
  border-radius: 20px;
  transition: background .15s;
  font-family: 'Vazirmatn', sans-serif;
}
.kv-grid-all-link:hover { background: #e8f0fe; }

/* ── App Dialog (launcher) ───────────────────────────────── */
.kv-apps-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity .22s ease;
  padding: 16px;
}
.kv-apps-overlay.kv-apps-visible {
  opacity: 1; pointer-events: auto;
}
.kv-apps-dialog {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(0,0,0,.2);
  width: 100%; max-width: 680px;
  height: min(80vh, 560px);
  display: flex; flex-direction: column;
  overflow: hidden;
  transform: scale(.96) translateY(12px);
  transition: transform .22s ease;
  direction: rtl;
}
.kv-apps-overlay.kv-apps-visible .kv-apps-dialog {
  transform: scale(1) translateY(0);
}
body.kv-apps-open { overflow: hidden; }

/* هدر دیالوگ */
.kv-apps-dialog-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid #e8eaed;
  flex-shrink: 0;
}
.kv-apps-dialog-title {
  font-size: 16px; font-weight: 600;
  color: #202124;
  font-family: 'Vazirmatn', sans-serif;
}
.kv-apps-dialog-actions { display: flex; gap: 4px; }
.kv-apps-icon-btn {
  width: 36px; height: 36px;
  border: none; background: transparent;
  border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: #70757a; font-size: 16px;
  transition: background .15s;
}
.kv-apps-icon-btn:hover { background: #f1f3f4; }
.kv-apps-icon-btn:focus-visible {
  outline: 2px solid var(--primary, #4285f4);
}

/* بدنه دیالوگ — iframe */
.kv-apps-dialog-body { flex: 1; overflow: hidden; position: relative; }
.kv-app-frame {
  width: 100%; height: 100%;
  border: none;
  display: block;
}

/* ── صفحه All Apps (/Apps) ───────────────────────────────── */
.kv-all-apps-page {
  font-family: 'Vazirmatn', 'Segoe UI', sans-serif;
  direction: rtl;
  min-height: 100vh;
  background: #f8f9fa;
  color: #202124;
}

/* هدر صفحه */
.kv-all-header {
  background: #fff;
  border-bottom: 1px solid #e8eaed;
  padding: 16px 24px;
  display: flex; align-items: center; gap: 16px;
  position: sticky; top: 0; z-index: 10;
}
.kv-all-header-logo {
  font-size: 20px; font-weight: 700;
  color: #4285f4; text-decoration: none;
  white-space: nowrap;
}
.kv-all-header-title {
  font-size: 18px; font-weight: 600; color: #202124;
}
.kv-all-search-wrap {
  position: relative; flex: 1; max-width: 360px;
}
.kv-all-search-input {
  width: 100%;
  padding: 10px 40px 10px 16px;
  border: 1px solid #e8eaed;
  border-radius: 24px;
  font-size: 14px;
  font-family: inherit;
  background: #f1f3f4;
  color: #202124;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  direction: rtl;
}
.kv-all-search-input:focus {
  border-color: #4285f4;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(66,133,244,.15);
}
.kv-all-search-icon {
  position: absolute; right: 12px; top: 50%;
  transform: translateY(-50%);
  color: #70757a; font-size: 15px;
  pointer-events: none;
}

/* محتوای اصلی */
.kv-all-content {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 16px;
}

/* فیلتر دسته‌بندی */
.kv-category-bar {
  display: flex; gap: 8px; flex-wrap: wrap;
  margin-bottom: 24px;
}
.kv-cat-btn {
  padding: 7px 18px;
  border: 1px solid #e8eaed;
  border-radius: 20px;
  background: #fff;
  color: #3c4043;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
  white-space: nowrap;
}
.kv-cat-btn:hover { background: #f1f3f4; }
.kv-cat-btn.active {
  background: #e8f0fe;
  border-color: #4285f4;
  color: #1a73e8;
  font-weight: 600;
}

/* عنوان بخش */
.kv-section-title {
  font-size: 13px; font-weight: 600;
  color: #70757a; margin-bottom: 12px;
  letter-spacing: .3px;
}

/* گرید اپ‌های صفحه all */
.kv-apps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 32px;
}
.kv-app-card {
  background: #fff;
  border: 1px solid #e8eaed;
  border-radius: 16px;
  padding: 20px 12px 16px;
  display: flex; flex-direction: column;
  align-items: center; gap: 10px;
  cursor: pointer;
  transition: box-shadow .18s, transform .18s, border-color .18s;
  position: relative;
  text-align: center;
  border: none;
  background: #fff;
}
.kv-app-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,.1);
  transform: translateY(-2px);
}
.kv-app-card:focus-visible {
  outline: 2px solid #4285f4;
  outline-offset: 2px;
}
.kv-app-card-icon {
  width: 56px; height: 56px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px;
}
.kv-app-card-name {
  font-size: 13px; font-weight: 600;
  color: #202124; line-height: 1.3;
}
.kv-app-card-desc {
  font-size: 11px; color: #70757a; line-height: 1.4;
}

/* دکمه علاقه‌مندی روی کارت */
.kv-fav-btn {
  position: absolute; top: 8px; left: 8px;
  width: 28px; height: 28px;
  border: none; background: transparent;
  border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: #bdc1c6; font-size: 14px;
  transition: color .15s, background .15s;
  opacity: 0;
}
.kv-app-card:hover .kv-fav-btn,
.kv-fav-btn.active { opacity: 1; }
.kv-fav-btn.active { color: #fbbc05; }
.kv-fav-btn:hover { background: #f1f3f4; color: #fbbc05; }

/* empty state */
.kv-apps-empty {
  text-align: center; padding: 48px 24px;
  color: #70757a; font-size: 15px;
}
.kv-apps-empty i {
  font-size: 40px; margin-bottom: 12px;
  display: block; opacity: .4;
}

/* ── موبایل ──────────────────────────────────────────────── */
@media (max-width: 600px) {
  .kv-grid-panel { width: calc(100vw - 16px); left: 8px !important; }
  .kv-apps-dialog {
    height: 90vh; max-width: 100%;
    border-radius: 20px 20px 0 0;
  }
  .kv-apps-overlay { align-items: flex-end; padding: 0; }
  .kv-all-header { flex-wrap: wrap; gap: 10px; }
  .kv-all-search-wrap { max-width: 100%; flex: 0 0 100%; order: 3; }
  .kv-apps-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
}
