// SS3 — Province Picker modal sheet, Light Mode

function ProvinceChip({ label, selected = false, full = false }) {
  return (
    <div style={{
      flex: full ? '1 1 auto' : '1 1 0',
      height: 116,
      borderRadius: 18,
      border: selected ? 'none' : `1.5px solid ${RC.borderLight}`,
      background: selected ? RC.accentLight : RC.surfaceLight,
      color: selected ? '#FFFFFF' : RC.textPrimaryLight,
      display: 'flex', alignItems: 'center', justifyContent: 'space-between',
      padding: full ? '0 32px' : '0',
      fontSize: 42, fontWeight: selected ? 600 : 500,
      fontFamily: RC.fontSans,
      letterSpacing: 1,
    }}>
      {full ? (
        <>
          <span>{label}</span>
          <span style={{
            fontFamily: RC.fontMono, fontSize: 30, color: RC.textTertiaryLight,
            fontWeight: 500, letterSpacing: 2,
          }}>CN</span>
        </>
      ) : (
        <span style={{ width: '100%', textAlign: 'center' }}>{label}</span>
      )}
    </div>
  );
}

function SegmentChip({ label, selected = false }) {
  return (
    <div style={{
      flex: '1 1 0',
      height: 92,
      borderRadius: 14,
      background: selected ? RC.accentLight : 'transparent',
      color: selected ? '#FFFFFF' : RC.textPrimaryLight,
      display: 'flex', alignItems: 'center', justifyContent: 'center',
      fontSize: 36, fontWeight: selected ? 600 : 500,
      fontFamily: RC.fontSans, letterSpacing: 0.5,
    }}>{label}</div>
  );
}

function SectionLabel({ children }) {
  return (
    <div style={{
      fontSize: 38, fontWeight: 600, color: RC.textPrimaryLight,
      fontFamily: RC.fontSans, letterSpacing: -0.2,
    }}>{children}</div>
  );
}

function SS3ProvincePicker() {
  // Idle measurement screen peek behind the sheet (dimmed)
  const BackdropPeek = () => (
    <div style={{
      position: 'absolute', inset: 0,
      background: RC.bgLight,
    }}>
      {/* Tiny placeholder hinting at the screen underneath */}
      <div style={{
        position: 'absolute', left: 60, right: 60, top: 220,
        height: 700,
        borderRadius: 32,
        background: 'linear-gradient(180deg, #E2E8F0 0%, #CBD5E1 100%)',
        opacity: 0.35,
      }} />
      <div style={{
        position: 'absolute', left: 60, right: 60, top: 940,
        height: 80, borderRadius: 16,
        background: '#E2E8F0', opacity: 0.5,
      }} />
      {/* Dim layer */}
      <div style={{ position: 'absolute', inset: 0, background: 'rgba(15,23,42,0.32)' }} />
    </div>
  );

  return (
    <ScreenshotShell
      dark={false}
      headline="精准匹配你所在省市"
      subline="北京 · 上海 · 广东 · 江苏 · 浙江 · 更多"
      caption="隐私本地 · 选定后不再询问"
    >
      <div style={{ position: 'absolute', inset: 0, overflow: 'hidden' }}>
        <BackdropPeek />
        <StatusBar dark={false} />

        {/* Bottom sheet */}
        <div style={{
          position: 'absolute', left: 0, right: 0, bottom: 0,
          background: RC.surfaceLight,
          borderTopLeftRadius: 40, borderTopRightRadius: 40,
          padding: '24px 56px 60px',
          boxShadow: '0 -8px 30px rgba(15,23,42,0.12)',
          height: 1530,
        }}>
          {/* Sheet handle */}
          <div style={{
            width: 96, height: 8, borderRadius: 9999,
            background: '#CBD5E1',
            margin: '0 auto 36px',
          }} />

          {/* Header */}
          <div style={{
            fontSize: 56, fontWeight: 700, color: RC.textPrimaryLight,
            letterSpacing: -1, fontFamily: RC.fontSans,
          }}>中考标准</div>
          <div style={{
            marginTop: 10, fontSize: 32, color: RC.textSecondaryLight, fontWeight: 400,
          }}>选好省份即可自动载入评分表</div>

          {/* Province section */}
          <div style={{ marginTop: 36 }}>
            <SectionLabel>省份</SectionLabel>
            <div style={{
              marginTop: 20,
              display: 'grid',
              gridTemplateColumns: 'repeat(3, 1fr)',
              gap: 14,
            }}>
              <ProvinceChip label="北京" selected />
              <ProvinceChip label="上海" />
              <ProvinceChip label="广东" />
              <ProvinceChip label="江苏" />
              <ProvinceChip label="浙江" />
              <ProvinceChip label="山东" />
              <ProvinceChip label="四川" />
              <ProvinceChip label="河南" />
              <ProvinceChip label="湖北" />
            </div>

            {/* Hairline + label */}
            <div style={{
              marginTop: 28,
              display: 'flex', alignItems: 'center', gap: 18,
            }}>
              <div style={{ flex: 1, height: 1, background: RC.borderLight }} />
              <span style={{
                fontSize: 26, color: RC.textTertiaryLight, fontWeight: 400,
              }}>未列出本省</span>
              <div style={{ flex: 1, height: 1, background: RC.borderLight }} />
            </div>
            <div style={{ marginTop: 16, display: 'flex' }}>
              <ProvinceChip label="通用国标" full />
            </div>
          </div>

          {/* Grade section */}
          <div style={{ marginTop: 38 }}>
            <SectionLabel>年级</SectionLabel>
            <div style={{
              marginTop: 18,
              padding: 8,
              background: RC.surfaceMutedLight,
              borderRadius: 18,
              display: 'flex', gap: 4,
            }}>
              <SegmentChip label="初五" />
              <SegmentChip label="初六" />
              <SegmentChip label="初七" />
              <SegmentChip label="初三" selected />
              <SegmentChip label="初九" />
              <SegmentChip label="通用" />
            </div>
          </div>

          {/* Gender section */}
          <div style={{ marginTop: 32 }}>
            <SectionLabel>性别</SectionLabel>
            <div style={{
              marginTop: 18,
              padding: 8,
              background: RC.surfaceMutedLight,
              borderRadius: 18,
              display: 'flex', gap: 4,
            }}>
              <SegmentChip label="男" selected />
              <SegmentChip label="女" />
            </div>
          </div>

          {/* Data source footnote */}
          <div style={{
            marginTop: 36,
            fontSize: 24, color: RC.textTertiaryLight, fontWeight: 400,
            textAlign: 'center',
          }}>数据来源 · 依据各省教委文件 · 最后更新 2025-09</div>

          {/* Save CTA */}
          <button style={{
            marginTop: 24,
            width: '100%', height: 116, borderRadius: 22,
            background: RC.accentLight, color: '#FFFFFF',
            fontSize: 40, fontWeight: 600, letterSpacing: 1,
            border: 'none', cursor: 'pointer',
            fontFamily: RC.fontSans,
            boxShadow: '0 4px 14px rgba(21,128,61,0.25)',
          }}>保存</button>
        </div>
      </div>
    </ScreenshotShell>
  );
}

window.SS3ProvincePicker = SS3ProvincePicker;
