/* =====================================================
   mypage.css — Dashboard styles
   ===================================================== */

/* ─── Layout ─── */
.mypage-wrap {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: calc(100vh - var(--nav-h));
  gap: 0;
}

/* ─── Sidebar ─── */
.sidebar {
  background: var(--bg-mid);
  border-right: 1px solid var(--border);
  padding: 32px 0;
  position: sticky;
  top: var(--nav-h);
  height: calc(100vh - var(--nav-h));
  overflow-y: auto;
  flex-shrink: 0;
}
.sidebar-user {
  padding: 0 20px 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.sidebar-avatar {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--gold-dim);
  border: 2px solid var(--border-strong);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  margin-bottom: 10px;
}
.sidebar-email {
  font-size: 0.8rem;
  color: var(--text-secondary);
  word-break: break-all;
}
.sidebar-name {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 2px;
}
.sidebar-nav { padding: 0 10px; }
.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.18s;
  width: 100%;
  text-align: left;
  background: none;
  margin-bottom: 2px;
}
.sidebar-nav-item:hover {
  color: var(--text-primary);
  background: var(--bg-card);
}
.sidebar-nav-item.tab-active {
  color: var(--gold-light);
  background: var(--gold-glow);
  border-color: var(--border);
}
.sidebar-nav-item .nav-icon { font-size: 1rem; width: 20px; text-align: center; }
.sidebar-divider {
  height: 1px;
  background: var(--border);
  margin: 12px 20px;
}
.sidebar-footer {
  padding: 0 20px;
  margin-top: 20px;
}
.sidebar-footer a {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: block;
  margin-bottom: 8px;
  transition: color 0.2s;
}
.sidebar-footer a:hover { color: var(--text-secondary); }
.sidebar-logout {
  font-size: 0.8rem;
  color: var(--text-muted);
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  transition: color 0.2s;
}
.sidebar-logout:hover { color: var(--danger); }

/* ─── Main content ─── */
.mypage-content {
  padding: 36px 40px;
  overflow-x: hidden;
}
.dash-section-title {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  margin-bottom: 24px;
  color: var(--text-primary);
}

/* ─── Loading skeleton ─── */
.skeleton-grid {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 24px;
  align-items: start;
}
.skeleton-main, .skeleton-side {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}
.skeleton-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  height: 120px;
  position: relative;
  overflow: hidden;
}
.skeleton-card.skeleton-tall { height: 320px; }
.skeleton-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(7,12,26,0.05) 50%,
    transparent 100%);
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
}
@keyframes skeleton-shimmer {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(100%);  }
}
@media (max-width: 1024px) {
  .skeleton-grid { grid-template-columns: 1fr; }
  .skeleton-side { flex-direction: row; flex-wrap: wrap; }
  .skeleton-side .skeleton-card { flex: 1; min-width: 140px; }
}

/* ─── Dashboard grid ─── */
.dash-grid {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 24px;
  align-items: start;
}
.dash-main { min-width: 0; display: flex; flex-direction: column; gap: 24px; }
.dash-side  { display: flex; flex-direction: column; gap: 16px; }

/* ─── Active eSIM card ─── */
.active-esim-card {
  background: linear-gradient(135deg, rgba(18,128,127,0.08) 0%, rgba(255,255,255,0) 60%);
  border: 1px solid rgba(18,128,127,0.30);
  border-radius: var(--radius);
  padding: 28px;
}
.aec-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
}
.aec-header h3 {
  font-family: var(--font-heading);
  font-size: 1.2rem;
}
.usage-section {
  display: flex;
  align-items: center;
  gap: 32px;
  margin-bottom: 20px;
}
.data-ring-wrap {
  position: relative;
  flex-shrink: 0;
  width: 180px;
  height: 180px;
}
.data-ring-wrap svg { display: block; }
.data-ring-label {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.data-ring-label .used {
  font-size: 1.6rem;
  font-weight: 700;
  font-family: var(--font-heading);
  line-height: 1;
}
.data-ring-label .total {
  font-size: 0.72rem;
  color: var(--text-secondary);
  margin-top: 4px;
}
.usage-stats {
  display: flex;
  gap: 24px;
  flex: 1;
}
.usage-stat { text-align: center; }
.us-val {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text-primary);
  font-family: var(--font-heading);
}
.us-val.text-warn { color: var(--danger); }
.us-lbl { font-size: 0.72rem; color: var(--text-secondary); margin-top: 2px; }

