/* Customer Storefront — Mobile-First Responsive Layout (320px to 1920px) */

.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--header-h-mobile);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

@media (min-width: 768px) {
  .app-header {
    height: var(--header-h-desktop);
  }
}

.header-inner {
  max-width: var(--container-max);
  height: 100%;
  margin: 0 auto;
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

@media (min-width: 768px) {
  .header-inner {
    padding: 0 20px;
  }
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: var(--text);
}

.brand-logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.brand-name {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 380px) {
  .brand-name {
    max-width: 96px;
    font-size: 13px;
  }
}

.desktop-nav {
  display: none;
  align-items: center;
  gap: 4px;
}

@media (min-width: 900px) {
  .desktop-nav {
    display: flex;
  }
}

.nav-tab {
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-muted);
  transition: color var(--ease-fast), background-color var(--ease-fast);
}

.nav-tab:hover {
  color: var(--text);
  background: var(--surface);
}

.nav-tab.active {
  color: var(--text);
  background: var(--surface-2);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.wallet-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent);
}

.icon-btn {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color var(--ease-fast), background-color var(--ease-fast);
}

.icon-btn:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
}

.notif-dot {
  position: absolute;
  top: 5px;
  right: 5px;
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  border-radius: 99px;
  background: var(--error);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lang-select {
  height: 36px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 12.5px;
  max-width: 78px;
  white-space: nowrap;
}

/* Main Container */
.main-container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 16px 14px calc(76px + env(safe-area-inset-bottom));
}

@media (min-width: 768px) {
  .main-container {
    padding: 20px 20px 40px;
  }
}

/* Compact Brand Banner (No oversized hero) */
.compact-banner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 16px;
}

@media (min-width: 768px) {
  .compact-banner {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
  }
}

.banner-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.banner-logo {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.banner-title {
  margin: 0 0 4px;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.25;
}

@media (min-width: 768px) {
  .banner-title {
    font-size: 22px;
  }
}

.banner-subtitle {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}

.banner-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex-shrink: 0;
}

/* Compact KPI Strip */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

@media (min-width: 768px) {
  .kpi-strip {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
  }
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}

.kpi-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.kpi-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

/* Important Notice Box */
.notice-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 18px;
  font-size: 13px;
  white-space: pre-line;
  color: var(--text);
}

html[dir="rtl"] .notice-box {
  border-left: 1px solid var(--border);
  border-right: 3px solid var(--accent);
}

.notice-box-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
  margin-bottom: 6px;
}

/* Section Header */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin: 18px 0 12px;
}

.section-head h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
}

/* 14-Server Responsive Grid: 1 col <380px, 2 cols mobile, 3 cols tablet, 4 cols desktop */
.server-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

@media (min-width: 380px) {
  .server-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }
}

@media (min-width: 820px) {
  .server-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
  }
}

@media (min-width: 1120px) {
  .server-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
  }
}

.server-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 13px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  transition: border-color var(--ease-fast), transform var(--ease-fast);
}

.server-card:hover {
  border-color: var(--border-strong);
}

.server-card.oos {
  opacity: 0.65;
}

.server-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.server-region-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 26px;
  padding: 0 6px;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  font-family: var(--font-mono);
}

.server-name {
  font-size: 14.5px;
  font-weight: 600;
  margin: 6px 0 2px;
  color: var(--text);
  word-break: break-word;
}

.server-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
}

.server-price {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.server-price span {
  font-size: 11.5px;
  font-weight: 400;
  color: var(--text-muted);
}

.server-stock {
  font-size: 12px;
  color: var(--text-muted);
}

/* Quantity Preset Pills */
.qty-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.qty-pill {
  min-height: 40px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.qty-pill.active {
  border-color: var(--accent);
  background: var(--accent-subtle);
  color: var(--accent);
}

/* Quote Summary Box */
.quote-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin: 12px 0;
}

.quote-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 0;
  font-size: 13px;
}

.quote-row.total {
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
}

/* Gateway Card */
.gateway-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.gateway-item {
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  cursor: pointer;
}

.gateway-item.active {
  border-color: var(--accent);
  background: var(--accent-subtle);
}

.gateway-val-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 6px;
}

