:root {
  --bg-body: #0f172a;
  --bg-card: #1e293b;
  --text-main: #f1f5f9;
  --text-sub: #94a3b8;
  --primary: #60a5fa;
  --primary-bg: #1e3a8a;
  --border: #334155;
  --radius: 12px;
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.5);
}
[data-theme="light"] {
  --bg-body: #f8fafc;
  --bg-card: #ffffff;
  --text-main: #0f172a;
  --text-sub: #64748b;
  --primary: #3b82f6;
  --primary-bg: #eff6ff;
  --border: #e2e8f0;
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
}
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}
body {
  background-color: var(--bg-body);
  color: var(--text-main);
  font-family: "Vazirmatn", "Tahoma", "Segoe UI", sans-serif;
  transition:
    background-color 0.3s,
    color 0.3s;
  padding-bottom: 60px;
  line-height: 1.6;
}
.container {
  max-width: 1024px;
  margin: 0 auto;
  padding: 0 1rem;
}
/* Main Navigation Menu */
.main-nav {
  position: sticky;
  top: 0;
  z-index: 101;
  background-color: var(--bg-body);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0.25rem 0;
}
.nav-items {
  display: flex;
  overflow-x: auto;
  gap: 0.25rem;
  scrollbar-width: none;
  padding: 0.15rem 0;
  align-items: center;
}
.nav-items::-webkit-scrollbar {
  display: none;
}
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 0.35rem 0.75rem;
  background: transparent;
  border: none;
  color: var(--text-sub);
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
  min-width: 60px;
  text-decoration: none;
}
.nav-item svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}
.nav-item span {
  font-size: 0.65rem;
  font-weight: 500;
  white-space: nowrap;
}
.nav-item.active {
  color: var(--primary);
}
.nav-item.active svg {
  fill: var(--primary);
}
.nav-item:active {
  transform: scale(0.95);
}
/* Nav Action Buttons */
.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-right: auto;
  padding-right: 0.35rem;
  flex-shrink: 0;
}
.nav-date {
  font-size: 0.62rem;
  color: var(--text-sub);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.25rem 0.3rem;
  line-height: 1.15;
  min-width: 58px;
  max-width: 58px;
  text-align: center;
}
.nav-date .date-line {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav-action-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-sub);
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}
.nav-action-btn:active {
  transform: scale(0.92);
  background: var(--primary-bg);
  color: var(--primary);
}
.nav-action-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}
/* Header */
header {
  position: sticky;
  top: 63px;
  z-index: 100;
  background-color: var(--bg-body);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
  display: none;
}
#tab-links.active ~ header,
body:has(#tab-links.active) header {
  display: block;
}
.header-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.search-box {
  flex: 1;
  padding: 0.55rem 0.85rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.85rem;
  transition: all 0.2s;
}
.search-box:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-bg);
}
.header-actions {
  display: flex;
  gap: 0.35rem;
  flex-shrink: 0;
}
.icon-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-main);
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}
.icon-btn:active {
  transform: scale(0.92);
  background: var(--primary-bg);
  color: var(--primary);
}
.icon-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}
/* Tab Content */
.tab-content {
  display: none;
}
.tab-content.active {
  display: block;
}
/* Favorites Quick Access */
#favorites-section {
  margin: 1rem 0;
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
}
.favorites-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.85rem;
  cursor: pointer;
  background: var(--bg-card);
  transition: background 0.2s;
}
.favorites-header:active {
  background: var(--primary-bg);
}
.section-title {
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: bold;
  font-size: 0.85rem;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
}
.section-title svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
  flex-shrink: 0;
}
.fav-badge {
  background: var(--primary);
  color: #fff;
  font-family: "Vazirmatn", sans-serif;
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 4px;
  flex-shrink: 0;
}
.accordion-arrow {
  width: 18px;
  height: 18px;
  fill: var(--text-sub);
  transition: transform 0.3s ease;
}
#favorites-section.collapsed .accordion-arrow {
  transform: rotate(-90deg);
}
#favorites-section.collapsed #favorites-list {
  display: none;
}
#favorites-list {
  padding: 0.4rem;
}
/* Tabs - Horizontal Scroll */
.tabs {
  display: flex;
  overflow-x: auto;
  gap: 0.4rem;
  padding: 0.5rem 0;
  margin: 0.75rem 0;
  scrollbar-width: none;
  position: sticky;
  top: 114px;
  z-index: 90;
  background-color: var(--bg-body);
  padding-top: 0.35rem;
  padding-bottom: 0.25rem;
  white-space: nowrap;
}
.tabs::-webkit-scrollbar {
  display: none;
}
.tab-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-sub);
  padding: 0.4rem 0.85rem;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  font-family: "Vazirmatn";
  transition: all 0.2s;
  flex-shrink: 0;
}
.tab-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
/* Grid & Cards */
.grid {
  display: grid;
  gap: 0.65rem;
  transition: all 0.3s ease;
}
.category-group-title {
  grid-column: 1 / -1;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary);
  margin: 1.25rem 0 0.4rem 0;
  padding-bottom: 0.2rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  scroll-margin-top: 100px;
  padding-top: 15px;
}
.category-group-title:first-child {
  margin-top: 0;
}
.category-group-title::before {
  content: "";
  display: block;
  width: 4px;
  height: 16px;
  background: var(--primary);
  border-radius: 2px;
}
.link-card {
  display: flex;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text-main);
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}
.link-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--primary);
}
.link-card:active {
  transform: scale(0.98);
}
.link-logo {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: 0.65rem;
  flex-shrink: 0;
  border: 1px solid var(--border);
  padding: 4px;
  overflow: hidden;
}
.link-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
}
.link-logo svg {
  width: 20px;
  height: 20px;
  fill: var(--text-sub);
}
.link-info {
  flex: 1;
  overflow: hidden;
}
.link-title {
  font-weight: 500;
  font-size: 0.875rem;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.link-desc {
  font-size: 0.7rem;
  color: var(--text-sub);
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
.fav-btn {
  background: transparent;
  border: none;
  color: var(--text-sub);
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
}
.fav-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}
.fav-btn.is-fav {
  color: #f59e0b;
}
.fav-btn.is-fav svg {
  fill: #f59e0b;
}
.list-mode .link-card {
  padding: 0.65rem;
}
.tile-mode {
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}
@media (min-width: 768px) {
  .tile-mode {
    grid-template-columns: repeat(6, 1fr);
  }
}
.tile-mode .link-card {
  flex-direction: column;
  text-align: center;
  padding: 0.85rem 0.4rem;
  aspect-ratio: 1;
  justify-content: center;
  align-items: center;
}
.tile-mode .link-logo {
  margin: 0 0 0.4rem 0;
  width: 52px;
  height: 52px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--border);
  padding: 5px;
}
.tile-mode .link-logo img {
  width: 100%;
  height: 100%;
  border-radius: 8px;
}
.tile-mode .link-logo svg {
  width: 24px;
  height: 24px;
  fill: var(--primary);
}
.tile-mode .link-info {
  width: 100%;
}
.tile-mode .link-desc {
  display: none;
}
.tile-mode .link-title {
  font-size: 0.875rem;
  text-align: center;
  white-space: normal;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.tile-mode .fav-btn {
  position: absolute;
  top: 3px;
  left: 3px;
  padding: 2px;
  background: var(--bg-card);
  border-radius: 50%;
  width: 24px;
  height: 24px;
  box-shadow: 0 2px 4px rgb(0 0 0 / 0.1);
}
/* Emergency Section */
.emergency-section {
  margin-top: 0.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}
.emergency-title {
  text-align: center;
  font-weight: 800;
  color: var(--text-sub);
  margin-bottom: 0.85rem;
  font-size: 0.8rem;
}
.emergency-grid {
  display: grid;
  gap: 0.5rem;
  transition: all 0.3s ease;
}
/* List Mode */
.emergency-grid.list-mode {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.65rem;
}
.emergency-grid.list-mode .emergency-card {
  background: var(--bg-body);
  color: var(--text-main);
  padding: 0.85rem 0.5rem;
  border-radius: 10px;
  text-align: center;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.85rem;
  border: 1px solid var(--border);
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}
.emergency-grid.list-mode .emergency-card .number {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--primary);
  display: block;
}
.emergency-grid.list-mode .emergency-card .label {
  font-size: 0.75rem;
  color: var(--text-sub);
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}
/* Compact Mode */
.emergency-grid.compact-mode {
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 0.4rem;
}
.emergency-grid.compact-mode .emergency-card {
  background: var(--bg-body);
  color: var(--text-main);
  padding: 0.5rem 0.3rem;
  border-radius: 8px;
  text-align: center;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.75rem;
  border: 1px solid var(--border);
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
}
.emergency-grid.compact-mode .emergency-card .number {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--primary);
  display: block;
}
.emergency-grid.compact-mode .emergency-card .label {
  font-size: 0.65rem;
  color: var(--text-sub);
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}
.emergency-card:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}
.emergency-card:hover .number,
.emergency-card:hover .label {
  color: white;
}
.emergency-card.danger:hover {
  background: #ef4444;
  border-color: #ef4444;
}
html {
  scroll-behavior: smooth;
}
/* Numbers Header & Search */
.numbers-header {
  display: none;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0;
  position: sticky;
  top: 63px;
  z-index: 100;
  background-color: var(--bg-body);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.numbers-search-box {
  flex: 1;
  padding: 0.55rem 0.85rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.85rem;
  transition: all 0.2s;
}
.numbers-search-box:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-bg);
}
.numbers-actions {
  display: flex;
  gap: 0.35rem;
  flex-shrink: 0;
}
#tab-numbers.active .numbers-header {
  display: flex;
}
/* Channels Header & Search */
.channels-header {
  display: none;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0;
  position: sticky;
  top: 63px;
  z-index: 100;
  background-color: var(--bg-body);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.channels-search-box {
  flex: 1;
  padding: 0.55rem 0.85rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.85rem;
  transition: all 0.2s;
}
.channels-search-box:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-bg);
}
.channels-actions {
  display: flex;
  gap: 0.35rem;
  flex-shrink: 0;
}
#tab-channels.active .channels-header {
  display: flex;
}
#tab-channels.active #channelAppTabs {
  display: flex;
}
.downloads-section {
  margin: 1rem 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem;
}
.download-card {
  padding: 0.65rem;
}
.download-platform {
  font-size: 0.65rem;
  color: var(--text-sub);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 8px;
  white-space: nowrap;
}
.downloads-header {
  display: none;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0;
  position: sticky;
  top: 63px;
  z-index: 100;
  background-color: var(--bg-body);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.downloads-search-box {
  flex: 1;
  padding: 0.55rem 0.85rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.85rem;
  transition: all 0.2s;
}
.downloads-search-box:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-bg);
}
#tab-downloads.active .downloads-header {
  display: flex;
}
#tab-downloads.active #downloadsTabs {
  display: flex;
}
@media (max-width: 480px) {
  .nav-item {
    min-width: 54px;
    padding: 0.35rem 0.5rem;
  }
}
/* App Badge Styles */
.app-badge {
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 700;
  margin-right: 6px;
  color: #fff;
}
.app-bale {
  background-color: #0088cc;
} /* Bale Blue */
.app-rubika {
  background-color: #d32f2f;
} /* Rubika Red */
.app-igap {
  background-color: #388e3c;
} /* iGap Green */

.update-toast {
  position: fixed;
  left: 50%;
  bottom: 74px;
  transform: translate(-50%, 16px);
  width: min(92vw, 360px);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.7rem 0.75rem;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  z-index: 250;
  opacity: 0;
  pointer-events: none;
  transition:
    transform 0.2s ease,
    opacity 0.2s ease;
}
.update-toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
  pointer-events: auto;
}
.update-toast-text {
  font-size: 0.8rem;
  color: var(--text-main);
}
.update-toast-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.35rem 0.7rem;
  font-family: inherit;
  font-size: 0.75rem;
  cursor: pointer;
}