.usage-bar-wrap { margin-bottom: 20px; }
.usage-bar-track {
  height: 6px;
  background: var(--bg-mid);
  border-radius: 3px;
  overflow: hidden;
}
.usage-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.6s ease;
}
.usage-bar-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 6px;
}
.aec-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ─── Side cards ─── */
.side-card {
  text-align: center;
  padding: 20px;
}
.side-card-icon { font-size: 1.6rem; margin-bottom: 8px; }
.side-card-val  { font-size: 1.6rem; font-weight: 700; font-family: var(--font-heading); }
.side-card-lbl  { font-size: 0.75rem; color: var(--text-secondary); margin-top: 2px; }

/* ─── Quick actions ─── */
.quick-actions { display: flex; flex-direction: column; gap: 6px; }
.qa-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.855rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-mid);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.18s;
  text-align: left;
  width: 100%;
}
.qa-btn:hover {
  color: var(--text-primary);
  background: var(--bg-card-hover);
  border-color: var(--border);
}

/* ─── Bar chart ─── */
.bar-chart {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
  height: 160px;
  padding-bottom: 32px;
  position: relative;
}
.bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  gap: 4px;
  position: relative;
}
.bar-bar {
  width: 100%;
  border-radius: 4px 4px 0 0;
  min-height: 4px;
  transition: height 0.4s ease;
  opacity: 0.8;
}
.bar-bar:hover { opacity: 1; }
.bar-lbl {
  position: absolute;
  bottom: -24px;
  font-size: 0.68rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.bar-val {
  position: absolute;
  top: -18px;
  font-size: 0.65rem;
  color: var(--text-secondary);
}

/* ─── QR Modal ─── */
.qr-modal {
  position: fixed;
  inset: 0;
  background: rgba(7,12,26,0.85);
  backdrop-filter: blur(8px);
  z-index: 9000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.qr-modal-box {
  background: var(--bg-mid);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 36px;
  max-width: 400px;
  width: 100%;
  margin: auto;
  text-align: center;
  position: relative;
  box-shadow: var(--shadow);
}
.qr-close {
  position: absolute;
  top: 16px; right: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 32px; height: 32px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}
.qr-close:hover { color: var(--text-primary); }
.qr-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0 auto;
}
/* White backing frame so the QR contrasts and scans reliably */
.qr-frame {
  border: 2px solid var(--border-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #fff;
  padding: 10px;
  line-height: 0;
}
.qr-frame img {
  max-width: 100%;
  height: auto !important;
}
/* Tap-to-install: the whole QR acts as a button */
.qr-install {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin: 0 auto;
  padding: 0;
  background: none;
  border: none;
  cursor: pointer;
}
.qr-install .qr-frame {
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.qr-install:hover .qr-frame,
.qr-install:active .qr-frame {
  transform: scale(1.02);
  box-shadow: 0 0 0 3px var(--gold, #c9a84c);
}
.qr-install-cta {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--gold, #c9a84c);
}
.qr-install-sub {
  font-size: 0.74rem;
  color: var(--text-secondary);
  text-align: center;
  max-width: 240px;
  line-height: 1.4;
}
/* ICCID / activation code — each on its own full-width row below the QR */
.qr-info-row {
  width: 100%;
  margin-top: 12px;
  text-align: center;
  word-break: break-all;
  font-size: 0.8rem;
  color: var(--text-secondary);
}
.qr-info-label {
  display: block;
  margin-bottom: 3px;
  font-size: 0.66rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ─── eSIM list ─── */
.esim-list { display: flex; flex-direction: column; gap: 16px; }
.esim-list-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  display: flex;
  align-items: center;
  gap: 20px;
}
.esim-list-card.active { border-color: rgba(18,128,127,0.35); }
.esim-list-card.expired { opacity: 0.6; }
.elc-status { flex-shrink: 0; }
.elc-status .badge { white-space: nowrap; }
.elc-body { flex: 1; min-width: 0; }
.elc-body h3 { font-family: var(--font-heading); font-size: 1rem; margin-bottom: 6px; }
.elc-meta {
  font-size: 0.8rem;
  color: var(--text-secondary);
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.elc-actions { display: flex; gap: 8px; }

/* ─── History table ─── */
.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.history-table th, .history-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.history-table th {
  font-family: var(--font-heading);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.history-table tbody tr:hover { background: var(--bg-mid); }
.history-table code {
  font-size: 0.8rem;
  color: var(--gold-light);
  background: var(--gold-glow);
  padding: 2px 6px;
  border-radius: 4px;
}

/* ─── Profile / Support grids ─── */
.profile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}
.support-grid {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 24px;
  align-items: start;
}

/* ─── FAQ（サポートタブの Quick Help）───
   中身は CMS の FAQ（api/cms/faqs.php）＝ /faq/ と同じ答え。<details> で開け閉めする。
   ★以前は .faq-item 全体を onclick で開閉し、答えも高さ 200px までだった
     → 長い答え（インストール手順など）が途中で切れ、答えの中のリンクや文字を触ると閉じた。
   答えの書式は /faq/ と同じ（p / p.heading / ul.dot / span.attention-i）。 */
.faq-list { display: flex; flex-direction: column; gap: 0; }
.faq-item { border-bottom: 1px solid var(--border); }
.faq-q {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  list-style: none;
  transition: color 0.2s;
}
.faq-q::-webkit-details-marker { display: none; }
.faq-q span { flex-shrink: 0; transition: transform 0.2s; }
.faq-item:hover .faq-q,
.faq-item[open] .faq-q { color: var(--text-primary); }
.faq-item[open] .faq-q span { transform: rotate(180deg); }
.faq-a {
  font-size: 0.84rem;
  color: var(--text-secondary);
  line-height: 1.7;
  padding: 0 0 14px;
}
.faq-a p { margin: 0 0 8px; }
.faq-a p.heading { margin: 14px 0 6px; font-weight: 600; color: var(--text-primary); }
.faq-a strong { color: var(--text-primary); }
.faq-a ul.dot { list-style: none; margin: 0 0 8px; padding: 0; }
.faq-a ul.dot li { position: relative; padding-left: 1em; margin: 3px 0; }
.faq-a ul.dot li::before { content: "・"; position: absolute; left: 0; }
.faq-a .attention-i {
  display: block;
  margin: 8px 0 10px;
  padding: 8px 12px;
  border-left: 3px solid var(--gold-light);
  border-radius: 4px;
  background: var(--gold-dim);
  color: var(--gold);
  font-weight: 600;
}
.faq-a a { color: var(--blue); text-decoration: underline; word-break: break-word; }
.faq-a a.quick-help-more { display: inline-block; margin-top: 4px; font-size: 0.8rem; text-decoration: none; }
.quick-help-all { display: inline-block; margin-top: 14px; font-size: 0.84rem; color: var(--blue); }
.quick-help-empty { margin: 4px 0 0; font-size: 0.84rem; color: var(--text-secondary); }

/* ─── FAQ の答えを読みやすく（FAQ フェーズ2）───
   /faq/ と同じ書き方（タブ .faq-tabs・番号つき手順 ol.faq-steps・コピー code.copy）の見た目。
   動きは assets/front/js/faq-enhance.js。Quick Help は横幅いっぱいで一番上に置く。 */
.quick-help-card { margin-bottom: 24px; }
.faq-a ol.faq-steps { list-style: none; counter-reset: faqstep; margin: 4px 0 10px; padding: 0; }
.faq-a ol.faq-steps > li { position: relative; counter-increment: faqstep; padding: 7px 0 7px 2.3em; }
.faq-a ol.faq-steps > li + li { border-top: 1px dashed var(--border); }
.faq-a ol.faq-steps > li::before {
  content: counter(faqstep);
  position: absolute;
  left: 0;
  top: 8px;
  width: 1.65em;
  height: 1.65em;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.65em;
  text-align: center;
}
.faq-a .faq-tabs { margin: 12px 0 8px; }
.faq-a .faq-tabs-nav { display: flex; gap: 6px; border-bottom: 2px solid var(--blue); }
.faq-a .faq-tabs-btn {
  padding: 7px 20px;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--blue);
  background: var(--blue-dim);
  border: none;
  border-radius: 6px 6px 0 0;
  cursor: pointer;
}
.faq-a .faq-tabs-btn.is-on { background: var(--blue); color: #fff; }
.faq-a .faq-tabs.is-ready > .faq-tab { padding-top: 4px; }
.faq-a .faq-tabs.is-ready > .faq-tab:not(.is-on) { display: none; }
.faq-a .faq-tabs.is-ready .faq-tab-label { display: none; }
.faq-a .faq-tabs:not(.is-ready) > .faq-tab + .faq-tab { margin-top: 12px; padding-top: 8px; border-top: 2px solid var(--border); }
/* 設定画面のイメージ図（FAQ の答えの中・/faq/ と同じ書き方）。狭い画面では横にすべらせて見る */
.faq-a .faq-shots { display: flex; gap: 14px; margin: 8px 0 4px; overflow-x: auto; padding-bottom: 6px; scroll-snap-type: x mandatory; }
.faq-a .faq-shots figure { flex: 0 0 180px; margin: 0; scroll-snap-align: start; }
.faq-a .faq-shots img { display: block; width: 100%; height: auto; }
.faq-a .faq-shots figcaption { margin-top: 5px; font-size: 0.76rem; line-height: 1.45; color: var(--text-secondary); }
.faq-a p.faq-shots-note { font-size: 0.72rem; color: var(--text-muted); }
/* コピー（FAQ の答えの中と、QR の画面の APN） */
code.copy {
  padding: 1px 7px;
  font-family: var(--font-mono, SFMono-Regular, Menlo, Consolas, monospace);
  font-size: 0.95em;
  color: var(--text-primary);
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
}
.copy-btn {
  margin-left: 6px;
  padding: 0 11px;
  font: inherit;
  font-size: 0.74rem;
  font-weight: 600;
  line-height: 22px;
  color: var(--blue);
  vertical-align: middle;
  background: #fff;
  border: 1px solid var(--blue);
  border-radius: 999px;
  cursor: pointer;
}
.copy-btn:hover { background: var(--blue); color: #fff; }
.copy-btn.is-done { background: #2e7d32; border-color: #2e7d32; color: #fff; }

/* ─── Mobile nav tab bar ─── */
.mobile-tab-bar {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--bg-mid);
  border-top: 1px solid var(--border);
  z-index: 900;
  padding: 8px 0 env(safe-area-inset-bottom, 0);
}
.mobile-tab-bar-inner {
  display: flex;
  justify-content: space-around;
}
.mobile-tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 4px;
  font-size: 0.65rem;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  transition: color 0.2s;
}
.mobile-tab-btn .mtb-icon { font-size: 1.2rem; }
.mobile-tab-btn.tab-active { color: var(--gold); }

/* ─── Responsive ─── */
@media (max-width: 1024px) {
  .dash-grid { grid-template-columns: 1fr; }
  .dash-side { flex-direction: row; flex-wrap: wrap; }
  .side-card { flex: 1; min-width: 140px; }
  .profile-grid { grid-template-columns: 1fr; }
  .support-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .mypage-wrap { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .mypage-content { padding: 24px 16px 100px; }
  .mobile-tab-bar { display: block; }
  .aec-header { flex-direction: column; gap: 12px; }
  .usage-section { flex-direction: column; align-items: flex-start; }
  .elc-meta { flex-direction: column; gap: 2px; }
  .esim-list-card { flex-direction: column; align-items: flex-start; }
  .qr-modal { padding: 14px; }
  .qr-modal-box { padding: 26px 18px; }
}