.gateway-code-val {
  font-family: var(--font-mono);
  font-size: 12.5px;
  word-break: break-all;
  color: var(--text);
}

/* Orders & Timeline */
.list-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.order-row-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 13px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.order-row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.timeline {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 10px 0;
  overflow-x: auto;
}

.tl-step {
  flex: 1;
  min-width: 72px;
  padding: 6px 8px;
  border-radius: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 11px;
  text-align: center;
  color: var(--text-muted);
}

.tl-step.done {
  border-color: rgba(52, 211, 153, 0.4);
  color: var(--success);
  background: var(--success-bg);
}

.tl-step.current {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-subtle);
}

.tl-step.error {
  border-color: rgba(248, 113, 113, 0.4);
  color: var(--error);
  background: var(--error-bg);
}

/* Two-Column Grid for Wallet & Account */
.two-col {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

@media (min-width: 860px) {
  .two-col {
    grid-template-columns: 1fr 1fr;
  }
}

/* Mobile Bottom Navigation (Max 5 items, safe-area aware) */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 45;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 2px;
}

@media (min-width: 900px) {
  .bottom-nav {
    display: none;
  }
}

.bottom-nav-btn {
  min-height: 46px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 11px;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
}

.bottom-nav-btn.active {
  color: var(--accent);
  background: var(--accent-subtle);
}

.bottom-nav-btn svg {
  width: 19px;
  height: 19px;
}

/* Toggle Switch */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
}

.switch {
  width: 42px;
  height: 24px;
  border-radius: 99px;
  background: var(--border-strong);
  position: relative;
  flex-shrink: 0;
  transition: background-color var(--ease-fast);
}

.switch.on {
  background: var(--success);
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform var(--ease-fast);
}

.switch.on::after {
  transform: translateX(18px);
}

/* Table wrapper for mobile horizontal safety */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th, .data-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table th {
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.data-table tr:last-child td {
  border-bottom: none;
}

/* Auth Tabs */
.tab-bar {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

.tab-btn {
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.tab-btn.active {
  background: var(--accent-subtle);
  color: var(--accent);
}

/* Floating CSKH / Admin Support FAB & Popup Cards */
.cskh-fab {
  position: fixed;
  right: 14px;
  bottom: calc(68px + env(safe-area-inset-bottom));
  z-index: 46;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 14px;
  border-radius: 99px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  transition: transform var(--ease-fast), border-color var(--ease-fast), background-color var(--ease-fast);
}

@media (min-width: 900px) {
  .cskh-fab {
    right: 22px;
    bottom: 22px;
  }
}

html[dir="rtl"] .cskh-fab {
  right: auto;
  left: 14px;
}

.cskh-fab:hover {
  border-color: var(--accent);
  background: #232833;
}

.cskh-fab:active {
  transform: scale(0.97);
}

.cskh-fab-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
}

.cskh-channel-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  padding: 13px 14px;
  border-radius: var(--radius-md);
  background: var(--bg);
  border: 1px solid var(--border);
  transition: border-color var(--ease-fast);
}

@media (min-width: 480px) {
  .cskh-channel-card {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

.cskh-channel-card:hover {
  border-color: var(--border-strong);
}

.cskh-channel-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.cskh-app-logo {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.cskh-app-logo.wa {
  background: rgba(37, 211, 102, 0.14);
  border: 1px solid rgba(37, 211, 102, 0.35);
}

.cskh-app-logo.tg {
  background: rgba(34, 158, 217, 0.14);
  border: 1px solid rgba(34, 158, 217, 0.35);
}

.cskh-channel-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  flex-shrink: 0;
}

@media (min-width: 480px) {
  .cskh-channel-actions {
    display: flex;
    align-items: center;
    gap: 6px;
  }
}

.turnstile-wrap {
  margin: 10px 0 12px;
}

.turnstile-box {
  min-height: 66px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}

.turnstile-status {
  margin-top: 6px;
  font-size: 11.5px;
  text-align: center;
  color: var(--text-muted);
  min-height: 16px;
}

.turnstile-status.is-ok {
  color: var(--success);
}

.turnstile-status.is-warn {
  color: var(--warning);
}

.turnstile-status.is-err {
  color: var(--error);
}
